1 /************************************************************************************
2 * FILE PURPOSE: C6472 Device Specific functions
3 ************************************************************************************
4 * FILE NAME: c6472.c
5 *
6 * DESCRIPTION: Implements the device specific functions for the IBL
7 *
8 * @file c6472.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 }
68 /**
69 * @brief
70 * Enable the DDR
71 *
72 * @details
73 * The DDR controller on the c6472 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 }
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));
102 }
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 int32 deviceConfigureForNand(void)
112 {
113 hwGpioSetDirection(NAND_MODE_GPIO, GPIO_OUT);
114 hwGpioSetOutput(NAND_MODE_GPIO);
115 return (0);
117 }
120 /**
121 * @brief
122 * The e-fuse mac address is loaded
123 */
124 void deviceLoadDefaultEthAddress (uint8 *maddr)
125 {
126 uint32 macA, macB;
128 /* Read the e-fuse mac address */
129 macA = *((uint32 *)0x2a80700);
130 macB = *((uint32 *)0x2a80704);
132 maddr[0] = (macA >> 24) & 0xff;
133 maddr[1] = (macA >> 16) & 0xff;
134 maddr[2] = (macA >> 8) & 0xff;
135 maddr[3] = (macA >> 0) & 0xff;
136 maddr[4] = (macB >> 24) & 0xff;
137 maddr[5] = (macB >> 16) & 0xff;
138 }