]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/device/c6474/c6474.c
Added two stage load for c6455 and c6474
[keystone-rtos/ibl.git] / src / device / c6474 / c6474.c
1 /************************************************************************************
2  * FILE PURPOSE: C6474 Device Specific functions
3  ************************************************************************************
4  * FILE NAME: c6474.c
5  *
6  * DESCRIPTION: Implements the device specific functions for the IBL
7  *
8  * @file c6474.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
70  *   Enable the DDR
71  *
72  * @details
73  *   The DDR controller on the c6474 is an emif 3.1. The controller is
74  *   initialized directly with the supplied values
75  */
76 void deviceDdrConfig (void)
77 {
78     if (ibl.ddrConfig.configDdr != 0)
79         hwEmif3p1Enable (&ibl.ddrConfig.uEmif.emif3p1);
81 }
82         
84 /**
85  *  @brief Power up a peripheral
86  *
87  *  @details
88  *    Boot peripherals are powered up
89  */
90 int32 devicePowerPeriph (int32 modNum)
91 {
92     /* If the input value is < 0 there is nothing to power up */
93     if (modNum < 0)
94         return (0);
97     if (modNum >= TARGET_PWR_MAX_MOD)
98         return (-1);
100     return ((int32)pscEnableModule(modNum));
101         
105 /**
106  *  @brief  Enable the pass through version of the nand controller
107  *
108  *  @details  On the evm the nand controller is enabled by setting 
109  *            gpio 14 high
110  */
111 #ifndef EXCLUDE_NAND
112 int32 deviceConfigureForNand(void)
114         hwGpioSetDirection(NAND_MODE_GPIO, GPIO_OUT);
115         hwGpioSetOutput(NAND_MODE_GPIO);
116     return (0);
119 #endif
122 /**
123  *  @brief
124  *    The e-fuse mac address is loaded
125  */
126 void deviceLoadDefaultEthAddress (uint8 *maddr)
128     uint32 macA, macB;
130     /* Read the e-fuse mac address */
131     macA = *((uint32 *)0x2880834);
132     macB = *((uint32 *)0x2880838);
134     maddr[0] = (macB >>  8) & 0xff;
135     maddr[1] = (macB >>  0) & 0xff;
136     maddr[2] = (macA >> 24) & 0xff;
137     maddr[3] = (macA >> 16) & 0xff;
138     maddr[4] = (macA >>  8) & 0xff;
139     maddr[5] = (macA >>  0) & 0xff;