2 * (C) Copyright 2004-2011
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>
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 #define pr_debug(fmt, args...) debug(fmt, ##args)
50 #define TWL4030_I2C_BUS 0
51 #define EXPANSION_EEPROM_I2C_BUS 1
52 #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
54 #define TINCANTOOLS_ZIPPY 0x01000100
55 #define TINCANTOOLS_ZIPPY2 0x02000100
56 #define TINCANTOOLS_TRAINER 0x04000100
57 #define TINCANTOOLS_SHOWDOG 0x03000100
58 #define KBADC_BEAGLEFPGA 0x01000600
59 #define LW_BEAGLETOUCH 0x01000700
60 #define BRAINMUX_LCDOG 0x01000800
61 #define BRAINMUX_LCDOGTOUCH 0x02000800
62 #define BBTOYS_WIFI 0x01000B00
63 #define BBTOYS_VGA 0x02000B00
64 #define BBTOYS_LCD 0x03000B00
65 #define BCT_BRETTL3 0x01000F00
66 #define BEAGLE_NO_EEPROM 0xffffffff
68 DECLARE_GLOBAL_DATA_PTR;
71 unsigned int device_vendor;
72 unsigned char revision;
73 unsigned char content;
81 * Description: Early hardware init.
85 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
86 /* board id for Linux */
87 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
89 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
91 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
92 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
99 * Routine: get_board_revision
100 * Description: Detect if we are running on a Beagle revision Ax/Bx,
101 * C1/2/3, C4 or xM. This can be done by reading
102 * the level of GPIO173, GPIO172 and GPIO171. This should
104 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
105 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
106 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
107 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
109 int get_board_revision(void)
113 if (!gpio_request(171, "") &&
114 !gpio_request(172, "") &&
115 !gpio_request(173, "")) {
117 gpio_direction_input(171);
118 gpio_direction_input(172);
119 gpio_direction_input(173);
121 revision = gpio_get_value(173) << 2 |
122 gpio_get_value(172) << 1 |
125 printf("Error: unable to acquire board revision GPIOs\n");
132 #ifdef CONFIG_SPL_BUILD
134 * Routine: get_board_mem_timings
135 * Description: If we use SPL then there is no x-loader nor config header
136 * so we have to setup the DDR timings ourself on both banks.
138 void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
144 * We need to identify what PoP memory is on the board so that
145 * we know what timings to use. If we can't identify it then
146 * we know it's an xM. To map the ID values please see nand_ids.c
148 identify_nand_chip(&pop_mfr, &pop_id);
150 *mr = MICRON_V_MR_165;
151 switch (get_board_revision()) {
153 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
155 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
156 *ctrla = NUMONYX_V_ACTIMA_165;
157 *ctrlb = NUMONYX_V_ACTIMB_165;
158 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
160 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
161 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
162 *mcfg = MICRON_V_MCFG_165(128 << 20);
163 *ctrla = MICRON_V_ACTIMA_165;
164 *ctrlb = MICRON_V_ACTIMB_165;
165 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
167 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
168 /* Beagleboard Rev C5, 256MB DDR */
169 *mcfg = MICRON_V_MCFG_200(256 << 20);
170 *ctrla = MICRON_V_ACTIMA_200;
171 *ctrlb = MICRON_V_ACTIMB_200;
172 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
180 *mcfg = MICRON_V_MCFG_200(256 << 20);
181 *ctrla = MICRON_V_ACTIMA_200;
182 *ctrlb = MICRON_V_ACTIMB_200;
183 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
186 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
187 *ctrla = NUMONYX_V_ACTIMA_165;
188 *ctrlb = NUMONYX_V_ACTIMB_165;
189 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
193 /* Assume 128MB and Micron/165MHz timings to be safe */
194 *mcfg = MICRON_V_MCFG_165(128 << 20);
195 *ctrla = MICRON_V_ACTIMA_165;
196 *ctrlb = MICRON_V_ACTIMB_165;
197 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
203 * Routine: get_expansion_id
204 * Description: This function checks for expansion board by checking I2C
205 * bus 1 for the availability of an AT24C01B serial EEPROM.
206 * returns the device_vendor field from the EEPROM
208 unsigned int get_expansion_id(void)
210 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
212 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
213 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
214 i2c_set_bus_num(TWL4030_I2C_BUS);
215 return BEAGLE_NO_EEPROM;
218 /* read configuration data */
219 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
220 sizeof(expansion_config));
222 i2c_set_bus_num(TWL4030_I2C_BUS);
224 return expansion_config.device_vendor;
228 * Configure DSS to display background color on DVID
229 * Configure VENC to display color bar on S-Video
231 void beagle_display_init(void)
233 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
234 switch (get_board_revision()) {
238 omap3_dss_panel_config(&dvid_cfg);
244 omap3_dss_panel_config(&dvid_cfg_xm);
250 * Routine: misc_init_r
251 * Description: Configure board specific parts
253 int misc_init_r(void)
255 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
256 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
257 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
259 /* Enable i2c2 pullup resisters */
260 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
262 switch (get_board_revision()) {
264 printf("Beagle Rev Ax/Bx\n");
265 setenv("beaglerev", "AxBx");
268 printf("Beagle Rev C1/C2/C3\n");
269 setenv("beaglerev", "Cx");
273 printf("Beagle Rev C4\n");
274 setenv("beaglerev", "C4");
276 /* Set VAUX2 to 1.8V for EHCI PHY */
277 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
278 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
279 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
280 TWL4030_PM_RECEIVER_DEV_GRP_P1);
283 printf("Beagle xM Rev A\n");
284 setenv("beaglerev", "xMA");
286 /* Set VAUX2 to 1.8V for EHCI PHY */
287 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
288 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
289 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
290 TWL4030_PM_RECEIVER_DEV_GRP_P1);
293 printf("Beagle xM Rev B\n");
294 setenv("beaglerev", "xMB");
296 /* Set VAUX2 to 1.8V for EHCI PHY */
297 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
298 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
299 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
300 TWL4030_PM_RECEIVER_DEV_GRP_P1);
303 printf("Beagle xM Rev C\n");
304 setenv("beaglerev", "xMC");
306 /* Set VAUX2 to 1.8V for EHCI PHY */
307 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
308 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
309 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
310 TWL4030_PM_RECEIVER_DEV_GRP_P1);
313 printf("Beagle unknown 0x%02x\n", get_board_revision());
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 switch (get_expansion_id()) {
323 case TINCANTOOLS_ZIPPY:
324 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
325 expansion_config.revision,
326 expansion_config.fab_revision);
327 MUX_TINCANTOOLS_ZIPPY();
328 setenv("buddy", "zippy");
330 case TINCANTOOLS_ZIPPY2:
331 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
332 expansion_config.revision,
333 expansion_config.fab_revision);
334 MUX_TINCANTOOLS_ZIPPY();
335 setenv("buddy", "zippy2");
337 case TINCANTOOLS_TRAINER:
338 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
339 expansion_config.revision,
340 expansion_config.fab_revision);
341 MUX_TINCANTOOLS_ZIPPY();
342 MUX_TINCANTOOLS_TRAINER();
343 setenv("buddy", "trainer");
345 case TINCANTOOLS_SHOWDOG:
346 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
347 expansion_config.revision,
348 expansion_config.fab_revision);
349 /* Place holder for DSS2 definition for showdog lcd */
350 setenv("defaultdisplay", "showdoglcd");
351 setenv("buddy", "showdog");
353 case KBADC_BEAGLEFPGA:
354 printf("Recognized KBADC Beagle FPGA board\n");
355 MUX_KBADC_BEAGLEFPGA();
356 setenv("buddy", "beaglefpga");
359 printf("Recognized Liquidware BeagleTouch board\n");
360 setenv("buddy", "beagletouch");
363 printf("Recognized Brainmux LCDog board\n");
364 setenv("buddy", "lcdog");
366 case BRAINMUX_LCDOGTOUCH:
367 printf("Recognized Brainmux LCDog Touch board\n");
368 setenv("buddy", "lcdogtouch");
371 printf("Recognized BeagleBoardToys WiFi board\n");
373 setenv("buddy", "bbtoys-wifi");
376 printf("Recognized BeagleBoardToys VGA board\n");
379 printf("Recognized BeagleBoardToys LCD board\n");
382 printf("Recognized bct electronic GmbH brettl3 board\n");
384 case BEAGLE_NO_EEPROM:
385 printf("No EEPROM on expansion board\n");
386 setenv("buddy", "none");
389 printf("Unrecognized expansion board: %x\n",
390 expansion_config.device_vendor);
391 setenv("buddy", "unknown");
394 if (expansion_config.content == 1)
395 setenv(expansion_config.env_var, expansion_config.env_setting);
397 twl4030_power_init();
398 switch (get_board_revision()) {
401 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
404 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
408 /* Set GPIO states before they are made outputs */
409 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
410 &gpio6_base->setdataout);
411 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
412 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
414 /* Configure GPIOs to output */
415 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
416 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
417 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
420 beagle_display_init();
427 * Routine: set_muxconf_regs
428 * Description: Setting up the configuration Mux registers specific to the
429 * hardware. Many pins need to be moved from protect to primary
432 void set_muxconf_regs(void)
437 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
438 int board_mmc_init(bd_t *bis)
445 #ifdef CONFIG_USB_EHCI
446 /* Call usb_stop() before starting the kernel */
447 void show_boot_progress(int val)
452 #endif /* CONFIG_USB_EHCI */
454 #ifndef CONFIG_SPL_BUILD
456 * This command returns the status of the user button on beagle xM
458 * Returns - 1 if button is held down
459 * 0 if button is not held down
461 int do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
467 * pass address parameter as argv[0] (aka command name),
468 * and all remaining args
470 switch (get_board_revision()) {
483 gpio_request(gpio, "");
484 gpio_direction_input(gpio);
485 printf("The user button is currently ");
486 if (gpio_get_value(gpio))
489 printf("PRESSED.\n");
494 printf("NOT pressed.\n");
500 /* -------------------------------------------------------------------- */
503 userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
504 "Return the status of the BeagleBoard USER button",