xref: /rk3399_ARM-atf/include/drivers/arm/ccn.h (revision c3cf06f1a3a9b9ee8ac7a0ae505f95c45f7dca84)
1fd6007deSAchin Gupta /*
2fd6007deSAchin Gupta  * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3fd6007deSAchin Gupta  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5fd6007deSAchin Gupta  */
6fd6007deSAchin Gupta 
7*c3cf06f1SAntonio Nino Diaz #ifndef CCN_H
8*c3cf06f1SAntonio Nino Diaz #define CCN_H
9fd6007deSAchin Gupta 
10fd6007deSAchin Gupta /*
11fd6007deSAchin Gupta  * This macro defines the maximum number of master interfaces that reside on
12fd6007deSAchin Gupta  * Request nodes which the CCN driver can accommodate. The driver APIs to add
13fd6007deSAchin Gupta  * and remove Request nodes from snoop/dvm domains take a bit map of master
14fd6007deSAchin Gupta  * interfaces as inputs. The largest C data type that can be used is a 64-bit
15fd6007deSAchin Gupta  * unsigned integer. Hence the value of 64. The platform will have to ensure
16fd6007deSAchin Gupta  * that the master interfaces are numbered from 0-63.
17fd6007deSAchin Gupta  */
18fd6007deSAchin Gupta #define CCN_MAX_RN_MASTERS	64
19fd6007deSAchin Gupta 
20fd6007deSAchin Gupta /*
21fd6007deSAchin Gupta  * The following constants define the various run modes that the platform can
22fd6007deSAchin Gupta  * request the CCN driver to place the L3 cache in. These map to the
23fd6007deSAchin Gupta  * programmable P-State values in a HN-F P-state register.
24fd6007deSAchin Gupta  */
25fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_NOL3	0x0	/* HNF_PM_NOL3 */
26fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_SFONLY	0x1	/* HNF_PM_SFONLY */
27fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_HAM	0x2	/* HNF_PM_HALF */
28fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_FAM	0x3	/* HNF_PM_FULL */
29fd6007deSAchin Gupta 
306331a31aSSoby Mathew /* part 0 IDs for various CCN variants */
316331a31aSSoby Mathew #define CCN_502_PART0_ID	0x30
326331a31aSSoby Mathew #define CCN_504_PART0_ID	0x26
336331a31aSSoby Mathew #define CCN_505_PART0_ID	0x27
346331a31aSSoby Mathew #define CCN_508_PART0_ID	0x28
356331a31aSSoby Mathew #define CCN_512_PART0_ID	0x29
366331a31aSSoby Mathew 
37fd6007deSAchin Gupta /*
38fd6007deSAchin Gupta  * The following macro takes the value returned from a read of a HN-F P-state
39fd6007deSAchin Gupta  * status register and returns the retention state value.
40fd6007deSAchin Gupta  */
41fd6007deSAchin Gupta #define CCN_GET_RETENTION_STATE(pstate)	((pstate >> 4) & 0x3)
42fd6007deSAchin Gupta 
43fd6007deSAchin Gupta /*
44fd6007deSAchin Gupta  * The following macro takes the value returned from a read of a HN-F P-state
45fd6007deSAchin Gupta  * status register and returns the run state value.
46fd6007deSAchin Gupta  */
47fd6007deSAchin Gupta #define CCN_GET_RUN_STATE(pstate)	(pstate & 0xf)
48fd6007deSAchin Gupta 
49fd6007deSAchin Gupta #ifndef __ASSEMBLY__
50fd6007deSAchin Gupta #include <stdint.h>
51fd6007deSAchin Gupta 
52fd6007deSAchin Gupta /*
53fd6007deSAchin Gupta  * This structure describes some of the implementation defined attributes of the
54fd6007deSAchin Gupta  * CCN IP. It is used by the platform port to specify these attributes in order
55fd6007deSAchin Gupta  * to initialise the CCN driver. The attributes are described below.
56fd6007deSAchin Gupta  *
57fd6007deSAchin Gupta  * 1. The 'num_masters' field specifies the total number of master interfaces
58fd6007deSAchin Gupta  *    resident on Request nodes.
59fd6007deSAchin Gupta  *
60fd6007deSAchin Gupta  * 2. The 'master_to_rn_id_map' field is a ponter to an array in which each
61fd6007deSAchin Gupta  *    index corresponds to a master interface and its value corresponds to the
62fd6007deSAchin Gupta  *    Request node on which the master interface resides.
63fd6007deSAchin Gupta  *    This field is not simply defined as an array of size CCN_MAX_RN_MASTERS.
64fd6007deSAchin Gupta  *    In reality, a platform will have much fewer master * interfaces than
65fd6007deSAchin Gupta  *    CCN_MAX_RN_MASTERS. With an array of this size, it would also have to
66fd6007deSAchin Gupta  *    set the unused entries to a suitable value. Zeroing the array would not
67fd6007deSAchin Gupta  *    be enough since 0 is also a valid node id. Hence, such an array is not
68fd6007deSAchin Gupta  *    used.
69fd6007deSAchin Gupta  *
70fd6007deSAchin Gupta  * 3. The 'periphbase' field is the base address of the programmer's view of the
71fd6007deSAchin Gupta  *    CCN IP.
72fd6007deSAchin Gupta  */
73fd6007deSAchin Gupta typedef struct ccn_desc {
74fd6007deSAchin Gupta 	unsigned int num_masters;
75fd6007deSAchin Gupta 	const unsigned char *master_to_rn_id_map;
76fd6007deSAchin Gupta 	uintptr_t periphbase;
77fd6007deSAchin Gupta } ccn_desc_t;
78fd6007deSAchin Gupta 
79fd6007deSAchin Gupta 
80fd6007deSAchin Gupta void ccn_init(const ccn_desc_t *plat_ccn_desc);
81fd6007deSAchin Gupta void ccn_enter_snoop_dvm_domain(unsigned long long master_iface_map);
82fd6007deSAchin Gupta void ccn_exit_snoop_dvm_domain(unsigned long long master_iface_map);
83fd6007deSAchin Gupta void ccn_enter_dvm_domain(unsigned long long master_iface_map);
84fd6007deSAchin Gupta void ccn_exit_dvm_domain(unsigned long long master_iface_map);
85fd6007deSAchin Gupta void ccn_set_l3_run_mode(unsigned int mode);
86fd6007deSAchin Gupta void ccn_program_sys_addrmap(unsigned int sn0_id,
87fd6007deSAchin Gupta 		 unsigned int sn1_id,
88fd6007deSAchin Gupta 		 unsigned int sn2_id,
89fd6007deSAchin Gupta 		 unsigned int top_addr_bit0,
90fd6007deSAchin Gupta 		 unsigned int top_addr_bit1,
91fd6007deSAchin Gupta 		 unsigned char three_sn_en);
92fd6007deSAchin Gupta unsigned int ccn_get_l3_run_mode(void);
936331a31aSSoby Mathew int ccn_get_part0_id(uintptr_t periphbase);
94fd6007deSAchin Gupta 
95fd6007deSAchin Gupta #endif /* __ASSEMBLY__ */
96*c3cf06f1SAntonio Nino Diaz #endif /* CCN_H */
97