Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004-2008 |
| 3 | * Texas Instruments, <www.ti.com> |
| 4 | * |
| 5 | * Author : |
| 6 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 7 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 8 | * |
| 9 | * Derived from Beagle Board and 3430 SDP code by |
| 10 | * Richard Woodruff <r-woodruff2@ti.com> |
| 11 | * Syed Mohammed Khasim <khasim@ti.com> |
| 12 | * |
| 13 | * |
| 14 | * See file CREDITS for list of people who contributed to this |
| 15 | * project. |
| 16 | * |
| 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. |
| 21 | * |
| 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. |
| 26 | * |
| 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, |
| 30 | * MA 02111-1307 USA |
| 31 | */ |
| 32 | #include <common.h> |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 33 | #ifdef CONFIG_STATUS_LED |
| 34 | #include <status_led.h> |
| 35 | #endif |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 36 | #include <twl4030.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 37 | #include <asm/io.h> |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 38 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 39 | #include <asm/arch/mux.h> |
| 40 | #include <asm/arch/sys_proto.h> |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 41 | #include <asm/arch/gpio.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 42 | #include <asm/mach-types.h> |
| 43 | #include "beagle.h" |
| 44 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 45 | #define TWL4030_I2C_BUS 0 |
| 46 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 47 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 48 | |
| 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 |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 54 | #define LW_BEAGLETOUCH 0x01000700 |
| 55 | #define BRAINMUX_LCDOG 0x01000800 |
| 56 | #define BRAINMUX_LCDOGTOUCH 0x02000800 |
| 57 | #define BBTOYS_WIFI 0x01000B00 |
| 58 | #define BBTOYS_VGA 0x02000B00 |
| 59 | #define BBTOYS_LCD 0x03000B00 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 60 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 61 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 62 | DECLARE_GLOBAL_DATA_PTR; |
| 63 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 64 | static struct { |
| 65 | unsigned int device_vendor; |
| 66 | unsigned char revision; |
| 67 | unsigned char content; |
| 68 | char fab_revision[8]; |
| 69 | char env_var[16]; |
| 70 | char env_setting[64]; |
| 71 | } expansion_config; |
| 72 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 73 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 74 | * Routine: board_init |
| 75 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 76 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 77 | int board_init(void) |
| 78 | { |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 79 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 80 | /* board id for Linux */ |
| 81 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 82 | /* boot param addr */ |
| 83 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 84 | |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 85 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) |
| 86 | status_led_set (STATUS_LED_BOOT, STATUS_LED_ON); |
| 87 | #endif |
| 88 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 92 | /* |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 93 | * Routine: get_board_revision |
| 94 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 95 | * C1/2/3, C4 or xM. This can be done by reading |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 96 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 97 | * result in |
| 98 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 99 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 100 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 101 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 102 | */ |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 103 | int get_board_revision(void) |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 104 | { |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 105 | int revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 106 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 107 | if (!omap_request_gpio(171) && |
| 108 | !omap_request_gpio(172) && |
| 109 | !omap_request_gpio(173)) { |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 110 | |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 111 | omap_set_gpio_direction(171, 1); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 112 | omap_set_gpio_direction(172, 1); |
| 113 | omap_set_gpio_direction(173, 1); |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 114 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 115 | revision = omap_get_gpio_datain(173) << 2 | |
| 116 | omap_get_gpio_datain(172) << 1 | |
| 117 | omap_get_gpio_datain(171); |
| 118 | |
| 119 | omap_free_gpio(171); |
| 120 | omap_free_gpio(172); |
| 121 | omap_free_gpio(173); |
| 122 | } else { |
| 123 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 124 | revision = -1; |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 125 | } |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 126 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 127 | return revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 130 | /* |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 131 | * Routine: get_expansion_id |
| 132 | * Description: This function checks for expansion board by checking I2C |
| 133 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 134 | * returns the device_vendor field from the EEPROM |
| 135 | */ |
| 136 | unsigned int get_expansion_id(void) |
| 137 | { |
| 138 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 139 | |
| 140 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 141 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 142 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 143 | return BEAGLE_NO_EEPROM; |
| 144 | } |
| 145 | |
| 146 | /* read configuration data */ |
| 147 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 148 | sizeof(expansion_config)); |
| 149 | |
| 150 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 151 | |
| 152 | return expansion_config.device_vendor; |
| 153 | } |
| 154 | |
| 155 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 156 | * Routine: misc_init_r |
| 157 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 158 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 159 | int misc_init_r(void) |
| 160 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 161 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 162 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Steve Kipisz | bf7438a | 2011-04-18 17:27:00 -0400 | [diff] [blame] | 163 | struct control_prog_io *prog_io_base = (struct gpio *)OMAP34XX_CTRL_BASE; |
| 164 | |
| 165 | /* Enable i2c2 pullup resisters */ |
| 166 | writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 167 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 168 | switch (get_board_revision()) { |
| 169 | case REVISION_AXBX: |
| 170 | printf("Beagle Rev Ax/Bx\n"); |
| 171 | setenv("beaglerev", "AxBx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 172 | break; |
| 173 | case REVISION_CX: |
| 174 | printf("Beagle Rev C1/C2/C3\n"); |
| 175 | setenv("beaglerev", "Cx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 176 | MUX_BEAGLE_C(); |
| 177 | break; |
| 178 | case REVISION_C4: |
| 179 | printf("Beagle Rev C4\n"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 180 | setenv("beaglerev", "C4"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 181 | MUX_BEAGLE_C(); |
| 182 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 183 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 184 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 185 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 186 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 187 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 188 | case REVISION_XM_A: |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 189 | printf("Beagle xM Rev A\n"); |
| 190 | setenv("beaglerev", "xMA"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 191 | MUX_BEAGLE_XM(); |
| 192 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 193 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 194 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 195 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 196 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 197 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 198 | case REVISION_XM_B: |
| 199 | printf("Beagle xM Rev B\n"); |
| 200 | setenv("beaglerev", "xMB"); |
| 201 | MUX_BEAGLE_XM(); |
| 202 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 203 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 204 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 205 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 206 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 207 | break; |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 208 | default: |
| 209 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 210 | MUX_BEAGLE_XM(); |
| 211 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 212 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 213 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 214 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 215 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 218 | switch (get_expansion_id()) { |
| 219 | case TINCANTOOLS_ZIPPY: |
| 220 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 221 | expansion_config.revision, |
| 222 | expansion_config.fab_revision); |
| 223 | MUX_TINCANTOOLS_ZIPPY(); |
| 224 | setenv("buddy", "zippy"); |
| 225 | break; |
| 226 | case TINCANTOOLS_ZIPPY2: |
| 227 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 228 | expansion_config.revision, |
| 229 | expansion_config.fab_revision); |
| 230 | MUX_TINCANTOOLS_ZIPPY(); |
| 231 | setenv("buddy", "zippy2"); |
| 232 | break; |
| 233 | case TINCANTOOLS_TRAINER: |
| 234 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 235 | expansion_config.revision, |
| 236 | expansion_config.fab_revision); |
| 237 | MUX_TINCANTOOLS_ZIPPY(); |
| 238 | MUX_TINCANTOOLS_TRAINER(); |
| 239 | setenv("buddy", "trainer"); |
| 240 | break; |
| 241 | case TINCANTOOLS_SHOWDOG: |
| 242 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 243 | expansion_config.revision, |
| 244 | expansion_config.fab_revision); |
| 245 | /* Place holder for DSS2 definition for showdog lcd */ |
| 246 | setenv("defaultdisplay", "showdoglcd"); |
| 247 | setenv("buddy", "showdog"); |
| 248 | break; |
| 249 | case KBADC_BEAGLEFPGA: |
| 250 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 251 | MUX_KBADC_BEAGLEFPGA(); |
| 252 | setenv("buddy", "beaglefpga"); |
| 253 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 254 | case LW_BEAGLETOUCH: |
| 255 | printf("Recognized Liquidware BeagleTouch board\n"); |
| 256 | setenv("buddy", "beagletouch"); |
| 257 | break; |
| 258 | case BRAINMUX_LCDOG: |
| 259 | printf("Recognized Brainmux LCDog board\n"); |
| 260 | setenv("buddy", "lcdog"); |
| 261 | break; |
| 262 | case BRAINMUX_LCDOGTOUCH: |
| 263 | printf("Recognized Brainmux LCDog Touch board\n"); |
| 264 | setenv("buddy", "lcdogtouch"); |
| 265 | break; |
| 266 | case BBTOYS_WIFI: |
| 267 | printf("Recognized BeagleBoardToys WiFi board\n"); |
| 268 | MUX_BBTOYS_WIFI() |
| 269 | setenv("buddy", "bbtoys-wifi"); |
| 270 | break;; |
| 271 | case BBTOYS_VGA: |
| 272 | printf("Recognized BeagleBoardToys VGA board\n"); |
| 273 | break;; |
| 274 | case BBTOYS_LCD: |
| 275 | printf("Recognized BeagleBoardToys LCD board\n"); |
| 276 | break;; |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 277 | case BEAGLE_NO_EEPROM: |
| 278 | printf("No EEPROM on expansion board\n"); |
| 279 | setenv("buddy", "none"); |
| 280 | break; |
| 281 | default: |
| 282 | printf("Unrecognized expansion board: %x\n", |
| 283 | expansion_config.device_vendor); |
| 284 | setenv("buddy", "unknown"); |
| 285 | } |
| 286 | |
| 287 | if (expansion_config.content == 1) |
| 288 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 289 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 290 | twl4030_power_init(); |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 291 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 292 | |
| 293 | /* Configure GPIOs to output */ |
| 294 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 295 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 296 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 297 | |
| 298 | /* Set GPIOs */ |
| 299 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 300 | &gpio6_base->setdataout); |
| 301 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 302 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 303 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 304 | dieid_num_r(); |
| 305 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 309 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 310 | * Routine: set_muxconf_regs |
| 311 | * Description: Setting up the configuration Mux registers specific to the |
| 312 | * hardware. Many pins need to be moved from protect to primary |
| 313 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 314 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 315 | void set_muxconf_regs(void) |
| 316 | { |
| 317 | MUX_BEAGLE(); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 318 | } |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 319 | |
| 320 | #ifdef CONFIG_GENERIC_MMC |
| 321 | int board_mmc_init(bd_t *bis) |
| 322 | { |
| 323 | omap_mmc_init(0); |
| 324 | return 0; |
| 325 | } |
| 326 | #endif |