Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
From: Christian Lamparter <chunkeey@gmail.com>
To: Vinod Koul <vkoul@kernel.org>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/5] usb: xhci: handle uPD720201 and uPD720202 w/o ROM
Date: Fri, 21 Jun 2019 21:53:31 +0200
Message-ID: <2243374.tJjtY2ZRGj@debian64> (raw)
In-Reply-To: <20190621085913.8722-3-vkoul@kernel.org>

On Friday, June 21, 2019 10:59:10 AM CEST Vinod Koul wrote:
> From: Christian Lamparter <chunkeey@googlemail.com>
> 
> This patch adds a firmware check for the uPD720201K8-711-BAC-A
> and uPD720202K8-711-BAA-A variant. Both of these chips are listed
> in Renesas' R19UH0078EJ0500 Rev.5.00 "User's Manual: Hardware" as
> devices which need a firmware in order to work as they do not have
> support to load the firmware from an external ROM.
> 
> Currently, the xhci-pci driver is unable to initialize the hcd in
> this case. Instead it will wait for 30 seconds and cause a timeout
> in xhci_handshake() and fails.
> 
> [    5.116990] xhci_hcd 0000:45:00.0: new USB bus registered ...
> [   32.335215] xhci_hcd 0000:45:00.0: can't setup: -110
> [   32.340179] xhci_hcd 0000:45:00.0: USB bus 2 deregistered
> [   32.345587] xhci_hcd 0000:45:00.0: init 0000:45:00.0 fail, -110
> [   32.351496] xhci_hcd: probe of 0000:45:00.0 failed with error -110
> 
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> Signed-off-by: Vinod Koul <vkoul@kernel.org>

From what I remember, this was the "backup" patch that just prevented
a stuck device (since the xhci-pci would trigger the watchdog on the
powerpc APM82181). I posted because it because I didn't get any reply
from Greg or Felipe. This patch should be skipable since patch 1/5 adds
the full loader.

> ---
>  drivers/usb/host/xhci-pci.c | 59 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index 724d0f567d98..65de5e961892 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -711,6 +711,55 @@ static int renesas_fw_download_to_hw(struct pci_dev *pdev,
>  	return 1;
>  }
>  
> +static int renesas_check_if_fw_dl_is_needed(struct pci_dev *pdev)
> +{
> +	int err;
> +	u8 fw_state;
> +
> +	/*
> +	 * Only the uPD720201K8-711-BAC-A or uPD720202K8-711-BAA-A
> +	 * are listed in R19UH0078EJ0500 Rev.5.00 as devices which
> +	 * need a firmware in order to work.
> +	 *
> +	 *  - uPD720202 ES 2.0 sample & CS sample & Mass product, ID is 2.
> +	 *  - uPD720201 ES 2.0 sample whose revision ID is 2.
> +	 *  - uPD720201 ES 2.1 sample & CS sample & Mass product, ID is 3.
> +	 */
> +	if (!((pdev->vendor == PCI_VENDOR_ID_RENESAS) &&
> +	    ((pdev->device == 0x0015 && pdev->revision == 0x02) ||
> +	    (pdev->device == 0x0014 &&
> +	    (pdev->revision == 0x02 || pdev->revision == 0x03)))))
> +		return 0;
> +
> +	/*
> +	 * Test if the firmware was uploaded and is running.
> +	 * As most BIOSes will initialize the device for us.
> +	 */
> +	err = pci_read_config_byte(pdev, 0xf4, &fw_state);
> +	if (err)
> +		return pcibios_err_to_errno(err);
> +
> +	/* Check the "Result Code" Bits (6:4) and act accordingly */
> +	switch (fw_state & 0x70) {
> +	case 0: /* No result yet */
> +		dev_err(&pdev->dev, "FW is not ready/loaded yet.");
> +		return -ENODEV;
> +
> +	case BIT(4): /* Success, device should be working. */
> +		dev_dbg(&pdev->dev, "FW is ready.");
> +		return 0;
> +
> +	case BIT(5): /* Error State */
> +		dev_err(&pdev->dev, "HW is in an error state.");
> +		return -ENODEV;
> +
> +	default: /* All other states are marked as "Reserved states" */
> +		dev_err(&pdev->dev, "HW is in an invalid state (%x).",
> +			(fw_state & 0x70) >> 4);
> +		return -EINVAL;
> +	}
> +}
> +
>  /* called during probe() after chip reset completes */
>  static int xhci_pci_setup(struct usb_hcd *hcd)
>  {
> @@ -765,6 +814,11 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  		return retval;
>  	};
>  
> +	/* Check if this device is a RENESAS uPD720201/2 device. */
> +	retval = renesas_check_if_fw_dl_is_needed(dev);
> +	if (retval)
> +		return retval;
> +
>  	driver = (struct hc_driver *)id->driver_data;
>  
>  	/* Prevent runtime suspending between USB-2 and USB-3 initialization */
> @@ -966,6 +1020,11 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
>  	if (pdev->vendor == PCI_VENDOR_ID_INTEL)
>  		usb_enable_intel_xhci_ports(pdev);
>  
> +	/* Check if this device is a RENESAS uPD720201/2 device. */
> +	retval = renesas_check_if_fw_dl_is_needed(pdev);
> +	if (retval)
> +		return retval;
> +
>  	if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
>  		xhci_ssic_port_unused_quirk(hcd, false);
>  
> 





  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21  8:59 [PATCH v2 0/5] usb: xhci: Add support for Renesas USB controllers Vinod Koul
2019-06-21  8:59 ` [PATCH v2 1/5] usb: xhci: add firmware loader for uPD720201 and uPD720202 w/o ROM Vinod Koul
2019-06-21 19:59   ` Christian Lamparter
2019-06-23 16:33     ` Vinod Koul
2019-06-21  8:59 ` [PATCH v2 2/5] usb: xhci: handle " Vinod Koul
2019-06-21 19:53   ` Christian Lamparter [this message]
2019-06-23 16:35     ` Vinod Koul
2019-06-21  8:59 ` [PATCH v2 3/5] usb: xhci: Use register defined and field names Vinod Koul
2019-06-21  8:59 ` [PATCH v2 4/5] usb: xhci: Add ROM loader for uPD720201 Vinod Koul
2019-06-21  8:59 ` [PATCH v2 5/5] usb: xhci: allow multiple firmware versions Vinod Koul
2019-06-21 19:46   ` Christian Lamparter
2019-06-23 16:36     ` Vinod Koul
2019-06-21 19:41 ` [PATCH v2 0/5] usb: xhci: Add support for Renesas USB controllers Christian Lamparter
2019-06-23 16:37   ` Vinod Koul

Reply instructions:

You may reply publically 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=2243374.tJjtY2ZRGj@debian64 \
    --to=chunkeey@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=vkoul@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org linux-arm-msm@archiver.kernel.org
	public-inbox-index linux-arm-msm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox