devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] usb: chipidea: add xilinx zynq platform data
@ 2015-08-31 14:49 Nathan Sullivan
  2015-08-31 14:49 ` [PATCH v2 2/2] Documentation: bindings: add doc for zynq USB Nathan Sullivan
       [not found] ` <1441032592-8121-1-git-send-email-nathan.sullivan-acOepvfBmUk@public.gmane.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Sullivan @ 2015-08-31 14:49 UTC (permalink / raw)
  To: Peter.Chen, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, gregkh
  Cc: devicetree, linux-kernel, linux-usb, Nathan Sullivan

Due to having hardware tx buffers less than 512 bytes in size, streaming
must be enabled on the Zynq for the udc to work at all.  Add platform data
specific to the Zynq udc, which does not set the CI_HDRC_DISABLE_STREAMING
flag.

Based on a patch by the same name from the Xilinx vendor tree.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
---
Changes from v1 - better describe the issue in the description, the root cause
is that the Zynq hardware does not have big enough tx buffers to hold entire
packets, so streaming must be on.
---
 drivers/usb/chipidea/ci_hdrc_usb2.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 9eae1a1..4456d2c 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -12,6 +12,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/usb/chipidea.h>
@@ -30,18 +31,36 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
 	.flags		= CI_HDRC_DISABLE_STREAMING,
 };
 
+static struct ci_hdrc_platform_data ci_zynq_pdata = {
+	.capoffset	= DEF_CAPOFFSET,
+};
+
+static const struct of_device_id ci_hdrc_usb2_of_match[] = {
+	{ .compatible = "chipidea,usb2"},
+	{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
+
 static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ci_hdrc_usb2_priv *priv;
 	struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
 	int ret;
+	const struct of_device_id *match;
 
 	if (!ci_pdata) {
 		ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
 		*ci_pdata = ci_default_pdata;	/* struct copy */
 	}
 
+	match = of_match_device(ci_hdrc_usb2_of_match, &pdev->dev);
+	if (match && match->data) {
+		/* struct copy */
+		*ci_pdata = *(struct ci_hdrc_platform_data *)match->data;
+	}
+
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
@@ -96,12 +115,6 @@ static int ci_hdrc_usb2_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id ci_hdrc_usb2_of_match[] = {
-	{ .compatible = "chipidea,usb2" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
-
 static struct platform_driver ci_hdrc_usb2_driver = {
 	.probe	= ci_hdrc_usb2_probe,
 	.remove	= ci_hdrc_usb2_remove,
-- 
1.7.10.4

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

* [PATCH v2 2/2] Documentation: bindings: add doc for zynq USB
  2015-08-31 14:49 [PATCH v2 1/2] usb: chipidea: add xilinx zynq platform data Nathan Sullivan
@ 2015-08-31 14:49 ` Nathan Sullivan
       [not found] ` <1441032592-8121-1-git-send-email-nathan.sullivan-acOepvfBmUk@public.gmane.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Sullivan @ 2015-08-31 14:49 UTC (permalink / raw)
  To: Peter.Chen, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
	galak, gregkh
  Cc: devicetree, linux-kernel, linux-usb, Nathan Sullivan

Document the binding for the zynq specific chipidea UDC binding.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt |    1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
index 553e2fa..29ec09e 100644
--- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
@@ -6,6 +6,7 @@ Required properties:
 	"lsi,zevio-usb"
 	"qcom,ci-hdrc"
 	"chipidea,usb2"
+	"xlnx,zynq-usb-2.20a"
 - reg: base address and length of the registers
 - interrupts: interrupt for the USB controller
 
-- 
1.7.10.4

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

* Re: [PATCH v2 1/2] usb: chipidea: add xilinx zynq platform data
       [not found] ` <1441032592-8121-1-git-send-email-nathan.sullivan-acOepvfBmUk@public.gmane.org>
@ 2015-09-01  0:55   ` Peter Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Chen @ 2015-09-01  0:55 UTC (permalink / raw)
  To: Nathan Sullivan
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA

On Mon, Aug 31, 2015 at 09:49:51AM -0500, Nathan Sullivan wrote:
> Due to having hardware tx buffers less than 512 bytes in size, streaming
> must be enabled on the Zynq for the udc to work at all.  Add platform data
> specific to the Zynq udc, which does not set the CI_HDRC_DISABLE_STREAMING
> flag.
> 
> Based on a patch by the same name from the Xilinx vendor tree.
> 
> Signed-off-by: Nathan Sullivan <nathan.sullivan-acOepvfBmUk@public.gmane.org>
> ---
> Changes from v1 - better describe the issue in the description, the root cause
> is that the Zynq hardware does not have big enough tx buffers to hold entire
> packets, so streaming must be on.
> ---
>  drivers/usb/chipidea/ci_hdrc_usb2.c |   25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index 9eae1a1..4456d2c 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -12,6 +12,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_platform.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
>  #include <linux/usb/chipidea.h>
> @@ -30,18 +31,36 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
>  	.flags		= CI_HDRC_DISABLE_STREAMING,
>  };
>  
> +static struct ci_hdrc_platform_data ci_zynq_pdata = {
> +	.capoffset	= DEF_CAPOFFSET,
> +};
> +
> +static const struct of_device_id ci_hdrc_usb2_of_match[] = {
> +	{ .compatible = "chipidea,usb2"},
> +	{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata},
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
> +
>  static int ci_hdrc_usb2_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct ci_hdrc_usb2_priv *priv;
>  	struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
>  	int ret;
> +	const struct of_device_id *match;
>  
>  	if (!ci_pdata) {
>  		ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
>  		*ci_pdata = ci_default_pdata;	/* struct copy */
>  	}
>  
> +	match = of_match_device(ci_hdrc_usb2_of_match, &pdev->dev);
> +	if (match && match->data) {
> +		/* struct copy */
> +		*ci_pdata = *(struct ci_hdrc_platform_data *)match->data;
> +	}
> +
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		return -ENOMEM;
> @@ -96,12 +115,6 @@ static int ci_hdrc_usb2_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static const struct of_device_id ci_hdrc_usb2_of_match[] = {
> -	{ .compatible = "chipidea,usb2" },
> -	{ }
> -};
> -MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
> -
>  static struct platform_driver ci_hdrc_usb2_driver = {
>  	.probe	= ci_hdrc_usb2_probe,
>  	.remove	= ci_hdrc_usb2_remove,
> -- 
> 1.7.10.4
> 

Thanks, I will queue it, and send it as bug fix for v4.3

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-09-01  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 14:49 [PATCH v2 1/2] usb: chipidea: add xilinx zynq platform data Nathan Sullivan
2015-08-31 14:49 ` [PATCH v2 2/2] Documentation: bindings: add doc for zynq USB Nathan Sullivan
     [not found] ` <1441032592-8121-1-git-send-email-nathan.sullivan-acOepvfBmUk@public.gmane.org>
2015-09-01  0:55   ` [PATCH v2 1/2] usb: chipidea: add xilinx zynq platform data Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).