]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/isee/igep00x0/igep00x0.c
OMAP3: use a single board file for IGEP devices
[karo-tx-uboot.git] / board / isee / igep00x0 / igep00x0.c
1 /*
2  * (C) Copyright 2010
3  * ISEE 2007 SL, <www.iseebcn.com>
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 #include <common.h>
24 #include <twl4030.h>
25 #include <netdev.h>
26 #include <asm/gpio.h>
27 #include <asm/arch/omap_gpmc.h>
28 #include <asm/io.h>
29 #include <asm/arch/mem.h>
30 #include <asm/arch/mmc_host_def.h>
31 #include <asm/arch/mux.h>
32 #include <asm/arch/sys_proto.h>
33 #include <asm/mach-types.h>
34 #include "igep00x0.h"
35
36 DECLARE_GLOBAL_DATA_PTR;
37
38 #if defined(CONFIG_CMD_NET)
39 /* GPMC definitions for LAN9221 chips */
40 static const u32 gpmc_lan_config[] = {
41         NET_LAN9221_GPMC_CONFIG1,
42         NET_LAN9221_GPMC_CONFIG2,
43         NET_LAN9221_GPMC_CONFIG3,
44         NET_LAN9221_GPMC_CONFIG4,
45         NET_LAN9221_GPMC_CONFIG5,
46         NET_LAN9221_GPMC_CONFIG6,
47 };
48 #endif
49
50 /*
51  * Routine: board_init
52  * Description: Early hardware init.
53  */
54 int board_init(void)
55 {
56         gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
57         /* boot param addr */
58         gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
59
60         return 0;
61 }
62
63 #ifdef CONFIG_SPL_BUILD
64 /*
65  * Routine: omap_rev_string
66  * Description: For SPL builds output board rev
67  */
68 void omap_rev_string(void)
69 {
70 }
71
72 /*
73  * Routine: get_board_mem_timings
74  * Description: If we use SPL then there is no x-loader nor config header
75  * so we have to setup the DDR timings ourself on both banks.
76  */
77 void get_board_mem_timings(struct board_sdrc_timings *timings)
78 {
79         timings->mr = MICRON_V_MR_165;
80 #ifdef CONFIG_BOOT_NAND
81         timings->mcfg = MICRON_V_MCFG_200(256 << 20);
82         timings->ctrla = MICRON_V_ACTIMA_200;
83         timings->ctrlb = MICRON_V_ACTIMB_200;
84         timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
85 #else
86         if (get_cpu_family() == CPU_OMAP34XX) {
87                 timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
88                 timings->ctrla = NUMONYX_V_ACTIMA_165;
89                 timings->ctrlb = NUMONYX_V_ACTIMB_165;
90                 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
91
92         } else {
93                 timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
94                 timings->ctrla = NUMONYX_V_ACTIMA_200;
95                 timings->ctrlb = NUMONYX_V_ACTIMB_200;
96                 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
97         }
98 #endif
99 }
100 #endif
101
102 #if defined(CONFIG_CMD_NET)
103 /*
104  * Routine: setup_net_chip
105  * Description: Setting up the configuration GPMC registers specific to the
106  *              Ethernet hardware.
107  */
108 static void setup_net_chip(void)
109 {
110         struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
111
112         enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
113                         GPMC_SIZE_16M);
114
115         /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
116         writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
117         /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
118         writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
119         /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
120         writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
121                 &ctrl_base->gpmc_nadv_ale);
122
123         /* Make GPIO 64 as output pin and send a magic pulse through it */
124         if (!gpio_request(64, "")) {
125                 gpio_direction_output(64, 0);
126                 gpio_set_value(64, 1);
127                 udelay(1);
128                 gpio_set_value(64, 0);
129                 udelay(1);
130                 gpio_set_value(64, 1);
131         }
132 }
133 #else
134 static inline void setup_net_chip(void) {}
135 #endif
136
137 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
138 int board_mmc_init(bd_t *bis)
139 {
140         omap_mmc_init(0, 0, 0);
141         return 0;
142 }
143 #endif
144
145 /*
146  * Routine: misc_init_r
147  * Description: Configure board specific parts
148  */
149 int misc_init_r(void)
150 {
151         twl4030_power_init();
152
153         setup_net_chip();
154
155         dieid_num_r();
156
157         return 0;
158 }
159
160 /*
161  * Routine: set_muxconf_regs
162  * Description: Setting up the configuration Mux registers specific to the
163  *              hardware. Many pins need to be moved from protect to primary
164  *              mode.
165  */
166 void set_muxconf_regs(void)
167 {
168         MUX_DEFAULT();
169
170 #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
171         MUX_IGEP0020();
172 #endif
173
174 #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
175         MUX_IGEP0030();
176 #endif
177 }
178
179 #if defined(CONFIG_CMD_NET)
180 int board_eth_init(bd_t *bis)
181 {
182         int rc = 0;
183 #ifdef CONFIG_SMC911X
184         rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
185 #endif
186         return rc;
187 }
188 #endif