All of lore.kernel.org
 help / color / mirror / Atom feed
From: <cristian.birsan@microchip.com>
To: <nicolas.ferre@atmel.com>, <balbi@kernel.org>,
	<gregkh@linuxfoundation.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <ludovic.desroches@atmel.com>,
	<alexandre.belloni@free-electrons.com>,
	<boris.brezillon@free-electrons.com>,
	Cristian Birsan <cristian.birsan@microchip.com>
Subject: [PATCH 1/4 linux-next] usb: gadget: udc: atmel: Check fifo configuration values against device tree
Date: Tue, 14 Feb 2017 18:09:03 +0200	[thread overview]
Message-ID: <f71b15dfe79e227491aced411af203297e746603.1487007870.git.cristian.birsan@microchip.com> (raw)
In-Reply-To: <cover.1487007870.git.cristian.birsan@microchip.com>

From: Cristian Birsan <cristian.birsan@microchip.com>

Check fifo configuration values against device tree values for endpoint
fifo in auto configuration mode (fifo_mode=0).

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 11bbce2..ce8bf8b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -371,7 +371,7 @@ static struct usba_fifo_cfg mode_4_cfg[] = {
 };
 /* Add additional configurations here */
 
-int usba_config_fifo_table(struct usba_udc *udc)
+static int usba_config_fifo_table(struct usba_udc *udc)
 {
 	int n;
 
@@ -2118,14 +2118,34 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
 			dev_err(&pdev->dev, "of_probe: fifo-size error(%d)\n", ret);
 			goto err;
 		}
-		ep->fifo_size = fifo_mode ? udc->fifo_cfg[i].fifo_size : val;
+		if (fifo_mode) {
+			if (val < udc->fifo_cfg[i].fifo_size) {
+				dev_warn(&pdev->dev,
+					 "of_probe: fifo-size table value not supported by HW, using DT value\n");
+				ep->fifo_size = val;
+			} else {
+				ep->fifo_size = udc->fifo_cfg[i].fifo_size;
+			}
+		} else {
+			ep->fifo_size = val;
+		}
 
 		ret = of_property_read_u32(pp, "atmel,nb-banks", &val);
 		if (ret) {
 			dev_err(&pdev->dev, "of_probe: nb-banks error(%d)\n", ret);
 			goto err;
 		}
-		ep->nr_banks = fifo_mode ? udc->fifo_cfg[i].nr_banks : val;
+		if (fifo_mode) {
+			if (val < udc->fifo_cfg[i].nr_banks) {
+				dev_warn(&pdev->dev,
+					 "of_probe: nb-banks table value not supported by HW, using DT value\n");
+				ep->nr_banks = val;
+			} else {
+				ep->nr_banks = udc->fifo_cfg[i].nr_banks;
+			}
+		} else {
+			ep->nr_banks = val;
+		}
 
 		ep->can_dma = of_property_read_bool(pp, "atmel,can-dma");
 		ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc");
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: cristian.birsan@microchip.com (cristian.birsan at microchip.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4 linux-next] usb: gadget: udc: atmel: Check fifo configuration values against device tree
Date: Tue, 14 Feb 2017 18:09:03 +0200	[thread overview]
Message-ID: <f71b15dfe79e227491aced411af203297e746603.1487007870.git.cristian.birsan@microchip.com> (raw)
In-Reply-To: <cover.1487007870.git.cristian.birsan@microchip.com>

From: Cristian Birsan <cristian.birsan@microchip.com>

Check fifo configuration values against device tree values for endpoint
fifo in auto configuration mode (fifo_mode=0).

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 11bbce2..ce8bf8b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -371,7 +371,7 @@ static struct usba_fifo_cfg mode_4_cfg[] = {
 };
 /* Add additional configurations here */
 
-int usba_config_fifo_table(struct usba_udc *udc)
+static int usba_config_fifo_table(struct usba_udc *udc)
 {
 	int n;
 
@@ -2118,14 +2118,34 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
 			dev_err(&pdev->dev, "of_probe: fifo-size error(%d)\n", ret);
 			goto err;
 		}
-		ep->fifo_size = fifo_mode ? udc->fifo_cfg[i].fifo_size : val;
+		if (fifo_mode) {
+			if (val < udc->fifo_cfg[i].fifo_size) {
+				dev_warn(&pdev->dev,
+					 "of_probe: fifo-size table value not supported by HW, using DT value\n");
+				ep->fifo_size = val;
+			} else {
+				ep->fifo_size = udc->fifo_cfg[i].fifo_size;
+			}
+		} else {
+			ep->fifo_size = val;
+		}
 
 		ret = of_property_read_u32(pp, "atmel,nb-banks", &val);
 		if (ret) {
 			dev_err(&pdev->dev, "of_probe: nb-banks error(%d)\n", ret);
 			goto err;
 		}
-		ep->nr_banks = fifo_mode ? udc->fifo_cfg[i].nr_banks : val;
+		if (fifo_mode) {
+			if (val < udc->fifo_cfg[i].nr_banks) {
+				dev_warn(&pdev->dev,
+					 "of_probe: nb-banks table value not supported by HW, using DT value\n");
+				ep->nr_banks = val;
+			} else {
+				ep->nr_banks = udc->fifo_cfg[i].nr_banks;
+			}
+		} else {
+			ep->nr_banks = val;
+		}
 
 		ep->can_dma = of_property_read_bool(pp, "atmel,can-dma");
 		ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc");
-- 
2.7.4

  reply	other threads:[~2017-02-14 16:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 16:09 [PATCH 0/4 linux-next] usb: gadget: udc: atmel: Endpoint allocation scheme fixes cristian.birsan
2017-02-14 16:09 ` cristian.birsan at microchip.com
2017-02-14 16:09 ` cristian.birsan [this message]
2017-02-14 16:09   ` [PATCH 1/4 linux-next] usb: gadget: udc: atmel: Check fifo configuration values against device tree cristian.birsan at microchip.com
2017-03-06 15:06   ` Felipe Balbi
2017-03-06 15:06     ` Felipe Balbi
2017-02-14 16:09 ` [PATCH 2/4 linux-next] usb: gadget: udc: atmel: Minor code cleanup cristian.birsan
2017-02-14 16:09   ` cristian.birsan at microchip.com
2017-02-14 16:09 ` [PATCH 3/4 linux-next] usb: gadget: udc: atmel: Use dev_warn() to display EP configuration error cristian.birsan
2017-02-14 16:09   ` cristian.birsan at microchip.com
2017-02-14 16:09 ` [PATCH 4/4 linux-next] usb: gadget: udc: atmel: Update Kconfig help for fifo_mode = 0 cristian.birsan
2017-02-14 16:09   ` cristian.birsan at microchip.com
2017-02-15  9:08 ` [PATCH 0/4 linux-next] usb: gadget: udc: atmel: Endpoint allocation scheme fixes Nicolas Ferre
2017-02-15  9:08   ` Nicolas Ferre

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=f71b15dfe79e227491aced411af203297e746603.1487007870.git.cristian.birsan@microchip.com \
    --to=cristian.birsan@microchip.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=balbi@kernel.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=nicolas.ferre@atmel.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
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.