xref: /rk3399_ARM-atf/include/drivers/arm/ccn.h (revision 6331a31a66cdcf53421d3dccd3067f072c6da175)
1fd6007deSAchin Gupta /*
2fd6007deSAchin Gupta  * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3fd6007deSAchin Gupta  *
4fd6007deSAchin Gupta  * Redistribution and use in source and binary forms, with or without
5fd6007deSAchin Gupta  * modification, are permitted provided that the following conditions are met:
6fd6007deSAchin Gupta  *
7fd6007deSAchin Gupta  * Redistributions of source code must retain the above copyright notice, this
8fd6007deSAchin Gupta  * list of conditions and the following disclaimer.
9fd6007deSAchin Gupta  *
10fd6007deSAchin Gupta  * Redistributions in binary form must reproduce the above copyright notice,
11fd6007deSAchin Gupta  * this list of conditions and the following disclaimer in the documentation
12fd6007deSAchin Gupta  * and/or other materials provided with the distribution.
13fd6007deSAchin Gupta  *
14fd6007deSAchin Gupta  * Neither the name of ARM nor the names of its contributors may be used
15fd6007deSAchin Gupta  * to endorse or promote products derived from this software without specific
16fd6007deSAchin Gupta  * prior written permission.
17fd6007deSAchin Gupta  *
18fd6007deSAchin Gupta  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19fd6007deSAchin Gupta  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20fd6007deSAchin Gupta  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21fd6007deSAchin Gupta  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22fd6007deSAchin Gupta  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23fd6007deSAchin Gupta  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24fd6007deSAchin Gupta  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25fd6007deSAchin Gupta  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26fd6007deSAchin Gupta  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27fd6007deSAchin Gupta  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28fd6007deSAchin Gupta  * POSSIBILITY OF SUCH DAMAGE.
29fd6007deSAchin Gupta  */
30fd6007deSAchin Gupta 
31fd6007deSAchin Gupta #ifndef __CCN_H__
32fd6007deSAchin Gupta #define __CCN_H__
33fd6007deSAchin Gupta 
34fd6007deSAchin Gupta /*
35fd6007deSAchin Gupta  * This macro defines the maximum number of master interfaces that reside on
36fd6007deSAchin Gupta  * Request nodes which the CCN driver can accommodate. The driver APIs to add
37fd6007deSAchin Gupta  * and remove Request nodes from snoop/dvm domains take a bit map of master
38fd6007deSAchin Gupta  * interfaces as inputs. The largest C data type that can be used is a 64-bit
39fd6007deSAchin Gupta  * unsigned integer. Hence the value of 64. The platform will have to ensure
40fd6007deSAchin Gupta  * that the master interfaces are numbered from 0-63.
41fd6007deSAchin Gupta  */
42fd6007deSAchin Gupta #define CCN_MAX_RN_MASTERS	64
43fd6007deSAchin Gupta 
44fd6007deSAchin Gupta /*
45fd6007deSAchin Gupta  * The following constants define the various run modes that the platform can
46fd6007deSAchin Gupta  * request the CCN driver to place the L3 cache in. These map to the
47fd6007deSAchin Gupta  * programmable P-State values in a HN-F P-state register.
48fd6007deSAchin Gupta  */
49fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_NOL3	0x0	/* HNF_PM_NOL3 */
50fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_SFONLY	0x1	/* HNF_PM_SFONLY */
51fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_HAM	0x2	/* HNF_PM_HALF */
52fd6007deSAchin Gupta #define CCN_L3_RUN_MODE_FAM	0x3	/* HNF_PM_FULL */
53fd6007deSAchin Gupta 
54*6331a31aSSoby Mathew /* part 0 IDs for various CCN variants */
55*6331a31aSSoby Mathew #define CCN_502_PART0_ID	0x30
56*6331a31aSSoby Mathew #define CCN_504_PART0_ID	0x26
57*6331a31aSSoby Mathew #define CCN_505_PART0_ID	0x27
58*6331a31aSSoby Mathew #define CCN_508_PART0_ID	0x28
59*6331a31aSSoby Mathew #define CCN_512_PART0_ID	0x29
60*6331a31aSSoby Mathew 
61fd6007deSAchin Gupta /*
62fd6007deSAchin Gupta  * The following macro takes the value returned from a read of a HN-F P-state
63fd6007deSAchin Gupta  * status register and returns the retention state value.
64fd6007deSAchin Gupta  */
65fd6007deSAchin Gupta #define CCN_GET_RETENTION_STATE(pstate)	((pstate >> 4) & 0x3)
66fd6007deSAchin Gupta 
67fd6007deSAchin Gupta /*
68fd6007deSAchin Gupta  * The following macro takes the value returned from a read of a HN-F P-state
69fd6007deSAchin Gupta  * status register and returns the run state value.
70fd6007deSAchin Gupta  */
71fd6007deSAchin Gupta #define CCN_GET_RUN_STATE(pstate)	(pstate & 0xf)
72fd6007deSAchin Gupta 
73fd6007deSAchin Gupta #ifndef __ASSEMBLY__
74fd6007deSAchin Gupta #include <stdint.h>
75fd6007deSAchin Gupta 
76fd6007deSAchin Gupta /*
77fd6007deSAchin Gupta  * This structure describes some of the implementation defined attributes of the
78fd6007deSAchin Gupta  * CCN IP. It is used by the platform port to specify these attributes in order
79fd6007deSAchin Gupta  * to initialise the CCN driver. The attributes are described below.
80fd6007deSAchin Gupta  *
81fd6007deSAchin Gupta  * 1. The 'num_masters' field specifies the total number of master interfaces
82fd6007deSAchin Gupta  *    resident on Request nodes.
83fd6007deSAchin Gupta  *
84fd6007deSAchin Gupta  * 2. The 'master_to_rn_id_map' field is a ponter to an array in which each
85fd6007deSAchin Gupta  *    index corresponds to a master interface and its value corresponds to the
86fd6007deSAchin Gupta  *    Request node on which the master interface resides.
87fd6007deSAchin Gupta  *    This field is not simply defined as an array of size CCN_MAX_RN_MASTERS.
88fd6007deSAchin Gupta  *    In reality, a platform will have much fewer master * interfaces than
89fd6007deSAchin Gupta  *    CCN_MAX_RN_MASTERS. With an array of this size, it would also have to
90fd6007deSAchin Gupta  *    set the unused entries to a suitable value. Zeroing the array would not
91fd6007deSAchin Gupta  *    be enough since 0 is also a valid node id. Hence, such an array is not
92fd6007deSAchin Gupta  *    used.
93fd6007deSAchin Gupta  *
94fd6007deSAchin Gupta  * 3. The 'periphbase' field is the base address of the programmer's view of the
95fd6007deSAchin Gupta  *    CCN IP.
96fd6007deSAchin Gupta  */
97fd6007deSAchin Gupta typedef struct ccn_desc {
98fd6007deSAchin Gupta 	unsigned int num_masters;
99fd6007deSAchin Gupta 	const unsigned char *master_to_rn_id_map;
100fd6007deSAchin Gupta 	uintptr_t periphbase;
101fd6007deSAchin Gupta } ccn_desc_t;
102fd6007deSAchin Gupta 
103fd6007deSAchin Gupta 
104fd6007deSAchin Gupta void ccn_init(const ccn_desc_t *plat_ccn_desc);
105fd6007deSAchin Gupta void ccn_enter_snoop_dvm_domain(unsigned long long master_iface_map);
106fd6007deSAchin Gupta void ccn_exit_snoop_dvm_domain(unsigned long long master_iface_map);
107fd6007deSAchin Gupta void ccn_enter_dvm_domain(unsigned long long master_iface_map);
108fd6007deSAchin Gupta void ccn_exit_dvm_domain(unsigned long long master_iface_map);
109fd6007deSAchin Gupta void ccn_set_l3_run_mode(unsigned int mode);
110fd6007deSAchin Gupta void ccn_program_sys_addrmap(unsigned int sn0_id,
111fd6007deSAchin Gupta 		 unsigned int sn1_id,
112fd6007deSAchin Gupta 		 unsigned int sn2_id,
113fd6007deSAchin Gupta 		 unsigned int top_addr_bit0,
114fd6007deSAchin Gupta 		 unsigned int top_addr_bit1,
115fd6007deSAchin Gupta 		 unsigned char three_sn_en);
116fd6007deSAchin Gupta unsigned int ccn_get_l3_run_mode(void);
117*6331a31aSSoby Mathew int ccn_get_part0_id(uintptr_t periphbase);
118fd6007deSAchin Gupta 
119fd6007deSAchin Gupta #endif /* __ASSEMBLY__ */
120fd6007deSAchin Gupta #endif /* __CCN_H__ */
121