Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2010 |
| 4 | * Texas Instruments Incorporated, <www.ti.com> |
| 5 | * Aneesh V <aneesh@ti.com> |
| 6 | * Steve Sakoman <steve@sakoman.com> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 7 | */ |
| 8 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 10 | #include <net.h> |
Nishanth Menon | 627612c | 2013-03-26 05:20:54 +0000 | [diff] [blame] | 11 | #include <palmas.h> |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 12 | #include <asm/arch/omap.h> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
| 14 | #include <asm/arch/mmc_host_def.h> |
Tero Kristo | f6c7fda | 2020-06-16 11:03:10 +0300 | [diff] [blame] | 15 | #include <serial.h> |
Dan Murphy | 05d5f99 | 2013-07-11 13:10:28 -0500 | [diff] [blame] | 16 | #include <tca642x.h> |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 17 | #include <usb.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 19 | #include <linux/delay.h> |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 20 | #include <linux/usb/gadget.h> |
| 21 | #include <dwc3-uboot.h> |
| 22 | #include <dwc3-omap-uboot.h> |
| 23 | #include <ti-usb-phy-uboot.h> |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 24 | |
| 25 | #include "mux_data.h" |
| 26 | |
Tom Rini | ceed5d2 | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 27 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_XHCI_OMAP) |
Dan Murphy | 57f29ab | 2014-02-03 06:59:02 -0600 | [diff] [blame] | 28 | #include <sata.h> |
Dan Murphy | 29d04b5 | 2013-08-01 14:05:59 -0500 | [diff] [blame] | 29 | #include <usb.h> |
Dan Murphy | dc649b3 | 2013-08-01 14:06:02 -0500 | [diff] [blame] | 30 | #include <asm/gpio.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 31 | #include <asm/mach-types.h> |
Dan Murphy | 29d04b5 | 2013-08-01 14:05:59 -0500 | [diff] [blame] | 32 | #include <asm/arch/clock.h> |
| 33 | #include <asm/arch/ehci.h> |
| 34 | #include <asm/ehci-omap.h> |
Roger Quadros | d88ab9c | 2013-11-11 16:56:42 +0200 | [diff] [blame] | 35 | #include <asm/arch/sata.h> |
Dan Murphy | 0a1df4f | 2013-08-01 14:06:00 -0500 | [diff] [blame] | 36 | |
| 37 | #define DIE_ID_REG_BASE (OMAP54XX_L4_CORE_BASE + 0x2000) |
| 38 | #define DIE_ID_REG_OFFSET 0x200 |
| 39 | |
Dan Murphy | 29d04b5 | 2013-08-01 14:05:59 -0500 | [diff] [blame] | 40 | #endif |
| 41 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 42 | DECLARE_GLOBAL_DATA_PTR; |
| 43 | |
| 44 | const struct omap_sysinfo sysinfo = { |
Dan Murphy | 3713e9d | 2013-08-01 14:05:56 -0500 | [diff] [blame] | 45 | "Board: OMAP5432 uEVM\n" |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | /** |
Dan Murphy | 05d5f99 | 2013-07-11 13:10:28 -0500 | [diff] [blame] | 49 | * @brief tca642x_init - uEVM default values for the GPIO expander |
| 50 | * input reg, output reg, polarity reg, configuration reg |
| 51 | */ |
| 52 | struct tca642x_bank_info tca642x_init[] = { |
| 53 | { .input_reg = 0x00, |
| 54 | .output_reg = 0x04, |
| 55 | .polarity_reg = 0x00, |
| 56 | .configuration_reg = 0x80 }, |
| 57 | { .input_reg = 0x00, |
| 58 | .output_reg = 0x00, |
| 59 | .polarity_reg = 0x00, |
| 60 | .configuration_reg = 0xff }, |
| 61 | { .input_reg = 0x00, |
| 62 | .output_reg = 0x00, |
| 63 | .polarity_reg = 0x00, |
| 64 | .configuration_reg = 0x40 }, |
| 65 | }; |
| 66 | |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 67 | #ifdef CONFIG_USB_DWC3 |
| 68 | static struct dwc3_device usb_otg_ss = { |
| 69 | .maximum_speed = USB_SPEED_SUPER, |
| 70 | .base = OMAP5XX_USB_OTG_SS_BASE, |
| 71 | .tx_fifo_resize = false, |
| 72 | .index = 0, |
| 73 | }; |
| 74 | |
| 75 | static struct dwc3_omap_device usb_otg_ss_glue = { |
| 76 | .base = (void *)OMAP5XX_USB_OTG_SS_GLUE_BASE, |
| 77 | .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, |
| 78 | .index = 0, |
| 79 | }; |
| 80 | |
| 81 | static struct ti_usb_phy_device usb_phy_device = { |
| 82 | .pll_ctrl_base = (void *)OMAP5XX_USB3_PHY_PLL_CTRL, |
| 83 | .usb2_phy_power = (void *)OMAP5XX_USB2_PHY_POWER, |
| 84 | .usb3_phy_power = (void *)OMAP5XX_USB3_PHY_POWER, |
| 85 | .index = 0, |
| 86 | }; |
| 87 | |
| 88 | int board_usb_init(int index, enum usb_init_type init) |
| 89 | { |
| 90 | if (index) { |
| 91 | printf("Invalid Controller Index\n"); |
| 92 | return -EINVAL; |
| 93 | } |
| 94 | |
| 95 | if (init == USB_INIT_DEVICE) { |
| 96 | usb_otg_ss.dr_mode = USB_DR_MODE_PERIPHERAL; |
| 97 | usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; |
| 98 | } else { |
| 99 | usb_otg_ss.dr_mode = USB_DR_MODE_HOST; |
| 100 | usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; |
| 101 | } |
| 102 | |
Kishon Vijay Abraham I | 831bcba | 2015-08-19 16:16:27 +0530 | [diff] [blame] | 103 | enable_usb_clocks(index); |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 104 | ti_usb_phy_uboot_init(&usb_phy_device); |
| 105 | dwc3_omap_uboot_init(&usb_otg_ss_glue); |
| 106 | dwc3_uboot_init(&usb_otg_ss); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 112 | { |
| 113 | if (index) { |
| 114 | printf("Invalid Controller Index\n"); |
| 115 | return -EINVAL; |
| 116 | } |
| 117 | |
| 118 | ti_usb_phy_uboot_exit(index); |
| 119 | dwc3_uboot_exit(index); |
| 120 | dwc3_omap_uboot_exit(index); |
Kishon Vijay Abraham I | 831bcba | 2015-08-19 16:16:27 +0530 | [diff] [blame] | 121 | disable_usb_clocks(index); |
Kishon Vijay Abraham I | 5a3e062 | 2015-08-19 14:13:20 +0530 | [diff] [blame] | 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | int usb_gadget_handle_interrupts(int index) |
| 127 | { |
| 128 | u32 status; |
| 129 | |
| 130 | status = dwc3_omap_uboot_interrupt_status(index); |
| 131 | if (status) |
| 132 | dwc3_uboot_handle_interrupt(index); |
| 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | #endif |
| 137 | |
Dan Murphy | 05d5f99 | 2013-07-11 13:10:28 -0500 | [diff] [blame] | 138 | /** |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 139 | * @brief board_init |
| 140 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 141 | * Return: 0 |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 142 | */ |
| 143 | int board_init(void) |
| 144 | { |
| 145 | gpmc_init(); |
Tom Rini | 4815734 | 2017-01-25 20:42:35 -0500 | [diff] [blame] | 146 | gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM; |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 147 | gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */ |
| 148 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 149 | tca642x_set_inital_state(CFG_SYS_I2C_TCA642X_ADDR, tca642x_init); |
Dan Murphy | 05d5f99 | 2013-07-11 13:10:28 -0500 | [diff] [blame] | 150 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 151 | return 0; |
| 152 | } |
| 153 | |
Tero Kristo | f6c7fda | 2020-06-16 11:03:10 +0300 | [diff] [blame] | 154 | #if defined(CONFIG_SPL_OS_BOOT) |
| 155 | int spl_start_uboot(void) |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 156 | { |
Tero Kristo | f6c7fda | 2020-06-16 11:03:10 +0300 | [diff] [blame] | 157 | /* break into full u-boot on 'c' */ |
| 158 | if (serial_tstc() && serial_getc() == 'c') |
| 159 | return 1; |
| 160 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 161 | return 0; |
| 162 | } |
Tero Kristo | f6c7fda | 2020-06-16 11:03:10 +0300 | [diff] [blame] | 163 | #endif /* CONFIG_SPL_OS_BOOT */ |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 164 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 165 | int board_eth_init(struct bd_info *bis) |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 166 | { |
Tero Kristo | f6c7fda | 2020-06-16 11:03:10 +0300 | [diff] [blame] | 167 | return 0; |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 168 | } |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 169 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 170 | /** |
| 171 | * @brief misc_init_r - Configure EVM board specific configurations |
| 172 | * such as power configurations, ethernet initialization as phase2 of |
| 173 | * boot sequence |
| 174 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 175 | * Return: 0 |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 176 | */ |
| 177 | int misc_init_r(void) |
| 178 | { |
Nishanth Menon | 627612c | 2013-03-26 05:20:54 +0000 | [diff] [blame] | 179 | #ifdef CONFIG_PALMAS_POWER |
Nishanth Menon | aa4f836 | 2013-03-26 05:20:55 +0000 | [diff] [blame] | 180 | palmas_init_settings(); |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 181 | #endif |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 182 | |
Paul Kocialkowski | 2edadee | 2015-08-27 19:37:12 +0200 | [diff] [blame] | 183 | omap_die_id_usbethaddr(); |
Dan Murphy | 2870a24 | 2013-10-11 12:28:19 -0500 | [diff] [blame] | 184 | |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 185 | return 0; |
| 186 | } |
| 187 | |
Paul Kocialkowski | a00b1e5 | 2016-02-27 19:18:56 +0100 | [diff] [blame] | 188 | void set_muxconf_regs(void) |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 189 | { |
Lokesh Vutla | 37bce59 | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 190 | do_set_mux((*ctrl)->control_padconf_core_base, |
| 191 | core_padconf_array_essential, |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 192 | sizeof(core_padconf_array_essential) / |
| 193 | sizeof(struct pad_conf_entry)); |
| 194 | |
Lokesh Vutla | 37bce59 | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 195 | do_set_mux((*ctrl)->control_padconf_wkup_base, |
| 196 | wkup_padconf_array_essential, |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 197 | sizeof(wkup_padconf_array_essential) / |
| 198 | sizeof(struct pad_conf_entry)); |
| 199 | } |
| 200 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 201 | #if defined(CONFIG_MMC) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 202 | int board_mmc_init(struct bd_info *bis) |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 203 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 204 | omap_mmc_init(0, 0, 0, -1, -1); |
| 205 | omap_mmc_init(1, 0, 0, -1, -1); |
Sricharan | 9310ff7 | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 206 | return 0; |
| 207 | } |
Dan Murphy | 29d04b5 | 2013-08-01 14:05:59 -0500 | [diff] [blame] | 208 | #endif |
| 209 | |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 210 | #ifdef CONFIG_USB_XHCI_OMAP |
| 211 | /** |
| 212 | * @brief board_usb_init - Configure EVM board specific configurations |
| 213 | * for the LDO's and clocks for the USB blocks. |
| 214 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 215 | * Return: 0 |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 216 | */ |
Troy Kisky | 3135dba | 2013-10-22 14:27:17 -0700 | [diff] [blame] | 217 | int board_usb_init(int index, enum usb_init_type init) |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 218 | { |
| 219 | int ret; |
| 220 | #ifdef CONFIG_PALMAS_USB_SS_PWR |
| 221 | ret = palmas_enable_ss_ldo(); |
| 222 | #endif |
| 223 | |
Dan Murphy | d7fcc34 | 2013-08-26 08:54:53 -0500 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | #endif |