blob: 0c9dca31e67ea8809d4405004b829542e86b4e58 [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>
Simon Glass52f24232020-05-10 11:40:00 -06007#include <bootstage.h>
Simon Glass691d7192020-05-10 11:40:02 -06008#include <init.h>
Simon Glass336d4612020-02-03 07:36:16 -07009#include <malloc.h>
Tapani Utriainen550e3752013-12-04 09:27:33 +010010#include <netdev.h>
11#include <twl4030.h>
Simon Glass401d1c42020-10-30 21:38:53 -060012#include <asm/global_data.h>
Tapani Utriainen550e3752013-12-04 09:27:33 +010013#include <asm/io.h>
14#include <asm/arch/mmc_host_def.h>
15#include <asm/arch/mem.h>
16#include <asm/arch/mux.h>
17#include <asm/arch/sys_proto.h>
18#include <asm/arch/gpio.h>
19#include <asm/gpio.h>
20#include <asm/mach-types.h>
21
22#include <usb.h>
23#include <asm/ehci-omap.h>
24
25#include "tao3530.h"
26
27DECLARE_GLOBAL_DATA_PTR;
28
29int tao3530_revision(void)
30{
31 int ret = 0;
32
33 /* char *label argument is unused in gpio_request() */
34 ret = gpio_request(65, "");
35 if (ret) {
36 puts("Error: GPIO 65 not available\n");
37 goto out;
38 }
39 MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4));
40
41 ret = gpio_request(1, "");
42 if (ret) {
43 puts("Error: GPIO 1 not available\n");
44 goto out2;
45 }
46 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M4));
47
48 ret = gpio_direction_input(65);
49 if (ret) {
50 puts("Error: GPIO 65 not available for input\n");
51 goto out3;
52 }
53
54 ret = gpio_direction_input(1);
55 if (ret) {
56 puts("Error: GPIO 1 not available for input\n");
57 goto out3;
58 }
59
60 ret = gpio_get_value(65) << 1 | gpio_get_value(1);
61
62out3:
63 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M0));
64 gpio_free(1);
65out2:
66 MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0));
67 gpio_free(65);
68out:
69
70 return ret;
71}
72
Stefan Roesea9f52492013-12-04 09:27:34 +010073#ifdef CONFIG_SPL_BUILD
74/*
75 * Routine: get_board_mem_timings
76 * Description: If we use SPL then there is no x-loader nor config header
77 * so we have to setup the DDR timings ourself on both banks.
78 */
79void get_board_mem_timings(struct board_sdrc_timings *timings)
80{
Stefan Roese8f0cbd62013-12-04 09:27:37 +010081#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
82 /*
83 * Switch baseboard LED to red upon power-on
84 */
85 MUX_OMAP3_HA();
86
87 /* Request a gpio before using it */
88 gpio_request(111, "");
89 /* Sets the gpio as output and its value to 1, switch LED to red */
90 gpio_direction_output(111, 1);
91#endif
92
Stefan Roesea9f52492013-12-04 09:27:34 +010093 if (tao3530_revision() < 3) {
94 /* 256MB / Bank */
95 timings->mcfg = MCFG(256 << 20, 14); /* RAS-width 14 */
96 timings->ctrla = HYNIX_V_ACTIMA_165;
97 timings->ctrlb = HYNIX_V_ACTIMB_165;
98 } else {
99 /* 128MB / Bank */
100 timings->mcfg = MCFG(128 << 20, 13); /* RAS-width 13 */
101 timings->ctrla = MICRON_V_ACTIMA_165;
102 timings->ctrlb = MICRON_V_ACTIMB_165;
103 }
104
105 timings->mr = MICRON_V_MR_165;
106 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
107}
108#endif
109
Tapani Utriainen550e3752013-12-04 09:27:33 +0100110/*
111 * Routine: board_init
112 * Description: Early hardware init.
113 */
114int board_init(void)
115{
116 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
117 /* board id for Linux */
118 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530;
119 /* boot param addr */
120 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
121
122 return 0;
123}
124
125/*
126 * Routine: misc_init_r
127 * Description: Configure board specific parts
128 */
129int misc_init_r(void)
130{
131 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
132 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
133
134 twl4030_power_init();
135 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
136
137 /* Configure GPIOs to output */
138 /* GPIO23 */
139 writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
140 writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 |
141 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
142
143 /* Set GPIOs */
144 writel(GPIO10 | GPIO8 | GPIO2 | GPIO1,
145 &gpio6_base->setdataout);
146 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
147 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
148
Stefan Roesefcd9adc2013-12-04 09:27:36 +0100149 switch (tao3530_revision()) {
150 case 0:
151 puts("TAO-3530 REV Reserve 1\n");
152 break;
153 case 1:
154 puts("TAO-3530 REV Reserve 2\n");
155 break;
156 case 2:
157 puts("TAO-3530 REV Cx\n");
158 break;
159 case 3:
160 puts("TAO-3530 REV Ax/Bx\n");
161 break;
162 default:
163 puts("Unknown board revision\n");
164 }
165
Paul Kocialkowski679f82c2015-08-27 19:37:13 +0200166 omap_die_id_display();
Tapani Utriainen550e3752013-12-04 09:27:33 +0100167
Tapani Utriainen550e3752013-12-04 09:27:33 +0100168 return 0;
169}
170
171/*
172 * Routine: set_muxconf_regs
173 * Description: Setting up the configuration Mux registers specific to the
174 * hardware. Many pins need to be moved from protect to primary
175 * mode.
176 */
177void set_muxconf_regs(void)
178{
179 MUX_TAO3530();
Stefan Roese8f0cbd62013-12-04 09:27:37 +0100180#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
181 MUX_OMAP3_HA();
182#endif
Tapani Utriainen550e3752013-12-04 09:27:33 +0100183}
184
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900185#if defined(CONFIG_MMC)
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900186int board_mmc_init(struct bd_info *bis)
Tapani Utriainen550e3752013-12-04 09:27:33 +0100187{
188 omap_mmc_init(0, 0, 0, -1, -1);
189
190 return 0;
191}
192#endif
193
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900194#if defined(CONFIG_MMC)
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100195void board_mmc_power_init(void)
196{
197 twl4030_power_mmc_init(0);
198}
199#endif
200
Tom Rini8850c5d2017-05-12 22:33:27 -0400201#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
Tapani Utriainen550e3752013-12-04 09:27:33 +0100202/* Call usb_stop() before starting the kernel */
203void show_boot_progress(int val)
204{
205 if (val == BOOTSTAGE_ID_RUN_OS)
206 usb_stop();
207}
208
209static struct omap_usbhs_board_data usbhs_bdata = {
210 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
211 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
212 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
213};
214
215int ehci_hcd_init(int index, enum usb_init_type init,
216 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
217{
218 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
219}
220
221int ehci_hcd_stop(int index)
222{
223 return omap_ehci_hcd_stop();
224}
Tom Rini8850c5d2017-05-12 22:33:27 -0400225#endif /* CONFIG_USB_EHCI_HCD */