]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/device/c661x/target.h
3b34bc8788017c06ad9e48faeeeecfd0cbb53a1e
[keystone-rtos/ibl.git] / src / device / c661x / target.h
1 /*
2  *
3  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 
4  * 
5  * 
6  *  Redistribution and use in source and binary forms, with or without 
7  *  modification, are permitted provided that the following conditions 
8  *  are met:
9  *
10  *    Redistributions of source code must retain the above copyright 
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  *    Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the 
15  *    documentation and/or other materials provided with the   
16  *    distribution.
17  *
18  *    Neither the name of Texas Instruments Incorporated nor the names of
19  *    its contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
23  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
24  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
26  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
27  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
28  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
31  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
32  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34 */
38 /**************************************************************************
39  * FILE PURPOSE: Target specific definitions
40  **************************************************************************
41  * FILE NAME: target.h
42  *
43  * DESCRIPTION: This file defines target specific values used by low level
44  *                              drivers.
45  *
46  * @file target.h
47  *
48  * @brief
49  *  Low level target specific values are defined
50  *
51  ***************************************************************************/
52 #ifndef _TARGET_H
53 #define _TARGET_H
54 #include "types.h"
55  
56  
57 /** 
58  *  @brief
59  *   Device EMAC definitions
60  */
61  
63 /**
64  *  @brief
65  *    Device Timer definitions
66  */
67 #define TIMER0_BASE             0x02200000u
69 #define TIMER_INPUT_DIVIDER     6           /* Timer driven from cpu clock / 6 */
72 /**
73  *  @def MAIN_PLL
74  */
75 #define MAIN_PLL        0   /**< The index to the main PLL */
77 /**
78  * @def NET_PLL
79  */
80 #define NET_PLL         1   /**< The index to the network PLL */
82 /**
83  *  @def DDR_PLL
84  */
85 #define DDR_PLL         2   /**< The index to the DDR PLL */
88 /**
89  *  @brief
90  *    Device PLL definitions
91  */
92 #define DEVICE_PLL_BASE(x)      ((x) == MAIN_PLL ? 0x2310000 : ((x) == NET_PLL ? 0x2620338 : 0x2620330))
93 #define DEVICE_MAIN_PLL_CTL_0       0x2620328
94 #define DEVICE_MAIN_PLL_CTL_1       0x262032c
97 /**
98  *  @brief
99  *   The c661x devices use a register external to the PLL controller for prediv configuration
100  */
101 #define chipPllExternalPrediv(x)    TRUE
103 /**
104  * @brief 
105  *  Device PSC definitions
106  */
107 #define DEVICE_PSC_BASE     0x02350000u
110 /**
111  * @brief
112  *  The PSC number for the PA sub-system */
113 #define TARGET_PWR_PA       7
115 /**
116  * @brief
117  *  The PSC number for the SGMII */
118 #define TARGET_PWR_ETH(x)   8
120 /** 
121  * @brief
122  *   The PSC numbers for EMIF16 and SPI vary between devices. The devices are run time
123  *   identified by reading the JTAG ID register 
124  */
125 #define DEVICE_C6616_JTAG_ID_VAL    0x9d02f
126 #define DEVICE_C6618_JTAG_ID_VAL    0x9e02f
127 #define DEVICE_JTAG_ID_REG          0x2620018
130 /**
131  *  @brief
132  *    The PSC number for NAND depends on the device
133  */
134 #define TARGET_PWR_NAND         deviceNandPscNum()
135 #define TARGET_PWR_NAND_C6618   3
137 /*
138  *  @brief
139  *     The PSC number for SPI depends on the device
140  */
141 #define TARGET_PWR_SPI      deviceSpiPscNum()
143 /**
144  * @brief
145  *  Flag to indicate timer 0 power up requested. The time is always on in the 6472
146  */
147 #define TARGET_PWR_TIMER_0  -1
149 /**
150  *  @brief
151  *    Device DDR controller definitions
152  */
153 #define DEVICE_EMIF4_BASE  0x21000000
155 /**
156  *  @brief
157  *     Device EMIF 2.5 controller definitions
158  */
159 #define DEVICE_EMIF25_BASE  0x20c00000
161 /** 
162  *  @brief
163  *      NAND memory regions
164  */
165 #define TARGET_MEM_NAND_CS_2    0x70000000 
166 #define TARGET_MEM_NAND_CS_3    0x74000000 
167 #define TARGET_MEM_NAND_CS_4    0x78000000 
168 #define TARGET_MEM_NAND_CS_5    0x7c000000 
169 uint32 deviceNandMemBase (int32 cs);
170 #define TARGET_SHFL(x)  _shfl(x)  /* The shuffle intrinsic */
173 /**
174  * @brief
175  *  The highest module number. The value for nyquist is used
176  */
177 #define TARGET_PWR_MAX_MOD  30
178  
180 /**
181  * @brief
182  *   The base address of MDIO 
183  */
184 #define TARGET_MDIO_BASE    0x2090300
186 /**
187  * @brief
188  *   The number of external ethernet ports
189  */
190 #define TARGET_EMAC_N_PORTS     2
194 /**
195  *  @brief
196  *      The base address of the I2C peripheral, and the module divisor of the cpu clock
197  */
198 #define DEVICE_I2C_BASE                 0x02530000
199 #define DEVICE_I2C_MODULE_DIVISOR       6
200  
201 /**
202  * @brief
203  *     Prototypes for the PLL functions handled outside the main PLL registers
204  */
205 SINT16 chipPllSetExternalPrediv(UINT16 pllNum, UINT32 predivRegVal);
206 SINT16 chipPllExternalBwAdj (UINT16 pllNum, UINT16 mult);
207 UINT32 chipPllExternalMult (UINT16 pllNum, UINT16 mult);
210 /**
211  *  @brief
212  *      Hardware network subsystem support, ethernet switch
213  */
214 #define DEVICE_CPSW
215 #define DEVICE_CPSW_NUM_PORTS       3                    /* 3 switch ports */
216 #define DEVICE_CPSW_BASE            (0x02090800)
217 #define targetGetSwitchCtl()        CPSW_CTL_P0_ENABLE   /* Enable port 0 */
218 #define targetGetSwitchMaxPktSize() 9000
220 #define DEVICE_QM
221 #define DEVICE_QM_MANAGER_BASE          0x02a68000
222 #define DEVICE_QM_DESC_SETUP_BASE       0x02a6a000
223 #define DEVICE_QM_MANAGER_QUEUES_BASE   0x02a20000
224 #define DEVICE_QM_MANAGER_Q_PROXY_BASE  0x02a40000
225 #define DEVICE_QM_QUEUE_STATUS_BASE             0x02a00000
226 #define DEVICE_QM_NUM_LINKRAMS          2
227 #define DEVICE_QM_NUM_MEMREGIONS        20
228 void    *targetGetQmConfig(void);
229 void     targetInitQs (void);
231 #define chipLmbd(x,y) _lmbd(x,y)
236 #define DEVICE_CPDMA
238 #define DEVICE_PA_CDMA_GLOBAL_CFG_BASE   0x02004000
239 #define DEVICE_PA_CDMA_TX_CHAN_CFG_BASE  0x02004400
240 #define DEVICE_PA_CDMA_RX_CHAN_CFG_BASE  0x02004800
241 #define DEVICE_PA_CDMA_RX_FLOW_CFG_BASE  0x02005000
243 #define DEVICE_PA_CDMA_RX_NUM_CHANNELS   24
244 #define DEVICE_PA_CDMA_RX_NUM_FLOWS      32
245 #define DEVICE_PA_CDMA_TX_NUM_CHANNELS   9
248 #define DEVICE_QM_FREE_Q                910
249 #define DEVICE_QM_LNK_BUF_Q             911
250 #define DEVICE_QM_RCV_Q                 912
251 #define DEVICE_QM_TX_Q                  913
252 #define DEVICE_QM_PA_CFG_Q              640
253 #define DEVICE_QM_ETH_TX_Q              648
255 #define DEVICE_RX_CDMA_TIMEOUT_COUNT    1000
259 #define DEVICE_PA
260 #define DEVICE_PA_BASE                  0x02000000
261 #define DEVICE_PA_NUM_PDSPS             6
262 #define DEVICE_PA_RUN_CHECK_COUNT       100         /* Number of loops to verify PA firmware is running */
263 #define DEVICE_PA_PLL_BASE              0x02620338
264 #define chipLower8(x)                   ((x) & 0x00ff)
267 #define TARGET_SGMII_EXTERNAL_SERDES
268 #define TARGET_SGMII_BASE_ADDRESSES    { 0x02090100, 0x02090200 }
269 #define TARGET_SGMII_SERDES_BASE        0x2620340
270 #define TARGET_SGMII_SERDES_STATUS_BASE 0x2620158
271 #define TARGET_SGMII_SOFT_RESET         0x04
272 #define TARGET_SGMII_CONTROL            0x10
273 #define TARGET_SGMII_MR_ADV_ABILITY     0x18
274 void targetSgmiiSerdesConfig (int32 port, void *cfg);
275 #define chipKickOpenSerdes(x)           *((uint32 *)0x2620038) = 0x83e70b13; *((uint32 *)0x262003c) = 0x95a4f1e0
276 #define chipKickClosedSerdes(x)         ;       /* never lock the registers */
277 #define TARGET_SERDES_LOCK_DELAY        (1600*1000)
279 #define DEVICE_EMACSL_BASE(x)           (0x02090900 + (x)*0x040)
280 #define DEVICE_N_GMACSL_PORTS           2
281 #define DEVICE_EMACSL_RESET_POLL_COUNT  100
282 Int32 targetMacSend (void *ptr_device, Uint8* buffer, int num_bytes);
283 Int32 targetMacRcv (void *ptr_device, UINT8 *buffer);
285 #define DEVICE_SS
286 #define DEVICE_PSTREAM_CFG_REG_ADDR                 0x2000604
287 #define DEVICE_PSTREAM_CFG_REG_VAL_ROUTE_PDSP0      0
288 #define hwConfigStreamingSwitch()                   DEVICE_REG32_W(DEVICE_PSTREAM_CFG_REG_ADDR, DEVICE_PSTREAM_CFG_REG_VAL_ROUTE_PDSP0);
291 /**
292  *  @brief
293  *      Register access macros
294  */
295 #define DEVICE_REG32_W(x,y)   *(volatile unsigned int *)(x)=(y)
296 #define DEVICE_REG32_R(x)    (*(volatile unsigned int *)(x))
298 #define BOOTBITMASK(x,y)      (   (   (  ((UINT32)1 << (((UINT32)x)-((UINT32)y)+(UINT32)1) ) - (UINT32)1 )   )   <<  ((UINT32)y)   )
299 #define BOOT_READ_BITFIELD(z,x,y)   (((UINT32)z) & BOOTBITMASK(x,y)) >> (y)
300 #define BOOT_SET_BITFIELD(z,f,x,y)  (((UINT32)z) & ~BOOTBITMASK(x,y)) | ( (((UINT32)f) << (y)) & BOOTBITMASK(x,y) )
302 /** 
303  *  @brief
304  *      Mpax configuration registers 
305  */
306 #define DEVICE_REG_XMPAX_L(x) *((volatile unsigned int *)(0x08000000 + (8*(x))))
307 #define DEVICE_REG_XMPAX_H(x) *((volatile unsigned int *)(0x08000004 + (8*(x))))
309 #endif /* _TARGET_H */