]> git.sur5r.net Git - u-boot/blob - board/technexion/tao3530/tao3530.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / board / technexion / tao3530 / tao3530.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Maintainer :
4  *      Tapani Utriainen <linuxfae@technexion.com>
5  */
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
23 DECLARE_GLOBAL_DATA_PTR;
24
25 int 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
58 out3:
59         MUX_VAL(CP(SYS_CLKREQ), (IEN  | PTU | EN | M0));
60         gpio_free(1);
61 out2:
62         MUX_VAL(CP(GPMC_WAIT3), (IEN  | PTU | EN  | M0));
63         gpio_free(65);
64 out:
65
66         return ret;
67 }
68
69 #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  */
75 void get_board_mem_timings(struct board_sdrc_timings *timings)
76 {
77 #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
89         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
106 /*
107  * Routine: board_init
108  * Description: Early hardware init.
109  */
110 int 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  */
125 int 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
145         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
162         omap_die_id_display();
163
164         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  */
173 void set_muxconf_regs(void)
174 {
175         MUX_TAO3530();
176 #if defined(CONFIG_SYS_BOARD_OMAP3_HA)
177         MUX_OMAP3_HA();
178 #endif
179 }
180
181 #if defined(CONFIG_MMC)
182 int board_mmc_init(bd_t *bis)
183 {
184         omap_mmc_init(0, 0, 0, -1, -1);
185
186         return 0;
187 }
188 #endif
189
190 #if defined(CONFIG_MMC)
191 void board_mmc_power_init(void)
192 {
193         twl4030_power_mmc_init(0);
194 }
195 #endif
196
197 #if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
198 /* Call usb_stop() before starting the kernel */
199 void show_boot_progress(int val)
200 {
201         if (val == BOOTSTAGE_ID_RUN_OS)
202                 usb_stop();
203 }
204
205 static 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
211 int 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
217 int ehci_hcd_stop(int index)
218 {
219         return omap_ehci_hcd_stop();
220 }
221 #endif /* CONFIG_USB_EHCI_HCD */