diff options
author | Tom Rini <trini@konsulko.com> | 2020-05-22 22:58:50 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-22 22:58:50 -0400 |
commit | 9c5fef577494769e3ff07952a85f9b7125ef765b (patch) | |
tree | 15d2ebcabd76b0644b931da010983f917e43c7f9 | |
parent | 5b6b2c6bf8ad14af32f489acaaba0d44ddfc41f3 (diff) | |
parent | 2cff87f7abf060dda00302680f051d5e9ce60ab9 (diff) | |
download | u-boot-9c5fef577494769e3ff07952a85f9b7125ef765b.zip u-boot-9c5fef577494769e3ff07952a85f9b7125ef765b.tar.gz u-boot-9c5fef577494769e3ff07952a85f9b7125ef765b.tar.bz2 |
Merge git://git.denx.de/u-boot-usb
- DM support for OMAP
- DWC3 fix
- Typo fix in eth/r8152
-rw-r--r-- | arch/arm/include/asm/ehci-omap.h | 2 | ||||
-rw-r--r-- | drivers/usb/eth/r8152.c | 8 | ||||
-rw-r--r-- | drivers/usb/eth/r8152.h | 4 | ||||
-rw-r--r-- | drivers/usb/host/ehci-omap.c | 123 | ||||
-rw-r--r-- | drivers/usb/host/xhci-dwc3.c | 6 |
5 files changed, 131 insertions, 12 deletions
diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h index 1549f7b..f970bba 100644 --- a/arch/arm/include/asm/ehci-omap.h +++ b/arch/arm/include/asm/ehci-omap.h @@ -123,6 +123,7 @@ struct omap_ehci { u32 insreg08; /* 0xb0 */ }; +#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL) /* * FIXME: forward declaration of this structs needed because omap got the * ehci implementation backwards. move out ehci_hcd_x from board files @@ -133,5 +134,6 @@ struct ehci_hcor; int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, struct ehci_hccr **hccr, struct ehci_hcor **hcor); int omap_ehci_hcd_stop(void); +#endif #endif /* _OMAP_COMMON_EHCI_H_ */ diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c index 61b8683..d9908ec 100644 --- a/drivers/usb/eth/r8152.c +++ b/drivers/usb/eth/r8152.c @@ -711,9 +711,9 @@ static void r8152b_enter_oob(struct r8152 *tp) rtl_rx_vlan_en(tp, false); - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_BDC_CR); ocp_data |= ALDPS_PROXY_MODE; - ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BDC_CR, ocp_data); ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; @@ -844,9 +844,9 @@ static void r8153_enter_oob(struct r8152 *tp) rtl_rx_vlan_en(tp, false); - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_BDC_CR); ocp_data |= ALDPS_PROXY_MODE; - ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_BDC_CR, ocp_data); ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; diff --git a/drivers/usb/eth/r8152.h b/drivers/usb/eth/r8152.h index 09f1c61..c7f62b8 100644 --- a/drivers/usb/eth/r8152.h +++ b/drivers/usb/eth/r8152.h @@ -22,7 +22,7 @@ #define PLA_TEREDO_CFG 0xc0bc #define PLA_MAR 0xcd00 #define PLA_BACKUP 0xd000 -#define PAL_BDC_CR 0xd1a0 +#define PLA_BDC_CR 0xd1a0 #define PLA_TEREDO_TIMER 0xd2cc #define PLA_REALWOW_TIMER 0xd2e8 #define PLA_LEDSEL 0xdd90 @@ -225,7 +225,7 @@ #define TEREDO_RS_EVENT_MASK 0x00fe #define OOB_TEREDO_EN 0x0001 -/* PAL_BDC_CR */ +/* PLA_BDC_CR */ #define ALDPS_PROXY_MODE 0x0001 /* PLA_CONFIG34 */ diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 5fee537..93ab839 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -20,6 +20,10 @@ #include <asm/gpio.h> #include <asm/arch/ehci.h> #include <asm/ehci-omap.h> +#include <dm.h> +#include <dm/device-internal.h> +#include <dm/lists.h> +#include <power/regulator.h> #include "ehci.h" @@ -179,9 +183,17 @@ int omap_ehci_hcd_stop(void) * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 * See there for additional Copyrights. */ +#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL) + int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { + *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE); + *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10); +#else +int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata) +{ +#endif int ret; unsigned int i, reg = 0, rev = 0; @@ -288,9 +300,114 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, if (is_ehci_phy_mode(usbhs_pdata->port_mode[i])) omap_ehci_soft_phy_reset(i); - *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE); - *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10); - debug("OMAP EHCI init done\n"); return 0; } + +#if CONFIG_IS_ENABLED(DM_USB) + +static struct omap_usbhs_board_data usbhs_bdata = { + .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, + .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, + .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, +}; + +static void omap_usbhs_set_mode(u8 index, const char *mode) +{ + if (!strcmp(mode, "ehci-phy")) + usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_PHY; + else if (!strcmp(mode, "ehci-tll")) + usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_TLL; + else if (!strcmp(mode, "ehci-hsic")) + usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_HSIC; +} + +static int omap_usbhs_probe(struct udevice *dev) +{ + u8 i; + const char *mode; + char prop[11]; + + /* Go through each port portX-mode to determing phy mode */ + for (i = 0; i < OMAP_HS_USB_PORTS; i++) { + snprintf(prop, sizeof(prop), "port%d-mode", i + 1); + mode = dev_read_string(dev, prop); + + /* If the portX-mode exists, set the mode */ + if (mode) + omap_usbhs_set_mode(i, mode); + } + + return omap_ehci_hcd_init(0, &usbhs_bdata); +} + +static const struct udevice_id omap_usbhs_dt_ids[] = { + { .compatible = "ti,usbhs-host" }, + { } +}; + +U_BOOT_DRIVER(usb_omaphs_host) = { + .name = "usbhs-host", + .id = UCLASS_SIMPLE_BUS, + .of_match = omap_usbhs_dt_ids, + .probe = omap_usbhs_probe, + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; + +struct ehci_omap_priv_data { + struct ehci_ctrl ctrl; + struct omap_ehci *ehci; +#ifdef CONFIG_DM_REGULATOR + struct udevice *vbus_supply; +#endif + enum usb_init_type init_type; + int portnr; + struct phy phy[OMAP_HS_USB_PORTS]; + int nports; +}; + +static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + + plat->init_type = USB_INIT_HOST; + + return 0; +} + +static int omap_ehci_probe(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + struct ehci_omap_priv_data *priv = dev_get_priv(dev); + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; + + priv->ehci = (struct omap_ehci *)devfdt_get_addr(dev); + priv->portnr = dev->seq; + priv->init_type = plat->init_type; + + hccr = (struct ehci_hccr *)&priv->ehci->hccapbase; + hcor = (struct ehci_hcor *)&priv->ehci->usbcmd; + + return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST); +} + +static const struct udevice_id omap_ehci_dt_ids[] = { + { .compatible = "ti,ehci-omap" }, + { } +}; + +U_BOOT_DRIVER(usb_omap_ehci) = { + .name = "omap-ehci", + .id = UCLASS_USB, + .of_match = omap_ehci_dt_ids, + .probe = omap_ehci_probe, + .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ehci_omap_priv_data), + .remove = ehci_deregister, + .ops = &ehci_usb_ops, + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; + +#endif diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index cf72f02..27f8410 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -21,7 +21,7 @@ #include <linux/usb/otg.h> struct xhci_dwc3_platdata { - struct phy_bulk *usb_phys; + struct phy_bulk phys; }; void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode) @@ -126,7 +126,7 @@ static int xhci_dwc3_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uintptr_t)hccr + HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); - ret = dwc3_setup_phy(dev, plat->usb_phys); + ret = dwc3_setup_phy(dev, &plat->phys); if (ret && (ret != -ENOTSUPP)) return ret; @@ -169,7 +169,7 @@ static int xhci_dwc3_remove(struct udevice *dev) { struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); - dwc3_shutdown_phy(dev, plat->usb_phys); + dwc3_shutdown_phy(dev, &plat->phys); return xhci_deregister(dev); } |