]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/device/c6474/c6474.c
c64x: Add Multi Boot Support
[keystone-rtos/ibl.git] / src / device / c6474 / c6474.c
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: C6474 Device Specific functions
40  ************************************************************************************
41  * FILE NAME: c6474.c
42  *
43  * DESCRIPTION: Implements the device specific functions for the IBL
44  *
45  * @file c6474.c
46  *
47  * @brief
48  *  This file implements the device specific functions for the IBL
49  *
50  ************************************************************************************/
51 #include "ibl.h"
52 #include "device.h"
53 #include "pllapi.h"
54 #include "emif31api.h"
55 #include "pscapi.h"
56 #include "gpio.h"
57 #include "nandhwapi.h"
58 #include <string.h>
60 extern cregister unsigned int DNUM;
63 /**
64  *  @brief Determine if an address is local
65  *
66  *  @details
67  *    Examines an input address to determine if it is a local address
68  */
69 bool address_is_local (Uint32 addr)
70 {
71     /* L2 */
72     if ((addr >= 0x00800000) && (addr < 0x00898000))
73         return (TRUE);
75     /* L1P */
76     if ((addr >= 0x00e00000) && (addr < 0x00e08000))
77         return (TRUE);
79     /* L2D */
80     if ((addr >= 0x00f00000) && (addr < 0x00f08000))
81         return (TRUE);
83     return (FALSE);
85 }
88 /**
89  * @brief  Convert a local l1d, l1p or l2 address to a global address
90  *
91  * @details
92  *  The global address is formed. If the address is not local then
93  *  the input address is returned
94  */
95 Uint32 deviceLocalAddrToGlobal (Uint32 addr)
96 {
98     if (address_is_local (addr))
99         addr = (1 << 28) | (DNUM << 24) | addr;
101     return (addr);
104         
105         
106 /**
107  * @brief
108  *   Enable the DDR
109  *
110  * @details
111  *   The DDR controller on the c6474 is an emif 3.1. The controller is
112  *   initialized directly with the supplied values
113  */
114 void deviceDdrConfig (void)
116     if (ibl.ddrConfig.configDdr != 0)
117         hwEmif3p1Enable (&ibl.ddrConfig.uEmif.emif3p1);
120         
122 /**
123  *  @brief Power up a peripheral
124  *
125  *  @details
126  *    Boot peripherals are powered up
127  */
128 int32 devicePowerPeriph (int32 modNum)
130     /* If the input value is < 0 there is nothing to power up */
131     if (modNum < 0)
132         return (0);
135     if (modNum >= TARGET_PWR_MAX_MOD)
136         return (-1);
138     return ((int32)pscEnableModule(modNum));
139         
142 unsigned int get_device_switch_setting()
144         return (0);
147 /**
148  *  @brief  Enable the pass through version of the nand controller
149  *
150  *  @details  On the evm the nand controller is enabled by setting 
151  *            gpio 14 high
152  */
153 #ifndef EXCLUDE_NAND_GPIO
154 int32 deviceConfigureForNand(void)
156         hwGpioSetDirection(NAND_MODE_GPIO, GPIO_OUT);
157         hwGpioSetOutput(NAND_MODE_GPIO);
158     return (0);
161 #endif
164 /**
165  *  @brief
166  *    The e-fuse mac address is loaded
167  */
168 void deviceLoadDefaultEthAddress (uint8 *maddr)
170     uint32 macA, macB;
172     /* Read the e-fuse mac address */
173     macA = *((uint32 *)0x2880834);
174     macB = *((uint32 *)0x2880838);
176     maddr[0] = (macB >>  8) & 0xff;
177     maddr[1] = (macB >>  0) & 0xff;
178     maddr[2] = (macA >> 24) & 0xff;
179     maddr[3] = (macA >> 16) & 0xff;
180     maddr[4] = (macA >>  8) & 0xff;
181     maddr[5] = (macA >>  0) & 0xff;
184 /**
185  *  @brief  Return the NAND interface call table. Only GPIO is supported on c6474 
186  */
188 #ifndef EXCLUDE_NAND_GPIO
189 nandCtbl_t nandCtbl =  {
191     nandHwGpioDriverInit,
192     nandHwGpioDriverReadBytes,
193     nandHwGpioDriverReadPage,
194     nandHwGpioDriverClose
196 };
198 nandCtbl_t *deviceGetNandCtbl (int32 interface)
200     return (&nandCtbl);
202 #endif