blob: cfdc4df9160ac65b41c5846e1006cd9c0ab39808 [file] [log] [blame]
Mike Rapoport36b4e2d2010-12-18 17:43:19 -05001/*
Igor Grinbergdccd9a02011-04-18 17:48:31 -04002 * (C) Copyright 2011
Mike Rapoport36b4e2d2010-12-18 17:43:19 -05003 * CompuLab, Ltd. <www.compulab.co.il>
4 *
Igor Grinbergdccd9a02011-04-18 17:48:31 -04005 * Authors: Mike Rapoport <mike@compulab.co.il>
6 * Igor Grinberg <grinberg@compulab.co.il>
Mike Rapoport36b4e2d2010-12-18 17:43:19 -05007 *
8 * Derived from omap3evm and Beagle Board by
9 * Manikandan Pillai <mani.pillai@ti.com>
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Syed Mohammed Khasim <x0khasim@ti.com>
12 *
13 * See file CREDITS for list of people who contributed to this
14 * project.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
Igor Grinbergdccd9a02011-04-18 17:48:31 -040028 * Foundation, Inc.
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050029 */
30
31#include <common.h>
Igor Grinberg2b8754b2011-04-18 17:54:33 -040032#include <status_led.h>
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050033#include <netdev.h>
34#include <net.h>
35#include <i2c.h>
36#include <twl4030.h>
37
38#include <asm/io.h>
39#include <asm/arch/mem.h>
40#include <asm/arch/mux.h>
41#include <asm/arch/mmc_host_def.h>
42#include <asm/arch/sys_proto.h>
43#include <asm/mach-types.h>
44
Igor Grinberg557aa152011-04-18 17:43:26 -040045DECLARE_GLOBAL_DATA_PTR;
46
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050047const omap3_sysinfo sysinfo = {
48 DDR_DISCRETE,
49 "CM-T35 board",
50 "NAND",
51};
52
53static u32 gpmc_net_config[GPMC_MAX_REG] = {
54 NET_GPMC_CONFIG1,
55 NET_GPMC_CONFIG2,
56 NET_GPMC_CONFIG3,
57 NET_GPMC_CONFIG4,
58 NET_GPMC_CONFIG5,
59 NET_GPMC_CONFIG6,
60 0
61};
62
63static u32 gpmc_nand_config[GPMC_MAX_REG] = {
64 SMNAND_GPMC_CONFIG1,
65 SMNAND_GPMC_CONFIG2,
66 SMNAND_GPMC_CONFIG3,
67 SMNAND_GPMC_CONFIG4,
68 SMNAND_GPMC_CONFIG5,
69 SMNAND_GPMC_CONFIG6,
70 0,
71};
72
73/*
74 * Routine: board_init
75 * Description: Early hardware init.
76 */
77int board_init(void)
78{
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050079 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
80
81 enable_gpmc_cs_config(gpmc_nand_config, &gpmc_cfg->cs[0],
82 CONFIG_SYS_NAND_BASE, GPMC_SIZE_16M);
83
84 /* board id for Linux */
85 gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
86 /* boot param addr */
87 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
88
Igor Grinberg2b8754b2011-04-18 17:54:33 -040089#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
90 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
91#endif
92
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050093 return 0;
94}
95
96/*
97 * Routine: misc_init_r
Igor Grinbergafff1fc2011-04-18 17:53:33 -040098 * Description: display die ID
Mike Rapoport36b4e2d2010-12-18 17:43:19 -050099 */
100int misc_init_r(void)
101{
Mike Rapoport36b4e2d2010-12-18 17:43:19 -0500102 dieid_num_r();
103
104 return 0;
105}
106
107/*
108 * Routine: set_muxconf_regs
109 * Description: Setting up the configuration Mux registers specific to the
110 * hardware. Many pins need to be moved from protect to primary
111 * mode.
112 */
113void set_muxconf_regs(void)
114{
115 /* SDRC */
116 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)); /*SDRC_D0*/
117 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)); /*SDRC_D1*/
118 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)); /*SDRC_D2*/
119 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)); /*SDRC_D3*/
120 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)); /*SDRC_D4*/
121 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)); /*SDRC_D5*/
122 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)); /*SDRC_D6*/
123 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)); /*SDRC_D7*/
124 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)); /*SDRC_D8*/
125 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)); /*SDRC_D9*/
126 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)); /*SDRC_D10*/
127 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)); /*SDRC_D11*/
128 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)); /*SDRC_D12*/
129 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)); /*SDRC_D13*/
130 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)); /*SDRC_D14*/
131 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)); /*SDRC_D15*/
132 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)); /*SDRC_D16*/
133 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)); /*SDRC_D17*/
134 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)); /*SDRC_D18*/
135 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)); /*SDRC_D19*/
136 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)); /*SDRC_D20*/
137 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)); /*SDRC_D21*/
138 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)); /*SDRC_D22*/
139 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)); /*SDRC_D23*/
140 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)); /*SDRC_D24*/
141 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)); /*SDRC_D25*/
142 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)); /*SDRC_D26*/
143 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)); /*SDRC_D27*/
144 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)); /*SDRC_D28*/
145 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)); /*SDRC_D29*/
146 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)); /*SDRC_D30*/
147 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)); /*SDRC_D31*/
148 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)); /*SDRC_CLK*/
149 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)); /*SDRC_DQS0*/
150 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)); /*SDRC_DQS1*/
151 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)); /*SDRC_DQS2*/
152 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)); /*SDRC_DQS3*/
153 MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0)); /*SDRC_CKE0*/
154 MUX_VAL(CP(SDRC_CKE1), (IDIS | PTD | DIS | M7)); /*SDRC_CKE1*/
155
156 /* GPMC */
157 MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0)); /*GPMC_A1*/
158 MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0)); /*GPMC_A2*/
159 MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0)); /*GPMC_A3*/
160 MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0)); /*GPMC_A4*/
161 MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0)); /*GPMC_A5*/
162 MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0)); /*GPMC_A6*/
163 MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0)); /*GPMC_A7*/
164 MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0)); /*GPMC_A8*/
165 MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0)); /*GPMC_A9*/
166 MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0)); /*GPMC_A10*/
167 MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0)); /*GPMC_D0*/
168 MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0)); /*GPMC_D1*/
169 MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0)); /*GPMC_D2*/
170 MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0)); /*GPMC_D3*/
171 MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0)); /*GPMC_D4*/
172 MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0)); /*GPMC_D5*/
173 MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0)); /*GPMC_D6*/
174 MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0)); /*GPMC_D7*/
175 MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0)); /*GPMC_D8*/
176 MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0)); /*GPMC_D9*/
177 MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0)); /*GPMC_D10*/
178 MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0)); /*GPMC_D11*/
179 MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0)); /*GPMC_D12*/
180 MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0)); /*GPMC_D13*/
181 MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0)); /*GPMC_D14*/
182 MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0)); /*GPMC_D15*/
183 MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0)); /*GPMC_nCS0*/
184
185 /* SB-T35 Ethernet */
186 MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M0)); /*GPMC_nCS4*/
187
188 /* CM-T35 Ethernet */
189 MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M0)); /*GPMC_nCS5*/
190 MUX_VAL(CP(GPMC_CLK), (IEN | PTD | DIS | M4)); /*GPIO_59*/
191 MUX_VAL(CP(GPMC_NADV_ALE), (IDIS | PTD | DIS | M0)); /*nADV_ALE*/
192 MUX_VAL(CP(GPMC_NOE), (IDIS | PTD | DIS | M0)); /*nOE*/
193 MUX_VAL(CP(GPMC_NWE), (IDIS | PTD | DIS | M0)); /*nWE*/
194 MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0)); /*nBE0_CLE*/
195 MUX_VAL(CP(GPMC_NBE1), (IDIS | PTD | DIS | M4)); /*GPIO_61*/
196 MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0)); /*nWP*/
197 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)); /*WAIT0*/
198
199 /* DSS */
200 MUX_VAL(CP(DSS_PCLK), (IDIS | PTD | DIS | M0)); /*DSS_PCLK*/
201 MUX_VAL(CP(DSS_HSYNC), (IDIS | PTD | DIS | M0)); /*DSS_HSYNC*/
202 MUX_VAL(CP(DSS_VSYNC), (IDIS | PTD | DIS | M0)); /*DSS_VSYNC*/
203 MUX_VAL(CP(DSS_ACBIAS), (IDIS | PTD | DIS | M0)); /*DSS_ACBIAS*/
204 MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0)); /*DSS_DATA0*/
205 MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0)); /*DSS_DATA1*/
206 MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0)); /*DSS_DATA2*/
207 MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0)); /*DSS_DATA3*/
208 MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0)); /*DSS_DATA4*/
209 MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0)); /*DSS_DATA5*/
210 MUX_VAL(CP(DSS_DATA6), (IDIS | PTD | DIS | M0)); /*DSS_DATA6*/
211 MUX_VAL(CP(DSS_DATA7), (IDIS | PTD | DIS | M0)); /*DSS_DATA7*/
212 MUX_VAL(CP(DSS_DATA8), (IDIS | PTD | DIS | M0)); /*DSS_DATA8*/
213 MUX_VAL(CP(DSS_DATA9), (IDIS | PTD | DIS | M0)); /*DSS_DATA9*/
214 MUX_VAL(CP(DSS_DATA10), (IDIS | PTD | DIS | M0)); /*DSS_DATA10*/
215 MUX_VAL(CP(DSS_DATA11), (IDIS | PTD | DIS | M0)); /*DSS_DATA11*/
216 MUX_VAL(CP(DSS_DATA12), (IDIS | PTD | DIS | M0)); /*DSS_DATA12*/
217 MUX_VAL(CP(DSS_DATA13), (IDIS | PTD | DIS | M0)); /*DSS_DATA13*/
218 MUX_VAL(CP(DSS_DATA14), (IDIS | PTD | DIS | M0)); /*DSS_DATA14*/
219 MUX_VAL(CP(DSS_DATA15), (IDIS | PTD | DIS | M0)); /*DSS_DATA15*/
220 MUX_VAL(CP(DSS_DATA16), (IDIS | PTD | DIS | M0)); /*DSS_DATA16*/
221 MUX_VAL(CP(DSS_DATA17), (IDIS | PTD | DIS | M0)); /*DSS_DATA17*/
222 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/
223 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/
224 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/
225 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/
226 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/
227 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/
228
229 /* serial interface */
230 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)); /*UART3_RX*/
231 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)); /*UART3_TX*/
232
233 /* mUSB */
234 MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0)); /*HSUSB0_CLK*/
235 MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0)); /*HSUSB0_STP*/
236 MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0)); /*HSUSB0_DIR*/
237 MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0)); /*HSUSB0_NXT*/
238 MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA0*/
239 MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA1*/
240 MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA2*/
241 MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA3*/
242 MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA4*/
243 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA5*/
244 MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA6*/
245 MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA7*/
246
247 /* I2C1 */
248 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)); /*I2C1_SCL*/
249 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)); /*I2C1_SDA*/
250
251 /* control and debug */
252 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)); /*SYS_32K*/
253 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTD | DIS | M0)); /*SYS_CLKREQ*/
254 MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0)); /*SYS_nIRQ*/
255 MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0)); /*OFF_MODE*/
256 MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0)); /*CLKOUT1*/
Igor Grinberg2b8754b2011-04-18 17:54:33 -0400257 MUX_VAL(CP(SYS_CLKOUT2), (IDIS | PTU | DIS | M4)); /*green LED*/
Mike Rapoport36b4e2d2010-12-18 17:43:19 -0500258 MUX_VAL(CP(JTAG_nTRST), (IEN | PTD | DIS | M0)); /*JTAG_nTRST*/
259 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)); /*JTAG_TCK*/
260 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)); /*JTAG_TMS*/
261 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)); /*JTAG_TDI*/
Igor Grinbergeec70c22011-04-18 17:50:07 -0400262
263 /* MMC1 */
264 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)); /*MMC1_CLK*/
265 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)); /*MMC1_CMD*/
266 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)); /*MMC1_DAT0*/
267 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)); /*MMC1_DAT1*/
268 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)); /*MMC1_DAT2*/
269 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)); /*MMC1_DAT3*/
270 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)); /*MMC1_DAT4*/
271 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)); /*MMC1_DAT5*/
272 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)); /*MMC1_DAT6*/
273 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)); /*MMC1_DAT7*/
Mike Rapoport36b4e2d2010-12-18 17:43:19 -0500274}
275
Mike Rapoport36b4e2d2010-12-18 17:43:19 -0500276/*
277 * Routine: setup_net_chip_gmpc
278 * Description: Setting up the configuration GPMC registers specific to the
279 * Ethernet hardware.
280 */
281static void setup_net_chip_gmpc(void)
282{
283 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
284
285 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[5],
286 CM_T35_SMC911X_BASE, GPMC_SIZE_16M);
287 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[4],
288 SB_T35_SMC911X_BASE, GPMC_SIZE_16M);
289
290 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
291 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
292
293 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
294 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
295
296 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
297 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
298 &ctrl_base->gpmc_nadv_ale);
299}
300
301#ifdef CONFIG_DRIVER_OMAP34XX_I2C
302/*
303 * Routine: reset_net_chip
304 * Description: reset the Ethernet controller via TPS65930 GPIO
305 */
306static void reset_net_chip(void)
307{
308 /* Set GPIO1 of TPS65930 as output */
309 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
310 TWL4030_BASEADD_GPIO+0x03);
311 /* Send a pulse on the GPIO pin */
312 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
313 TWL4030_BASEADD_GPIO+0x0C);
314 udelay(1);
315 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
316 TWL4030_BASEADD_GPIO+0x09);
317 udelay(1);
318 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
319 TWL4030_BASEADD_GPIO+0x0C);
320}
321#else
322static inline void reset_net_chip(void) {}
323#endif
324
325/*
326 * Routine: handle_mac_address
327 * Description: prepare MAC address for on-board Ethernet.
328 */
329static int handle_mac_address(void)
330{
331 unsigned char enetaddr[6];
332 int rc;
333
334 rc = eth_getenv_enetaddr("ethaddr", enetaddr);
335 if (rc)
336 return 0;
337
338#ifdef CONFIG_DRIVER_OMAP34XX_I2C
339 rc = i2c_read(0x50, 0, 1, enetaddr, 6);
340 if (rc)
341 return rc;
342#endif
343
344 if (!is_valid_ether_addr(enetaddr))
345 return -1;
346
347 return eth_setenv_enetaddr("ethaddr", enetaddr);
348}
349
350
351/*
352 * Routine: board_eth_init
353 * Description: initialize module and base-board Ethernet chips
354 */
355int board_eth_init(bd_t *bis)
356{
357 int rc = 0, rc1 = 0;
358
359#ifdef CONFIG_SMC911X
360 setup_net_chip_gmpc();
361 reset_net_chip();
362
363 rc1 = handle_mac_address();
364 if (rc1)
365 printf("CM-T35: No MAC address found\n");
366
367 rc1 = smc911x_initialize(0, CM_T35_SMC911X_BASE);
368 if (rc1 > 0)
369 rc++;
370
371 rc1 = smc911x_initialize(1, SB_T35_SMC911X_BASE);
372 if (rc1 > 0)
373 rc++;
374#endif
375
376 return rc;
377}