This commit is contained in:
commit
c4c32e3596
13 changed files with 97 additions and 145 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
/*
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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[] = {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue