2 * (C) Copyright 2004-2008
3 * Texas Instruments, <www.ti.com>
6 * Sunil Kumar <sunilsaini05@gmail.com>
7 * Shashi Ranjan <shashiranjanmca05@gmail.com>
9 * Derived from Beagle Board and 3430 SDP code by
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Syed Mohammed Khasim <khasim@ti.com>
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #ifdef CONFIG_STATUS_LED
34 #include <status_led.h>
38 #include <asm/arch/mmc_host_def.h>
39 #include <asm/arch/mux.h>
40 #include <asm/arch/sys_proto.h>
41 #include <asm/arch/gpio.h>
42 #include <asm/mach-types.h>
45 #define TWL4030_I2C_BUS 0
46 #define EXPANSION_EEPROM_I2C_BUS 1
47 #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
49 #define TINCANTOOLS_ZIPPY 0x01000100
50 #define TINCANTOOLS_ZIPPY2 0x02000100
51 #define TINCANTOOLS_TRAINER 0x04000100
52 #define TINCANTOOLS_SHOWDOG 0x03000100
53 #define KBADC_BEAGLEFPGA 0x01000600
55 #define BEAGLE_NO_EEPROM 0xffffffff
57 DECLARE_GLOBAL_DATA_PTR;
60 unsigned int device_vendor;
61 unsigned char revision;
62 unsigned char content;
70 * Description: Early hardware init.
74 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
75 /* board id for Linux */
76 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
78 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
80 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
81 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
88 * Routine: get_board_revision
89 * Description: Detect if we are running on a Beagle revision Ax/Bx,
90 * C1/2/3, C4 or xM. This can be done by reading
91 * the level of GPIO173, GPIO172 and GPIO171. This should
93 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
94 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
95 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
96 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
98 int get_board_revision(void)
102 if (!omap_request_gpio(171) &&
103 !omap_request_gpio(172) &&
104 !omap_request_gpio(173)) {
106 omap_set_gpio_direction(171, 1);
107 omap_set_gpio_direction(172, 1);
108 omap_set_gpio_direction(173, 1);
110 revision = omap_get_gpio_datain(173) << 2 |
111 omap_get_gpio_datain(172) << 1 |
112 omap_get_gpio_datain(171);
118 printf("Error: unable to acquire board revision GPIOs\n");
126 * Routine: get_expansion_id
127 * Description: This function checks for expansion board by checking I2C
128 * bus 1 for the availability of an AT24C01B serial EEPROM.
129 * returns the device_vendor field from the EEPROM
131 unsigned int get_expansion_id(void)
133 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
135 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
136 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
137 i2c_set_bus_num(TWL4030_I2C_BUS);
138 return BEAGLE_NO_EEPROM;
141 /* read configuration data */
142 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
143 sizeof(expansion_config));
145 i2c_set_bus_num(TWL4030_I2C_BUS);
147 return expansion_config.device_vendor;
151 * Routine: misc_init_r
152 * Description: Configure board specific parts
154 int misc_init_r(void)
156 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
157 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
158 struct control_prog_io *prog_io_base = (struct gpio *)OMAP34XX_CTRL_BASE;
160 /* Enable i2c2 pullup resisters */
161 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
163 switch (get_board_revision()) {
165 printf("Beagle Rev Ax/Bx\n");
166 setenv("beaglerev", "AxBx");
169 printf("Beagle Rev C1/C2/C3\n");
170 setenv("beaglerev", "Cx");
174 printf("Beagle Rev C4\n");
175 setenv("beaglerev", "C4");
177 /* Set VAUX2 to 1.8V for EHCI PHY */
178 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
179 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
180 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
181 TWL4030_PM_RECEIVER_DEV_GRP_P1);
184 printf("Beagle xM Rev A\n");
185 setenv("beaglerev", "xMA");
187 /* Set VAUX2 to 1.8V for EHCI PHY */
188 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
189 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
190 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
191 TWL4030_PM_RECEIVER_DEV_GRP_P1);
194 printf("Beagle xM Rev B\n");
195 setenv("beaglerev", "xMB");
197 /* Set VAUX2 to 1.8V for EHCI PHY */
198 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
199 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
200 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
201 TWL4030_PM_RECEIVER_DEV_GRP_P1);
204 printf("Beagle unknown 0x%02x\n", get_board_revision());
206 /* Set VAUX2 to 1.8V for EHCI PHY */
207 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
208 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
209 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
210 TWL4030_PM_RECEIVER_DEV_GRP_P1);
213 switch (get_expansion_id()) {
214 case TINCANTOOLS_ZIPPY:
215 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
216 expansion_config.revision,
217 expansion_config.fab_revision);
218 MUX_TINCANTOOLS_ZIPPY();
219 setenv("buddy", "zippy");
221 case TINCANTOOLS_ZIPPY2:
222 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
223 expansion_config.revision,
224 expansion_config.fab_revision);
225 MUX_TINCANTOOLS_ZIPPY();
226 setenv("buddy", "zippy2");
228 case TINCANTOOLS_TRAINER:
229 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
230 expansion_config.revision,
231 expansion_config.fab_revision);
232 MUX_TINCANTOOLS_ZIPPY();
233 MUX_TINCANTOOLS_TRAINER();
234 setenv("buddy", "trainer");
236 case TINCANTOOLS_SHOWDOG:
237 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
238 expansion_config.revision,
239 expansion_config.fab_revision);
240 /* Place holder for DSS2 definition for showdog lcd */
241 setenv("defaultdisplay", "showdoglcd");
242 setenv("buddy", "showdog");
244 case KBADC_BEAGLEFPGA:
245 printf("Recognized KBADC Beagle FPGA board\n");
246 MUX_KBADC_BEAGLEFPGA();
247 setenv("buddy", "beaglefpga");
249 case BEAGLE_NO_EEPROM:
250 printf("No EEPROM on expansion board\n");
251 setenv("buddy", "none");
254 printf("Unrecognized expansion board: %x\n",
255 expansion_config.device_vendor);
256 setenv("buddy", "unknown");
259 if (expansion_config.content == 1)
260 setenv(expansion_config.env_var, expansion_config.env_setting);
262 twl4030_power_init();
263 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
265 /* Configure GPIOs to output */
266 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
267 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
268 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
271 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
272 &gpio6_base->setdataout);
273 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
274 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
282 * Routine: set_muxconf_regs
283 * Description: Setting up the configuration Mux registers specific to the
284 * hardware. Many pins need to be moved from protect to primary
287 void set_muxconf_regs(void)
292 #ifdef CONFIG_GENERIC_MMC
293 int board_mmc_init(bd_t *bis)