blob: 4777622156b86ec72c9ce378db98e8bffd101bf7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sricharan9310ff72011-11-15 09:49:55 -05002/*
3 * (C) Copyright 2010
4 * Texas Instruments Incorporated, <www.ti.com>
5 * Aneesh V <aneesh@ti.com>
6 * Steve Sakoman <steve@sakoman.com>
Sricharan9310ff72011-11-15 09:49:55 -05007 */
8#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060010#include <net.h>
Nishanth Menon627612c2013-03-26 05:20:54 +000011#include <palmas.h>
Kishon Vijay Abraham I5a3e0622015-08-19 14:13:20 +053012#include <asm/arch/omap.h>
Sricharan9310ff72011-11-15 09:49:55 -050013#include <asm/arch/sys_proto.h>
14#include <asm/arch/mmc_host_def.h>
Tero Kristof6c7fda2020-06-16 11:03:10 +030015#include <serial.h>
Dan Murphy05d5f992013-07-11 13:10:28 -050016#include <tca642x.h>
Kishon Vijay Abraham I5a3e0622015-08-19 14:13:20 +053017#include <usb.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Simon Glassdbd79542020-05-10 11:40:11 -060019#include <linux/delay.h>
Kishon Vijay Abraham I5a3e0622015-08-19 14:13:20 +053020#include <linux/usb/gadget.h>
21#include <dwc3-uboot.h>
22#include <dwc3-omap-uboot.h>
23#include <ti-usb-phy-uboot.h>
Sricharan9310ff72011-11-15 09:49:55 -050024
25#include "mux_data.h"
26
Tom Riniceed5d22017-05-12 22:33:27 -040027#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_XHCI_OMAP)
Dan Murphy57f29ab2014-02-03 06:59:02 -060028#include <sata.h>
Dan Murphy29d04b52013-08-01 14:05:59 -050029#include <usb.h>
Dan Murphydc649b32013-08-01 14:06:02 -050030#include <asm/gpio.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060031#include <asm/mach-types.h>
Dan Murphy29d04b52013-08-01 14:05:59 -050032#include <asm/arch/clock.h>
33#include <asm/arch/ehci.h>
34#include <asm/ehci-omap.h>
Roger Quadrosd88ab9c2013-11-11 16:56:42 +020035#include <asm/arch/sata.h>
Dan Murphy0a1df4f2013-08-01 14:06:00 -050036
37#define DIE_ID_REG_BASE (OMAP54XX_L4_CORE_BASE + 0x2000)
38#define DIE_ID_REG_OFFSET 0x200
39
Dan Murphy29d04b52013-08-01 14:05:59 -050040#endif
41
Sricharan9310ff72011-11-15 09:49:55 -050042DECLARE_GLOBAL_DATA_PTR;
43
44const struct omap_sysinfo sysinfo = {
Dan Murphy3713e9d2013-08-01 14:05:56 -050045 "Board: OMAP5432 uEVM\n"
Sricharan9310ff72011-11-15 09:49:55 -050046};
47
48/**
Dan Murphy05d5f992013-07-11 13:10:28 -050049 * @brief tca642x_init - uEVM default values for the GPIO expander
50 * input reg, output reg, polarity reg, configuration reg
51 */
52struct 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 I5a3e0622015-08-19 14:13:20 +053067#ifdef CONFIG_USB_DWC3
68static 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
75static 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
81static 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
88int 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 I831bcba2015-08-19 16:16:27 +0530103 enable_usb_clocks(index);
Kishon Vijay Abraham I5a3e0622015-08-19 14:13:20 +0530104 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
111int 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 I831bcba2015-08-19 16:16:27 +0530121 disable_usb_clocks(index);
Kishon Vijay Abraham I5a3e0622015-08-19 14:13:20 +0530122
123 return 0;
124}
125
126int 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 Murphy05d5f992013-07-11 13:10:28 -0500138/**
Sricharan9310ff72011-11-15 09:49:55 -0500139 * @brief board_init
140 *
141 * @return 0
142 */
143int board_init(void)
144{
145 gpmc_init();
Tom Rini48157342017-01-25 20:42:35 -0500146 gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
Sricharan9310ff72011-11-15 09:49:55 -0500147 gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
148
Dan Murphy05d5f992013-07-11 13:10:28 -0500149 tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
150
Sricharan9310ff72011-11-15 09:49:55 -0500151 return 0;
152}
153
Tero Kristof6c7fda2020-06-16 11:03:10 +0300154#if defined(CONFIG_SPL_OS_BOOT)
155int spl_start_uboot(void)
Sricharan9310ff72011-11-15 09:49:55 -0500156{
Tero Kristof6c7fda2020-06-16 11:03:10 +0300157 /* break into full u-boot on 'c' */
158 if (serial_tstc() && serial_getc() == 'c')
159 return 1;
160
Sricharan9310ff72011-11-15 09:49:55 -0500161 return 0;
162}
Tero Kristof6c7fda2020-06-16 11:03:10 +0300163#endif /* CONFIG_SPL_OS_BOOT */
Sricharan9310ff72011-11-15 09:49:55 -0500164
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900165int board_eth_init(struct bd_info *bis)
Dan Murphyd7fcc342013-08-26 08:54:53 -0500166{
Tero Kristof6c7fda2020-06-16 11:03:10 +0300167 return 0;
Dan Murphyd7fcc342013-08-26 08:54:53 -0500168}
Dan Murphyd7fcc342013-08-26 08:54:53 -0500169
Sricharan9310ff72011-11-15 09:49:55 -0500170/**
171 * @brief misc_init_r - Configure EVM board specific configurations
172 * such as power configurations, ethernet initialization as phase2 of
173 * boot sequence
174 *
175 * @return 0
176 */
177int misc_init_r(void)
178{
Nishanth Menon627612c2013-03-26 05:20:54 +0000179#ifdef CONFIG_PALMAS_POWER
Nishanth Menonaa4f8362013-03-26 05:20:55 +0000180 palmas_init_settings();
Sricharan9310ff72011-11-15 09:49:55 -0500181#endif
Dan Murphyd7fcc342013-08-26 08:54:53 -0500182
Paul Kocialkowski2edadee2015-08-27 19:37:12 +0200183 omap_die_id_usbethaddr();
Dan Murphy2870a242013-10-11 12:28:19 -0500184
Sricharan9310ff72011-11-15 09:49:55 -0500185 return 0;
186}
187
Paul Kocialkowskia00b1e52016-02-27 19:18:56 +0100188void set_muxconf_regs(void)
Sricharan9310ff72011-11-15 09:49:55 -0500189{
Lokesh Vutla37bce592013-05-30 02:54:30 +0000190 do_set_mux((*ctrl)->control_padconf_core_base,
191 core_padconf_array_essential,
Sricharan9310ff72011-11-15 09:49:55 -0500192 sizeof(core_padconf_array_essential) /
193 sizeof(struct pad_conf_entry));
194
Lokesh Vutla37bce592013-05-30 02:54:30 +0000195 do_set_mux((*ctrl)->control_padconf_wkup_base,
196 wkup_padconf_array_essential,
Sricharan9310ff72011-11-15 09:49:55 -0500197 sizeof(wkup_padconf_array_essential) /
198 sizeof(struct pad_conf_entry));
199}
200
Masahiro Yamada0a780172017-05-09 20:31:39 +0900201#if defined(CONFIG_MMC)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900202int board_mmc_init(struct bd_info *bis)
Sricharan9310ff72011-11-15 09:49:55 -0500203{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000204 omap_mmc_init(0, 0, 0, -1, -1);
205 omap_mmc_init(1, 0, 0, -1, -1);
Sricharan9310ff72011-11-15 09:49:55 -0500206 return 0;
207}
Dan Murphy29d04b52013-08-01 14:05:59 -0500208#endif
209
Dan Murphyd7fcc342013-08-26 08:54:53 -0500210#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 *
215 * @return 0
216 */
Troy Kisky3135dba2013-10-22 14:27:17 -0700217int board_usb_init(int index, enum usb_init_type init)
Dan Murphyd7fcc342013-08-26 08:54:53 -0500218{
219 int ret;
220#ifdef CONFIG_PALMAS_USB_SS_PWR
221 ret = palmas_enable_ss_ldo();
222#endif
223
Dan Murphyd7fcc342013-08-26 08:54:53 -0500224 return 0;
225}
226#endif