2 * (C) Copyright 2004-2011
3 * Texas Instruments, <www.ti.com>
9 * Derived from Beagle Board and 3430 SDP code by
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>
37 #include <linux/mtd/nand.h>
39 #include <asm/arch/mmc_host_def.h>
40 #include <asm/arch/mux.h>
41 #include <asm/arch/mem.h>
42 #include <asm/arch/sys_proto.h>
44 #include <asm/mach-types.h>
48 #ifdef CONFIG_USB_EHCI
50 #include <asm/ehci-omap.h>
53 #define TWL4030_I2C_BUS 0
54 #define EXPANSION_EEPROM_I2C_BUS 1
55 #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
57 #define TINCANTOOLS_ZIPPY 0x01000100
58 #define TINCANTOOLS_ZIPPY2 0x02000100
59 #define TINCANTOOLS_TRAINER 0x04000100
60 #define TINCANTOOLS_SHOWDOG 0x03000100
61 #define KBADC_BEAGLEFPGA 0x01000600
62 #define LW_BEAGLETOUCH 0x01000700
63 #define BRAINMUX_LCDOG 0x01000800
64 #define BRAINMUX_LCDOGTOUCH 0x02000800
65 #define BBTOYS_WIFI 0x01000B00
66 #define BBTOYS_VGA 0x02000B00
67 #define BBTOYS_LCD 0x03000B00
68 #define BCT_BRETTL3 0x01000F00
69 #define BCT_BRETTL4 0x02000F00
70 #define BEAGLE_NO_EEPROM 0xffffffff
72 DECLARE_GLOBAL_DATA_PTR;
75 unsigned int device_vendor;
76 unsigned char revision;
77 unsigned char content;
85 * Description: Early hardware init.
89 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
90 /* board id for Linux */
91 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
93 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
95 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
96 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
103 * Routine: get_board_revision
104 * Description: Detect if we are running on a Beagle revision Ax/Bx,
105 * C1/2/3, C4 or xM. This can be done by reading
106 * the level of GPIO173, GPIO172 and GPIO171. This should
108 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
109 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
110 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
111 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
113 static int get_board_revision(void)
117 if (!gpio_request(171, "") &&
118 !gpio_request(172, "") &&
119 !gpio_request(173, "")) {
121 gpio_direction_input(171);
122 gpio_direction_input(172);
123 gpio_direction_input(173);
125 revision = gpio_get_value(173) << 2 |
126 gpio_get_value(172) << 1 |
129 printf("Error: unable to acquire board revision GPIOs\n");
136 #ifdef CONFIG_SPL_BUILD
138 * Routine: get_board_mem_timings
139 * Description: If we use SPL then there is no x-loader nor config header
140 * so we have to setup the DDR timings ourself on both banks.
142 void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
148 * We need to identify what PoP memory is on the board so that
149 * we know what timings to use. If we can't identify it then
150 * we know it's an xM. To map the ID values please see nand_ids.c
152 identify_nand_chip(&pop_mfr, &pop_id);
154 *mr = MICRON_V_MR_165;
155 switch (get_board_revision()) {
157 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
159 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
160 *ctrla = NUMONYX_V_ACTIMA_165;
161 *ctrlb = NUMONYX_V_ACTIMB_165;
162 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
164 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
165 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
166 *mcfg = MICRON_V_MCFG_165(128 << 20);
167 *ctrla = MICRON_V_ACTIMA_165;
168 *ctrlb = MICRON_V_ACTIMB_165;
169 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
171 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
172 /* Beagleboard Rev C5, 256MB DDR */
173 *mcfg = MICRON_V_MCFG_200(256 << 20);
174 *ctrla = MICRON_V_ACTIMA_200;
175 *ctrlb = MICRON_V_ACTIMB_200;
176 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
184 *mcfg = MICRON_V_MCFG_200(256 << 20);
185 *ctrla = MICRON_V_ACTIMA_200;
186 *ctrlb = MICRON_V_ACTIMB_200;
187 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
190 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
191 *ctrla = NUMONYX_V_ACTIMA_165;
192 *ctrlb = NUMONYX_V_ACTIMB_165;
193 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
197 /* Assume 128MB and Micron/165MHz timings to be safe */
198 *mcfg = MICRON_V_MCFG_165(128 << 20);
199 *ctrla = MICRON_V_ACTIMA_165;
200 *ctrlb = MICRON_V_ACTIMB_165;
201 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
207 * Routine: get_expansion_id
208 * Description: This function checks for expansion board by checking I2C
209 * bus 1 for the availability of an AT24C01B serial EEPROM.
210 * returns the device_vendor field from the EEPROM
212 static unsigned int get_expansion_id(void)
214 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
216 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
217 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
218 i2c_set_bus_num(TWL4030_I2C_BUS);
219 return BEAGLE_NO_EEPROM;
222 /* read configuration data */
223 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
224 sizeof(expansion_config));
226 i2c_set_bus_num(TWL4030_I2C_BUS);
228 return expansion_config.device_vendor;
231 #ifdef CONFIG_VIDEO_OMAP3
233 * Configure DSS to display background color on DVID
234 * Configure VENC to display color bar on S-Video
236 static void beagle_display_init(void)
238 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
239 switch (get_board_revision()) {
243 omap3_dss_panel_config(&dvid_cfg);
249 omap3_dss_panel_config(&dvid_cfg_xm);
257 static void beagle_dvi_pup(void)
261 switch (get_board_revision()) {
266 gpio_request(170, "");
267 gpio_direction_output(170, 0);
268 gpio_set_value(170, 1);
273 #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
274 #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
276 i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
278 i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
280 i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
282 i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
289 * Routine: misc_init_r
290 * Description: Configure board specific parts
292 int misc_init_r(void)
294 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
295 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
296 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
298 /* Enable i2c2 pullup resisters */
299 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
301 switch (get_board_revision()) {
303 printf("Beagle Rev Ax/Bx\n");
304 setenv("beaglerev", "AxBx");
307 printf("Beagle Rev C1/C2/C3\n");
308 setenv("beaglerev", "Cx");
312 printf("Beagle Rev C4\n");
313 setenv("beaglerev", "C4");
315 /* Set VAUX2 to 1.8V for EHCI PHY */
316 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
317 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
318 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
319 TWL4030_PM_RECEIVER_DEV_GRP_P1);
322 printf("Beagle xM Rev A\n");
323 setenv("beaglerev", "xMA");
325 /* Set VAUX2 to 1.8V for EHCI PHY */
326 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
327 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
328 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
329 TWL4030_PM_RECEIVER_DEV_GRP_P1);
332 printf("Beagle xM Rev B\n");
333 setenv("beaglerev", "xMB");
335 /* Set VAUX2 to 1.8V for EHCI PHY */
336 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
337 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
338 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
339 TWL4030_PM_RECEIVER_DEV_GRP_P1);
342 printf("Beagle xM Rev C\n");
343 setenv("beaglerev", "xMC");
345 /* Set VAUX2 to 1.8V for EHCI PHY */
346 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
347 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
348 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
349 TWL4030_PM_RECEIVER_DEV_GRP_P1);
352 printf("Beagle unknown 0x%02x\n", get_board_revision());
354 /* Set VAUX2 to 1.8V for EHCI PHY */
355 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
356 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
357 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
358 TWL4030_PM_RECEIVER_DEV_GRP_P1);
361 switch (get_expansion_id()) {
362 case TINCANTOOLS_ZIPPY:
363 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
364 expansion_config.revision,
365 expansion_config.fab_revision);
366 MUX_TINCANTOOLS_ZIPPY();
367 setenv("buddy", "zippy");
369 case TINCANTOOLS_ZIPPY2:
370 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
371 expansion_config.revision,
372 expansion_config.fab_revision);
373 MUX_TINCANTOOLS_ZIPPY();
374 setenv("buddy", "zippy2");
376 case TINCANTOOLS_TRAINER:
377 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
378 expansion_config.revision,
379 expansion_config.fab_revision);
380 MUX_TINCANTOOLS_ZIPPY();
381 MUX_TINCANTOOLS_TRAINER();
382 setenv("buddy", "trainer");
384 case TINCANTOOLS_SHOWDOG:
385 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
386 expansion_config.revision,
387 expansion_config.fab_revision);
388 /* Place holder for DSS2 definition for showdog lcd */
389 setenv("defaultdisplay", "showdoglcd");
390 setenv("buddy", "showdog");
392 case KBADC_BEAGLEFPGA:
393 printf("Recognized KBADC Beagle FPGA board\n");
394 MUX_KBADC_BEAGLEFPGA();
395 setenv("buddy", "beaglefpga");
398 printf("Recognized Liquidware BeagleTouch board\n");
399 setenv("buddy", "beagletouch");
402 printf("Recognized Brainmux LCDog board\n");
403 setenv("buddy", "lcdog");
405 case BRAINMUX_LCDOGTOUCH:
406 printf("Recognized Brainmux LCDog Touch board\n");
407 setenv("buddy", "lcdogtouch");
410 printf("Recognized BeagleBoardToys WiFi board\n");
412 setenv("buddy", "bbtoys-wifi");
415 printf("Recognized BeagleBoardToys VGA board\n");
418 printf("Recognized BeagleBoardToys LCD board\n");
421 printf("Recognized bct electronic GmbH brettl3 board\n");
424 printf("Recognized bct electronic GmbH brettl4 board\n");
426 case BEAGLE_NO_EEPROM:
427 printf("No EEPROM on expansion board\n");
428 setenv("buddy", "none");
431 printf("Unrecognized expansion board: %x\n",
432 expansion_config.device_vendor);
433 setenv("buddy", "unknown");
436 if (expansion_config.content == 1)
437 setenv(expansion_config.env_var, expansion_config.env_setting);
439 twl4030_power_init();
440 switch (get_board_revision()) {
443 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
446 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
450 /* Set GPIO states before they are made outputs */
451 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
452 &gpio6_base->setdataout);
453 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
454 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
456 /* Configure GPIOs to output */
457 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
458 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
459 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
463 #ifdef CONFIG_VIDEO_OMAP3
465 beagle_display_init();
473 * Routine: set_muxconf_regs
474 * Description: Setting up the configuration Mux registers specific to the
475 * hardware. Many pins need to be moved from protect to primary
478 void set_muxconf_regs(void)
483 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
484 int board_mmc_init(bd_t *bis)
486 omap_mmc_init(0, 0, 0);
491 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
492 /* Call usb_stop() before starting the kernel */
493 void show_boot_progress(int val)
495 if (val == BOOTSTAGE_ID_RUN_OS)
499 static struct omap_usbhs_board_data usbhs_bdata = {
500 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
501 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
502 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
505 int ehci_hcd_init(void)
507 return omap_ehci_hcd_init(&usbhs_bdata);
510 int ehci_hcd_stop(void)
512 return omap_ehci_hcd_stop();
515 #endif /* CONFIG_USB_EHCI */