2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-04-25 10:21:04 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2014, Xilinx, Inc
|
|
|
|
*
|
|
|
|
* USB Low level initialization(Specific to zynq)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2016-07-05 23:10:14 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <usb.h>
|
2014-04-25 10:21:04 +00:00
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/io.h>
|
2016-03-31 21:12:23 +00:00
|
|
|
#include <usb/ehci-ci.h>
|
2014-04-25 10:21:04 +00:00
|
|
|
#include <usb/ulpi.h>
|
|
|
|
|
|
|
|
#include "ehci.h"
|
|
|
|
|
2016-07-05 23:10:14 +00:00
|
|
|
struct zynq_ehci_priv {
|
|
|
|
struct ehci_ctrl ehcictrl;
|
|
|
|
struct usb_ehci *ehci;
|
|
|
|
};
|
2014-04-25 10:21:04 +00:00
|
|
|
|
2020-12-03 23:55:21 +00:00
|
|
|
static int ehci_zynq_of_to_plat(struct udevice *dev)
|
2014-04-25 10:21:04 +00:00
|
|
|
{
|
2016-07-05 23:10:14 +00:00
|
|
|
struct zynq_ehci_priv *priv = dev_get_priv(dev);
|
|
|
|
|
2020-08-04 05:14:43 +00:00
|
|
|
priv->ehci = dev_read_addr_ptr(dev);
|
2016-07-05 23:10:14 +00:00
|
|
|
if (!priv->ehci)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ehci_zynq_probe(struct udevice *dev)
|
|
|
|
{
|
2020-12-03 23:55:23 +00:00
|
|
|
struct usb_plat *plat = dev_get_plat(dev);
|
2016-07-05 23:10:14 +00:00
|
|
|
struct zynq_ehci_priv *priv = dev_get_priv(dev);
|
|
|
|
struct ehci_hccr *hccr;
|
|
|
|
struct ehci_hcor *hcor;
|
2014-04-25 10:21:04 +00:00
|
|
|
struct ulpi_viewport ulpi_vp;
|
|
|
|
/* Used for writing the ULPI data address */
|
|
|
|
struct ulpi_regs *ulpi = (struct ulpi_regs *)0;
|
2016-07-05 23:10:14 +00:00
|
|
|
int ret;
|
2014-04-25 10:21:04 +00:00
|
|
|
|
2016-07-05 23:10:14 +00:00
|
|
|
hccr = (struct ehci_hccr *)((uint32_t)&priv->ehci->caplength);
|
|
|
|
hcor = (struct ehci_hcor *)((uint32_t) hccr +
|
|
|
|
HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
|
2014-04-25 10:21:04 +00:00
|
|
|
|
2016-07-05 23:10:14 +00:00
|
|
|
ulpi_vp.viewport_addr = (u32)&priv->ehci->ulpi_viewpoint;
|
2014-04-25 10:21:04 +00:00
|
|
|
ulpi_vp.port_num = 0;
|
|
|
|
|
|
|
|
ret = ulpi_init(&ulpi_vp);
|
|
|
|
if (ret) {
|
|
|
|
puts("zynq ULPI viewport init failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ULPI set flags */
|
|
|
|
ulpi_write(&ulpi_vp, &ulpi->otg_ctrl,
|
|
|
|
ULPI_OTG_DP_PULLDOWN | ULPI_OTG_DM_PULLDOWN |
|
|
|
|
ULPI_OTG_EXTVBUSIND);
|
|
|
|
ulpi_write(&ulpi_vp, &ulpi->function_ctrl,
|
|
|
|
ULPI_FC_FULL_SPEED | ULPI_FC_OPMODE_NORMAL |
|
|
|
|
ULPI_FC_SUSPENDM);
|
|
|
|
ulpi_write(&ulpi_vp, &ulpi->iface_ctrl, 0);
|
|
|
|
|
|
|
|
/* Set VBus */
|
|
|
|
ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set,
|
|
|
|
ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
|
|
|
|
|
2016-07-05 23:10:14 +00:00
|
|
|
return ehci_register(dev, hccr, hcor, NULL, 0, plat->init_type);
|
2014-04-25 10:21:04 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 23:10:14 +00:00
|
|
|
static const struct udevice_id ehci_zynq_ids[] = {
|
|
|
|
{ .compatible = "xlnx,zynq-usb-2.20a" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(ehci_zynq) = {
|
|
|
|
.name = "ehci_zynq",
|
|
|
|
.id = UCLASS_USB,
|
|
|
|
.of_match = ehci_zynq_ids,
|
2020-12-03 23:55:21 +00:00
|
|
|
.of_to_plat = ehci_zynq_of_to_plat,
|
2016-07-05 23:10:14 +00:00
|
|
|
.probe = ehci_zynq_probe,
|
2016-09-06 13:17:34 +00:00
|
|
|
.remove = ehci_deregister,
|
2016-07-05 23:10:14 +00:00
|
|
|
.ops = &ehci_usb_ops,
|
2020-12-03 23:55:23 +00:00
|
|
|
.plat_auto = sizeof(struct usb_plat),
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct zynq_ehci_priv),
|
2016-07-05 23:10:14 +00:00
|
|
|
.flags = DM_FLAG_ALLOC_PRIV_DMA,
|
|
|
|
};
|