2 * (C) Copyright 2011 Comelit Group SpA
3 * Luca Ceresoli <luca.ceresoli@comelit.it>
5 * Based on board/ti/beagle/beagle.c:
6 * (C) Copyright 2004-2008
7 * Texas Instruments, <www.ti.com>
10 * Sunil Kumar <sunilsaini05@gmail.com>
11 * Shashi Ranjan <shashiranjanmca05@gmail.com>
13 * Derived from Beagle Board and 3430 SDP code by
14 * Richard Woodruff <r-woodruff2@ti.com>
15 * Syed Mohammed Khasim <khasim@ti.com>
18 * See file CREDITS for list of people who contributed to this
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License as
23 * published by the Free Software Foundation; either version 2 of
24 * the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
40 #include <asm/arch/omap3-regs.h>
41 #include <asm/arch/mux.h>
42 #include <asm/arch/mem.h>
43 #include <asm/arch/sys_proto.h>
44 #include <asm/arch/gpio.h>
45 #include <asm/mach-types.h>
48 DECLARE_GLOBAL_DATA_PTR;
51 static void setup_net_chip(void);
53 #define NET_LAN9221_RESET_GPIO 12
55 /* GPMC CS 5 connected to an SMSC LAN9220 ethernet controller */
56 #define NET_LAN9220_GPMC_CONFIG1 (DEVICESIZE_16BIT)
57 #define NET_LAN9220_GPMC_CONFIG2 (CSWROFFTIME(8) | \
60 #define NET_LAN9220_GPMC_CONFIG3 (ADVWROFFTIME(2) | \
63 #define NET_LAN9220_GPMC_CONFIG4 (WEOFFTIME(8) | \
67 #define NET_LAN9220_GPMC_CONFIG5 (PAGEBURSTACCESSTIME(0) | \
71 #define NET_LAN9220_GPMC_CONFIG6 ((1 << 31) | \
72 WRACCESSTIME(0x1D) | \
75 static const u32 gpmc_lan_config[] = {
76 NET_LAN9220_GPMC_CONFIG1,
77 NET_LAN9220_GPMC_CONFIG2,
78 NET_LAN9220_GPMC_CONFIG3,
79 NET_LAN9220_GPMC_CONFIG4,
80 NET_LAN9220_GPMC_CONFIG5,
81 NET_LAN9220_GPMC_CONFIG6,
82 /* CONFIG7: computed by enable_gpmc_cs_config() */
84 #endif /* CONFIG_CMD_NET */
88 * Description: Early hardware init.
92 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
93 /* board id for Linux */
94 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_CPS;
96 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
102 * Routine: misc_init_r
103 * Description: Configure board specific parts
105 int misc_init_r(void)
107 struct gpio *gpio1_base = (struct gpio *)OMAP34XX_GPIO1_BASE;
108 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
110 twl4030_power_init();
111 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
115 * - 159 OUT (GPIO5+31): reset for remote camera interface connector.
116 * - 19 OUT (GPIO1+19): integrated speaker amplifier (1=on, 0=shdn).
117 * - 20 OUT (GPIO1+20): handset amplifier (1=on, 0=shdn).
120 /* Configure GPIOs to output */
121 writel(~(GPIO19 | GPIO20), &gpio1_base->oe);
122 writel(~(GPIO31), &gpio5_base->oe);
124 /* Set GPIO values */
125 writel((GPIO19 | GPIO20), &gpio1_base->setdataout);
126 writel(0, &gpio5_base->setdataout);
128 #if defined(CONFIG_CMD_NET)
138 * Routine: set_muxconf_regs
139 * Description: Setting up the configuration Mux registers specific to the
140 * hardware. Many pins need to be moved from protect to primary
143 void set_muxconf_regs(void)
148 #ifdef CONFIG_CMD_NET
150 * Routine: setup_net_chip
151 * Description: Setting up the configuration GPMC registers specific to the
154 static void setup_net_chip(void)
156 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
158 /* Configure GPMC registers */
159 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
160 CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
162 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
163 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
164 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
165 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
166 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
167 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
168 &ctrl_base->gpmc_nadv_ale);
170 /* Make GPIO 12 as output pin and send a magic pulse through it */
171 if (!omap_request_gpio(NET_LAN9221_RESET_GPIO)) {
172 omap_set_gpio_direction(NET_LAN9221_RESET_GPIO, 0);
173 omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 1);
175 omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 0);
176 udelay(31000); /* Should be >= 30ms according to datasheet */
177 omap_set_gpio_dataout(NET_LAN9221_RESET_GPIO, 1);
180 #endif /* CONFIG_CMD_NET */
182 int board_eth_init(bd_t *bis)
185 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);