All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] usb: host: xhci-{plat,rcar}: clean up the drivers
@ 2019-09-02 12:01 Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv Yoshihiro Shimoda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-02 12:01 UTC (permalink / raw)
  To: gregkh, mathias.nyman; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch series is based on the latest Greg's linux-usb.git /
usb-next branch.

Changes from v1:
 - Rebase today's usb-next branch.
 - Remove 4/4 patch (because I need more time to investigate how to fix it).
 - Add Geert-san's Reviewed-by from patch 1/3 to 3/3.
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=165847


Yoshihiro Shimoda (3):
  usb: host: xhci-plat: add quirks member into struct xhci_plat_priv
  usb: host: xhci-rcar: Add a helper macro to set xhci_plat_priv
  usb: host: xhci-rcar: Use xhci_plat_priv.quirks instead of code
    settings

 drivers/usb/host/xhci-plat.c | 14 +++++---------
 drivers/usb/host/xhci-plat.h |  2 ++
 drivers/usb/host/xhci-rcar.c | 28 ----------------------------
 drivers/usb/host/xhci-rcar.h | 21 +++++++++++++++++++++
 4 files changed, 28 insertions(+), 37 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv
  2019-09-02 12:01 [PATCH v2 0/3] usb: host: xhci-{plat,rcar}: clean up the drivers Yoshihiro Shimoda
@ 2019-09-02 12:01 ` Yoshihiro Shimoda
  2019-09-03 13:52   ` Greg KH
  2019-09-02 12:01 ` [PATCH v2 2/3] usb: host: xhci-rcar: Add a helper macro to set xhci_plat_priv Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 3/3] usb: host: xhci-rcar: Use xhci_plat_priv.quirks instead of code settings Yoshihiro Shimoda
  2 siblings, 1 reply; 5+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-02 12:01 UTC (permalink / raw)
  To: gregkh, mathias.nyman; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

To simplify adding xhci->quirks instead of the .init_quirk()
function, this patch adds a new parameter "quirks" into
the struct xhci_plat_priv.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/usb/host/xhci-plat.c | 4 +++-
 drivers/usb/host/xhci-plat.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index a1e5ce4..1843b69 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -66,12 +66,14 @@ static int xhci_priv_resume_quirk(struct usb_hcd *hcd)
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+	struct xhci_plat_priv *priv = xhci_to_priv(xhci);
+
 	/*
 	 * As of now platform drivers don't provide MSI support so we ensure
 	 * here that the generic code does not try to make a pci_dev from our
 	 * dev struct in order to setup MSI
 	 */
-	xhci->quirks |= XHCI_PLAT;
+	xhci->quirks |= XHCI_PLAT | priv->quirks;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index ae29f22..5681723 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -12,10 +12,12 @@
 
 struct xhci_plat_priv {
 	const char *firmware_name;
+	unsigned long long quirks;
 	void (*plat_start)(struct usb_hcd *);
 	int (*init_quirk)(struct usb_hcd *);
 	int (*resume_quirk)(struct usb_hcd *);
 };
 
 #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
+#define xhci_to_priv(x) ((struct xhci_plat_priv *)(x)->priv)
 #endif	/* _XHCI_PLAT_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] usb: host: xhci-rcar: Add a helper macro to set xhci_plat_priv
  2019-09-02 12:01 [PATCH v2 0/3] usb: host: xhci-{plat,rcar}: clean up the drivers Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv Yoshihiro Shimoda
@ 2019-09-02 12:01 ` Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 3/3] usb: host: xhci-rcar: Use xhci_plat_priv.quirks instead of code settings Yoshihiro Shimoda
  2 siblings, 0 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-02 12:01 UTC (permalink / raw)
  To: gregkh, mathias.nyman; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

