]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/device/c6474l/c6474l.c
IBL-c6x: C6474 Lite device specific files
[keystone-rtos/ibl.git] / src / device / c6474l / c6474l.c
1 /************************************************************************************\r
2  * FILE PURPOSE: C6474 Device Specific functions\r
3  ************************************************************************************\r
4  * FILE NAME: c6474l.c\r
5  *\r
6  * DESCRIPTION: Implements the device specific functions for the IBL\r
7  *\r
8  * @file c6474l.c\r
9  *\r
10  * @brief\r
11  *  This file implements the device specific functions for the IBL\r
12  *\r
13  ************************************************************************************/\r
14 #include "ibl.h"\r
15 #include "device.h"\r
16 #include "pllapi.h"\r
17 #include "emif31api.h"\r
18 #include "pscapi.h"\r
19 #include "gpio.h"\r
20 #include <string.h>\r
21 \r
22 extern cregister unsigned int DNUM;\r
23 \r
24 \r
25 /**\r
26  *  @brief Determine if an address is local\r
27  *\r
28  *  @details\r
29  *    Examines an input address to determine if it is a local address\r
30  */\r
31 bool address_is_local (Uint32 addr)\r
32 {\r
33     /* L2 */\r
34     if ((addr >= 0x00800000) && (addr < 0x00898000))\r
35         return (TRUE);\r
36 \r
37     /* L1P */\r
38     if ((addr >= 0x00e00000) && (addr < 0x00e08000))\r
39         return (TRUE);\r
40 \r
41     /* L2D */\r
42     if ((addr >= 0x00f00000) && (addr < 0x00f08000))\r
43         return (TRUE);\r
44 \r
45     return (FALSE);\r
46 \r
47 }\r
48 \r
49 \r
50 /**\r
51  * @brief  Convert a local l1d, l1p or l2 address to a global address\r
52  *\r
53  * @details\r
54  *  The global address is formed. If the address is not local then\r
55  *  the input address is returned\r
56  */\r
57 Uint32 deviceLocalAddrToGlobal (Uint32 addr)\r
58 {\r
59 \r
60     if (address_is_local (addr))\r
61         addr = (1 << 28) | (DNUM << 24) | addr;\r
62 \r
63     return (addr);\r
64 \r
65 }\r
66         \r
67         \r
68 /**\r
69  * @brief Configure the PLLs\r
70  *\r
71  * @details\r
72  *   Only the main PLL can be configured here. The DDR pll is enabled by default,\r
73  *   and the network PLL is enabled through serdes configuration.\r
74  *   the multiplier and dividers.\r
75  */\r
76 void devicePllConfig (void)\r
77 {\r
78     if (ibl.pllConfig[ibl_MAIN_PLL].doEnable == TRUE)\r
79         hwPllSetPll (MAIN_PLL, \r
80                      ibl.pllConfig[ibl_MAIN_PLL].prediv,\r
81                      ibl.pllConfig[ibl_MAIN_PLL].mult,\r
82                      ibl.pllConfig[ibl_MAIN_PLL].postdiv);\r
83 \r
84 }\r
85 \r
86 /**\r
87  * @brief\r
88  *   Enable the DDR\r
89  *\r
90  * @details\r
91  *   The DDR controller on the c6474 is an emif 3.1. The controller is\r
92  *   initialized directly with the supplied values\r
93  */\r
94 void deviceDdrConfig (void)\r
95 {\r
96     if (ibl.ddrConfig.configDdr != 0)\r
97         hwEmif3p1Enable (&ibl.ddrConfig.uEmif.emif3p1);\r
98 \r
99 }\r
100         \r
101 \r
102 /**\r
103  *  @brief Power up a peripheral\r
104  *\r
105  *  @details\r
106  *    Boot peripherals are powered up\r
107  */\r
108 int32 devicePowerPeriph (int32 modNum)\r
109 {\r
110     /* If the input value is < 0 there is nothing to power up */\r
111     if (modNum < 0)\r
112         return (0);\r
113 \r
114 \r
115     if (modNum >= TARGET_PWR_MAX_MOD)\r
116         return (-1);\r
117 \r
118     return ((int32)pscEnableModule(modNum));\r
119         \r
120 }\r
121 \r
122 \r
123 /**\r
124  *  @brief  Enable the pass through version of the nand controller\r
125  *\r
126  *  @details  On the evm the nand controller is enabled by setting \r
127  *            gpio 14 high\r
128  */\r
129 #if 0\r
130 int32 deviceConfigureForNand(void)\r
131 {\r
132         hwGpioSetDirection(NAND_MODE_GPIO, GPIO_OUT);\r
133         hwGpioSetOutput(NAND_MODE_GPIO);\r
134     return (0);\r
135 \r
136 }\r
137 #endif\r
138 \r
139 \r
140 /**\r
141  *  @brief\r
142  *    The e-fuse mac address is loaded\r
143  */\r
144 void deviceLoadDefaultEthAddress (uint8 *maddr)\r
145 {\r
146     uint32 macA, macB;\r
147 \r
148     /* Read the e-fuse mac address */\r
149     macA = *((uint32 *)0x2880834);\r
150     macB = *((uint32 *)0x2880838);\r
151 \r
152     maddr[0] = (macB >>  8) & 0xff;\r
153     maddr[1] = (macB >>  0) & 0xff;\r
154     maddr[2] = (macA >> 24) & 0xff;\r
155     maddr[3] = (macA >> 16) & 0xff;\r
156     maddr[4] = (macA >>  8) & 0xff;\r
157     maddr[5] = (macA >>  0) & 0xff;\r
158 }\r
159 \r
160 \r
161 \r
162 \r
163 \r