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