aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-10-10 15:38:14 -0400
committerTom Rini <trini@konsulko.com>2022-10-10 15:38:14 -0400
commitc4c32e359662aa95d9dbda2bd1272181bd9cb830 (patch)
tree69f549936a023bd2b1fada4343789ba779579570
parent2877e9ddca83180ec1e3567f6bab3ffc380e0b60 (diff)
parent5f7e01e9d5d8005e9a8fbbdf8a05dfd63a5e5f04 (diff)
downloadu-boot-WIP/10Oct2022.zip
u-boot-WIP/10Oct2022.tar.gz
u-boot-WIP/10Oct2022.tar.bz2
Merge https://source.denx.de/u-boot/custodians/u-boot-usbWIP/10Oct2022
-rw-r--r--cmd/fastboot.c2
-rw-r--r--common/usb_hub.c4
-rw-r--r--drivers/phy/phy-uclass.c42
-rw-r--r--drivers/usb/gadget/Makefile17
-rw-r--r--drivers/usb/gadget/f_fastboot.c1
-rw-r--r--drivers/usb/host/ehci-generic.c6
-rw-r--r--drivers/usb/host/ehci-hcd.c66
-rw-r--r--drivers/usb/host/ehci-msm.c4
-rw-r--r--drivers/usb/host/ehci-mx6.c6
-rw-r--r--drivers/usb/host/ehci-pci.c4
-rw-r--r--drivers/usb/host/ehci.h4
-rw-r--r--drivers/usb/host/ohci-generic.c56
-rw-r--r--include/generic-phy.h30
13 files changed, 97 insertions, 145 deletions
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index dd223b1..b498e4b 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -83,9 +83,9 @@ static int do_fastboot_usb(int argc, char *const argv[],
ret = CMD_RET_SUCCESS;
exit:
+ usb_gadget_release(controller_index);
g_dnl_unregister();
g_dnl_clear_detach();
- usb_gadget_release(controller_index);
return ret;
#else
diff --git a/common/usb_hub.c b/common/usb_hub.c
index d736389..95f1449 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -168,7 +168,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
int i;
struct usb_device *dev;
unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
- const char *env;
+ const char __maybe_unused *env;
dev = hub->pusb_dev;
@@ -193,10 +193,12 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
* but allow this time to be increased via env variable as some
* devices break the spec and require longer warm-up times
*/
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
env = env_get("usb_pgood_delay");
if (env)
pgood_delay = max(pgood_delay,
(unsigned)simple_strtol(env, NULL, 0));
+#endif
debug("pgood_delay=%dms\n", pgood_delay);
/*
diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 8b84da3..3fef513 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -455,6 +455,48 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
return ret;
}
+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
+{
+ int ret = 0;
+
+ if (!phy)
+ return 0;
+
+ ret = generic_phy_get_by_index(dev, index, phy);
+ if (ret) {
+ if (ret != -ENOENT)
+ return ret;
+ } else {
+ ret = generic_phy_init(phy);
+ if (ret)
+ return ret;
+
+ ret = generic_phy_power_on(phy);
+ if (ret)
+ ret = generic_phy_exit(phy);
+ }
+
+ return ret;
+}
+
+int generic_shutdown_phy(struct phy *phy)
+{
+ int ret = 0;
+
+ if (!phy)
+ return 0;
+
+ if (generic_phy_valid(phy)) {
+ ret = generic_phy_power_off(phy);
+ if (ret)
+ return ret;
+
+ ret = generic_phy_exit(phy);
+ }
+
+ return ret;
+}
+
UCLASS_DRIVER(phy) = {
.id = UCLASS_PHY,
.name = "phy",
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index dd09ee0..9c04403 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_USB_GADGET_DWC2_OTG) += dwc2_udc_otg.o
obj-$(CONFIG_USB_GADGET_DWC2_OTG_PHY) += dwc2_udc_otg_phy.o
obj-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
obj-$(CONFIG_USB_GADGET_MAX3420) += max3420_udc.o
-obj-$(CONFIG_CI_UDC) += ci_udc.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_USB_GADGET_DOWNLOAD) += g_dnl.o
obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
@@ -33,14 +32,12 @@ obj-$(CONFIG_USB_FUNCTION_ROCKUSB) += f_rockusb.o
obj-$(CONFIG_USB_FUNCTION_ACM) += f_acm.o
endif
endif
-ifdef CONFIG_USB_ETHER
-obj-y += ether.o
+
+obj-$(CONFIG_CI_UDC) += ci_udc.o
+
+obj-$(CONFIG_USB_ETHER) += ether.o
obj-$(CONFIG_USB_ETH_RNDIS) += rndis.o
-obj-$(CONFIG_CI_UDC) += ci_udc.o
-else
+
# Devices not related to the new gadget layer depend on CONFIG_USB_DEVICE
-ifdef CONFIG_USB_DEVICE
-obj-y += core.o
-obj-y += ep0.o
-endif
-endif
+# This is really only N900 and USBTTY now.
+obj-$(CONFIG_USB_DEVICE) += core.o ep0.o
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index d0e92c7..07b1681 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -544,6 +544,7 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
case FASTBOOT_COMMAND_REBOOT_RECOVERY:
fastboot_func->in_req->complete = compl_do_reset;
+ g_dnl_trigger_detach();
break;
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
case FASTBOOT_COMMAND_ACMD:
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 75c73bf..a765a30 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -96,7 +96,7 @@ static int ehci_usb_probe(struct udevice *dev)
if (err)
goto reset_err;
- err = ehci_setup_phy(dev, &priv->phy, 0);
+ err = generic_setup_phy(dev, &priv->phy, 0);
if (err)
goto regulator_err;
@@ -111,7 +111,7 @@ static int ehci_usb_probe(struct udevice *dev)
return 0;
phy_err:
- ret = ehci_shutdown_phy(dev, &priv->phy);
+ ret = generic_shutdown_phy(&priv->phy);
if (ret)
dev_err(dev, "failed to shutdown usb phy (ret=%d)\n", ret);
@@ -141,7 +141,7 @@ static int ehci_usb_remove(struct udevice *dev)
if (ret)
return ret;
- ret = ehci_shutdown_phy(dev, &priv->phy);
+ ret = generic_shutdown_phy(&priv->phy);
if (ret)
return ret;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d30f2a0..9139d61 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1767,69 +1767,3 @@ struct dm_usb_ops ehci_usb_ops = {
};
#endif
-
-#ifdef CONFIG_PHY
-int ehci_setup_phy(struct udevice *dev, struct phy *phy, int index)
-{
- int ret;
-
- if (!phy)
- return 0;
-
- ret = generic_phy_get_by_index(dev, index, phy);
- if (ret) {
- if (ret != -ENOENT) {
- dev_err(dev, "failed to get usb phy\n");
- return ret;
- }
- } else {
- ret = generic_phy_init(phy);
- if (ret) {
- dev_dbg(dev, "failed to init usb phy\n");
- return ret;
- }
-
- ret = generic_phy_power_on(phy);
- if (ret) {
- dev_dbg(dev, "failed to power on usb phy\n");
- return generic_phy_exit(phy);
- }
- }
-
- return 0;
-}
-
-int ehci_shutdown_phy(struct udevice *dev, struct phy *phy)
-{
- int ret = 0;
-
- if (!phy)
- return 0;
-
- if (generic_phy_valid(phy)) {
- ret = generic_phy_power_off(phy);
- if (ret) {
- dev_dbg(dev, "failed to power off usb phy\n");
- return ret;
- }
-
- ret = generic_phy_exit(phy);
- if (ret) {
- dev_dbg(dev, "failed to power off usb phy\n");
- return ret;
- }
- }
-
- return 0;
-}
-#else
-int ehci_setup_phy(struct udevice *dev, struct phy *phy, int index)
-{
- return 0;
-}
-
-int ehci_shutdown_phy(struct udevice *dev, struct phy *phy)
-{
- return 0;
-}
-#endif
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index d160cf0..dd0d153 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -56,7 +56,7 @@ static int ehci_usb_probe(struct udevice *dev)
hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
- ret = ehci_setup_phy(dev, &p->phy, 0);
+ ret = generic_setup_phy(dev, &p->phy, 0);
if (ret)
return ret;
@@ -81,7 +81,7 @@ static int ehci_usb_remove(struct udevice *dev)
/* Stop controller. */
clrbits_le32(&ehci->usbcmd, CMD_RUN);
- ret = ehci_shutdown_phy(dev, &p->phy);
+ ret = generic_shutdown_phy(&p->phy);
if (ret)
return ret;
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index e30449b..fa2ca2a 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -726,7 +726,7 @@ static int ehci_usb_probe(struct udevice *dev)
mdelay(10);
#if defined(CONFIG_PHY)
- ret = ehci_setup_phy(dev, &priv->phy, 0);
+ ret = generic_setup_phy(dev, &priv->phy, 0);
if (ret)
goto err_regulator;
#endif
@@ -743,7 +743,7 @@ static int ehci_usb_probe(struct udevice *dev)
err_phy:
#if defined(CONFIG_PHY)
- ehci_shutdown_phy(dev, &priv->phy);
+ generic_shutdown_phy(&priv->phy);
err_regulator:
#endif
#if CONFIG_IS_ENABLED(DM_REGULATOR)
@@ -767,7 +767,7 @@ int ehci_usb_remove(struct udevice *dev)
ehci_deregister(dev);
#if defined(CONFIG_PHY)
- ehci_shutdown_phy(dev, &priv->phy);
+ generic_shutdown_phy(&priv->phy);
#endif
#if CONFIG_IS_ENABLED(DM_REGULATOR)
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 1ab3061..e98ab31 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -31,7 +31,7 @@ static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
int ret;
u32 cmd;
- ret = ehci_setup_phy(dev, &priv->phy, 0);
+ ret = generic_setup_phy(dev, &priv->phy, 0);
if (ret)
return ret;
@@ -149,7 +149,7 @@ static int ehci_pci_remove(struct udevice *dev)
if (ret)
return ret;
- return ehci_shutdown_phy(dev, &priv->phy);
+ return generic_shutdown_phy(&priv->phy);
}
static const struct udevice_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 5170044..5770d35 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -295,9 +295,5 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
int ehci_deregister(struct udevice *dev);
extern struct dm_usb_ops ehci_usb_ops;
-/* EHCI PHY functions */
-int ehci_setup_phy(struct udevice *dev, struct phy *phy, int index);
-int ehci_shutdown_phy(struct udevice *dev, struct phy *phy);
-
#include <linux/bitops.h>
#endif /* USB_EHCI_H */
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 5d23058..2d8d38c 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -23,56 +23,6 @@ struct generic_ohci {
int reset_count; /* number of reset in reset list */
};
-static int ohci_setup_phy(struct udevice *dev, int index)
-{
- struct generic_ohci *priv = dev_get_priv(dev);
- int ret;
-
- ret = generic_phy_get_by_index(dev, index, &priv->phy);
- if (ret) {
- if (ret != -ENOENT) {
- dev_err(dev, "failed to get usb phy\n");
- return ret;
- }
- } else {
- ret = generic_phy_init(&priv->phy);
- if (ret) {
- dev_dbg(dev, "failed to init usb phy\n");
- return ret;
- }
-
- ret = generic_phy_power_on(&priv->phy);
- if (ret) {
- dev_dbg(dev, "failed to power on usb phy\n");
- return generic_phy_exit(&priv->phy);
- }
- }
-
- return 0;
-}
-
-static int ohci_shutdown_phy(struct udevice *dev)
-{
- struct generic_ohci *priv = dev_get_priv(dev);
- int ret = 0;
-
- if (generic_phy_valid(&priv->phy)) {
- ret = generic_phy_power_off(&priv->phy);
- if (ret) {
- dev_dbg(dev, "failed to power off usb phy\n");
- return ret;
- }
-
- ret = generic_phy_exit(&priv->phy);
- if (ret) {
- dev_dbg(dev, "failed to power off usb phy\n");
- return ret;
- }
- }
-
- return 0;
-}
-
static int ohci_usb_probe(struct udevice *dev)
{
struct ohci_regs *regs = dev_read_addr_ptr(dev);
@@ -135,7 +85,7 @@ static int ohci_usb_probe(struct udevice *dev)
goto clk_err;
}
- err = ohci_setup_phy(dev, 0);
+ err = generic_setup_phy(dev, &priv->phy, 0);
if (err)
goto reset_err;
@@ -146,7 +96,7 @@ static int ohci_usb_probe(struct udevice *dev)
return 0;
phy_err:
- ret = ohci_shutdown_phy(dev);
+ ret = generic_shutdown_phy(&priv->phy);
if (ret)
dev_err(dev, "failed to shutdown usb phy\n");
@@ -171,7 +121,7 @@ static int ohci_usb_remove(struct udevice *dev)
if (ret)
return ret;
- ret = ohci_shutdown_phy(dev);
+ ret = generic_shutdown_phy(&priv->phy);
if (ret)
return ret;
diff --git a/include/generic-phy.h b/include/generic-phy.h
index d40ce58..f8eddef 100644
--- a/include/generic-phy.h
+++ b/include/generic-phy.h
@@ -342,6 +342,26 @@ int generic_phy_power_on_bulk(struct phy_bulk *bulk);
*/
int generic_phy_power_off_bulk(struct phy_bulk *bulk);
+/**
+ * generic_setup_phy() - Get, initialize and power on phy.
+ *
+ * @dev: The consumer device.
+ * @phy: A pointer to the PHY port
+ * @index: The index in the list of available PHYs
+ *
+ * Return: 0 if OK, or negative error code.
+ */
+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index);
+
+/**
+ * generic_shutdown_phy() - Power off and de-initialize phy.
+ *
+ * @phy: A pointer to the PHY port.
+ *
+ * Return: 0 if OK, or negative error code.
+ */
+int generic_shutdown_phy(struct phy *phy);
+
#else /* CONFIG_PHY */
static inline int generic_phy_init(struct phy *phy)
@@ -407,6 +427,16 @@ static inline int generic_phy_power_off_bulk(struct phy_bulk *bulk)
return 0;
}
+static inline int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
+{
+ return 0;
+}
+
+static inline int generic_shutdown_phy(struct phy *phy)
+{
+ return 0;
+}
+
#endif /* CONFIG_PHY */
/**