To avoid copy-and-paste setting of xhci_plat_priv for R-Car SoCs,
this patch add a helper macro SET_XHCI_PLAT_PRIV_FOR_RCAR.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/usb/host/xhci-plat.c | 10 ++--------
 drivers/usb/host/xhci-rcar.h |  7 +++++++
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 1843b69..d90cd5e 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -105,17 +105,11 @@ static const struct xhci_plat_priv xhci_plat_marvell_armada3700 = {
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
-	.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
-	.init_quirk = xhci_rcar_init_quirk,
-	.plat_start = xhci_rcar_start,
-	.resume_quirk = xhci_rcar_resume_quirk,
+	SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V1)
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
-	.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V3,
-	.init_quirk = xhci_rcar_init_quirk,
-	.plat_start = xhci_rcar_start,
-	.resume_quirk = xhci_rcar_resume_quirk,
+	SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V3)
 };
 
 static const struct of_device_id usb_xhci_of_match[] = {
diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h
index 804b6ab..1f8c225 100644
--- a/drivers/usb/host/xhci-rcar.h
+++ b/drivers/usb/host/xhci-rcar.h
@@ -31,4 +31,11 @@ static inline int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
 	return 0;
 }
 #endif
+
+#define SET_XHCI_PLAT_PRIV_FOR_RCAR(firmware)				\
+	.firmware_name = firmware,					\
+	.init_quirk = xhci_rcar_init_quirk,				\
+	.plat_start = xhci_rcar_start,					\
+	.resume_quirk = xhci_rcar_resume_quirk,
+
 #endif /* _XHCI_RCAR_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] usb: host: xhci-rcar: Use xhci_plat_priv.quirks instead of code settings
  2019-09-02 12:01 [PATCH v2 0/3] usb: host: xhci-{plat,rcar}: clean up the drivers Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv Yoshihiro Shimoda
  2019-09-02 12:01 ` [PATCH v2 2/3] usb: host: xhci-rcar: Add a helper macro to set xhci_plat_priv Yoshihiro Shimoda
@ 2019-09-02 12:01 ` Yoshihiro Shimoda
  2 siblings, 0 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2019-09-02 12:01 UTC (permalink / raw)
  To: gregkh, mathias.nyman; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch uses xhci_plat_priv.quirks to simplify. The previous
code had conditions to set some quirks in xhci_rcar_init_quirk().
But, the xhci_rcar_init_quirk() is called at the same conditions.
So, no behavior change.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/usb/host/xhci-rcar.c | 28 ----------------------------
 drivers/usb/host/xhci-rcar.h | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index 8616c52..34761be 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -107,15 +107,6 @@ static int xhci_rcar_is_gen2(struct device *dev)
 		of_device_is_compatible(node, "renensas,rcar-gen2-xhci");
 }
 
-static int xhci_rcar_is_gen3(struct device *dev)
-{
-	struct device_node *node = dev->of_node;
-
-	return of_device_is_compatible(node, "renesas,xhci-r8a7795") ||
-		of_device_is_compatible(node, "renesas,xhci-r8a7796") ||
-		of_device_is_compatible(node, "renesas,rcar-gen3-xhci");
-}
-
 void xhci_rcar_start(struct usb_hcd *hcd)
 {
 	u32 temp;
@@ -226,32 +217,13 @@ static bool xhci_rcar_wait_for_pll_active(struct usb_hcd *hcd)
 /* This function needs to initialize a "phy" of usb before */
 int xhci_rcar_init_quirk(struct usb_hcd *hcd)
 {
-	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-
 	/* If hcd->regs is NULL, we don't just call the following function */
 	if (!hcd->regs)
 		return 0;
 
-	/*
-	 * On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set
-	 * to 1. However, these SoCs don't support 64-bit address memory
-	 * pointers. So, this driver clears the AC64 bit of xhci->hcc_params
-	 * to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in
-	 * xhci_gen_setup().
-	 *
-	 * And, since the firmware/internal CPU control the USBSTS.STS_HALT
-	 * and the process speed is down when the roothub port enters U3,
-	 * long delay for the handshake of STS_HALT is neeed in xhci_suspend().
-	 */
-	if (xhci_rcar_is_gen2(hcd->self.controller) ||
-			xhci_rcar_is_gen3(hcd->self.controller)) {
-		xhci->quirks |= XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND;
-	}
-
 	if (!xhci_rcar_wait_for_pll_active(hcd))
 		return -ETIMEDOUT;
 
-	xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 	return xhci_rcar_download_firmware(hcd);
 }
 
diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h
index 1f8c225..012744a 100644
--- a/drivers/usb/host/xhci-rcar.h
+++ b/drivers/usb/host/xhci-rcar.h
@@ -32,8 +32,22 @@ static inline int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
 }
 #endif
 
