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