12c2a9f3aSSRICHARAN R /* 22c2a9f3aSSRICHARAN R * (C) Copyright 2010 32c2a9f3aSSRICHARAN R * Texas Instruments Incorporated, <www.ti.com> 42c2a9f3aSSRICHARAN R * Aneesh V <aneesh@ti.com> 52c2a9f3aSSRICHARAN R * Steve Sakoman <steve@sakoman.com> 62c2a9f3aSSRICHARAN R * 71a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 82c2a9f3aSSRICHARAN R */ 92c2a9f3aSSRICHARAN R #include <common.h> 10cb199102SNishanth Menon #include <palmas.h> 117ba792c0SKishon Vijay Abraham I #include <asm/arch/omap.h> 122c2a9f3aSSRICHARAN R #include <asm/arch/sys_proto.h> 132c2a9f3aSSRICHARAN R #include <asm/arch/mmc_host_def.h> 14fdce7b63SDan Murphy #include <tca642x.h> 157ba792c0SKishon Vijay Abraham I #include <usb.h> 167ba792c0SKishon Vijay Abraham I #include <linux/usb/gadget.h> 177ba792c0SKishon Vijay Abraham I #include <dwc3-uboot.h> 187ba792c0SKishon Vijay Abraham I #include <dwc3-omap-uboot.h> 197ba792c0SKishon Vijay Abraham I #include <ti-usb-phy-uboot.h> 202c2a9f3aSSRICHARAN R 212c2a9f3aSSRICHARAN R #include "mux_data.h" 222c2a9f3aSSRICHARAN R 2396805532SDan Murphy #if defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_XHCI_OMAP) 24e9024ef2SDan Murphy #include <sata.h> 255e5cfaf9SDan Murphy #include <usb.h> 261572eadfSDan Murphy #include <asm/gpio.h> 275e5cfaf9SDan Murphy #include <asm/arch/clock.h> 285e5cfaf9SDan Murphy #include <asm/arch/ehci.h> 295e5cfaf9SDan Murphy #include <asm/ehci-omap.h> 30afdc6321SRoger Quadros #include <asm/arch/sata.h> 3104025b42SDan Murphy 3204025b42SDan Murphy #define DIE_ID_REG_BASE (OMAP54XX_L4_CORE_BASE + 0x2000) 3304025b42SDan Murphy #define DIE_ID_REG_OFFSET 0x200 3404025b42SDan Murphy 355e5cfaf9SDan Murphy #endif 365e5cfaf9SDan Murphy 372c2a9f3aSSRICHARAN R DECLARE_GLOBAL_DATA_PTR; 382c2a9f3aSSRICHARAN R 392c2a9f3aSSRICHARAN R const struct omap_sysinfo sysinfo = { 405a7bd384SDan Murphy "Board: OMAP5432 uEVM\n" 412c2a9f3aSSRICHARAN R }; 422c2a9f3aSSRICHARAN R 432c2a9f3aSSRICHARAN R /** 44fdce7b63SDan Murphy * @brief tca642x_init - uEVM default values for the GPIO expander 45fdce7b63SDan Murphy * input reg, output reg, polarity reg, configuration reg 46fdce7b63SDan Murphy */ 47fdce7b63SDan Murphy struct tca642x_bank_info tca642x_init[] = { 48fdce7b63SDan Murphy { .input_reg = 0x00, 49fdce7b63SDan Murphy .output_reg = 0x04, 50fdce7b63SDan Murphy .polarity_reg = 0x00, 51fdce7b63SDan Murphy .configuration_reg = 0x80 }, 52fdce7b63SDan Murphy { .input_reg = 0x00, 53fdce7b63SDan Murphy .output_reg = 0x00, 54fdce7b63SDan Murphy .polarity_reg = 0x00, 55fdce7b63SDan Murphy .configuration_reg = 0xff }, 56fdce7b63SDan Murphy { .input_reg = 0x00, 57fdce7b63SDan Murphy .output_reg = 0x00, 58fdce7b63SDan Murphy .polarity_reg = 0x00, 59fdce7b63SDan Murphy .configuration_reg = 0x40 }, 60fdce7b63SDan Murphy }; 61fdce7b63SDan Murphy 627ba792c0SKishon Vijay Abraham I #ifdef CONFIG_USB_DWC3 637ba792c0SKishon Vijay Abraham I static struct dwc3_device usb_otg_ss = { 647ba792c0SKishon Vijay Abraham I .maximum_speed = USB_SPEED_SUPER, 657ba792c0SKishon Vijay Abraham I .base = OMAP5XX_USB_OTG_SS_BASE, 667ba792c0SKishon Vijay Abraham I .tx_fifo_resize = false, 677ba792c0SKishon Vijay Abraham I .index = 0, 687ba792c0SKishon Vijay Abraham I }; 697ba792c0SKishon Vijay Abraham I 707ba792c0SKishon Vijay Abraham I static struct dwc3_omap_device usb_otg_ss_glue = { 717ba792c0SKishon Vijay Abraham I .base = (void *)OMAP5XX_USB_OTG_SS_GLUE_BASE, 727ba792c0SKishon Vijay Abraham I .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, 737ba792c0SKishon Vijay Abraham I .index = 0, 747ba792c0SKishon Vijay Abraham I }; 757ba792c0SKishon Vijay Abraham I 767ba792c0SKishon Vijay Abraham I static struct ti_usb_phy_device usb_phy_device = { 777ba792c0SKishon Vijay Abraham I .pll_ctrl_base = (void *)OMAP5XX_USB3_PHY_PLL_CTRL, 787ba792c0SKishon Vijay Abraham I .usb2_phy_power = (void *)OMAP5XX_USB2_PHY_POWER, 797ba792c0SKishon Vijay Abraham I .usb3_phy_power = (void *)OMAP5XX_USB3_PHY_POWER, 807ba792c0SKishon Vijay Abraham I .index = 0, 817ba792c0SKishon Vijay Abraham I }; 827ba792c0SKishon Vijay Abraham I 837ba792c0SKishon Vijay Abraham I int board_usb_init(int index, enum usb_init_type init) 847ba792c0SKishon Vijay Abraham I { 857ba792c0SKishon Vijay Abraham I if (index) { 867ba792c0SKishon Vijay Abraham I printf("Invalid Controller Index\n"); 877ba792c0SKishon Vijay Abraham I return -EINVAL; 887ba792c0SKishon Vijay Abraham I } 897ba792c0SKishon Vijay Abraham I 907ba792c0SKishon Vijay Abraham I if (init == USB_INIT_DEVICE) { 917ba792c0SKishon Vijay Abraham I usb_otg_ss.dr_mode = USB_DR_MODE_PERIPHERAL; 927ba792c0SKishon Vijay Abraham I usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; 937ba792c0SKishon Vijay Abraham I } else { 947ba792c0SKishon Vijay Abraham I usb_otg_ss.dr_mode = USB_DR_MODE_HOST; 957ba792c0SKishon Vijay Abraham I usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; 967ba792c0SKishon Vijay Abraham I } 977ba792c0SKishon Vijay Abraham I 986f1af1e3SKishon Vijay Abraham I enable_usb_clocks(index); 997ba792c0SKishon Vijay Abraham I ti_usb_phy_uboot_init(&usb_phy_device); 1007ba792c0SKishon Vijay Abraham I dwc3_omap_uboot_init(&usb_otg_ss_glue); 1017ba792c0SKishon Vijay Abraham I dwc3_uboot_init(&usb_otg_ss); 1027ba792c0SKishon Vijay Abraham I 1037ba792c0SKishon Vijay Abraham I return 0; 1047ba792c0SKishon Vijay Abraham I } 1057ba792c0SKishon Vijay Abraham I 1067ba792c0SKishon Vijay Abraham I int board_usb_cleanup(int index, enum usb_init_type init) 1077ba792c0SKishon Vijay Abraham I { 1087ba792c0SKishon Vijay Abraham I if (index) { 1097ba792c0SKishon Vijay Abraham I printf("Invalid Controller Index\n"); 1107ba792c0SKishon Vijay Abraham I return -EINVAL; 1117ba792c0SKishon Vijay Abraham I } 1127ba792c0SKishon Vijay Abraham I 1137ba792c0SKishon Vijay Abraham I ti_usb_phy_uboot_exit(index); 1147ba792c0SKishon Vijay Abraham I dwc3_uboot_exit(index); 1157ba792c0SKishon Vijay Abraham I dwc3_omap_uboot_exit(index); 1166f1af1e3SKishon Vijay Abraham I disable_usb_clocks(index); 1177ba792c0SKishon Vijay Abraham I 1187ba792c0SKishon Vijay Abraham I return 0; 1197ba792c0SKishon Vijay Abraham I } 1207ba792c0SKishon Vijay Abraham I 1217ba792c0SKishon Vijay Abraham I int usb_gadget_handle_interrupts(int index) 1227ba792c0SKishon Vijay Abraham I { 1237ba792c0SKishon Vijay Abraham I u32 status; 1247ba792c0SKishon Vijay Abraham I 1257ba792c0SKishon Vijay Abraham I status = dwc3_omap_uboot_interrupt_status(index); 1267ba792c0SKishon Vijay Abraham I if (status) 1277ba792c0SKishon Vijay Abraham I dwc3_uboot_handle_interrupt(index); 1287ba792c0SKishon Vijay Abraham I 1297ba792c0SKishon Vijay Abraham I return 0; 1307ba792c0SKishon Vijay Abraham I } 1317ba792c0SKishon Vijay Abraham I #endif 1327ba792c0SKishon Vijay Abraham I 133fdce7b63SDan Murphy /** 1342c2a9f3aSSRICHARAN R * @brief board_init 1352c2a9f3aSSRICHARAN R * 1362c2a9f3aSSRICHARAN R * @return 0 1372c2a9f3aSSRICHARAN R */ 1382c2a9f3aSSRICHARAN R int board_init(void) 1392c2a9f3aSSRICHARAN R { 1402c2a9f3aSSRICHARAN R gpmc_init(); 1412c2a9f3aSSRICHARAN R gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM; 1422c2a9f3aSSRICHARAN R gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */ 1432c2a9f3aSSRICHARAN R 144fdce7b63SDan Murphy tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init); 145fdce7b63SDan Murphy 1462c2a9f3aSSRICHARAN R return 0; 1472c2a9f3aSSRICHARAN R } 1482c2a9f3aSSRICHARAN R 1492c2a9f3aSSRICHARAN R int board_eth_init(bd_t *bis) 1502c2a9f3aSSRICHARAN R { 1512c2a9f3aSSRICHARAN R return 0; 1522c2a9f3aSSRICHARAN R } 1532c2a9f3aSSRICHARAN R 15496805532SDan Murphy #if defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_XHCI_OMAP) 15596805532SDan Murphy static void enable_host_clocks(void) 15696805532SDan Murphy { 15796805532SDan Murphy int auxclk; 15896805532SDan Murphy int hs_clk_ctrl_val = (OPTFCLKEN_HSIC60M_P3_CLK | 15996805532SDan Murphy OPTFCLKEN_HSIC480M_P3_CLK | 16096805532SDan Murphy OPTFCLKEN_HSIC60M_P2_CLK | 16196805532SDan Murphy OPTFCLKEN_HSIC480M_P2_CLK | 16296805532SDan Murphy OPTFCLKEN_UTMI_P3_CLK | OPTFCLKEN_UTMI_P2_CLK); 16396805532SDan Murphy 16496805532SDan Murphy /* Enable port 2 and 3 clocks*/ 16596805532SDan Murphy setbits_le32((*prcm)->cm_l3init_hsusbhost_clkctrl, hs_clk_ctrl_val); 16696805532SDan Murphy 16796805532SDan Murphy /* Enable port 2 and 3 usb host ports tll clocks*/ 16896805532SDan Murphy setbits_le32((*prcm)->cm_l3init_hsusbtll_clkctrl, 16996805532SDan Murphy (OPTFCLKEN_USB_CH1_CLK_ENABLE | OPTFCLKEN_USB_CH2_CLK_ENABLE)); 17096805532SDan Murphy #ifdef CONFIG_USB_XHCI_OMAP 17196805532SDan Murphy /* Enable the USB OTG Super speed clocks */ 17296805532SDan Murphy setbits_le32((*prcm)->cm_l3init_usb_otg_ss_clkctrl, 17396805532SDan Murphy (OPTFCLKEN_REFCLK960M | OTG_SS_CLKCTRL_MODULEMODE_HW)); 17496805532SDan Murphy #endif 17596805532SDan Murphy 17696805532SDan Murphy auxclk = readl((*prcm)->scrm_auxclk1); 17796805532SDan Murphy /* Request auxilary clock */ 17896805532SDan Murphy auxclk |= AUXCLK_ENABLE_MASK; 17996805532SDan Murphy writel(auxclk, (*prcm)->scrm_auxclk1); 18096805532SDan Murphy } 18196805532SDan Murphy #endif 18296805532SDan Murphy 1832c2a9f3aSSRICHARAN R /** 1842c2a9f3aSSRICHARAN R * @brief misc_init_r - Configure EVM board specific configurations 1852c2a9f3aSSRICHARAN R * such as power configurations, ethernet initialization as phase2 of 1862c2a9f3aSSRICHARAN R * boot sequence 1872c2a9f3aSSRICHARAN R * 1882c2a9f3aSSRICHARAN R * @return 0 1892c2a9f3aSSRICHARAN R */ 1902c2a9f3aSSRICHARAN R int misc_init_r(void) 1912c2a9f3aSSRICHARAN R { 192cb199102SNishanth Menon #ifdef CONFIG_PALMAS_POWER 19312733881SNishanth Menon palmas_init_settings(); 1942c2a9f3aSSRICHARAN R #endif 19596805532SDan Murphy 19607815eb9SPaul Kocialkowski omap_die_id_usbethaddr(); 197ea02b653SDan Murphy 1982c2a9f3aSSRICHARAN R return 0; 1992c2a9f3aSSRICHARAN R } 2002c2a9f3aSSRICHARAN R 201*3ef56e61SPaul Kocialkowski void set_muxconf_regs(void) 2022c2a9f3aSSRICHARAN R { 2039239f5b6SLokesh Vutla do_set_mux((*ctrl)->control_padconf_core_base, 2049239f5b6SLokesh Vutla core_padconf_array_essential, 2052c2a9f3aSSRICHARAN R sizeof(core_padconf_array_essential) / 2062c2a9f3aSSRICHARAN R sizeof(struct pad_conf_entry)); 2072c2a9f3aSSRICHARAN R 2089239f5b6SLokesh Vutla do_set_mux((*ctrl)->control_padconf_wkup_base, 2099239f5b6SLokesh Vutla wkup_padconf_array_essential, 2102c2a9f3aSSRICHARAN R sizeof(wkup_padconf_array_essential) / 2112c2a9f3aSSRICHARAN R sizeof(struct pad_conf_entry)); 2122c2a9f3aSSRICHARAN R } 2132c2a9f3aSSRICHARAN R 2142c2a9f3aSSRICHARAN R #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC) 2152c2a9f3aSSRICHARAN R int board_mmc_init(bd_t *bis) 2162c2a9f3aSSRICHARAN R { 2172c2a9f3aSSRICHARAN R omap_mmc_init(0, 0, 0, -1, -1); 2182c2a9f3aSSRICHARAN R omap_mmc_init(1, 0, 0, -1, -1); 2192c2a9f3aSSRICHARAN R return 0; 2202c2a9f3aSSRICHARAN R } 2212c2a9f3aSSRICHARAN R #endif 2225e5cfaf9SDan Murphy 2235e5cfaf9SDan Murphy #ifdef CONFIG_USB_EHCI 2245e5cfaf9SDan Murphy static struct omap_usbhs_board_data usbhs_bdata = { 2255e5cfaf9SDan Murphy .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, 2265e5cfaf9SDan Murphy .port_mode[1] = OMAP_EHCI_PORT_MODE_HSIC, 2275e5cfaf9SDan Murphy .port_mode[2] = OMAP_EHCI_PORT_MODE_HSIC, 2285e5cfaf9SDan Murphy }; 2295e5cfaf9SDan Murphy 230127efc4fSTroy Kisky int ehci_hcd_init(int index, enum usb_init_type init, 231127efc4fSTroy Kisky struct ehci_hccr **hccr, struct ehci_hcor **hcor) 2325e5cfaf9SDan Murphy { 2335e5cfaf9SDan Murphy int ret; 2345e5cfaf9SDan Murphy 2355e5cfaf9SDan Murphy enable_host_clocks(); 2365e5cfaf9SDan Murphy 23716297cfbSMateusz Zalega ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); 2385e5cfaf9SDan Murphy if (ret < 0) { 2395e5cfaf9SDan Murphy puts("Failed to initialize ehci\n"); 2405e5cfaf9SDan Murphy return ret; 2415e5cfaf9SDan Murphy } 2425e5cfaf9SDan Murphy 2435e5cfaf9SDan Murphy return 0; 2445e5cfaf9SDan Murphy } 2455e5cfaf9SDan Murphy 2465e5cfaf9SDan Murphy int ehci_hcd_stop(void) 2475e5cfaf9SDan Murphy { 2485e5cfaf9SDan Murphy int ret; 2495e5cfaf9SDan Murphy 2505e5cfaf9SDan Murphy ret = omap_ehci_hcd_stop(); 2515e5cfaf9SDan Murphy return ret; 2525e5cfaf9SDan Murphy } 2531572eadfSDan Murphy 2541572eadfSDan Murphy void usb_hub_reset_devices(int port) 2551572eadfSDan Murphy { 2561572eadfSDan Murphy /* The LAN9730 needs to be reset after the port power has been set. */ 2571572eadfSDan Murphy if (port == 3) { 2581572eadfSDan Murphy gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, 0); 2591572eadfSDan Murphy udelay(10); 2601572eadfSDan Murphy gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, 1); 2611572eadfSDan Murphy } 2621572eadfSDan Murphy } 2635e5cfaf9SDan Murphy #endif 26496805532SDan Murphy 26596805532SDan Murphy #ifdef CONFIG_USB_XHCI_OMAP 26696805532SDan Murphy /** 26796805532SDan Murphy * @brief board_usb_init - Configure EVM board specific configurations 26896805532SDan Murphy * for the LDO's and clocks for the USB blocks. 26996805532SDan Murphy * 27096805532SDan Murphy * @return 0 27196805532SDan Murphy */ 2727e575c46STroy Kisky int board_usb_init(int index, enum usb_init_type init) 27396805532SDan Murphy { 27496805532SDan Murphy int ret; 27596805532SDan Murphy #ifdef CONFIG_PALMAS_USB_SS_PWR 27696805532SDan Murphy ret = palmas_enable_ss_ldo(); 27796805532SDan Murphy #endif 27896805532SDan Murphy 27996805532SDan Murphy enable_host_clocks(); 28096805532SDan Murphy 28196805532SDan Murphy return 0; 28296805532SDan Murphy } 28396805532SDan Murphy #endif 284