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 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 14 | * SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 15 | */ |
| 16 | #include <common.h> |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 17 | #include <dm.h> |
| 18 | #include <ns16550.h> |
Jason Kridner | 70d8c94 | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 19 | #ifdef CONFIG_STATUS_LED |
| 20 | #include <status_led.h> |
| 21 | #endif |
Tom Rix | 2c15513 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 22 | #include <twl4030.h> |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 23 | #include <linux/mtd/nand.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 24 | #include <asm/io.h> |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 25 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 26 | #include <asm/arch/mux.h> |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 27 | #include <asm/arch/mem.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 28 | #include <asm/arch/sys_proto.h> |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 29 | #include <asm/gpio.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 30 | #include <asm/mach-types.h> |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 31 | #include <asm/omap_musb.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 32 | #include <linux/errno.h> |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 33 | #include <linux/usb/ch9.h> |
| 34 | #include <linux/usb/gadget.h> |
| 35 | #include <linux/usb/musb.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 36 | #include "beagle.h" |
Jason Kridner | f835ea7 | 2010-07-21 07:41:25 -0500 | [diff] [blame] | 37 | #include <command.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 38 | |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_USB_EHCI |
| 40 | #include <usb.h> |
| 41 | #include <asm/ehci-omap.h> |
| 42 | #endif |
| 43 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 44 | #define TWL4030_I2C_BUS 0 |
| 45 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 46 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 47 | |
| 48 | #define TINCANTOOLS_ZIPPY 0x01000100 |
| 49 | #define TINCANTOOLS_ZIPPY2 0x02000100 |
| 50 | #define TINCANTOOLS_TRAINER 0x04000100 |
| 51 | #define TINCANTOOLS_SHOWDOG 0x03000100 |
| 52 | #define KBADC_BEAGLEFPGA 0x01000600 |
Koen Kooi | ee8485f | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 53 | #define LW_BEAGLETOUCH 0x01000700 |
| 54 | #define BRAINMUX_LCDOG 0x01000800 |
| 55 | #define BRAINMUX_LCDOGTOUCH 0x02000800 |
| 56 | #define BBTOYS_WIFI 0x01000B00 |
| 57 | #define BBTOYS_VGA 0x02000B00 |
| 58 | #define BBTOYS_LCD 0x03000B00 |
Peter Meerwald | 6cce550 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 59 | #define BCT_BRETTL3 0x01000F00 |
Peter Meerwald | ef88e60 | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 60 | #define BCT_BRETTL4 0x02000F00 |
robertcnelson@gmail.com | 8a1f2dc | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 61 | #define LSR_COM6L_ADPT 0x01001300 |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 62 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 63 | |
John Rigby | 2956532 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 64 | DECLARE_GLOBAL_DATA_PTR; |
| 65 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 66 | static struct { |
| 67 | unsigned int device_vendor; |
| 68 | unsigned char revision; |
| 69 | unsigned char content; |
| 70 | char fab_revision[8]; |
| 71 | char env_var[16]; |
| 72 | char env_setting[64]; |
| 73 | } expansion_config; |
| 74 | |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 75 | static const struct ns16550_platdata beagle_serial = { |
Adam Ford | 2f6ed3b | 2016-03-07 21:08:49 -0600 | [diff] [blame] | 76 | .base = OMAP34XX_UART3, |
| 77 | .reg_shift = 2, |
Heiko Schocher | 17fa032 | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 78 | .clock = V_NS16550_CLK, |
| 79 | .fcr = UART_FCR_DEFVAL, |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | U_BOOT_DEVICE(beagle_uart) = { |
Thomas Chou | c7b9686 | 2015-11-19 21:48:12 +0800 | [diff] [blame] | 83 | "ns16550_serial", |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 84 | &beagle_serial |
| 85 | }; |
| 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, |
Tom Rini | 8ce4e5f | 2013-04-16 16:31:20 -0400 | [diff] [blame] | 109 | * 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] | 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 |
Tom Rini | 8ce4e5f | 2013-04-16 16:31:20 -0400 | [diff] [blame] | 115 | * GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx |
| 116 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 117 | */ |
Peter Meerwald | fff1a57 | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 118 | static int get_board_revision(void) |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 119 | { |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 120 | static int revision = -1; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 121 | |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 122 | if (revision == -1) { |
| 123 | if (!gpio_request(171, "rev0") && |
| 124 | !gpio_request(172, "rev1") && |
| 125 | !gpio_request(173, "rev2")) { |
| 126 | gpio_direction_input(171); |
| 127 | gpio_direction_input(172); |
| 128 | gpio_direction_input(173); |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 129 | |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 130 | revision = gpio_get_value(173) << 2 | |
| 131 | gpio_get_value(172) << 1 | |
| 132 | gpio_get_value(171); |
| 133 | } else { |
| 134 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 135 | } |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 136 | } |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 137 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 138 | return revision; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Tom Rini | 75c57a3 | 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 | */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 147 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 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 | |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 158 | timings->mr = MICRON_V_MR_165; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 159 | switch (get_board_revision()) { |
| 160 | case REVISION_C4: |
| 161 | if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) { |
| 162 | /* 512MB DDR */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 163 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 164 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 165 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 166 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 167 | break; |
robertcnelson@gmail.com | 223b8aa | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 168 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) { |
| 169 | /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 170 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 171 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 172 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 173 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
robertcnelson@gmail.com | 223b8aa | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 174 | break; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 175 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) { |
| 176 | /* Beagleboard Rev C5, 256MB DDR */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 177 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 178 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 179 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 180 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 181 | break; |
| 182 | } |
Nishanth Menon | af4d896 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 183 | case REVISION_XM_AB: |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 184 | case REVISION_XM_C: |
| 185 | if (pop_mfr == 0) { |
| 186 | /* 256MB DDR */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 187 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 188 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 189 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 190 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 191 | } else { |
| 192 | /* 512MB DDR */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 193 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 194 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 195 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 196 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 197 | } |
| 198 | break; |
| 199 | default: |
| 200 | /* Assume 128MB and Micron/165MHz timings to be safe */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 201 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 202 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 203 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 204 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | #endif |
| 208 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 209 | /* |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 210 | * Routine: get_expansion_id |
| 211 | * Description: This function checks for expansion board by checking I2C |
| 212 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 213 | * returns the device_vendor field from the EEPROM |
| 214 | */ |
Peter Meerwald | fff1a57 | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 215 | static unsigned int get_expansion_id(void) |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 216 | { |
| 217 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 218 | |
| 219 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 220 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 221 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 222 | return BEAGLE_NO_EEPROM; |
| 223 | } |
| 224 | |
| 225 | /* read configuration data */ |
| 226 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 227 | sizeof(expansion_config)); |
| 228 | |
robertcnelson@gmail.com | ff229ec | 2013-02-04 06:03:10 +0000 | [diff] [blame] | 229 | /* retry reading configuration data with 16bit addressing */ |
| 230 | if ((expansion_config.device_vendor == 0xFFFFFF00) || |
| 231 | (expansion_config.device_vendor == 0xFFFFFFFF)) { |
| 232 | printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n"); |
| 233 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config, |
| 234 | sizeof(expansion_config)); |
| 235 | } |
| 236 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 237 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 238 | |
| 239 | return expansion_config.device_vendor; |
| 240 | } |
| 241 | |
Peter Meerwald | 2c30c18 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 242 | #ifdef CONFIG_VIDEO_OMAP3 |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 243 | /* |
Jason Kridner | 3f16ab9 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 244 | * Configure DSS to display background color on DVID |
| 245 | * Configure VENC to display color bar on S-Video |
| 246 | */ |
Peter Meerwald | fff1a57 | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 247 | static void beagle_display_init(void) |
Jason Kridner | 3f16ab9 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 248 | { |
| 249 | omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH); |
| 250 | switch (get_board_revision()) { |
| 251 | case REVISION_AXBX: |
| 252 | case REVISION_CX: |
| 253 | case REVISION_C4: |
| 254 | omap3_dss_panel_config(&dvid_cfg); |
| 255 | break; |
Nishanth Menon | af4d896 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 256 | case REVISION_XM_AB: |
Jason Kridner | 3f16ab9 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 257 | case REVISION_XM_C: |
| 258 | default: |
| 259 | omap3_dss_panel_config(&dvid_cfg_xm); |
| 260 | break; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /* |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 265 | * Enable DVI power |
| 266 | */ |
Anatolij Gustschin | 3fbc693 | 2012-03-27 23:05:07 +0000 | [diff] [blame] | 267 | static void beagle_dvi_pup(void) |
| 268 | { |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 269 | uchar val; |
| 270 | |
| 271 | switch (get_board_revision()) { |
| 272 | case REVISION_AXBX: |
| 273 | case REVISION_CX: |
| 274 | case REVISION_C4: |
Simon Glass | b3f4ca1 | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 275 | gpio_request(170, "dvi"); |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 276 | gpio_direction_output(170, 0); |
| 277 | gpio_set_value(170, 1); |
| 278 | break; |
Nishanth Menon | af4d896 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 279 | case REVISION_XM_AB: |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 280 | case REVISION_XM_C: |
| 281 | default: |
| 282 | #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3) |
| 283 | #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6) |
| 284 | |
| 285 | i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 286 | val |= 4; |
| 287 | i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 288 | |
| 289 | i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 290 | val |= 4; |
| 291 | i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 292 | break; |
| 293 | } |
| 294 | } |
Peter Meerwald | 2c30c18 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 295 | #endif |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 296 | |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 297 | #ifdef CONFIG_USB_MUSB_OMAP2PLUS |
| 298 | static struct musb_hdrc_config musb_config = { |
| 299 | .multipoint = 1, |
| 300 | .dyn_fifo = 1, |
| 301 | .num_eps = 16, |
| 302 | .ram_bits = 12, |
| 303 | }; |
| 304 | |
| 305 | static struct omap_musb_board_data musb_board_data = { |
| 306 | .interface_type = MUSB_INTERFACE_ULPI, |
| 307 | }; |
| 308 | |
| 309 | static struct musb_hdrc_platform_data musb_plat = { |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 310 | #if defined(CONFIG_USB_MUSB_HOST) |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 311 | .mode = MUSB_HOST, |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 312 | #elif defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 313 | .mode = MUSB_PERIPHERAL, |
| 314 | #else |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 315 | #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET" |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 316 | #endif |
| 317 | .config = &musb_config, |
| 318 | .power = 100, |
| 319 | .platform_ops = &omap2430_ops, |
| 320 | .board_data = &musb_board_data, |
| 321 | }; |
| 322 | #endif |
| 323 | |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 324 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 325 | * Routine: misc_init_r |
| 326 | * Description: Configure board specific parts |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 327 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 328 | int misc_init_r(void) |
| 329 | { |
Dirk Behme | 97a099e | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 330 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 331 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Jason Kridner | f14a522 | 2011-04-20 13:52:26 +0000 | [diff] [blame] | 332 | struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE; |
Nishanth Menon | 548a64d | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 333 | bool generate_fake_mac = false; |
Alexander Kochetkov | 04e2a13 | 2014-09-29 21:46:48 +0400 | [diff] [blame] | 334 | u32 value; |
Steve Kipisz | d4e53f0 | 2011-04-18 17:27:00 -0400 | [diff] [blame] | 335 | |
| 336 | /* Enable i2c2 pullup resisters */ |
Alexander Kochetkov | 04e2a13 | 2014-09-29 21:46:48 +0400 | [diff] [blame] | 337 | value = readl(&prog_io_base->io1); |
| 338 | value &= ~(PRG_I2C2_PULLUPRESX); |
| 339 | writel(value, &prog_io_base->io1); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 340 | |
Steve Sakoman | 06b95bd | 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 | 06b95bd | 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 | 06b95bd | 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 | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 353 | setenv("beaglerev", "C4"); |
Steve Sakoman | 06b95bd | 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; |
Nishanth Menon | af4d896 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 361 | case REVISION_XM_AB: |
| 362 | printf("Beagle xM Rev A/B\n"); |
| 363 | setenv("beaglerev", "xMAB"); |
Steve Sakoman | 08cbba2ab | 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); |
Nishanth Menon | 548a64d | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 370 | generate_fake_mac = true; |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 371 | break; |
Koen Kooi | 1ffcb34 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 372 | case REVISION_XM_C: |
| 373 | printf("Beagle xM Rev C\n"); |
| 374 | setenv("beaglerev", "xMC"); |
| 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); |
Nishanth Menon | 548a64d | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 381 | generate_fake_mac = true; |
Koen Kooi | 1ffcb34 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 382 | break; |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 383 | default: |
| 384 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
Koen Kooi | f6e593b | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 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); |
Nishanth Menon | 548a64d | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 391 | generate_fake_mac = true; |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 394 | switch (get_expansion_id()) { |
| 395 | case TINCANTOOLS_ZIPPY: |
| 396 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 397 | expansion_config.revision, |
| 398 | expansion_config.fab_revision); |
| 399 | MUX_TINCANTOOLS_ZIPPY(); |
| 400 | setenv("buddy", "zippy"); |
| 401 | break; |
| 402 | case TINCANTOOLS_ZIPPY2: |
| 403 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 404 | expansion_config.revision, |
| 405 | expansion_config.fab_revision); |
| 406 | MUX_TINCANTOOLS_ZIPPY(); |
| 407 | setenv("buddy", "zippy2"); |
| 408 | break; |
| 409 | case TINCANTOOLS_TRAINER: |
| 410 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 411 | expansion_config.revision, |
| 412 | expansion_config.fab_revision); |
| 413 | MUX_TINCANTOOLS_ZIPPY(); |
| 414 | MUX_TINCANTOOLS_TRAINER(); |
| 415 | setenv("buddy", "trainer"); |
| 416 | break; |
| 417 | case TINCANTOOLS_SHOWDOG: |
| 418 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 419 | expansion_config.revision, |
| 420 | expansion_config.fab_revision); |
| 421 | /* Place holder for DSS2 definition for showdog lcd */ |
| 422 | setenv("defaultdisplay", "showdoglcd"); |
| 423 | setenv("buddy", "showdog"); |
| 424 | break; |
| 425 | case KBADC_BEAGLEFPGA: |
| 426 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 427 | MUX_KBADC_BEAGLEFPGA(); |
| 428 | setenv("buddy", "beaglefpga"); |
| 429 | break; |
Koen Kooi | ee8485f | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 430 | case LW_BEAGLETOUCH: |
| 431 | printf("Recognized Liquidware BeagleTouch board\n"); |
| 432 | setenv("buddy", "beagletouch"); |
| 433 | break; |
| 434 | case BRAINMUX_LCDOG: |
| 435 | printf("Recognized Brainmux LCDog board\n"); |
| 436 | setenv("buddy", "lcdog"); |
| 437 | break; |
| 438 | case BRAINMUX_LCDOGTOUCH: |
| 439 | printf("Recognized Brainmux LCDog Touch board\n"); |
| 440 | setenv("buddy", "lcdogtouch"); |
| 441 | break; |
| 442 | case BBTOYS_WIFI: |
| 443 | printf("Recognized BeagleBoardToys WiFi board\n"); |
| 444 | MUX_BBTOYS_WIFI() |
| 445 | setenv("buddy", "bbtoys-wifi"); |
| 446 | break;; |
| 447 | case BBTOYS_VGA: |
| 448 | printf("Recognized BeagleBoardToys VGA board\n"); |
| 449 | break;; |
| 450 | case BBTOYS_LCD: |
| 451 | printf("Recognized BeagleBoardToys LCD board\n"); |
| 452 | break;; |
Peter Meerwald | 6cce550 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 453 | case BCT_BRETTL3: |
Peter Meerwald | ef88e60 | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 454 | printf("Recognized bct electronic GmbH brettl3 board\n"); |
| 455 | break; |
| 456 | case BCT_BRETTL4: |
| 457 | printf("Recognized bct electronic GmbH brettl4 board\n"); |
| 458 | break; |
robertcnelson@gmail.com | 8a1f2dc | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 459 | case LSR_COM6L_ADPT: |
| 460 | printf("Recognized LSR COM6L Adapter Board\n"); |
| 461 | MUX_BBTOYS_WIFI() |
| 462 | setenv("buddy", "lsr-com6l-adpt"); |
| 463 | break; |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 464 | case BEAGLE_NO_EEPROM: |
| 465 | printf("No EEPROM on expansion board\n"); |
| 466 | setenv("buddy", "none"); |
| 467 | break; |
| 468 | default: |
| 469 | printf("Unrecognized expansion board: %x\n", |
| 470 | expansion_config.device_vendor); |
| 471 | setenv("buddy", "unknown"); |
| 472 | } |
| 473 | |
| 474 | if (expansion_config.content == 1) |
| 475 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 476 | |
Tom Rix | 2c15513 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 477 | twl4030_power_init(); |
Christian Spielberger | 38a77c3 | 2011-08-24 17:17:31 -0500 | [diff] [blame] | 478 | switch (get_board_revision()) { |
Nishanth Menon | af4d896 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 479 | case REVISION_XM_AB: |
Christian Spielberger | 38a77c3 | 2011-08-24 17:17:31 -0500 | [diff] [blame] | 480 | twl4030_led_init(TWL4030_LED_LEDEN_LEDBON); |
| 481 | break; |
| 482 | default: |
| 483 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
| 484 | break; |
| 485 | } |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 486 | |
Bob Feretich | 52d82e4 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 487 | /* Set GPIO states before they are made outputs */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 488 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 489 | &gpio6_base->setdataout); |
| 490 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 491 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 492 | |
Bob Feretich | 52d82e4 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 493 | /* Configure GPIOs to output */ |
| 494 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 495 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 496 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 497 | |
Paul Kocialkowski | 679f82c | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 498 | omap_die_id_display(); |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 499 | |
Peter Meerwald | 2c30c18 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 500 | #ifdef CONFIG_VIDEO_OMAP3 |
Peter Meerwald | 4258aa6 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 501 | beagle_dvi_pup(); |
Jason Kridner | 3f16ab9 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 502 | beagle_display_init(); |
| 503 | omap3_dss_enable(); |
Peter Meerwald | 2c30c18 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 504 | #endif |
Dirk Behme | e6a6a70 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 505 | |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 506 | #ifdef CONFIG_USB_MUSB_OMAP2PLUS |
| 507 | musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE); |
| 508 | #endif |
| 509 | |
Paul Kocialkowski | 07815eb | 2015-08-27 19:37:12 +0200 | [diff] [blame] | 510 | if (generate_fake_mac) |
| 511 | omap_die_id_usbethaddr(); |
Nishanth Menon | 548a64d | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 512 | |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 513 | return 0; |
| 514 | } |
| 515 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 516 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 517 | * Routine: set_muxconf_regs |
| 518 | * Description: Setting up the configuration Mux registers specific to the |
| 519 | * hardware. Many pins need to be moved from protect to primary |
| 520 | * mode. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 521 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 522 | void set_muxconf_regs(void) |
| 523 | { |
| 524 | MUX_BEAGLE(); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 525 | } |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 526 | |
Tom Rini | 75c57a3 | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 527 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 528 | int board_mmc_init(bd_t *bis) |
| 529 | { |
Nikita Kiryanov | e3913f5 | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 530 | return omap_mmc_init(0, 0, 0, -1, -1); |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 531 | } |
| 532 | #endif |
Alexander Holler | d90859a | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 533 | |
Paul Kocialkowski | aac5450 | 2014-11-08 20:55:47 +0100 | [diff] [blame] | 534 | #if defined(CONFIG_GENERIC_MMC) |
| 535 | void board_mmc_power_init(void) |
| 536 | { |
| 537 | twl4030_power_mmc_init(0); |
| 538 | } |
| 539 | #endif |
| 540 | |
Ilya Yanok | 7ac2fe2 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 541 | #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD) |
Alexander Holler | d90859a | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 542 | /* Call usb_stop() before starting the kernel */ |
| 543 | void show_boot_progress(int val) |
| 544 | { |
Simon Glass | 578ac1e | 2011-12-10 11:07:54 +0000 | [diff] [blame] | 545 | if (val == BOOTSTAGE_ID_RUN_OS) |
Alexander Holler | d90859a | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 546 | usb_stop(); |
| 547 | } |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 548 | |
| 549 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 550 | .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, |
| 551 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 552 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED |
| 553 | }; |
| 554 | |
Troy Kisky | 127efc4 | 2013-10-10 15:27:57 -0700 | [diff] [blame] | 555 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 556 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 557 | { |
Mateusz Zalega | 16297cf | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 558 | return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 561 | int ehci_hcd_stop(int index) |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 562 | { |
| 563 | return omap_ehci_hcd_stop(); |
| 564 | } |
| 565 | |
Alexander Holler | d90859a | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 566 | #endif /* CONFIG_USB_EHCI */ |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 567 | |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 568 | #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | c642b15 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 569 | int board_eth_init(bd_t *bis) |
| 570 | { |
| 571 | return usb_eth_initialize(bis); |
| 572 | } |
| 573 | #endif |