Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004-2008 |
| 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> |
Tom Rix | 2c15513 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 33 | #include <twl4030.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 34 | #include <asm/io.h> |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 35 | #include <asm/arch/mmc_host_def.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 36 | #include <asm/arch/mux.h> |
| 37 | #include <asm/arch/sys_proto.h> |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 38 | #include <asm/arch/gpio.h> |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 39 | #include <asm/mach-types.h> |
| 40 | #include "beagle.h" |
| 41 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 42 | #define TWL4030_I2C_BUS 0 |
| 43 | #define EXPANSION_EEPROM_I2C_BUS 1 |
| 44 | #define EXPANSION_EEPROM_I2C_ADDRESS 0x50 |
| 45 | |
| 46 | #define TINCANTOOLS_ZIPPY 0x01000100 |
| 47 | #define TINCANTOOLS_ZIPPY2 0x02000100 |
| 48 | #define TINCANTOOLS_TRAINER 0x04000100 |
| 49 | #define TINCANTOOLS_SHOWDOG 0x03000100 |
| 50 | #define KBADC_BEAGLEFPGA 0x01000600 |
| 51 | |
| 52 | #define BEAGLE_NO_EEPROM 0xffffffff |
| 53 | |
John Rigby | 2956532 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 54 | DECLARE_GLOBAL_DATA_PTR; |
| 55 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 56 | static struct { |
| 57 | unsigned int device_vendor; |
| 58 | unsigned char revision; |
| 59 | unsigned char content; |
| 60 | char fab_revision[8]; |
| 61 | char env_var[16]; |
| 62 | char env_setting[64]; |
| 63 | } expansion_config; |
| 64 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 65 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 66 | * Routine: board_init |
| 67 | * Description: Early hardware init. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 68 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 69 | int board_init(void) |
| 70 | { |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 71 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 72 | /* board id for Linux */ |
| 73 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 74 | /* boot param addr */ |
| 75 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 80 | /* |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 81 | * Routine: get_board_revision |
| 82 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 83 | * C1/2/3, C4 or xM. This can be done by reading |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 84 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 85 | * result in |
| 86 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 87 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 88 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 89 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 90 | */ |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 91 | int get_board_revision(void) |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 92 | { |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 93 | int revision; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 94 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 95 | if (!omap_request_gpio(171) && |
| 96 | !omap_request_gpio(172) && |
| 97 | !omap_request_gpio(173)) { |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 98 | |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 99 | omap_set_gpio_direction(171, 1); |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 100 | omap_set_gpio_direction(172, 1); |
| 101 | omap_set_gpio_direction(173, 1); |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 102 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 103 | revision = omap_get_gpio_datain(173) << 2 | |
| 104 | omap_get_gpio_datain(172) << 1 | |
| 105 | omap_get_gpio_datain(171); |
| 106 | |
| 107 | omap_free_gpio(171); |
| 108 | omap_free_gpio(172); |
| 109 | omap_free_gpio(173); |
| 110 | } else { |
| 111 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 112 | revision = -1; |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 113 | } |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 114 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 115 | return revision; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 116 | } |
| 117 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 118 | /* |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 119 | * Routine: get_expansion_id |
| 120 | * Description: This function checks for expansion board by checking I2C |
| 121 | * bus 1 for the availability of an AT24C01B serial EEPROM. |
| 122 | * returns the device_vendor field from the EEPROM |
| 123 | */ |
| 124 | unsigned int get_expansion_id(void) |
| 125 | { |
| 126 | i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); |
| 127 | |
| 128 | /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */ |
| 129 | if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) { |
| 130 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 131 | return BEAGLE_NO_EEPROM; |
| 132 | } |
| 133 | |
| 134 | /* read configuration data */ |
| 135 | i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config, |
| 136 | sizeof(expansion_config)); |
| 137 | |
| 138 | i2c_set_bus_num(TWL4030_I2C_BUS); |
| 139 | |
| 140 | return expansion_config.device_vendor; |
| 141 | } |
| 142 | |
| 143 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 144 | * Routine: misc_init_r |
| 145 | * Description: Configure board specific parts |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 146 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 147 | int misc_init_r(void) |
| 148 | { |
Dirk Behme | 97a099e | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 149 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 150 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 151 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 152 | switch (get_board_revision()) { |
| 153 | case REVISION_AXBX: |
| 154 | printf("Beagle Rev Ax/Bx\n"); |
| 155 | setenv("beaglerev", "AxBx"); |
| 156 | setenv("mpurate", "600"); |
| 157 | break; |
| 158 | case REVISION_CX: |
| 159 | printf("Beagle Rev C1/C2/C3\n"); |
| 160 | setenv("beaglerev", "Cx"); |
| 161 | setenv("mpurate", "600"); |
| 162 | MUX_BEAGLE_C(); |
| 163 | break; |
| 164 | case REVISION_C4: |
| 165 | printf("Beagle Rev C4\n"); |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 166 | setenv("beaglerev", "C4"); |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 167 | setenv("mpurate", "720"); |
| 168 | MUX_BEAGLE_C(); |
| 169 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 170 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 171 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 172 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 173 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 174 | break; |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 175 | case REVISION_XM: |
| 176 | printf("Beagle xM Rev A\n"); |
| 177 | setenv("beaglerev", "xMA"); |
| 178 | setenv("mpurate", "1000"); |
| 179 | MUX_BEAGLE_XM(); |
| 180 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 181 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 182 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 183 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 184 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 185 | break; |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 186 | default: |
| 187 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
| 188 | } |
| 189 | |
Koen Kooi | ca5f80a | 2010-09-20 10:21:33 -0700 | [diff] [blame] | 190 | switch (get_expansion_id()) { |
| 191 | case TINCANTOOLS_ZIPPY: |
| 192 | printf("Recognized Tincantools Zippy board (rev %d %s)\n", |
| 193 | expansion_config.revision, |
| 194 | expansion_config.fab_revision); |
| 195 | MUX_TINCANTOOLS_ZIPPY(); |
| 196 | setenv("buddy", "zippy"); |
| 197 | break; |
| 198 | case TINCANTOOLS_ZIPPY2: |
| 199 | printf("Recognized Tincantools Zippy2 board (rev %d %s)\n", |
| 200 | expansion_config.revision, |
| 201 | expansion_config.fab_revision); |
| 202 | MUX_TINCANTOOLS_ZIPPY(); |
| 203 | setenv("buddy", "zippy2"); |
| 204 | break; |
| 205 | case TINCANTOOLS_TRAINER: |
| 206 | printf("Recognized Tincantools Trainer board (rev %d %s)\n", |
| 207 | expansion_config.revision, |
| 208 | expansion_config.fab_revision); |
| 209 | MUX_TINCANTOOLS_ZIPPY(); |
| 210 | MUX_TINCANTOOLS_TRAINER(); |
| 211 | setenv("buddy", "trainer"); |
| 212 | break; |
| 213 | case TINCANTOOLS_SHOWDOG: |
| 214 | printf("Recognized Tincantools Showdow board (rev %d %s)\n", |
| 215 | expansion_config.revision, |
| 216 | expansion_config.fab_revision); |
| 217 | /* Place holder for DSS2 definition for showdog lcd */ |
| 218 | setenv("defaultdisplay", "showdoglcd"); |
| 219 | setenv("buddy", "showdog"); |
| 220 | break; |
| 221 | case KBADC_BEAGLEFPGA: |
| 222 | printf("Recognized KBADC Beagle FPGA board\n"); |
| 223 | MUX_KBADC_BEAGLEFPGA(); |
| 224 | setenv("buddy", "beaglefpga"); |
| 225 | break; |
| 226 | case BEAGLE_NO_EEPROM: |
| 227 | printf("No EEPROM on expansion board\n"); |
| 228 | setenv("buddy", "none"); |
| 229 | break; |
| 230 | default: |
| 231 | printf("Unrecognized expansion board: %x\n", |
| 232 | expansion_config.device_vendor); |
| 233 | setenv("buddy", "unknown"); |
| 234 | } |
| 235 | |
| 236 | if (expansion_config.content == 1) |
| 237 | setenv(expansion_config.env_var, expansion_config.env_setting); |
| 238 | |
Tom Rix | 2c15513 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 239 | twl4030_power_init(); |
Grazvydas Ignotas | ead39d7 | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 240 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 241 | |
| 242 | /* Configure GPIOs to output */ |
| 243 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 244 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 245 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 246 | |
| 247 | /* Set GPIOs */ |
| 248 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 249 | &gpio6_base->setdataout); |
| 250 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 251 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 252 | |
Dirk Behme | e6a6a70 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 253 | dieid_num_r(); |
| 254 | |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 255 | return 0; |
| 256 | } |
| 257 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 258 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 259 | * Routine: set_muxconf_regs |
| 260 | * Description: Setting up the configuration Mux registers specific to the |
| 261 | * hardware. Many pins need to be moved from protect to primary |
| 262 | * mode. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 263 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 264 | void set_muxconf_regs(void) |
| 265 | { |
| 266 | MUX_BEAGLE(); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 267 | } |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 268 | |
| 269 | #ifdef CONFIG_GENERIC_MMC |
| 270 | int board_mmc_init(bd_t *bis) |
| 271 | { |
| 272 | omap_mmc_init(0); |
| 273 | return 0; |
| 274 | } |
| 275 | #endif |