All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] usb: zynqmp: Add XHCI driver support
Date: Tue, 1 Sep 2015 13:38:31 +0200	[thread overview]
Message-ID: <201509011338.31875.marex@denx.de> (raw)
In-Reply-To: <1441103463-29741-1-git-send-email-sivadur@xilinx.com>

On Tuesday, September 01, 2015 at 12:31:02 PM, Siva Durga Prasad Paladugu wrote:
> Added USB XHCI driver support for zynqmp.
> 
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>

Hi, looks almost good, a few minor nits though ...

[...]

> +unsigned long ctr_addr[] = {ZYNQMP_USB0_XHCI_BASEADDR,

static const void __iomem *ctl_addr[]

> +			    ZYNQMP_USB1_XHCI_BASEADDR};

I guess you can define something like CONFIG_ZYNQMP_XHCI_LIST { address ... }
in your board config file and then use static const unsigned long ctl_addr[] =
CONFIG_ZYNQMP... ; This will cover board which only use one controller.
The ideal way would be to obtain these information from DT though.

> +__weak int __board_usb_init(int index, enum usb_init_type init)
> +{
> +	return 0;
> +}
> +
> +void usb_phy_reset(struct dwc3 *dwc3_reg)
> +{
> +	/* Assert USB3 PHY reset */
> +	setbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +
> +	/* Assert USB2 PHY reset */
> +	setbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +
> +	mdelay(200);

That's some lazy crappy controller. Is this long delay needed ?

> +	/* Clear USB3 PHY reset */
> +	clrbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +
> +	/* Clear USB2 PHY reset */
> +	clrbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +}
> +
> +static int zynqmp_xhci_core_init(struct zynqmp_xhci *zynqmp_xhci)
> +{
> +	int ret = 0;
> +
> +	ret = dwc3_core_init(zynqmp_xhci->dwc3_reg);
> +	if (ret) {
> +		debug("%s:failed to initialize core\n", __func__);
> +		return ret;
> +	}
> +
> +	/* We are hard-coding DWC3 core to Host Mode */
> +	dwc3_set_mode(zynqmp_xhci->dwc3_reg, DWC3_GCTL_PRTCAP_HOST);
> +
> +	return ret;
> +}
> +
> +int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor
> **hcor) +{
> +	struct zynqmp_xhci *ctx = &zynqmp_xhci;
> +	int ret = 0;
> +
> +	ctx->hcd = (struct xhci_hccr *)ctr_addr[index];
> +	ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET);
> +
> +	ret = board_usb_init(index, USB_INIT_HOST);
> +	if (ret != 0) {
> +		puts("Failed to initialize board for USB\n");
> +		return ret;
> +	}
> +
> +	ret = zynqmp_xhci_core_init(ctx);
> +	if (ret < 0) {
> +		puts("Failed to initialize xhci\n");
> +		return ret;
> +	}
> +
> +	*hccr = (struct xhci_hccr *)ctx->hcd;
> +	*hcor = (struct xhci_hcor *)((uint32_t) *hccr
> +				+ HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase)));
> +
> +	debug("zynqmp-xhci: init hccr %x and hcor %x hc_length %d\n",

Use %p in the formating string to print pointers and drop the type casts.

> +	      (uint32_t)*hccr, (uint32_t)*hcor,
> +	      (uint32_t)HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase)));
> +
> +	return ret;
> +}
> +
> +void xhci_hcd_stop(int index)
> +{
> +	/*
> +	 * Currently zynqmp socs do not support PHY shutdown from
> +	 * sw. But this support may be added in future socs.
> +	 */
> +
> +	return 0;
> +}

  parent reply	other threads:[~2015-09-01 11:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 10:31 [U-Boot] [PATCH v2 1/2] usb: zynqmp: Add XHCI driver support Siva Durga Prasad Paladugu
2015-09-01 10:31 ` [U-Boot] [PATCH v2 2/2] usb: zynqmp: Enable USB XHCI support Siva Durga Prasad Paladugu
2015-09-01 11:38   ` Marek Vasut
2015-09-01 12:49     ` Siva Durga Prasad Paladugu
2015-09-01 11:38 ` Marek Vasut [this message]
2015-09-01 12:48   ` [U-Boot] [PATCH v2 1/2] usb: zynqmp: Add XHCI driver support Siva Durga Prasad Paladugu
2015-09-01 13:20     ` Marek Vasut
2015-09-01 13:37       ` Siva Durga Prasad Paladugu
2015-09-01 13:58         ` Marek Vasut
2015-09-01 15:58           ` Siva Durga Prasad Paladugu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201509011338.31875.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.