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