+/*
+ * On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set
+ * to 1. However, these SoCs don't support 64-bit address memory
+ * pointers. So, this driver clears the AC64 bit of xhci->hcc_params
+ * to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in
+ * xhci_gen_setup() by using the XHCI_NO_64BIT_SUPPORT quirk.
+ *
+ * And, since the firmware/internal CPU control the USBSTS.STS_HALT
+ * and the process speed is down when the roothub port enters U3,
+ * long delay for the handshake of STS_HALT is neeed in xhci_suspend()
+ * by using the XHCI_SLOW_SUSPEND quirk.
+ */
 #define SET_XHCI_PLAT_PRIV_FOR_RCAR(firmware)				\
 	.firmware_name = firmware,					\
+	.quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH |	\
+		  XHCI_SLOW_SUSPEND,					\
 	.init_quirk = xhci_rcar_init_quirk,				\
 	.plat_start = xhci_rcar_start,					\
 	.resume_quirk = xhci_rcar_resume_quirk,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv
  2019-09-02 12:01 ` [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv Yoshihiro Shimoda
@ 2019-09-03 13:52   ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-09-03 13:52 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: mathias.nyman, linux-usb, linux-renesas-soc

On Mon, Sep 02, 2019 at 09:01:36PM +0900, Yoshihiro Shimoda wrote:
> To simplify adding xhci->quirks instead of the .init_quirk()
> function, this patch adds a new parameter "quirks" into
> the struct xhci_plat_priv.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/usb/host/xhci-plat.c | 4 +++-
>  drivers/usb/host/xhci-plat.h | 2 ++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index a1e5ce4..1843b69 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -66,12 +66,14 @@ static int xhci_priv_resume_quirk(struct usb_hcd *hcd)
>  
>  static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
>  {
> +	struct xhci_plat_priv *priv = xhci_to_priv(xhci);
> +
>  	/*
>  	 * As of now platform drivers don't provide MSI support so we ensure
>  	 * here that the generic code does not try to make a pci_dev from our
>  	 * dev struct in order to setup MSI
>  	 */
> -	xhci->quirks |= XHCI_PLAT;
> +	xhci->quirks |= XHCI_PLAT | priv->quirks;
>  }
>  
>  /* called during probe() after chip reset completes */
> diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
> index ae29f22..5681723 100644
> --- a/drivers/usb/host/xhci-plat.h
> +++ b/drivers/usb/host/xhci-plat.h
> @@ -12,10 +12,12 @@
>  
>  struct xhci_plat_priv {
>  	const char *firmware_name;
> +	unsigned long long quirks;

So you mean u64?  Or something else?

Please be specific here so we know the size of this field.

Ugh, looks like xhci.c uses unsigned long long too, ok, nevermind :(


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-03 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-02 12:01 [PATCH v2 0/3] usb: host: xhci-{plat,rcar}: clean up the drivers Yoshihiro Shimoda
2019-09-02 12:01 ` [PATCH v2 1/3] usb: host: xhci-plat: add quirks member into struct xhci_plat_priv Yoshihiro Shimoda
2019-09-03 13:52   ` Greg KH
2019-09-02 12:01 ` [PATCH v2 2/3] usb: host: xhci-rcar: Add a helper macro to set xhci_plat_priv Yoshihiro Shimoda
2019-09-02 12:01 ` [PATCH v2 3/3] usb: host: xhci-rcar: Use xhci_plat_priv.quirks instead of code settings Yoshihiro Shimoda

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.