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