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