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,
35 #include <asm/arch/mmc_host_def.h>
36 #include <asm/arch/mux.h>
37 #include <asm/arch/sys_proto.h>
38 #include <asm/arch/gpio.h>
39 #include <asm/mach-types.h>
42 #define TWL4030_I2C_BUS 0
43 #define EXPANSION_EEPROM_I2C_BUS 1
44 #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
46 #define TINCANTOOLS_ZIPPY 0x01000100
47 #define TINCANTOOLS_ZIPPY2 0x02000100
48 #define TINCANTOOLS_TRAINER 0x04000100
49 #define TINCANTOOLS_SHOWDOG 0x03000100
50 #define KBADC_BEAGLEFPGA 0x01000600
52 #define BEAGLE_NO_EEPROM 0xffffffff
55 unsigned int device_vendor;
56 unsigned char revision;
57 unsigned char content;
65 * Description: Early hardware init.
69 DECLARE_GLOBAL_DATA_PTR;
71 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
72 /* board id for Linux */
73 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
75 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
81 * Routine: get_board_revision
82 * Description: Detect if we are running on a Beagle revision Ax/Bx,
83 * C1/2/3, C4 or xM. This can be done by reading
84 * the level of GPIO173, GPIO172 and GPIO171. This should
86 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
87 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
88 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
89 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
91 int get_board_revision(void)
95 if (!omap_request_gpio(171) &&
96 !omap_request_gpio(172) &&
97 !omap_request_gpio(173)) {
99 omap_set_gpio_direction(171, 1);
100 omap_set_gpio_direction(172, 1);
101 omap_set_gpio_direction(173, 1);
103 revision = omap_get_gpio_datain(173) << 2 |
104 omap_get_gpio_datain(172) << 1 |
105 omap_get_gpio_datain(171);
111 printf("Error: unable to acquire board revision GPIOs\n");
119 * Routine: get_expansion_id
120 * Description: This function checks for expansion board by checking I2C
121 * bus 1 for the availability of an AT24C01B serial EEPROM.
122 * returns the device_vendor field from the EEPROM
124 unsigned int get_expansion_id(void)
126 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
128 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
129 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
130 i2c_set_bus_num(TWL4030_I2C_BUS);
131 return BEAGLE_NO_EEPROM;
134 /* read configuration data */
135 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
136 sizeof(expansion_config));
138 i2c_set_bus_num(TWL4030_I2C_BUS);
140 return expansion_config.device_vendor;
144 * Routine: misc_init_r
145 * Description: Configure board specific parts
147 int misc_init_r(void)
149 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
150 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
152 switch (get_board_revision()) {
154 printf("Beagle Rev Ax/Bx\n");
155 setenv("beaglerev", "AxBx");
156 setenv("mpurate", "600");
159 printf("Beagle Rev C1/C2/C3\n");
160 setenv("beaglerev", "Cx");
161 setenv("mpurate", "600");
165 printf("Beagle Rev C4\n");
166 setenv("beaglerev", "C4");
167 setenv("mpurate", "720");
169 /* Set VAUX2 to 1.8V for EHCI PHY */
170 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
171 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
172 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
173 TWL4030_PM_RECEIVER_DEV_GRP_P1);
176 printf("Beagle xM Rev A\n");
177 setenv("beaglerev", "xMA");
178 setenv("mpurate", "1000");
180 /* Set VAUX2 to 1.8V for EHCI PHY */
181 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
182 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
183 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
184 TWL4030_PM_RECEIVER_DEV_GRP_P1);
187 printf("Beagle unknown 0x%02x\n", get_board_revision());
190 switch (get_expansion_id()) {
191 case TINCANTOOLS_ZIPPY:
192 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
193 expansion_config.revision,
194 expansion_config.fab_revision);
195 MUX_TINCANTOOLS_ZIPPY();
196 setenv("buddy", "zippy");
198 case TINCANTOOLS_ZIPPY2:
199 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
200 expansion_config.revision,
201 expansion_config.fab_revision);
202 MUX_TINCANTOOLS_ZIPPY();
203 setenv("buddy", "zippy2");
205 case TINCANTOOLS_TRAINER:
206 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
207 expansion_config.revision,
208 expansion_config.fab_revision);
209 MUX_TINCANTOOLS_ZIPPY();
210 MUX_TINCANTOOLS_TRAINER();
211 setenv("buddy", "trainer");
213 case TINCANTOOLS_SHOWDOG:
214 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
215 expansion_config.revision,
216 expansion_config.fab_revision);
217 /* Place holder for DSS2 definition for showdog lcd */
218 setenv("defaultdisplay", "showdoglcd");
219 setenv("buddy", "showdog");
221 case KBADC_BEAGLEFPGA:
222 printf("Recognized KBADC Beagle FPGA board\n");
223 MUX_KBADC_BEAGLEFPGA();
224 setenv("buddy", "beaglefpga");
226 case BEAGLE_NO_EEPROM:
227 printf("No EEPROM on expansion board\n");
228 setenv("buddy", "none");
231 printf("Unrecognized expansion board: %x\n",
232 expansion_config.device_vendor);
233 setenv("buddy", "unknown");
236 if (expansion_config.content == 1)
237 setenv(expansion_config.env_var, expansion_config.env_setting);
239 twl4030_power_init();
240 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
242 /* Configure GPIOs to output */
243 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
244 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
245 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
248 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
249 &gpio6_base->setdataout);
250 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
251 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
259 * Routine: set_muxconf_regs
260 * Description: Setting up the configuration Mux registers specific to the
261 * hardware. Many pins need to be moved from protect to primary
264 void set_muxconf_regs(void)
269 #ifdef CONFIG_GENERIC_MMC
270 int board_mmc_init(bd_t *bis)