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