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 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 42 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 43 | * Routine: board_init |
| 44 | * Description: Early hardware init. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 45 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 46 | int board_init(void) |
| 47 | { |
| 48 | DECLARE_GLOBAL_DATA_PTR; |
| 49 | |
| 50 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 51 | /* board id for Linux */ |
| 52 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; |
| 53 | /* boot param addr */ |
| 54 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 59 | /* |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 60 | * Routine: get_board_revision |
| 61 | * Description: Detect if we are running on a Beagle revision Ax/Bx, |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 62 | * C1/2/3, C4 or xM. This can be done by reading |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 63 | * the level of GPIO173, GPIO172 and GPIO171. This should |
| 64 | * result in |
| 65 | * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx |
| 66 | * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3 |
| 67 | * GPIO173, GPIO172, GPIO171: 1 0 1 => C4 |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 68 | * GPIO173, GPIO172, GPIO171: 0 0 0 => xM |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 69 | */ |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 70 | int get_board_revision(void) |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 71 | { |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 72 | int revision; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 73 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 74 | if (!omap_request_gpio(171) && |
| 75 | !omap_request_gpio(172) && |
| 76 | !omap_request_gpio(173)) { |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 77 | |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 78 | omap_set_gpio_direction(171, 1); |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 79 | omap_set_gpio_direction(172, 1); |
| 80 | omap_set_gpio_direction(173, 1); |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 81 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 82 | revision = omap_get_gpio_datain(173) << 2 | |
| 83 | omap_get_gpio_datain(172) << 1 | |
| 84 | omap_get_gpio_datain(171); |
| 85 | |
| 86 | omap_free_gpio(171); |
| 87 | omap_free_gpio(172); |
| 88 | omap_free_gpio(173); |
| 89 | } else { |
| 90 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 91 | revision = -1; |
Tom Rix | 718763c | 2009-06-03 01:53:57 -0500 | [diff] [blame] | 92 | } |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 93 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 94 | return revision; |
Dirk Behme | f956fd0 | 2009-02-12 18:55:41 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 97 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 98 | * Routine: misc_init_r |
| 99 | * Description: Configure board specific parts |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 100 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 101 | int misc_init_r(void) |
| 102 | { |
Dirk Behme | 97a099e | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 103 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 104 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 105 | |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 106 | switch (get_board_revision()) { |
| 107 | case REVISION_AXBX: |
| 108 | printf("Beagle Rev Ax/Bx\n"); |
| 109 | setenv("beaglerev", "AxBx"); |
| 110 | setenv("mpurate", "600"); |
| 111 | break; |
| 112 | case REVISION_CX: |
| 113 | printf("Beagle Rev C1/C2/C3\n"); |
| 114 | setenv("beaglerev", "Cx"); |
| 115 | setenv("mpurate", "600"); |
| 116 | MUX_BEAGLE_C(); |
| 117 | break; |
| 118 | case REVISION_C4: |
| 119 | printf("Beagle Rev C4\n"); |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 120 | setenv("beaglerev", "C4"); |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 121 | setenv("mpurate", "720"); |
| 122 | MUX_BEAGLE_C(); |
| 123 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 124 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 125 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 126 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 127 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 128 | break; |
Steve Sakoman | 08cbba2ab | 2010-08-19 20:56:11 -0700 | [diff] [blame] | 129 | case REVISION_XM: |
| 130 | printf("Beagle xM Rev A\n"); |
| 131 | setenv("beaglerev", "xMA"); |
| 132 | setenv("mpurate", "1000"); |
| 133 | MUX_BEAGLE_XM(); |
| 134 | /* Set VAUX2 to 1.8V for EHCI PHY */ |
| 135 | twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, |
| 136 | TWL4030_PM_RECEIVER_VAUX2_VSEL_18, |
| 137 | TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, |
| 138 | TWL4030_PM_RECEIVER_DEV_GRP_P1); |
| 139 | break; |
Steve Sakoman | 06b95bd | 2010-08-12 15:17:37 -0700 | [diff] [blame] | 140 | default: |
| 141 | printf("Beagle unknown 0x%02x\n", get_board_revision()); |
| 142 | } |
| 143 | |
Tom Rix | 2c15513 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 144 | twl4030_power_init(); |
Grazvydas Ignotas | ead39d7 | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 145 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 146 | |
| 147 | /* Configure GPIOs to output */ |
| 148 | writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 149 | writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 150 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 151 | |
| 152 | /* Set GPIOs */ |
| 153 | writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 154 | &gpio6_base->setdataout); |
| 155 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 156 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 157 | |
Dirk Behme | e6a6a70 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 158 | dieid_num_r(); |
| 159 | |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 163 | /* |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 164 | * Routine: set_muxconf_regs |
| 165 | * Description: Setting up the configuration Mux registers specific to the |
| 166 | * hardware. Many pins need to be moved from protect to primary |
| 167 | * mode. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 168 | */ |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 169 | void set_muxconf_regs(void) |
| 170 | { |
| 171 | MUX_BEAGLE(); |
Dirk Behme | f904cdb | 2009-01-27 18:19:12 +0100 | [diff] [blame] | 172 | } |
Steve Sakoman | 0cd3114 | 2010-09-19 21:19:48 -0700 | [diff] [blame] | 173 | |
| 174 | #ifdef CONFIG_GENERIC_MMC |
| 175 | int board_mmc_init(bd_t *bis) |
| 176 | { |
| 177 | omap_mmc_init(0); |
| 178 | return 0; |
| 179 | } |
| 180 | #endif |