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> |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 45 | #include <asm/omap_musb.h> |
| 46 | #include <asm/errno.h> |
| 47 | #include <linux/usb/ch9.h> |
| 48 | #include <linux/usb/gadget.h> |
| 49 | #include <linux/usb/musb.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 50 | #include "beagle.h" |
Jason Kridner | 85a08fb | 2010-07-21 07:41:25 -0500 | [diff] [blame] | 51 | #include <command.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 52 | |
Govindraj.R | edc16a0 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 53 | #ifdef CONFIG_USB_EHCI |
| 54 | #include <usb.h> |
| 55 | #include <asm/ehci-omap.h> |
| 56 | #endif |
| 57 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 58 | #define TWL4030_I2C_BUS 0 |
| 59 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 60 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 61 | |
| 62 | #define TINCANTOOLS_ZIPPY 0x01000100 |
| 63 | #define TINCANTOOLS_ZIPPY2 0x02000100 |
| 64 | #define TINCANTOOLS_TRAINER 0x04000100 |
| 65 | #define TINCANTOOLS_SHOWDOG 0x03000100 |
| 66 | #define KBADC_BEAGLEFPGA 0x01000600 |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 67 | #define LW_BEAGLETOUCH 0x01000700 |
| 68 | #define BRAINMUX_LCDOG 0x01000800 |
| 69 | #define BRAINMUX_LCDOGTOUCH 0x02000800 |
| 70 | #define BBTOYS_WIFI 0x01000B00 |
| 71 | #define BBTOYS_VGA 0x02000B00 |
| 72 | #define BBTOYS_LCD 0x03000B00 |
Peter Meerwald | 1aca738 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 73 | #define BCT_BRETTL3 0x01000F00 |
Peter Meerwald | ad5691f | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 74 | #define BCT_BRETTL4 0x02000F00 |
robertcnelson@gmail.com | 346d7eb | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 75 | #define LSR_COM6L_ADPT 0x01001300 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 76 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 77 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 78 | DECLARE_GLOBAL_DATA_PTR; |
| 79 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 80 | static struct { |
| 81 | unsigned int device_vendor; |
| 82 | unsigned char revision; |
| 83 | unsigned char content; |
| 84 | char fab_revision[8]; |
| 85 | char env_var[16]; |
| 86 | char env_setting[64]; |
| 87 | } expansion_config; |
| 88 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 89 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 90 | * Routine: board_init |
| 91 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 92 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 93 | int board_init(void) |
| 94 | { |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 95 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 96 | /* board id for Linux */ |
| 97 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 98 | /* boot param addr */ |
| 99 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 100 | |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 101 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) |
| 102 | status_led_set (STATUS_LED_BOOT, STATUS_LED_ON); |
| 103 | #endif |
| 104 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 105 | return 0; |
| 106 | } |
| 107 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 108 | /* |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 109 | * Routine: get_board_revision |
| 110 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 111 | * C1/2/3, C4 or xM. This can be done by reading |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 112 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 113 | * result in |
| 114 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 115 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 116 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 117 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 118 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 119 | static int get_board_revision(void) |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 120 | { |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 121 | int revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 122 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 123 | if (!gpio_request(171, "") && |
| 124 | !gpio_request(172, "") && |
| 125 | !gpio_request(173, "")) { |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 126 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 127 | gpio_direction_input(171); |
| 128 | gpio_direction_input(172); |
| 129 | gpio_direction_input(173); |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 130 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 131 | revision = gpio_get_value(173) << 2 | |
| 132 | gpio_get_value(172) << 1 | |
| 133 | gpio_get_value(171); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 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 Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 142 | #ifdef CONFIG_SPL_BUILD |
| 143 | /* |
| 144 | * Routine: get_board_mem_timings |
| 145 | * Description: If we use SPL then there is no x-loader nor config header |
| 146 | * so we have to setup the DDR timings ourself on both banks. |
| 147 | */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 148 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 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 | |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 159 | timings->mr = MICRON_V_MR_165; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 160 | switch (get_board_revision()) { |
| 161 | case REVISION_C4: |
| 162 | if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) { |
| 163 | /* 512MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 164 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 165 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 166 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 167 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 168 | break; |
robertcnelson@gmail.com | 4b949bb | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 169 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) { |
| 170 | /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 171 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 172 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 173 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 174 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
robertcnelson@gmail.com | 4b949bb | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 175 | break; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 176 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) { |
| 177 | /* Beagleboard Rev C5, 256MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 178 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 179 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 180 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 181 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 182 | break; |
| 183 | } |
| 184 | case REVISION_XM_A: |
| 185 | case REVISION_XM_B: |
| 186 | case REVISION_XM_C: |
| 187 | if (pop_mfr == 0) { |
| 188 | /* 256MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 189 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 190 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 191 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 192 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 193 | } else { |
| 194 | /* 512MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 195 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 196 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 197 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 198 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 199 | } |
| 200 | break; |
| 201 | default: |
| 202 | /* Assume 128MB and Micron/165MHz timings to be safe */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 203 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 204 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 205 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 206 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | #endif |
| 210 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 211 | /* |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 212 | * Routine: get_expansion_id |
| 213 | * Description: This function checks for expansion board by checking I2C |
| 214 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 215 | * returns the device_vendor field from the EEPROM |
| 216 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 217 | static unsigned int get_expansion_id(void) |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 218 | { |
| 219 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 220 | |
| 221 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 222 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 223 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 224 | return BEAGLE_NO_EEPROM; |
| 225 | } |
| 226 | |
| 227 | /* read configuration data */ |
| 228 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 229 | sizeof(expansion_config)); |
| 230 | |
robertcnelson@gmail.com | aba0c9c | 2013-02-04 06:03:10 +0000 | [diff] [blame] | 231 | /* retry reading configuration data with 16bit addressing */ |
| 232 | if ((expansion_config.device_vendor == 0xFFFFFF00) || |
| 233 | (expansion_config.device_vendor == 0xFFFFFFFF)) { |
| 234 | printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n"); |
| 235 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config, |
| 236 | sizeof(expansion_config)); |
| 237 | } |
| 238 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 239 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 240 | |
| 241 | return expansion_config.device_vendor; |
| 242 | } |
| 243 | |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 244 | #ifdef CONFIG_VIDEO_OMAP3 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 245 | /* |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 246 | * Configure DSS to display background color on DVID |
| 247 | * Configure VENC to display color bar on S-Video |
| 248 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 249 | static void beagle_display_init(void) |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 250 | { |
| 251 | omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH); |
| 252 | switch (get_board_revision()) { |
| 253 | case REVISION_AXBX: |
| 254 | case REVISION_CX: |
| 255 | case REVISION_C4: |
| 256 | omap3_dss_panel_config(&dvid_cfg); |
| 257 | break; |
| 258 | case REVISION_XM_A: |
| 259 | case REVISION_XM_B: |
| 260 | case REVISION_XM_C: |
| 261 | default: |
| 262 | omap3_dss_panel_config(&dvid_cfg_xm); |
| 263 | break; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | /* |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 268 | * Enable DVI power |
| 269 | */ |
Anatolij Gustschin | 359260b | 2012-03-27 23:05:07 +0000 | [diff] [blame] | 270 | static void beagle_dvi_pup(void) |
| 271 | { |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 272 | uchar val; |
| 273 | |
| 274 | switch (get_board_revision()) { |
| 275 | case REVISION_AXBX: |
| 276 | case REVISION_CX: |
| 277 | case REVISION_C4: |
| 278 | case REVISION_XM_A: |
| 279 | gpio_request(170, ""); |
| 280 | gpio_direction_output(170, 0); |
| 281 | gpio_set_value(170, 1); |
| 282 | break; |
| 283 | case REVISION_XM_B: |
| 284 | case REVISION_XM_C: |
| 285 | default: |
| 286 | #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3) |
| 287 | #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6) |
| 288 | |
| 289 | i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 290 | val |= 4; |
| 291 | i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 292 | |
| 293 | i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 294 | val |= 4; |
| 295 | i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 296 | break; |
| 297 | } |
| 298 | } |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 299 | #endif |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 300 | |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 301 | #ifdef CONFIG_USB_MUSB_OMAP2PLUS |
| 302 | static struct musb_hdrc_config musb_config = { |
| 303 | .multipoint = 1, |
| 304 | .dyn_fifo = 1, |
| 305 | .num_eps = 16, |
| 306 | .ram_bits = 12, |
| 307 | }; |
| 308 | |
| 309 | static struct omap_musb_board_data musb_board_data = { |
| 310 | .interface_type = MUSB_INTERFACE_ULPI, |
| 311 | }; |
| 312 | |
| 313 | static struct musb_hdrc_platform_data musb_plat = { |
| 314 | #if defined(CONFIG_MUSB_HOST) |
| 315 | .mode = MUSB_HOST, |
| 316 | #elif defined(CONFIG_MUSB_GADGET) |
| 317 | .mode = MUSB_PERIPHERAL, |
| 318 | #else |
| 319 | #error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET" |
| 320 | #endif |
| 321 | .config = &musb_config, |
| 322 | .power = 100, |
| 323 | .platform_ops = &omap2430_ops, |
| 324 | .board_data = &musb_board_data, |
| 325 | }; |
| 326 | #endif |
| 327 | |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 328 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 329 | * Routine: misc_init_r |
| 330 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 331 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 332 | int misc_init_r(void) |
| 333 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 334 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 335 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Jason Kridner | 40aebca | 2011-04-20 13:52:26 +0000 | [diff] [blame] | 336 | 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] | 337 | |
| 338 | /* Enable i2c2 pullup resisters */ |
| 339 | writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 340 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 341 | switch (get_board_revision()) { |
| 342 | case REVISION_AXBX: |
| 343 | printf("Beagle Rev Ax/Bx\n"); |
| 344 | setenv("beaglerev", "AxBx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 345 | break; |
| 346 | case REVISION_CX: |
| 347 | printf("Beagle Rev C1/C2/C3\n"); |
| 348 | setenv("beaglerev", "Cx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 349 | MUX_BEAGLE_C(); |
| 350 | break; |
| 351 | case REVISION_C4: |
| 352 | printf("Beagle Rev C4\n"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 353 | setenv("beaglerev", "C4"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 354 | MUX_BEAGLE_C(); |
| 355 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 356 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 357 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 358 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 359 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 360 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 361 | case REVISION_XM_A: |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 362 | printf("Beagle xM Rev A\n"); |
| 363 | setenv("beaglerev", "xMA"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 364 | MUX_BEAGLE_XM(); |
| 365 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 366 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 367 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 368 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 369 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 370 | break; |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 371 | case REVISION_XM_B: |
| 372 | printf("Beagle xM Rev B\n"); |
| 373 | setenv("beaglerev", "xMB"); |
| 374 | MUX_BEAGLE_XM(); |
| 375 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 376 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 377 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 378 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 379 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 380 | break; |
Koen Kooi | 6330844 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 381 | case REVISION_XM_C: |
| 382 | printf("Beagle xM Rev C\n"); |
| 383 | setenv("beaglerev", "xMC"); |
| 384 | MUX_BEAGLE_XM(); |
| 385 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 386 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 387 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 388 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 389 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 390 | break; |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 391 | default: |
| 392 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 393 | MUX_BEAGLE_XM(); |
| 394 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 395 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 396 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 397 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 398 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 401 | switch (get_expansion_id()) { |
| 402 | case TINCANTOOLS_ZIPPY: |
| 403 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 404 | expansion_config.revision, |
| 405 | expansion_config.fab_revision); |
| 406 | MUX_TINCANTOOLS_ZIPPY(); |
| 407 | setenv("buddy", "zippy"); |
| 408 | break; |
| 409 | case TINCANTOOLS_ZIPPY2: |
| 410 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 411 | expansion_config.revision, |
| 412 | expansion_config.fab_revision); |
| 413 | MUX_TINCANTOOLS_ZIPPY(); |
| 414 | setenv("buddy", "zippy2"); |
| 415 | break; |
| 416 | case TINCANTOOLS_TRAINER: |
| 417 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 418 | expansion_config.revision, |
| 419 | expansion_config.fab_revision); |
| 420 | MUX_TINCANTOOLS_ZIPPY(); |
| 421 | MUX_TINCANTOOLS_TRAINER(); |
| 422 | setenv("buddy", "trainer"); |
| 423 | break; |
| 424 | case TINCANTOOLS_SHOWDOG: |
| 425 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 426 | expansion_config.revision, |
| 427 | expansion_config.fab_revision); |
| 428 | /* Place holder for DSS2 definition for showdog lcd */ |
| 429 | setenv("defaultdisplay", "showdoglcd"); |
| 430 | setenv("buddy", "showdog"); |
| 431 | break; |
| 432 | case KBADC_BEAGLEFPGA: |
| 433 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 434 | MUX_KBADC_BEAGLEFPGA(); |
| 435 | setenv("buddy", "beaglefpga"); |
| 436 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 437 | case LW_BEAGLETOUCH: |
| 438 | printf("Recognized Liquidware BeagleTouch board\n"); |
| 439 | setenv("buddy", "beagletouch"); |
| 440 | break; |
| 441 | case BRAINMUX_LCDOG: |
| 442 | printf("Recognized Brainmux LCDog board\n"); |
| 443 | setenv("buddy", "lcdog"); |
| 444 | break; |
| 445 | case BRAINMUX_LCDOGTOUCH: |
| 446 | printf("Recognized Brainmux LCDog Touch board\n"); |
| 447 | setenv("buddy", "lcdogtouch"); |
| 448 | break; |
| 449 | case BBTOYS_WIFI: |
| 450 | printf("Recognized BeagleBoardToys WiFi board\n"); |
| 451 | MUX_BBTOYS_WIFI() |
| 452 | setenv("buddy", "bbtoys-wifi"); |
| 453 | break;; |
| 454 | case BBTOYS_VGA: |
| 455 | printf("Recognized BeagleBoardToys VGA board\n"); |
| 456 | break;; |
| 457 | case BBTOYS_LCD: |
| 458 | printf("Recognized BeagleBoardToys LCD board\n"); |
| 459 | break;; |
Peter Meerwald | 1aca738 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 460 | case BCT_BRETTL3: |
Peter Meerwald | ad5691f | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 461 | printf("Recognized bct electronic GmbH brettl3 board\n"); |
| 462 | break; |
| 463 | case BCT_BRETTL4: |
| 464 | printf("Recognized bct electronic GmbH brettl4 board\n"); |
| 465 | break; |
robertcnelson@gmail.com | 346d7eb | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 466 | case LSR_COM6L_ADPT: |
| 467 | printf("Recognized LSR COM6L Adapter Board\n"); |
| 468 | MUX_BBTOYS_WIFI() |
| 469 | setenv("buddy", "lsr-com6l-adpt"); |
| 470 | break; |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 471 | case BEAGLE_NO_EEPROM: |
| 472 | printf("No EEPROM on expansion board\n"); |
| 473 | setenv("buddy", "none"); |
| 474 | break; |
| 475 | default: |
| 476 | printf("Unrecognized expansion board: %x\n", |
| 477 | expansion_config.device_vendor); |
| 478 | setenv("buddy", "unknown"); |
| 479 | } |
| 480 | |
| 481 | if (expansion_config.content == 1) |
| 482 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 483 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 484 | twl4030_power_init(); |
Christian Spielberger | 3be83dc | 2011-08-24 17:17:31 -0500 | [diff] [blame] | 485 | switch (get_board_revision()) { |
| 486 | case REVISION_XM_A: |
| 487 | case REVISION_XM_B: |
| 488 | twl4030_led_init(TWL4030_LED_LEDEN_LEDBON); |
| 489 | break; |
| 490 | default: |
| 491 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
| 492 | break; |
| 493 | } |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 494 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 495 | /* Set GPIO states before they are made outputs */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 496 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 497 | &gpio6_base->setdataout); |
| 498 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 499 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 500 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 501 | /* Configure GPIOs to output */ |
| 502 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 503 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 504 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 505 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 506 | dieid_num_r(); |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 507 | |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 508 | #ifdef CONFIG_VIDEO_OMAP3 |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 509 | beagle_dvi_pup(); |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 510 | beagle_display_init(); |
| 511 | omap3_dss_enable(); |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 512 | #endif |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 513 | |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 514 | #ifdef CONFIG_USB_MUSB_OMAP2PLUS |
| 515 | musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE); |
| 516 | #endif |
| 517 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 518 | return 0; |
| 519 | } |
| 520 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 521 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 522 | * Routine: set_muxconf_regs |
| 523 | * Description: Setting up the configuration Mux registers specific to the |
| 524 | * hardware. Many pins need to be moved from protect to primary |
| 525 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 526 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 527 | void set_muxconf_regs(void) |
| 528 | { |
| 529 | MUX_BEAGLE(); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 530 | } |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 531 | |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 532 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 533 | int board_mmc_init(bd_t *bis) |
| 534 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 535 | return omap_mmc_init(0, 0, 0, -1, -1); |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 536 | } |
| 537 | #endif |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 538 | |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 539 | #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD) |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 540 | /* Call usb_stop() before starting the kernel */ |
| 541 | void show_boot_progress(int val) |
| 542 | { |
Simon Glass | 2939564 | 2011-12-10 11:07:54 +0000 | [diff] [blame] | 543 | if (val == BOOTSTAGE_ID_RUN_OS) |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 544 | usb_stop(); |
| 545 | } |
Govindraj.R | edc16a0 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 546 | |
| 547 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 548 | .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, |
| 549 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 550 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED |
| 551 | }; |
| 552 | |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 553 | int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Govindraj.R | edc16a0 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 554 | { |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 555 | return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); |
Govindraj.R | edc16a0 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 558 | int ehci_hcd_stop(int index) |
Govindraj.R | edc16a0 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 559 | { |
| 560 | return omap_ehci_hcd_stop(); |
| 561 | } |
| 562 | |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 563 | #endif /* CONFIG_USB_EHCI */ |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 564 | |
| 565 | #if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET) |
| 566 | int board_eth_init(bd_t *bis) |
| 567 | { |
| 568 | return usb_eth_initialize(bis); |
| 569 | } |
| 570 | #endif |