1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments Incorporated, <www.ti.com>
5 * Steve Sakoman <steve@sakoman.com>
11 #include <asm/mach-types.h>
12 #include <asm/arch/sys_proto.h>
13 #include <asm/arch/mmc_host_def.h>
14 #include <asm/arch/clock.h>
15 #include <asm/arch/gpio.h>
20 #include "panda_mux_data.h"
22 #ifdef CONFIG_USB_EHCI_HCD
24 #include <asm/arch/ehci.h>
25 #include <asm/ehci-omap.h>
28 #define PANDA_ULPI_PHY_TYPE_GPIO 182
29 #define PANDA_BOARD_ID_1_GPIO 101
30 #define PANDA_ES_BOARD_ID_1_GPIO 48
31 #define PANDA_BOARD_ID_2_GPIO 171
32 #define PANDA_ES_BOARD_ID_3_GPIO 3
33 #define PANDA_ES_BOARD_ID_4_GPIO 2
35 DECLARE_GLOBAL_DATA_PTR;
37 const struct omap_sysinfo sysinfo = {
38 "Board: OMAP4 Panda\n"
41 struct omap4_scrm_regs *const scrm = (struct omap4_scrm_regs *)0x4a30a000;
52 gd->bd->bi_arch_number = MACH_TYPE_OMAP4_PANDA;
53 gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
58 int board_eth_init(bd_t *bis)
64 * Routine: get_board_revision
65 * Description: Detect if we are running on a panda revision A1-A6,
66 * or an ES panda board. This can be done by reading
67 * the level of GPIOs and checking the processor revisions.
68 * This should result in:
70 * GPIO171, GPIO101, GPIO182: 0 1 1 => A1-A5
71 * GPIO171, GPIO101, GPIO182: 1 0 1 => A6
73 * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 0 1 1 => B1/B2
74 * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 1 1 1 => B3
76 int get_board_revision(void)
78 int board_id0, board_id1, board_id2;
79 int board_id3, board_id4;
82 int processor_rev = omap_revision();
84 /* Setup the mux for the common board ID pins (gpio 171 and 182) */
85 writew((IEN | M3), (*ctrl)->control_padconf_core_base + UNIPRO_TX0);
86 writew((IEN | M3), (*ctrl)->control_padconf_core_base + FREF_CLK2_OUT);
88 board_id0 = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO);
89 board_id2 = gpio_get_value(PANDA_BOARD_ID_2_GPIO);
91 if ((processor_rev >= OMAP4460_ES1_0 &&
92 processor_rev <= OMAP4460_ES1_1)) {
94 * Setup the mux for the ES specific board ID pins (gpio 101,
97 writew((IEN | M3), (*ctrl)->control_padconf_core_base +
99 writew((IEN | M3), (*ctrl)->control_padconf_core_base +
101 writew((IEN | M3), (*ctrl)->control_padconf_core_base +
104 board_id1 = gpio_get_value(PANDA_ES_BOARD_ID_1_GPIO);
105 board_id3 = gpio_get_value(PANDA_ES_BOARD_ID_3_GPIO);
106 board_id4 = gpio_get_value(PANDA_ES_BOARD_ID_4_GPIO);
108 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
109 env_set("board_name", "panda-es");
111 board_id = ((board_id4 << 4) | (board_id3 << 3) |
112 (board_id2 << 2) | (board_id1 << 1) | (board_id0));
114 /* Setup the mux for the Ax specific board ID pins (gpio 101) */
115 writew((IEN | M3), (*ctrl)->control_padconf_core_base +
118 board_id1 = gpio_get_value(PANDA_BOARD_ID_1_GPIO);
119 board_id = ((board_id2 << 2) | (board_id1 << 1) | (board_id0));
121 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
122 if ((board_id >= 0x3) && (processor_rev == OMAP4430_ES2_3))
123 env_set("board_name", "panda-a4");
131 * is_panda_es_rev_b3() - Detect if we are running on rev B3 of panda board ES
134 * Detect if we are running on B3 version of ES panda board,
135 * This can be done by reading the level of GPIO 171 and checking the
136 * processor revisions.
137 * GPIO171: 1 => Panda ES Rev B3
139 * Return : return 1 if Panda ES Rev B3 , else return 0
141 u8 is_panda_es_rev_b3(void)
143 int processor_rev = omap_revision();
146 if ((processor_rev >= OMAP4460_ES1_0 &&
147 processor_rev <= OMAP4460_ES1_1)) {
149 /* Setup the mux for the common board ID pins (gpio 171) */
151 (*ctrl)->control_padconf_core_base + UNIPRO_TX0);
153 /* if processor_rev is panda ES and GPIO171 is 1,it is rev b3 */
154 ret = gpio_get_value(PANDA_BOARD_ID_2_GPIO);
159 #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
161 * emif_get_reg_dump() - emif_get_reg_dump strong function
163 * @emif_nr - emif base
164 * @regs - reg dump of timing values
166 * Strong function to override emif_get_reg_dump weak function in sdram_elpida.c
168 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
170 u32 omap4_rev = omap_revision();
172 /* Same devices and geometry on both EMIFs */
173 if (omap4_rev == OMAP4430_ES1_0)
174 *regs = &emif_regs_elpida_380_mhz_1cs;
175 else if (omap4_rev == OMAP4430_ES2_0)
176 *regs = &emif_regs_elpida_200_mhz_2cs;
177 else if (omap4_rev == OMAP4430_ES2_3)
178 *regs = &emif_regs_elpida_400_mhz_1cs;
179 else if (omap4_rev < OMAP4470_ES1_0) {
180 if(is_panda_es_rev_b3())
181 *regs = &emif_regs_elpida_400_mhz_1cs;
183 *regs = &emif_regs_elpida_400_mhz_2cs;
186 *regs = &emif_regs_elpida_400_mhz_1cs;
189 void emif_get_dmm_regs(const struct dmm_lisa_map_regs
192 u32 omap_rev = omap_revision();
194 if (omap_rev == OMAP4430_ES1_0)
195 *dmm_lisa_regs = &lisa_map_2G_x_1_x_2;
196 else if (omap_rev == OMAP4430_ES2_3)
197 *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
198 else if (omap_rev < OMAP4460_ES1_0)
199 *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
201 *dmm_lisa_regs = &ma_lisa_map_2G_x_2_x_2;
207 * @brief misc_init_r - Configure Panda board specific configurations
208 * such as power configurations, ethernet initialization as phase2 of
213 int misc_init_r(void)
216 u32 auxclk, altclksrc;
218 /* EHCI is not supported on ES1.0 */
219 if (omap_revision() == OMAP4430_ES1_0)
222 get_board_revision();
224 gpio_direction_input(PANDA_ULPI_PHY_TYPE_GPIO);
225 phy_type = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO);
228 /* ULPI PHY supplied by auxclk3 derived from sys_clk */
229 debug("ULPI PHY supplied by auxclk3\n");
231 auxclk = readl(&scrm->auxclk3);
233 auxclk &= ~AUXCLK_SRCSELECT_MASK;
234 auxclk |= AUXCLK_SRCSELECT_SYS_CLK << AUXCLK_SRCSELECT_SHIFT;
235 /* Set the divisor to 2 */
236 auxclk &= ~AUXCLK_CLKDIV_MASK;
237 auxclk |= AUXCLK_CLKDIV_2 << AUXCLK_CLKDIV_SHIFT;
238 /* Request auxilary clock #3 */
239 auxclk |= AUXCLK_ENABLE_MASK;
241 writel(auxclk, &scrm->auxclk3);
243 /* ULPI PHY supplied by auxclk1 derived from PER dpll */
244 debug("ULPI PHY supplied by auxclk1\n");
246 auxclk = readl(&scrm->auxclk1);
247 /* Select per DPLL */
248 auxclk &= ~AUXCLK_SRCSELECT_MASK;
249 auxclk |= AUXCLK_SRCSELECT_PER_DPLL << AUXCLK_SRCSELECT_SHIFT;
250 /* Set the divisor to 16 */
251 auxclk &= ~AUXCLK_CLKDIV_MASK;
252 auxclk |= AUXCLK_CLKDIV_16 << AUXCLK_CLKDIV_SHIFT;
253 /* Request auxilary clock #3 */
254 auxclk |= AUXCLK_ENABLE_MASK;
256 writel(auxclk, &scrm->auxclk1);
259 altclksrc = readl(&scrm->altclksrc);
261 /* Activate alternate system clock supplier */
262 altclksrc &= ~ALTCLKSRC_MODE_MASK;
263 altclksrc |= ALTCLKSRC_MODE_ACTIVE;
266 altclksrc |= ALTCLKSRC_ENABLE_INT_MASK | ALTCLKSRC_ENABLE_EXT_MASK;
268 writel(altclksrc, &scrm->altclksrc);
270 omap_die_id_usbethaddr();
275 void set_muxconf_regs(void)
277 do_set_mux((*ctrl)->control_padconf_core_base,
278 core_padconf_array_essential,
279 sizeof(core_padconf_array_essential) /
280 sizeof(struct pad_conf_entry));
282 do_set_mux((*ctrl)->control_padconf_wkup_base,
283 wkup_padconf_array_essential,
284 sizeof(wkup_padconf_array_essential) /
285 sizeof(struct pad_conf_entry));
287 if (omap_revision() >= OMAP4460_ES1_0)
288 do_set_mux((*ctrl)->control_padconf_wkup_base,
289 wkup_padconf_array_essential_4460,
290 sizeof(wkup_padconf_array_essential_4460) /
291 sizeof(struct pad_conf_entry));
294 #if defined(CONFIG_MMC)
295 int board_mmc_init(bd_t *bis)
297 return omap_mmc_init(0, 0, 0, -1, -1);
300 #if !defined(CONFIG_SPL_BUILD)
301 void board_mmc_power_init(void)
303 twl6030_power_mmc_init(0);
308 #ifdef CONFIG_USB_EHCI_HCD
310 static struct omap_usbhs_board_data usbhs_bdata = {
311 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
312 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
313 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
316 int ehci_hcd_init(int index, enum usb_init_type init,
317 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
320 unsigned int utmi_clk;
322 /* Now we can enable our port clocks */
323 utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
324 utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
325 setbits_le32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, utmi_clk);
327 ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
334 int ehci_hcd_stop(int index)
336 return omap_ehci_hcd_stop();
341 * get_board_rev() - get board revision
343 u32 get_board_rev(void)