blob: c5d6679f482493a48417cc53f54416a3168b30b7 [file] [log] [blame]
Dirk Behmef904cdb2009-01-27 18:19:12 +01001/*
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 Rix2c155132009-06-28 12:52:30 -050033#include <twl4030.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010034#include <asm/io.h>
Steve Sakoman0cd31142010-09-19 21:19:48 -070035#include <asm/arch/mmc_host_def.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010036#include <asm/arch/mux.h>
37#include <asm/arch/sys_proto.h>
Tom Rix718763c2009-06-03 01:53:57 -050038#include <asm/arch/gpio.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010039#include <asm/mach-types.h>
40#include "beagle.h"
41
Tom Rix58911512009-04-01 22:02:20 -050042/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010043 * Routine: board_init
44 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050045 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010046int 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 Rix58911512009-04-01 22:02:20 -050059/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -070060 * Routine: get_board_revision
61 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -070062 * C1/2/3, C4 or xM. This can be done by reading
Steve Sakoman06b95bd2010-08-12 15:17:37 -070063 * 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 Sakoman08cbba2ab2010-08-19 20:56:11 -070068 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
Tom Rix58911512009-04-01 22:02:20 -050069 */
Steve Sakoman06b95bd2010-08-12 15:17:37 -070070int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +010071{
Steve Sakoman06b95bd2010-08-12 15:17:37 -070072 int revision;
Dirk Behmef956fd02009-02-12 18:55:41 +010073
Steve Sakoman06b95bd2010-08-12 15:17:37 -070074 if (!omap_request_gpio(171) &&
75 !omap_request_gpio(172) &&
76 !omap_request_gpio(173)) {
Dirk Behmef956fd02009-02-12 18:55:41 +010077
Tom Rix718763c2009-06-03 01:53:57 -050078 omap_set_gpio_direction(171, 1);
Steve Sakoman06b95bd2010-08-12 15:17:37 -070079 omap_set_gpio_direction(172, 1);
80 omap_set_gpio_direction(173, 1);
Dirk Behmef956fd02009-02-12 18:55:41 +010081
Steve Sakoman06b95bd2010-08-12 15:17:37 -070082 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 Rix718763c2009-06-03 01:53:57 -050092 }
Dirk Behmef956fd02009-02-12 18:55:41 +010093
Steve Sakoman06b95bd2010-08-12 15:17:37 -070094 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +010095}
96
Tom Rix58911512009-04-01 22:02:20 -050097/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010098 * Routine: misc_init_r
99 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500100 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100101int misc_init_r(void)
102{
Dirk Behme97a099e2009-08-08 09:30:21 +0200103 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
104 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Dirk Behmef904cdb2009-01-27 18:19:12 +0100105
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700106 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 Sakoman08cbba2ab2010-08-19 20:56:11 -0700120 setenv("beaglerev", "C4");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700121 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 Sakoman08cbba2ab2010-08-19 20:56:11 -0700129 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 Sakoman06b95bd2010-08-12 15:17:37 -0700140 default:
141 printf("Beagle unknown 0x%02x\n", get_board_revision());
142 }
143
Tom Rix2c155132009-06-28 12:52:30 -0500144 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200145 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100146
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 Behmee6a6a702009-03-12 19:30:50 +0100158 dieid_num_r();
159
Dirk Behmef904cdb2009-01-27 18:19:12 +0100160 return 0;
161}
162
Tom Rix58911512009-04-01 22:02:20 -0500163/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100164 * 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 Rix58911512009-04-01 22:02:20 -0500168 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100169void set_muxconf_regs(void)
170{
171 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100172}
Steve Sakoman0cd31142010-09-19 21:19:48 -0700173
174#ifdef CONFIG_GENERIC_MMC
175int board_mmc_init(bd_t *bis)
176{
177 omap_mmc_init(0);
178 return 0;
179}
180#endif