blob: ec95ad09b850b14f0ea1446ae463bf1b714d9cb9 [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>
35#include <asm/arch/mux.h>
36#include <asm/arch/sys_proto.h>
Tom Rix718763c2009-06-03 01:53:57 -050037#include <asm/arch/gpio.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010038#include <asm/mach-types.h>
39#include "beagle.h"
40
Tom Rix58911512009-04-01 22:02:20 -050041/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010042 * Routine: board_init
43 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050044 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010045int 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 Rix58911512009-04-01 22:02:20 -050058/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -070059 * Routine: get_board_revision
60 * Description: Detect if we are running on a Beagle revision Ax/Bx,
61 * C1/2/3, or C4. This can be done by reading
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
Tom Rix58911512009-04-01 22:02:20 -050067 */
Steve Sakoman06b95bd2010-08-12 15:17:37 -070068int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +010069{
Steve Sakoman06b95bd2010-08-12 15:17:37 -070070 int revision;
Dirk Behmef956fd02009-02-12 18:55:41 +010071
Steve Sakoman06b95bd2010-08-12 15:17:37 -070072 if (!omap_request_gpio(171) &&
73 !omap_request_gpio(172) &&
74 !omap_request_gpio(173)) {
Dirk Behmef956fd02009-02-12 18:55:41 +010075
Tom Rix718763c2009-06-03 01:53:57 -050076 omap_set_gpio_direction(171, 1);
Steve Sakoman06b95bd2010-08-12 15:17:37 -070077 omap_set_gpio_direction(172, 1);
78 omap_set_gpio_direction(173, 1);
Dirk Behmef956fd02009-02-12 18:55:41 +010079
Steve Sakoman06b95bd2010-08-12 15:17:37 -070080 revision = omap_get_gpio_datain(173) << 2 |
81 omap_get_gpio_datain(172) << 1 |
82 omap_get_gpio_datain(171);
83
84 omap_free_gpio(171);
85 omap_free_gpio(172);
86 omap_free_gpio(173);
87 } else {
88 printf("Error: unable to acquire board revision GPIOs\n");
89 revision = -1;
Tom Rix718763c2009-06-03 01:53:57 -050090 }
Dirk Behmef956fd02009-02-12 18:55:41 +010091
Steve Sakoman06b95bd2010-08-12 15:17:37 -070092 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +010093}
94
Tom Rix58911512009-04-01 22:02:20 -050095/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010096 * Routine: misc_init_r
97 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -050098 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010099int misc_init_r(void)
100{
Dirk Behme97a099e2009-08-08 09:30:21 +0200101 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
102 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Dirk Behmef904cdb2009-01-27 18:19:12 +0100103
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700104 switch (get_board_revision()) {
105 case REVISION_AXBX:
106 printf("Beagle Rev Ax/Bx\n");
107 setenv("beaglerev", "AxBx");
108 setenv("mpurate", "600");
109 break;
110 case REVISION_CX:
111 printf("Beagle Rev C1/C2/C3\n");
112 setenv("beaglerev", "Cx");
113 setenv("mpurate", "600");
114 MUX_BEAGLE_C();
115 break;
116 case REVISION_C4:
117 printf("Beagle Rev C4\n");
118 setenv("beaglerev", "Cx");
119 setenv("mpurate", "720");
120 MUX_BEAGLE_C();
121 /* Set VAUX2 to 1.8V for EHCI PHY */
122 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
123 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
124 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
125 TWL4030_PM_RECEIVER_DEV_GRP_P1);
126 break;
127 default:
128 printf("Beagle unknown 0x%02x\n", get_board_revision());
129 }
130
Tom Rix2c155132009-06-28 12:52:30 -0500131 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200132 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100133
134 /* Configure GPIOs to output */
135 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
136 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
137 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
138
139 /* Set GPIOs */
140 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
141 &gpio6_base->setdataout);
142 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
143 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
144
Dirk Behmee6a6a702009-03-12 19:30:50 +0100145 dieid_num_r();
146
Dirk Behmef904cdb2009-01-27 18:19:12 +0100147 return 0;
148}
149
Tom Rix58911512009-04-01 22:02:20 -0500150/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100151 * Routine: set_muxconf_regs
152 * Description: Setting up the configuration Mux registers specific to the
153 * hardware. Many pins need to be moved from protect to primary
154 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500155 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100156void set_muxconf_regs(void)
157{
158 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100159}