Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 2 | /* |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 3 | * (C) Copyright 2004-2011 |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 4 | * Texas Instruments, <www.ti.com> |
| 5 | * |
| 6 | * Author : |
| 7 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 8 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 9 | * |
| 10 | * Derived from Beagle Board and 3430 SDP code by |
| 11 | * Richard Woodruff <r-woodruff2@ti.com> |
| 12 | * Syed Mohammed Khasim <khasim@ti.com> |
| 13 | * |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 14 | */ |
| 15 | #include <common.h> |
Simon Glass | 1ea9789 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 16 | #include <bootstage.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 17 | #include <dm.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 18 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 19 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 20 | #include <net.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 21 | #include <ns16550.h> |
Simon Glass | 3673618 | 2019-11-14 12:57:24 -0700 | [diff] [blame] | 22 | #include <serial.h> |
Uri Mashiach | 4892d39 | 2017-01-19 10:51:45 +0200 | [diff] [blame] | 23 | #ifdef CONFIG_LED_STATUS |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 24 | #include <status_led.h> |
| 25 | #endif |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 26 | #include <twl4030.h> |
Masahiro Yamada | 2b7a873 | 2017-11-30 13:45:24 +0900 | [diff] [blame] | 27 | #include <linux/mtd/rawnand.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 28 | #include <asm/io.h> |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 29 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 30 | #include <asm/arch/mux.h> |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 31 | #include <asm/arch/mem.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 32 | #include <asm/arch/sys_proto.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 33 | #include <asm/gpio.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 35 | #include <asm/omap_musb.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 36 | #include <linux/errno.h> |
Ilya Yanok | cb7b2b8 | 2012-11-06 13:48:30 +0000 | [diff] [blame] | 37 | #include <linux/usb/ch9.h> |
| 38 | #include <linux/usb/gadget.h> |
| 39 | #include <linux/usb/musb.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 40 | #include "beagle.h" |
Jason Kridner | 85a08fb | 2010-07-21 07:41:25 -0500 | [diff] [blame] | 41 | #include <command.h> |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 42 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 43 | #define TWL4030_I2C_BUS 0 |
| 44 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 45 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 46 | |
| 47 | #define TINCANTOOLS_ZIPPY 0x01000100 |
| 48 | #define TINCANTOOLS_ZIPPY2 0x02000100 |
| 49 | #define TINCANTOOLS_TRAINER 0x04000100 |
| 50 | #define TINCANTOOLS_SHOWDOG 0x03000100 |
| 51 | #define KBADC_BEAGLEFPGA 0x01000600 |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 52 | #define LW_BEAGLETOUCH 0x01000700 |
| 53 | #define BRAINMUX_LCDOG 0x01000800 |
| 54 | #define BRAINMUX_LCDOGTOUCH 0x02000800 |
| 55 | #define BBTOYS_WIFI 0x01000B00 |
| 56 | #define BBTOYS_VGA 0x02000B00 |
| 57 | #define BBTOYS_LCD 0x03000B00 |
Peter Meerwald | 1aca738 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 58 | #define BCT_BRETTL3 0x01000F00 |
Peter Meerwald | ad5691f | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 59 | #define BCT_BRETTL4 0x02000F00 |
robertcnelson@gmail.com | 346d7eb | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 60 | #define LSR_COM6L_ADPT 0x01001300 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 61 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 62 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 63 | DECLARE_GLOBAL_DATA_PTR; |
| 64 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 65 | static struct { |
| 66 | unsigned int device_vendor; |
| 67 | unsigned char revision; |
| 68 | unsigned char content; |
| 69 | char fab_revision[8]; |
| 70 | char env_var[16]; |
| 71 | char env_setting[64]; |
| 72 | } expansion_config; |
| 73 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 74 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 75 | * Routine: board_init |
| 76 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 77 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 78 | int board_init(void) |
| 79 | { |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 80 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 81 | /* board id for Linux */ |
| 82 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 83 | /* boot param addr */ |
| 84 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 85 | |
Uri Mashiach | 4892d39 | 2017-01-19 10:51:45 +0200 | [diff] [blame] | 86 | #if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE) |
| 87 | status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON); |
Jason Kridner | c3ef8bc | 2011-04-18 17:23:35 -0400 | [diff] [blame] | 88 | #endif |
| 89 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 90 | return 0; |
| 91 | } |
| 92 | |
Derald D. Woods | 2b6b089 | 2017-12-29 10:37:32 -0600 | [diff] [blame] | 93 | #if defined(CONFIG_SPL_OS_BOOT) |
| 94 | int spl_start_uboot(void) |
| 95 | { |
| 96 | /* break into full u-boot on 'c' */ |
| 97 | if (serial_tstc() && serial_getc() == 'c') |
| 98 | return 1; |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | #endif /* CONFIG_SPL_OS_BOOT */ |
| 103 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 104 | /* |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 105 | * Routine: get_board_revision |
| 106 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Tom Rini | 4dfad75 | 2013-04-16 16:31:20 -0400 | [diff] [blame] | 107 | * C1/2/3, C4, xM Ax/Bx or xM Cx. This can be done by reading |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 108 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 109 | * result in |
| 110 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 111 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 112 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Tom Rini | 4dfad75 | 2013-04-16 16:31:20 -0400 | [diff] [blame] | 113 | * GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx |
| 114 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 115 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 116 | static int get_board_revision(void) |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 117 | { |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 118 | static int revision = -1; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 119 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 120 | if (revision == -1) { |
| 121 | if (!gpio_request(171, "rev0") && |
| 122 | !gpio_request(172, "rev1") && |
| 123 | !gpio_request(173, "rev2")) { |
| 124 | gpio_direction_input(171); |
| 125 | gpio_direction_input(172); |
| 126 | gpio_direction_input(173); |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 127 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 128 | revision = gpio_get_value(173) << 2 | |
| 129 | gpio_get_value(172) << 1 | |
| 130 | gpio_get_value(171); |
| 131 | } else { |
| 132 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 133 | } |
Tom Rix | 70d0541 | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 134 | } |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 135 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 136 | return revision; |
Dirk Behme | 7871611 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 137 | } |
| 138 | |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 139 | #ifdef CONFIG_SPL_BUILD |
| 140 | /* |
| 141 | * Routine: get_board_mem_timings |
| 142 | * Description: If we use SPL then there is no x-loader nor config header |
| 143 | * so we have to setup the DDR timings ourself on both banks. |
| 144 | */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 145 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 146 | { |
| 147 | int pop_mfr, pop_id; |
| 148 | |
| 149 | /* |
| 150 | * We need to identify what PoP memory is on the board so that |
| 151 | * we know what timings to use. If we can't identify it then |
| 152 | * we know it's an xM. To map the ID values please see nand_ids.c |
| 153 | */ |
| 154 | identify_nand_chip(&pop_mfr, &pop_id); |
| 155 | |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 156 | timings->mr = MICRON_V_MR_165; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 157 | switch (get_board_revision()) { |
| 158 | case REVISION_C4: |
| 159 | if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) { |
| 160 | /* 512MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 161 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 162 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 163 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 164 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 165 | break; |
robertcnelson@gmail.com | 4b949bb | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 166 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) { |
| 167 | /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 168 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 169 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 170 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 171 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
robertcnelson@gmail.com | 4b949bb | 2012-01-27 07:09:42 +0000 | [diff] [blame] | 172 | break; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 173 | } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) { |
| 174 | /* Beagleboard Rev C5, 256MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 175 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 176 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 177 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 178 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 179 | break; |
| 180 | } |
Nishanth Menon | 1d65fb3 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 181 | case REVISION_XM_AB: |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 182 | case REVISION_XM_C: |
| 183 | if (pop_mfr == 0) { |
| 184 | /* 256MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 185 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 186 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 187 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 188 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 189 | } else { |
| 190 | /* 512MB DDR */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 191 | timings->mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 192 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 193 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 194 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 195 | } |
| 196 | break; |
| 197 | default: |
| 198 | /* Assume 128MB and Micron/165MHz timings to be safe */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 199 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 200 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 201 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 202 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 06c32fb | 2011-11-18 12:48:08 +0000 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | #endif |
| 206 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 207 | /* |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 208 | * Routine: get_expansion_id |
| 209 | * Description: This function checks for expansion board by checking I2C |
| 210 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 211 | * returns the device_vendor field from the EEPROM |
| 212 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 213 | static unsigned int get_expansion_id(void) |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 214 | { |
| 215 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 216 | |
| 217 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 218 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 219 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 220 | return BEAGLE_NO_EEPROM; |
| 221 | } |
| 222 | |
| 223 | /* read configuration data */ |
| 224 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 225 | sizeof(expansion_config)); |
| 226 | |
robertcnelson@gmail.com | aba0c9c | 2013-02-04 06:03:10 +0000 | [diff] [blame] | 227 | /* retry reading configuration data with 16bit addressing */ |
| 228 | if ((expansion_config.device_vendor == 0xFFFFFF00) || |
| 229 | (expansion_config.device_vendor == 0xFFFFFFFF)) { |
| 230 | printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n"); |
| 231 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config, |
| 232 | sizeof(expansion_config)); |
| 233 | } |
| 234 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 235 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 236 | |
| 237 | return expansion_config.device_vendor; |
| 238 | } |
| 239 | |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_VIDEO_OMAP3 |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 241 | /* |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 242 | * Configure DSS to display background color on DVID |
| 243 | * Configure VENC to display color bar on S-Video |
| 244 | */ |
Peter Meerwald | a93ee5f | 2012-07-02 03:19:03 +0000 | [diff] [blame] | 245 | static void beagle_display_init(void) |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 246 | { |
| 247 | omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH); |
| 248 | switch (get_board_revision()) { |
| 249 | case REVISION_AXBX: |
| 250 | case REVISION_CX: |
| 251 | case REVISION_C4: |
| 252 | omap3_dss_panel_config(&dvid_cfg); |
| 253 | break; |
Nishanth Menon | 1d65fb3 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 254 | case REVISION_XM_AB: |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 255 | case REVISION_XM_C: |
| 256 | default: |
| 257 | omap3_dss_panel_config(&dvid_cfg_xm); |
| 258 | break; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /* |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 263 | * Enable DVI power |
| 264 | */ |
Anatolij Gustschin | 359260b | 2012-03-27 23:05:07 +0000 | [diff] [blame] | 265 | static void beagle_dvi_pup(void) |
| 266 | { |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 267 | uchar val; |
| 268 | |
| 269 | switch (get_board_revision()) { |
| 270 | case REVISION_AXBX: |
| 271 | case REVISION_CX: |
| 272 | case REVISION_C4: |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 273 | gpio_request(170, "dvi"); |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 274 | gpio_direction_output(170, 0); |
| 275 | gpio_set_value(170, 1); |
| 276 | break; |
Nishanth Menon | 1d65fb3 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 277 | case REVISION_XM_AB: |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 278 | case REVISION_XM_C: |
| 279 | default: |
| 280 | #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3) |
| 281 | #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6) |
| 282 | |
| 283 | i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 284 | val |= 4; |
| 285 | i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); |
| 286 | |
| 287 | i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 288 | val |= 4; |
| 289 | i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); |
| 290 | break; |
| 291 | } |
| 292 | } |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 293 | #endif |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 294 | |
| 295 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 296 | * Routine: misc_init_r |
| 297 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 298 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 299 | int misc_init_r(void) |
| 300 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 301 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 302 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Jason Kridner | 40aebca | 2011-04-20 13:52:26 +0000 | [diff] [blame] | 303 | struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE; |
Nishanth Menon | 739b98f | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 304 | bool generate_fake_mac = false; |
Alexander Kochetkov | 7822fe0 | 2014-09-29 21:46:48 +0400 | [diff] [blame] | 305 | u32 value; |
Steve Kipisz | bf7438a | 2011-04-18 17:27:00 -0400 | [diff] [blame] | 306 | |
| 307 | /* Enable i2c2 pullup resisters */ |
Alexander Kochetkov | 7822fe0 | 2014-09-29 21:46:48 +0400 | [diff] [blame] | 308 | value = readl(&prog_io_base->io1); |
| 309 | value &= ~(PRG_I2C2_PULLUPRESX); |
| 310 | writel(value, &prog_io_base->io1); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 311 | |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 312 | switch (get_board_revision()) { |
| 313 | case REVISION_AXBX: |
| 314 | printf("Beagle Rev Ax/Bx\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 315 | env_set("beaglerev", "AxBx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 316 | break; |
| 317 | case REVISION_CX: |
| 318 | printf("Beagle Rev C1/C2/C3\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 319 | env_set("beaglerev", "Cx"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 320 | MUX_BEAGLE_C(); |
| 321 | break; |
| 322 | case REVISION_C4: |
| 323 | printf("Beagle Rev C4\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 324 | env_set("beaglerev", "C4"); |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 325 | MUX_BEAGLE_C(); |
| 326 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 327 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 328 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 329 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 330 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 331 | break; |
Nishanth Menon | 1d65fb3 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 332 | case REVISION_XM_AB: |
| 333 | printf("Beagle xM Rev A/B\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 334 | env_set("beaglerev", "xMAB"); |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 335 | MUX_BEAGLE_XM(); |
| 336 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 337 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 338 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 339 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 340 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Nishanth Menon | 739b98f | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 341 | generate_fake_mac = true; |
Steve Sakoman | ac92995 | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 342 | break; |
Koen Kooi | 6330844 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 343 | case REVISION_XM_C: |
| 344 | printf("Beagle xM Rev C\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 345 | env_set("beaglerev", "xMC"); |
Koen Kooi | 6330844 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 346 | MUX_BEAGLE_XM(); |
| 347 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 348 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 349 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 350 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 351 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Nishanth Menon | 739b98f | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 352 | generate_fake_mac = true; |
Koen Kooi | 6330844 | 2011-06-17 09:37:37 +0200 | [diff] [blame] | 353 | break; |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 354 | default: |
| 355 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
Koen Kooi | 5b8018c | 2011-04-18 17:28:32 -0400 | [diff] [blame] | 356 | MUX_BEAGLE_XM(); |
| 357 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 358 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 359 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 360 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 361 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
Nishanth Menon | 739b98f | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 362 | generate_fake_mac = true; |
Steve Sakoman | 3ca3376 | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 365 | switch (get_expansion_id()) { |
| 366 | case TINCANTOOLS_ZIPPY: |
| 367 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 368 | expansion_config.revision, |
| 369 | expansion_config.fab_revision); |
| 370 | MUX_TINCANTOOLS_ZIPPY(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 371 | env_set("buddy", "zippy"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 372 | break; |
| 373 | case TINCANTOOLS_ZIPPY2: |
| 374 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 375 | expansion_config.revision, |
| 376 | expansion_config.fab_revision); |
| 377 | MUX_TINCANTOOLS_ZIPPY(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 378 | env_set("buddy", "zippy2"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 379 | break; |
| 380 | case TINCANTOOLS_TRAINER: |
| 381 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 382 | expansion_config.revision, |
| 383 | expansion_config.fab_revision); |
| 384 | MUX_TINCANTOOLS_ZIPPY(); |
| 385 | MUX_TINCANTOOLS_TRAINER(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 386 | env_set("buddy", "trainer"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 387 | break; |
| 388 | case TINCANTOOLS_SHOWDOG: |
| 389 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 390 | expansion_config.revision, |
| 391 | expansion_config.fab_revision); |
| 392 | /* Place holder for DSS2 definition for showdog lcd */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 393 | env_set("defaultdisplay", "showdoglcd"); |
| 394 | env_set("buddy", "showdog"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 395 | break; |
| 396 | case KBADC_BEAGLEFPGA: |
| 397 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 398 | MUX_KBADC_BEAGLEFPGA(); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 399 | env_set("buddy", "beaglefpga"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 400 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 401 | case LW_BEAGLETOUCH: |
| 402 | printf("Recognized Liquidware BeagleTouch board\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 403 | env_set("buddy", "beagletouch"); |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 404 | break; |
| 405 | case BRAINMUX_LCDOG: |
| 406 | printf("Recognized Brainmux LCDog board\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 407 | env_set("buddy", "lcdog"); |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 408 | break; |
| 409 | case BRAINMUX_LCDOGTOUCH: |
| 410 | printf("Recognized Brainmux LCDog Touch board\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 411 | env_set("buddy", "lcdogtouch"); |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 412 | break; |
| 413 | case BBTOYS_WIFI: |
| 414 | printf("Recognized BeagleBoardToys WiFi board\n"); |
| 415 | MUX_BBTOYS_WIFI() |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 416 | env_set("buddy", "bbtoys-wifi"); |
Masahiro Yamada | 622b7b3 | 2017-06-13 15:17:28 +0900 | [diff] [blame] | 417 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 418 | case BBTOYS_VGA: |
| 419 | printf("Recognized BeagleBoardToys VGA board\n"); |
Masahiro Yamada | 622b7b3 | 2017-06-13 15:17:28 +0900 | [diff] [blame] | 420 | break; |
Koen Kooi | 3d5dac6 | 2011-04-18 17:29:35 -0400 | [diff] [blame] | 421 | case BBTOYS_LCD: |
| 422 | printf("Recognized BeagleBoardToys LCD board\n"); |
Masahiro Yamada | 622b7b3 | 2017-06-13 15:17:28 +0900 | [diff] [blame] | 423 | break; |
Peter Meerwald | 1aca738 | 2012-01-03 04:14:35 +0000 | [diff] [blame] | 424 | case BCT_BRETTL3: |
Peter Meerwald | ad5691f | 2012-06-28 05:38:35 +0000 | [diff] [blame] | 425 | printf("Recognized bct electronic GmbH brettl3 board\n"); |
| 426 | break; |
| 427 | case BCT_BRETTL4: |
| 428 | printf("Recognized bct electronic GmbH brettl4 board\n"); |
| 429 | break; |
robertcnelson@gmail.com | 346d7eb | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 430 | case LSR_COM6L_ADPT: |
| 431 | printf("Recognized LSR COM6L Adapter Board\n"); |
| 432 | MUX_BBTOYS_WIFI() |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 433 | env_set("buddy", "lsr-com6l-adpt"); |
robertcnelson@gmail.com | 346d7eb | 2013-02-04 06:03:30 +0000 | [diff] [blame] | 434 | break; |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 435 | case BEAGLE_NO_EEPROM: |
| 436 | printf("No EEPROM on expansion board\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 437 | env_set("buddy", "none"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 438 | break; |
| 439 | default: |
| 440 | printf("Unrecognized expansion board: %x\n", |
| 441 | expansion_config.device_vendor); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 442 | env_set("buddy", "unknown"); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | if (expansion_config.content == 1) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 446 | env_set(expansion_config.env_var, expansion_config.env_setting); |
Koen Kooi | b6241c2 | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 447 | |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 448 | twl4030_power_init(); |
Christian Spielberger | 3be83dc | 2011-08-24 17:17:31 -0500 | [diff] [blame] | 449 | switch (get_board_revision()) { |
Nishanth Menon | 1d65fb3 | 2013-07-15 07:11:30 -0500 | [diff] [blame] | 450 | case REVISION_XM_AB: |
Christian Spielberger | 3be83dc | 2011-08-24 17:17:31 -0500 | [diff] [blame] | 451 | twl4030_led_init(TWL4030_LED_LEDEN_LEDBON); |
| 452 | break; |
| 453 | default: |
| 454 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
| 455 | break; |
| 456 | } |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 457 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 458 | /* Set GPIO states before they are made outputs */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 459 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 460 | &gpio6_base->setdataout); |
| 461 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 462 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 463 | |
Bob Feretich | 0ad8951 | 2011-02-24 13:16:44 +0000 | [diff] [blame] | 464 | /* Configure GPIOs to output */ |
| 465 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 466 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 467 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 468 | |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 469 | omap_die_id_display(); |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 470 | |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 471 | #ifdef CONFIG_VIDEO_OMAP3 |
Peter Meerwald | 03ed046 | 2012-02-08 05:24:26 +0000 | [diff] [blame] | 472 | beagle_dvi_pup(); |
Jason Kridner | b8f6ac5 | 2011-04-19 14:01:13 -0500 | [diff] [blame] | 473 | beagle_display_init(); |
| 474 | omap3_dss_enable(); |
Peter Meerwald | a2f5456 | 2012-07-10 06:07:34 +0000 | [diff] [blame] | 475 | #endif |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 476 | |
Paul Kocialkowski | 2edadee | 2015-08-27 19:37:12 +0200 | [diff] [blame] | 477 | if (generate_fake_mac) |
| 478 | omap_die_id_usbethaddr(); |
Nishanth Menon | 739b98f | 2014-03-28 11:00:06 -0500 | [diff] [blame] | 479 | |
Derald D. Woods | be01035 | 2018-02-26 17:52:57 -0600 | [diff] [blame] | 480 | #if defined(CONFIG_MTDIDS_DEFAULT) && defined(CONFIG_MTDPARTS_DEFAULT) |
| 481 | if (strlen(CONFIG_MTDIDS_DEFAULT)) |
| 482 | env_set("mtdids", CONFIG_MTDIDS_DEFAULT); |
| 483 | |
| 484 | if (strlen(CONFIG_MTDPARTS_DEFAULT)) |
| 485 | env_set("mtdparts", CONFIG_MTDPARTS_DEFAULT); |
| 486 | #endif |
| 487 | |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 488 | return 0; |
| 489 | } |
| 490 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 491 | /* |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 492 | * Routine: set_muxconf_regs |
| 493 | * Description: Setting up the configuration Mux registers specific to the |
| 494 | * hardware. Many pins need to be moved from protect to primary |
| 495 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 496 | */ |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 497 | void set_muxconf_regs(void) |
| 498 | { |
| 499 | MUX_BEAGLE(); |
Dirk Behme | 2781f80 | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 500 | } |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 501 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 502 | #if defined(CONFIG_MMC) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 503 | int board_mmc_init(struct bd_info *bis) |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 504 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 505 | return omap_mmc_init(0, 0, 0, -1, -1); |
Steve Sakoman | 57c6241 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 506 | } |
| 507 | #endif |
Alexander Holler | 8f6f15c | 2011-04-19 09:30:35 -0400 | [diff] [blame] | 508 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 509 | #if defined(CONFIG_MMC) |
Paul Kocialkowski | 6955989 | 2014-11-08 20:55:47 +0100 | [diff] [blame] | 510 | void board_mmc_power_init(void) |
| 511 | { |
| 512 | twl4030_power_mmc_init(0); |
| 513 | } |
| 514 | #endif |