Merge branch 'master' of git://git.denx.de/u-boot-usb
This commit is contained in:
commit
1b74e9ce50
|
|
@ -15,6 +15,7 @@
|
||||||
#include <wait_bit.h>
|
#include <wait_bit.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <power/regulator.h>
|
#include <power/regulator.h>
|
||||||
|
#include <reset.h>
|
||||||
|
|
||||||
#include "dwc2.h"
|
#include "dwc2.h"
|
||||||
|
|
||||||
|
|
@ -49,6 +50,8 @@ struct dwc2_priv {
|
||||||
*/
|
*/
|
||||||
bool hnp_srp_disable;
|
bool hnp_srp_disable;
|
||||||
bool oc_disable;
|
bool oc_disable;
|
||||||
|
|
||||||
|
struct reset_ctl_bulk resets;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef CONFIG_DM_USB
|
#ifndef CONFIG_DM_USB
|
||||||
|
|
@ -1124,11 +1127,43 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dwc2_reset(struct udevice *dev)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct dwc2_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
|
ret = reset_get_bulk(dev, &priv->resets);
|
||||||
|
if (ret) {
|
||||||
|
dev_warn(dev, "Can't get reset: %d\n", ret);
|
||||||
|
/* Return 0 if error due to !CONFIG_DM_RESET and reset
|
||||||
|
* DT property is not present.
|
||||||
|
*/
|
||||||
|
if (ret == -ENOENT || ret == -ENOTSUPP)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = reset_deassert_bulk(&priv->resets);
|
||||||
|
if (ret) {
|
||||||
|
reset_release_bulk(&priv->resets);
|
||||||
|
dev_err(dev, "Failed to reset: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
|
static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
|
||||||
{
|
{
|
||||||
struct dwc2_core_regs *regs = priv->regs;
|
struct dwc2_core_regs *regs = priv->regs;
|
||||||
uint32_t snpsid;
|
uint32_t snpsid;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = dwc2_reset(dev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
snpsid = readl(®s->gsnpsid);
|
snpsid = readl(®s->gsnpsid);
|
||||||
dev_info(dev, "Core Release: %x.%03x\n",
|
dev_info(dev, "Core Release: %x.%03x\n",
|
||||||
|
|
@ -1303,6 +1338,8 @@ static int dwc2_usb_remove(struct udevice *dev)
|
||||||
|
|
||||||
dwc2_uninit_common(priv->regs);
|
dwc2_uninit_common(priv->regs);
|
||||||
|
|
||||||
|
reset_release_bulk(&priv->resets);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,56 +26,6 @@ struct generic_ehci {
|
||||||
int reset_count;
|
int reset_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ehci_setup_phy(struct udevice *dev, int index)
|
|
||||||
{
|
|
||||||
struct generic_ehci *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_err(dev, "failed to init usb phy\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = generic_phy_power_on(&priv->phy);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "failed to power on usb phy\n");
|
|
||||||
return generic_phy_exit(&priv->phy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ehci_shutdown_phy(struct udevice *dev)
|
|
||||||
{
|
|
||||||
struct generic_ehci *priv = dev_get_priv(dev);
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (generic_phy_valid(&priv->phy)) {
|
|
||||||
ret = generic_phy_power_off(&priv->phy);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "failed to power off usb phy\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = generic_phy_exit(&priv->phy);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "failed to power off usb phy\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ehci_usb_probe(struct udevice *dev)
|
static int ehci_usb_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct generic_ehci *priv = dev_get_priv(dev);
|
struct generic_ehci *priv = dev_get_priv(dev);
|
||||||
|
|
@ -145,7 +95,7 @@ static int ehci_usb_probe(struct udevice *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ehci_setup_phy(dev, 0);
|
err = ehci_setup_phy(dev, &priv->phy, 0);
|
||||||
if (err)
|
if (err)
|
||||||
goto reset_err;
|
goto reset_err;
|
||||||
|
|
||||||
|
|
@ -160,7 +110,7 @@ static int ehci_usb_probe(struct udevice *dev)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
phy_err:
|
phy_err:
|
||||||
ret = ehci_shutdown_phy(dev);
|
ret = ehci_shutdown_phy(dev, &priv->phy);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(dev, "failed to shutdown usb phy\n");
|
dev_err(dev, "failed to shutdown usb phy\n");
|
||||||
|
|
||||||
|
|
@ -185,7 +135,7 @@ static int ehci_usb_remove(struct udevice *dev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = ehci_shutdown_phy(dev);
|
ret = ehci_shutdown_phy(dev, &priv->phy);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1675,3 +1675,69 @@ struct dm_usb_ops ehci_usb_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#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_err(dev, "failed to init usb phy\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = generic_phy_power_on(phy);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(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_err(dev, "failed to power off usb phy\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = generic_phy_exit(phy);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(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
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,23 @@
|
||||||
/* Information about a USB port */
|
/* Information about a USB port */
|
||||||
struct ehci_pci_priv {
|
struct ehci_pci_priv {
|
||||||
struct ehci_ctrl ehci;
|
struct ehci_ctrl ehci;
|
||||||
|
struct phy phy;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_DM_USB
|
#ifdef CONFIG_DM_USB
|
||||||
|
static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
|
||||||
static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
|
|
||||||
struct ehci_hcor **ret_hcor)
|
struct ehci_hcor **ret_hcor)
|
||||||
{
|
{
|
||||||
|
struct ehci_pci_priv *priv = dev_get_priv(dev);
|
||||||
struct ehci_hccr *hccr;
|
struct ehci_hccr *hccr;
|
||||||
struct ehci_hcor *hcor;
|
struct ehci_hcor *hcor;
|
||||||
|
int ret;
|
||||||
u32 cmd;
|
u32 cmd;
|
||||||
|
|
||||||
|
ret = ehci_setup_phy(dev, &priv->phy, 0);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
hccr = (struct ehci_hccr *)dm_pci_map_bar(dev,
|
hccr = (struct ehci_hccr *)dm_pci_map_bar(dev,
|
||||||
PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
|
PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
|
||||||
hcor = (struct ehci_hcor *)((uintptr_t) hccr +
|
hcor = (struct ehci_hcor *)((uintptr_t) hccr +
|
||||||
|
|
@ -43,6 +49,8 @@ static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
|
||||||
dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
|
dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
|
||||||
cmd |= PCI_COMMAND_MASTER;
|
cmd |= PCI_COMMAND_MASTER;
|
||||||
dm_pci_write_config32(dev, PCI_COMMAND, cmd);
|
dm_pci_write_config32(dev, PCI_COMMAND, cmd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
@ -120,12 +128,27 @@ static int ehci_pci_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct ehci_hccr *hccr;
|
struct ehci_hccr *hccr;
|
||||||
struct ehci_hcor *hcor;
|
struct ehci_hcor *hcor;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ehci_pci_init(dev, &hccr, &hcor);
|
ret = ehci_pci_init(dev, &hccr, &hcor);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
|
return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ehci_pci_remove(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct ehci_pci_priv *priv = dev_get_priv(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = ehci_deregister(dev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return ehci_shutdown_phy(dev, &priv->phy);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct udevice_id ehci_pci_ids[] = {
|
static const struct udevice_id ehci_pci_ids[] = {
|
||||||
{ .compatible = "ehci-pci" },
|
{ .compatible = "ehci-pci" },
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -135,7 +158,7 @@ U_BOOT_DRIVER(ehci_pci) = {
|
||||||
.name = "ehci_pci",
|
.name = "ehci_pci",
|
||||||
.id = UCLASS_USB,
|
.id = UCLASS_USB,
|
||||||
.probe = ehci_pci_probe,
|
.probe = ehci_pci_probe,
|
||||||
.remove = ehci_deregister,
|
.remove = ehci_pci_remove,
|
||||||
.of_match = ehci_pci_ids,
|
.of_match = ehci_pci_ids,
|
||||||
.ops = &ehci_usb_ops,
|
.ops = &ehci_usb_ops,
|
||||||
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
|
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#define USB_EHCI_H
|
#define USB_EHCI_H
|
||||||
|
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
|
#include <generic-phy.h>
|
||||||
|
|
||||||
/* Section 2.2.3 - N_PORTS */
|
/* Section 2.2.3 - N_PORTS */
|
||||||
#define MAX_HC_PORTS 15
|
#define MAX_HC_PORTS 15
|
||||||
|
|
@ -288,4 +289,8 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
|
||||||
int ehci_deregister(struct udevice *dev);
|
int ehci_deregister(struct udevice *dev);
|
||||||
extern struct dm_usb_ops ehci_usb_ops;
|
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);
|
||||||
|
|
||||||
#endif /* USB_EHCI_H */
|
#endif /* USB_EHCI_H */
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef __GENERIC_PHY_H
|
#ifndef __GENERIC_PHY_H
|
||||||
#define __GENERIC_PHY_H
|
#define __GENERIC_PHY_H
|
||||||
|
|
||||||
|
struct ofnode_phandle_args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct phy - A handle to (allowing control of) a single phy port.
|
* struct phy - A handle to (allowing control of) a single phy port.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue