blob: 22d26e550e01d5c7693bc601e4093b41464cbb2a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tapani Utriainen550e3752013-12-04 09:27:33 +01002/*
3 * Maintainer :
4 * Tapani Utriainen <linuxfae@technexion.com>
Tapani Utriainen550e3752013-12-04 09:27:33 +01005 */
6#include <common.h>
7#include <netdev.h>
8#include <twl4030.h>
9#include <asm/io.h>
10#include <asm/arch/mmc_host_def.h>
11#include <asm/arch/mem.h>
12#include <asm/arch/mux.h>
13#include <asm/arch/sys_proto.h>
14#include <asm/arch/gpio.h>
15#include <asm/gpio.h>
16#include <asm/mach-types.h>
17
18#include <usb.h>
19#include <asm/ehci-omap.h>
20
21#include "tao3530.h"
22
23DECLARE_GLOBAL_DATA_PTR;
24
25int tao3530_revision(void)
26{
27 int ret = 0;
28
29 /* char *label argument is unused in gpio_request() */
30 ret = gpio_request(65, "");
31 if (ret) {
32 puts("Error: GPIO 65 not available\n");
33 goto out;
34 }
35 MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4));
36
37 ret = gpio_request(1, "");
38 if (ret) {
39 puts("Error: GPIO 1 not available\n");
40 goto out2;
41 }
42 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M4));
43
44 ret = gpio_direction_input(65);
45 if (ret) {
46 puts("Error: GPIO 65 not available for input\n");
47 goto out3;
48 }
49
50 ret = gpio_direction_input(1);
51 if (ret) {
52 puts("Error: GPIO 1 not available for input\n");
53 goto out3;
54 }
55
56 ret = gpio_get_value(65) << 1 | gpio_get_value(1);
57
58out3:
59 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M0));
60 gpio_free(1);
61out2:
62 MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0));
63 gpio_free(65);
64out:
65
66 return ret;
67}
68
Stefan Roesea9f52492013-12-04 09:27:34 +010069#ifdef CONFIG_SPL_BUILD
70/*
71 * Routine: get_board_mem_timings
72 * Description: If we use SPL then there is no x-loader nor config header
73 * so we have to setup the DDR timings ourself on both banks.
74 */
75void get_board_mem_timings(struct board_sdrc_timings *timings)
76{
Stefan Roese8f0cbd62013-12-04 09:27:37 +010077#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
78 /*
79 * Switch baseboard LED to red upon power-on
80 */
81 MUX_OMAP3_HA();
82
83 /* Request a gpio before using it */
84 gpio_request(111, "");
85 /* Sets the gpio as output and its value to 1, switch LED to red */
86 gpio_direction_output(111, 1);
87#endif
88
Stefan Roesea9f52492013-12-04 09:27:34 +010089 if (tao3530_revision() < 3) {
90 /* 256MB / Bank */
91 timings->mcfg = MCFG(256 << 20, 14); /* RAS-width 14 */
92 timings->ctrla = HYNIX_V_ACTIMA_165;
93 timings->ctrlb = HYNIX_V_ACTIMB_165;
94 } else {
95 /* 128MB / Bank */
96 timings->mcfg = MCFG(128 << 20, 13); /* RAS-width 13 */
97 timings->ctrla = MICRON_V_ACTIMA_165;
98 timings->ctrlb = MICRON_V_ACTIMB_165;
99 }
100
101 timings->mr = MICRON_V_MR_165;
102 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
103}
104#endif
105
Tapani Utriainen550e3752013-12-04 09:27:33 +0100106/*
107 * Routine: board_init
108 * Description: Early hardware init.
109 */
110int board_init(void)
111{
112 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
113 /* board id for Linux */
114 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530;
115 /* boot param addr */
116 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
117
118 return 0;
119}
120
121/*
122 * Routine: misc_init_r
123 * Description: Configure board specific parts
124 */
125int misc_init_r(void)
126{
127 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
128 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
129
130 twl4030_power_init();
131 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
132
133 /* Configure GPIOs to output */
134 /* GPIO23 */
135 writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
136 writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 |
137 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
138
139 /* Set GPIOs */
140 writel(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
Stefan Roesefcd9adc2013-12-04 09:27:36 +0100145 switch (tao3530_revision()) {
146 case 0:
147 puts("TAO-3530 REV Reserve 1\n");
148 break;
149 case 1:
150 puts("TAO-3530 REV Reserve 2\n");
151 break;
152 case 2:
153 puts("TAO-3530 REV Cx\n");
154 break;
155 case 3:
156 puts("TAO-3530 REV Ax/Bx\n");
157 break;
158 default:
159 puts("Unknown board revision\n");
160 }
161
Paul Kocialkowski679f82c2015-08-27 19:37:13 +0200162 omap_die_id_display();
Tapani Utriainen550e3752013-12-04 09:27:33 +0100163
Tapani Utriainen550e3752013-12-04 09:27:33 +0100164 return 0;
165}
166
167/*
168 * Routine: set_muxconf_regs
169 * Description: Setting up the configuration Mux registers specific to the
170 * hardware. Many pins need to be moved from protect to primary
171 * mode.
172 */
173void set_muxconf_regs(void)
174{
175 MUX_TAO3530();
Stefan Roese8f0cbd62013-12-04 09:27:37 +0100176#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
177 MUX_OMAP3_HA();
178#endif
Tapani Utriainen550e3752013-12-04 09:27:33 +0100179}
180
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900181#if defined(CONFIG_MMC)
Tapani Utriainen550e3752013-12-04 09:27:33 +0100182int board_mmc_init(bd_t *bis)
183{
184 omap_mmc_init(0, 0, 0, -1, -1);
185
186 return 0;
187}
188#endif
189
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900190#if defined(CONFIG_MMC)
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100191void board_mmc_power_init(void)
192{
193 twl4030_power_mmc_init(0);
194}
195#endif
196
Tom Rini8850c5d2017-05-12 22:33:27 -0400197#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
Tapani Utriainen550e3752013-12-04 09:27:33 +0100198/* Call usb_stop() before starting the kernel */
199void show_boot_progress(int val)
200{
201 if (val == BOOTSTAGE_ID_RUN_OS)
202 usb_stop();
203}
204
205static struct omap_usbhs_board_data usbhs_bdata = {
206 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
207 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
208 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
209};
210
211int ehci_hcd_init(int index, enum usb_init_type init,
212 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
213{
214 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
215}
216
217int ehci_hcd_stop(int index)
218{
219 return omap_ehci_hcd_stop();
220}
Tom Rini8850c5d2017-05-12 22:33:27 -0400221#endif /* CONFIG_USB_EHCI_HCD */