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> |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 43 | #ifdef CONFIG_USB_EHCI |
| 44 | #include <usb.h> |
| 45 | #include <asm/arch/clocks.h> |
| 46 | #include <asm/arch/clocks_omap3.h> |
| 47 | #include <asm/arch/ehci_omap3.h> |
| 48 | /* from drivers/usb/host/ehci-core.h */ |
| 49 | extern struct ehci_hccr *hccr; |
| 50 | extern volatile struct ehci_hcor *hcor; |
| 51 | #endif |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 52 | #include "beagle.h" |
Jason Kridner | 85a08fb | 2010-07-21 07:41:25 -0500 | [diff] [blame] | 53 | #include <command.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 54 | |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 55 | #define pr_debug(fmt, args...) debug(fmt, ##args) |
| 56 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 57 | #define TWL4030_I2C_BUS 0 |
| 58 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 59 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 60 | |
| 61 | #define TINCANTOOLS_ZIPPY 0x01000100 |
| 62 | #define TINCANTOOLS_ZIPPY2 0x02000100 |
| 63 | #define TINCANTOOLS_TRAINER 0x04000100 |
| 64 | #define TINCANTOOLS_SHOWDOG 0x03000100 |
| 65 | #define KBADC_BEAGLEFPGA 0x01000600 |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 66 | #define LW_BEAGLETOUCH 0x01000700 |
| 67 | #define BRAINMUX_LCDOG 0x01000800 |
| 68 | #define BRAINMUX_LCDOGTOUCH 0x02000800 |
| 69 | #define BBTOYS_WIFI 0x01000B00 |
| 70 | #define BBTOYS_VGA 0x02000B00 |
| 71 | #define BBTOYS_LCD 0x03000B00 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 72 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 73 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 74 | DECLARE_GLOBAL_DATA_PTR; |
| 75 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 76 | static struct { |
| 77 | unsigned int device_vendor; |
| 78 | unsigned char revision; |
| 79 | unsigned char content; |
| 80 | char fab_revision[8]; |
| 81 | char env_var[16]; |
| 82 | char env_setting[64]; |
| 83 | } expansion_config; |
| 84 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 85 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 86 | * Routine: board_init |
| 87 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 88 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 89 | int board_init(void) |
| 90 | { |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 91 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 92 | /* board id for Linux */ |
| 93 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 94 | /* boot param addr */ |
| 95 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 96 | |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 97 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) |
| 98 | status_led_set (STATUS_LED_BOOT, STATUS_LED_ON); |
| 99 | #endif |
| 100 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 101 | return 0; |
| 102 | } |
| 103 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 104 | /* |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 105 | * Routine: get_board_revision |
| 106 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 107 | * C1/2/3, C4 or xM. This can be done by reading |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 108 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 109 | * result in |
| 110 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 111 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 112 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 113 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 114 | */ |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 115 | int get_board_revision(void) |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 116 | { |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 117 | int revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 118 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 119 | if (!omap_request_gpio(171) && |
| 120 | !omap_request_gpio(172) && |
| 121 | !omap_request_gpio(173)) { |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 122 | |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 123 | omap_set_gpio_direction(171, 1); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 124 | omap_set_gpio_direction(172, 1); |
| 125 | omap_set_gpio_direction(173, 1); |
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 | revision = omap_get_gpio_datain(173) << 2 | |
| 128 | omap_get_gpio_datain(172) << 1 | |
| 129 | omap_get_gpio_datain(171); |
| 130 | |
| 131 | omap_free_gpio(171); |
| 132 | omap_free_gpio(172); |
| 133 | omap_free_gpio(173); |
| 134 | } else { |
| 135 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 136 | revision = -1; |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 137 | } |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 138 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 139 | return revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 140 | } |
| 141 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 142 | /* |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 143 | * Routine: get_expansion_id |
| 144 | * Description: This function checks for expansion board by checking I2C |
| 145 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 146 | * returns the device_vendor field from the EEPROM |
| 147 | */ |
| 148 | unsigned int get_expansion_id(void) |
| 149 | { |
| 150 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 151 | |
| 152 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 153 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 154 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 155 | return BEAGLE_NO_EEPROM; |
| 156 | } |
| 157 | |
| 158 | /* read configuration data */ |
| 159 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 160 | sizeof(expansion_config)); |
| 161 | |
| 162 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 163 | |
| 164 | return expansion_config.device_vendor; |
| 165 | } |
| 166 | |
| 167 | /* |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 168 | * Configure DSS to display background color on DVID |
| 169 | * Configure VENC to display color bar on S-Video |
| 170 | */ |
| 171 | void beagle_display_init(void) |
| 172 | { |
| 173 | omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH); |
| 174 | switch (get_board_revision()) { |
| 175 | case REVISION_AXBX: |
| 176 | case REVISION_CX: |
| 177 | case REVISION_C4: |
| 178 | omap3_dss_panel_config(&dvid_cfg); |
| 179 | break; |
| 180 | case REVISION_XM_A: |
| 181 | case REVISION_XM_B: |
| 182 | case REVISION_XM_C: |
| 183 | default: |
| 184 | omap3_dss_panel_config(&dvid_cfg_xm); |
| 185 | break; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 190 | * Routine: misc_init_r |
| 191 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 192 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 193 | int misc_init_r(void) |
| 194 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 195 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 196 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Jason Kridner | 40aebca | 2011-04-20 13:52:26 +0000 | [diff] [blame] | 197 | struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE; |
Steve Kipisz | bf7438a | 2011-04-18 17:27:00 -0400 | [diff] [blame] | 198 | |
| 199 | /* Enable i2c2 pullup resisters */ |
| 200 | writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 201 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 202 | switch (get_board_revision()) { |
| 203 | case REVISION_AXBX: |
| 204 | printf("Beagle Rev Ax/Bx\n"); |
| 205 | setenv("beaglerev", "AxBx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 206 | break; |
| 207 | case REVISION_CX: |
| 208 | printf("Beagle Rev C1/C2/C3\n"); |
| 209 | setenv("beaglerev", "Cx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 210 | MUX_BEAGLE_C(); |
| 211 | break; |
| 212 | case REVISION_C4: |
| 213 | printf("Beagle Rev C4\n"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 214 | setenv("beaglerev", "C4"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 215 | MUX_BEAGLE_C(); |
| 216 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 217 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 218 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 219 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 220 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 221 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 222 | case REVISION_XM_A: |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 223 | printf("Beagle xM Rev A\n"); |
| 224 | setenv("beaglerev", "xMA"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 225 | MUX_BEAGLE_XM(); |
| 226 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 227 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 228 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 229 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 230 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 231 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 232 | case REVISION_XM_B: |
| 233 | printf("Beagle xM Rev B\n"); |
| 234 | setenv("beaglerev", "xMB"); |
| 235 | MUX_BEAGLE_XM(); |
| 236 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 237 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 238 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 239 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 240 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 241 | break; |
Koen Kooi | 6330844 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 242 | case REVISION_XM_C: |
| 243 | printf("Beagle xM Rev C\n"); |
| 244 | setenv("beaglerev", "xMC"); |
| 245 | MUX_BEAGLE_XM(); |
| 246 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 247 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 248 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 249 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 250 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 251 | break; |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 252 | default: |
| 253 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 254 | MUX_BEAGLE_XM(); |
| 255 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 256 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 257 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 258 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 259 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 262 | switch (get_expansion_id()) { |
| 263 | case TINCANTOOLS_ZIPPY: |
| 264 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 265 | expansion_config.revision, |
| 266 | expansion_config.fab_revision); |
| 267 | MUX_TINCANTOOLS_ZIPPY(); |
| 268 | setenv("buddy", "zippy"); |
| 269 | break; |
| 270 | case TINCANTOOLS_ZIPPY2: |
| 271 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 272 | expansion_config.revision, |
| 273 | expansion_config.fab_revision); |
| 274 | MUX_TINCANTOOLS_ZIPPY(); |
| 275 | setenv("buddy", "zippy2"); |
| 276 | break; |
| 277 | case TINCANTOOLS_TRAINER: |
| 278 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 279 | expansion_config.revision, |
| 280 | expansion_config.fab_revision); |
| 281 | MUX_TINCANTOOLS_ZIPPY(); |
| 282 | MUX_TINCANTOOLS_TRAINER(); |
| 283 | setenv("buddy", "trainer"); |
| 284 | break; |
| 285 | case TINCANTOOLS_SHOWDOG: |
| 286 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 287 | expansion_config.revision, |
| 288 | expansion_config.fab_revision); |
| 289 | /* Place holder for DSS2 definition for showdog lcd */ |
| 290 | setenv("defaultdisplay", "showdoglcd"); |
| 291 | setenv("buddy", "showdog"); |
| 292 | break; |
| 293 | case KBADC_BEAGLEFPGA: |
| 294 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 295 | MUX_KBADC_BEAGLEFPGA(); |
| 296 | setenv("buddy", "beaglefpga"); |
| 297 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 298 | case LW_BEAGLETOUCH: |
| 299 | printf("Recognized Liquidware BeagleTouch board\n"); |
| 300 | setenv("buddy", "beagletouch"); |
| 301 | break; |
| 302 | case BRAINMUX_LCDOG: |
| 303 | printf("Recognized Brainmux LCDog board\n"); |
| 304 | setenv("buddy", "lcdog"); |
| 305 | break; |
| 306 | case BRAINMUX_LCDOGTOUCH: |
| 307 | printf("Recognized Brainmux LCDog Touch board\n"); |
| 308 | setenv("buddy", "lcdogtouch"); |
| 309 | break; |
| 310 | case BBTOYS_WIFI: |
| 311 | printf("Recognized BeagleBoardToys WiFi board\n"); |
| 312 | MUX_BBTOYS_WIFI() |
| 313 | setenv("buddy", "bbtoys-wifi"); |
| 314 | break;; |
| 315 | case BBTOYS_VGA: |
| 316 | printf("Recognized BeagleBoardToys VGA board\n"); |
| 317 | break;; |
| 318 | case BBTOYS_LCD: |
| 319 | printf("Recognized BeagleBoardToys LCD board\n"); |
| 320 | break;; |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 321 | case BEAGLE_NO_EEPROM: |
| 322 | printf("No EEPROM on expansion board\n"); |
| 323 | setenv("buddy", "none"); |
| 324 | break; |
| 325 | default: |
| 326 | printf("Unrecognized expansion board: %x\n", |
| 327 | expansion_config.device_vendor); |
| 328 | setenv("buddy", "unknown"); |
| 329 | } |
| 330 | |
| 331 | if (expansion_config.content == 1) |
| 332 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 333 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 334 | twl4030_power_init(); |
Christian Spielberger | 3be83dc | 2011-08-24 17:17:31 -0500 | [diff] [blame^] | 335 | switch (get_board_revision()) { |
| 336 | case REVISION_XM_A: |
| 337 | case REVISION_XM_B: |
| 338 | twl4030_led_init(TWL4030_LED_LEDEN_LEDBON); |
| 339 | break; |
| 340 | default: |
| 341 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
| 342 | break; |
| 343 | } |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 344 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 345 | /* Set GPIO states before they are made outputs */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 346 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 347 | &gpio6_base->setdataout); |
| 348 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 349 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 350 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 351 | /* Configure GPIOs to output */ |
| 352 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 353 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 354 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 355 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 356 | dieid_num_r(); |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 357 | beagle_display_init(); |
| 358 | omap3_dss_enable(); |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 359 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 363 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 364 | * Routine: set_muxconf_regs |
| 365 | * Description: Setting up the configuration Mux registers specific to the |
| 366 | * hardware. Many pins need to be moved from protect to primary |
| 367 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 368 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 369 | void set_muxconf_regs(void) |
| 370 | { |
| 371 | MUX_BEAGLE(); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 372 | } |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 373 | |
| 374 | #ifdef CONFIG_GENERIC_MMC |
| 375 | int board_mmc_init(bd_t *bis) |
| 376 | { |
| 377 | omap_mmc_init(0); |
| 378 | return 0; |
| 379 | } |
| 380 | #endif |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 381 | |
| 382 | #ifdef CONFIG_USB_EHCI |
| 383 | |
| 384 | #define GPIO_PHY_RESET 147 |
| 385 | |
| 386 | /* Reset is needed otherwise the kernel-driver will throw an error. */ |
| 387 | int ehci_hcd_stop(void) |
| 388 | { |
| 389 | pr_debug("Resetting OMAP3 EHCI\n"); |
| 390 | omap_set_gpio_dataout(GPIO_PHY_RESET, 0); |
| 391 | writel(OMAP_UHH_SYSCONFIG_SOFTRESET, OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG); |
Koen Kooi | f1f731f | 2011-06-17 09:26:17 +0200 | [diff] [blame] | 392 | /* disable USB clocks */ |
| 393 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 394 | sr32(&prcm_base->iclken_usbhost, 0, 1, 0); |
| 395 | sr32(&prcm_base->fclken_usbhost, 0, 2, 0); |
| 396 | sr32(&prcm_base->iclken3_core, 2, 1, 0); |
| 397 | sr32(&prcm_base->fclken3_core, 2, 1, 0); |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | /* Call usb_stop() before starting the kernel */ |
| 402 | void show_boot_progress(int val) |
| 403 | { |
| 404 | if(val == 15) |
| 405 | usb_stop(); |
| 406 | } |
| 407 | |
| 408 | /* |
| 409 | * Initialize the OMAP3 EHCI controller and PHY on the BeagleBoard. |
| 410 | * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37. |
| 411 | * See there for additional Copyrights. |
| 412 | */ |
| 413 | int ehci_hcd_init(void) |
| 414 | { |
| 415 | pr_debug("Initializing OMAP3 ECHI\n"); |
| 416 | |
| 417 | /* Put the PHY in RESET */ |
| 418 | omap_request_gpio(GPIO_PHY_RESET); |
| 419 | omap_set_gpio_direction(GPIO_PHY_RESET, 0); |
| 420 | omap_set_gpio_dataout(GPIO_PHY_RESET, 0); |
| 421 | |
| 422 | /* Hold the PHY in RESET for enough time till DIR is high */ |
| 423 | /* Refer: ISSUE1 */ |
| 424 | udelay(10); |
| 425 | |
| 426 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 427 | /* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */ |
| 428 | sr32(&prcm_base->iclken_usbhost, 0, 1, 1); |
| 429 | /* |
| 430 | * Enable USBHOST_48M_FCLK (USBHOST_FCLK1) |
| 431 | * and USBHOST_120M_FCLK (USBHOST_FCLK2) |
| 432 | */ |
| 433 | sr32(&prcm_base->fclken_usbhost, 0, 2, 3); |
| 434 | /* Enable USBTTL_ICLK */ |
| 435 | sr32(&prcm_base->iclken3_core, 2, 1, 1); |
| 436 | /* Enable USBTTL_FCLK */ |
| 437 | sr32(&prcm_base->fclken3_core, 2, 1, 1); |
| 438 | pr_debug("USB clocks enabled\n"); |
| 439 | |
| 440 | /* perform TLL soft reset, and wait until reset is complete */ |
| 441 | writel(OMAP_USBTLL_SYSCONFIG_SOFTRESET, |
| 442 | OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG); |
| 443 | /* Wait for TLL reset to complete */ |
| 444 | while (!(readl(OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSSTATUS) |
| 445 | & OMAP_USBTLL_SYSSTATUS_RESETDONE)); |
| 446 | pr_debug("TLL reset done\n"); |
| 447 | |
| 448 | writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP | |
| 449 | OMAP_USBTLL_SYSCONFIG_SIDLEMODE | |
| 450 | OMAP_USBTLL_SYSCONFIG_CACTIVITY, |
| 451 | OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG); |
| 452 | |
| 453 | /* Put UHH in NoIdle/NoStandby mode */ |
| 454 | writel(OMAP_UHH_SYSCONFIG_ENAWAKEUP |
| 455 | | OMAP_UHH_SYSCONFIG_SIDLEMODE |
| 456 | | OMAP_UHH_SYSCONFIG_CACTIVITY |
| 457 | | OMAP_UHH_SYSCONFIG_MIDLEMODE, |
| 458 | OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG); |
| 459 | |
| 460 | /* setup burst configurations */ |
| 461 | writel(OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN |
| 462 | | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN |
| 463 | | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN, |
| 464 | OMAP3_UHH_BASE + OMAP_UHH_HOSTCONFIG); |
| 465 | |
| 466 | /* |
| 467 | * Refer ISSUE1: |
| 468 | * Hold the PHY in RESET for enough time till |
| 469 | * PHY is settled and ready |
| 470 | */ |
| 471 | udelay(10); |
| 472 | omap_set_gpio_dataout(GPIO_PHY_RESET, 1); |
| 473 | |
| 474 | hccr = (struct ehci_hccr *)(OMAP3_EHCI_BASE); |
| 475 | hcor = (struct ehci_hcor *)(OMAP3_EHCI_BASE + 0x10); |
| 476 | |
| 477 | pr_debug("OMAP3 EHCI init done\n"); |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | #endif /* CONFIG_USB_EHCI */ |
Jason Kridner | 85a08fb | 2010-07-21 07:41:25 -0500 | [diff] [blame] | 482 | |
| 483 | /* |
| 484 | * This command returns the status of the user button on beagle xM |
| 485 | * Input - none |
| 486 | * Returns - 1 if button is held down |
| 487 | * 0 if button is not held down |
| 488 | */ |
| 489 | int do_userbutton (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 490 | { |
| 491 | int button = 0; |
| 492 | int gpio; |
| 493 | |
| 494 | /* |
| 495 | * pass address parameter as argv[0] (aka command name), |
| 496 | * and all remaining args |
| 497 | */ |
| 498 | switch (get_board_revision()) { |
| 499 | case REVISION_AXBX: |
| 500 | case REVISION_CX: |
| 501 | case REVISION_C4: |
| 502 | gpio = 7; |
| 503 | break; |
| 504 | case REVISION_XM_A: |
| 505 | case REVISION_XM_B: |
| 506 | case REVISION_XM_C: |
| 507 | default: |
| 508 | gpio = 4; |
| 509 | break; |
| 510 | } |
| 511 | omap_request_gpio(gpio); |
| 512 | omap_set_gpio_direction(gpio, 1); |
| 513 | printf("The user button is currently "); |
| 514 | if(omap_get_gpio_datain(gpio)) |
| 515 | { |
| 516 | button = 1; |
| 517 | printf("PRESSED.\n"); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | button = 0; |
| 522 | printf("NOT pressed.\n"); |
| 523 | } |
| 524 | |
| 525 | omap_free_gpio(gpio); |
| 526 | |
| 527 | return !button; |
| 528 | } |
| 529 | |
| 530 | /* -------------------------------------------------------------------- */ |
| 531 | |
| 532 | U_BOOT_CMD( |
| 533 | userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton, |
| 534 | "Return the status of the BeagleBoard USER button", |
| 535 | "" |
| 536 | ); |