blob: d9b6f01163b609cfdbc4f6340574b04718a6566c [file] [log] [blame]
Dirk Behme2781f802009-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 Rix0f2a8042009-06-28 12:52:30 -050033#include <twl4030.h>
Dirk Behme2781f802009-01-27 18:19:12 +010034#include <asm/io.h>
Steve Sakoman57c62412010-09-19 21:19:48 -070035#include <asm/arch/mmc_host_def.h>
Dirk Behme2781f802009-01-27 18:19:12 +010036#include <asm/arch/mux.h>
37#include <asm/arch/sys_proto.h>
Tom Rix70d05412009-06-03 01:53:57 -050038#include <asm/arch/gpio.h>
Dirk Behme2781f802009-01-27 18:19:12 +010039#include <asm/mach-types.h>
40#include "beagle.h"
41
Koen Kooib6241c22010-09-20 10:21:33 -070042#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
54static struct {
55 unsigned int device_vendor;
56 unsigned char revision;
57 unsigned char content;
58 char fab_revision[8];
59 char env_var[16];
60 char env_setting[64];
61} expansion_config;
62
Tom Rix558bb832009-04-01 22:02:20 -050063/*
Dirk Behme2781f802009-01-27 18:19:12 +010064 * Routine: board_init
65 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050066 */
Dirk Behme2781f802009-01-27 18:19:12 +010067int board_init(void)
68{
69 DECLARE_GLOBAL_DATA_PTR;
70
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 Rix558bb832009-04-01 22:02:20 -050080/*
Steve Sakoman3ca33762010-08-12 15:17:37 -070081 * Routine: get_board_revision
82 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Steve Sakomanac929952010-08-19 20:56:11 -070083 * C1/2/3, C4 or xM. This can be done by reading
Steve Sakoman3ca33762010-08-12 15:17:37 -070084 * 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 Sakomanac929952010-08-19 20:56:11 -070089 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
Tom Rix558bb832009-04-01 22:02:20 -050090 */
Steve Sakoman3ca33762010-08-12 15:17:37 -070091int get_board_revision(void)
Dirk Behme78716112009-02-12 18:55:41 +010092{
Steve Sakoman3ca33762010-08-12 15:17:37 -070093 int revision;
Dirk Behme78716112009-02-12 18:55:41 +010094
Steve Sakoman3ca33762010-08-12 15:17:37 -070095 if (!omap_request_gpio(171) &&
96 !omap_request_gpio(172) &&
97 !omap_request_gpio(173)) {
Dirk Behme78716112009-02-12 18:55:41 +010098
Tom Rix70d05412009-06-03 01:53:57 -050099 omap_set_gpio_direction(171, 1);
Steve Sakoman3ca33762010-08-12 15:17:37 -0700100 omap_set_gpio_direction(172, 1);
101 omap_set_gpio_direction(173, 1);
Dirk Behme78716112009-02-12 18:55:41 +0100102
Steve Sakoman3ca33762010-08-12 15:17:37 -0700103 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 Rix70d05412009-06-03 01:53:57 -0500113 }
Dirk Behme78716112009-02-12 18:55:41 +0100114
Steve Sakoman3ca33762010-08-12 15:17:37 -0700115 return revision;
Dirk Behme78716112009-02-12 18:55:41 +0100116}
117
Tom Rix558bb832009-04-01 22:02:20 -0500118/*
Koen Kooib6241c22010-09-20 10:21:33 -0700119 * 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 */
124unsigned 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 Behme2781f802009-01-27 18:19:12 +0100144 * Routine: misc_init_r
145 * Description: Configure board specific parts
Tom Rix558bb832009-04-01 22:02:20 -0500146 */
Dirk Behme2781f802009-01-27 18:19:12 +0100147int misc_init_r(void)
148{
Dirk Behmedc7af202009-08-08 09:30:21 +0200149 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
150 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Dirk Behme2781f802009-01-27 18:19:12 +0100151
Steve Sakoman3ca33762010-08-12 15:17:37 -0700152 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 Sakomanac929952010-08-19 20:56:11 -0700166 setenv("beaglerev", "C4");
Steve Sakoman3ca33762010-08-12 15:17:37 -0700167 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 Sakomanac929952010-08-19 20:56:11 -0700175 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 Sakoman3ca33762010-08-12 15:17:37 -0700186 default:
187 printf("Beagle unknown 0x%02x\n", get_board_revision());
188 }
189
Koen Kooib6241c22010-09-20 10:21:33 -0700190 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 Rix0f2a8042009-06-28 12:52:30 -0500239 twl4030_power_init();
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +0200240 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme2781f802009-01-27 18:19:12 +0100241
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 Behme12dbcf62009-03-12 19:30:50 +0100253 dieid_num_r();
254
Dirk Behme2781f802009-01-27 18:19:12 +0100255 return 0;
256}
257
Tom Rix558bb832009-04-01 22:02:20 -0500258/*
Dirk Behme2781f802009-01-27 18:19:12 +0100259 * 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 Rix558bb832009-04-01 22:02:20 -0500263 */
Dirk Behme2781f802009-01-27 18:19:12 +0100264void set_muxconf_regs(void)
265{
266 MUX_BEAGLE();
Dirk Behme2781f802009-01-27 18:19:12 +0100267}
Steve Sakoman57c62412010-09-19 21:19:48 -0700268
269#ifdef CONFIG_GENERIC_MMC
270int board_mmc_init(bd_t *bis)
271{
272 omap_mmc_init(0);
273 return 0;
274}
275#endif