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