linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver
@ 2014-09-09  8:44 Robert Baldyga
  2014-09-09  8:44 ` [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization Robert Baldyga
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman; +Cc: gregkh, balbi, linux-usb, linux-kernel, Robert Baldyga

Hi,

I have splitted my patchset "usb: dwc2/gadget: fix series" into two series.
This patch series contains improvements for dwc2/gadget driver. It's intended
for 3.18.

Andrzej Pietrasiewicz (1):
  usb: dwc2/gadget: Fix comment text

Kamil Debski (1):
  usb: dwc2/gadget: move phy bus legth initialization

Marek Szyprowski (2):
  usb: dwc2/gadget: hide some not really needed debug messages
  usb: dwc2/gadget: ensure that all fifos have correct memory buffers

Robert Baldyga (2):
  usb: dwc2/gadget: assign TX FIFO dynamically
  usb: dwc2/gadget: disable clock when it's not needed

 drivers/usb/dwc2/core.h   |   3 ++
 drivers/usb/dwc2/gadget.c | 132 +++++++++++++++++++++++++++++-----------------
 2 files changed, 86 insertions(+), 49 deletions(-)

-- 
1.9.1


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

* [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-25 12:26   ` Marek Szyprowski
  2014-09-09  8:44 ` [PATCH 2/6] usb: dwc2/gadget: Fix comment text Robert Baldyga
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman
  Cc: gregkh, balbi, linux-usb, linux-kernel, Kamil Debski,
	Marek Szyprowski, Robert Baldyga

From: Kamil Debski <k.debski@samsung.com>

This patch moves the part of code that initializes the PHY bus width.
This results in simpler code and removes the need to check whether
the Generic PHY Framework is used.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/gadget.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ce6071d..9cbe136 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3392,6 +3392,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 	if (!hsotg)
 		return -ENOMEM;
 
+	/* Set default UTMI width */
+	hsotg->phyif = GUSBCFG_PHYIF16;
+
 	/*
 	 * Attempt to find a generic PHY, then look for an old style
 	 * USB PHY, finally fall back to pdata
@@ -3410,8 +3413,15 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 			hsotg->plat = plat;
 		} else
 			hsotg->uphy = uphy;
-	} else
+	} else {
 		hsotg->phy = phy;
+		/*
+		 * If using the generic PHY framework, check if the PHY bus
+		 * width is 8-bit and set the phyif appropriately.
+		 */
+		if (phy_get_bus_width(phy) == 8)
+			hsotg->phyif = GUSBCFG_PHYIF8;
+	}
 
 	hsotg->dev = dev;
 
@@ -3471,16 +3481,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_supplies;
 	}
 
-	/* Set default UTMI width */
-	hsotg->phyif = GUSBCFG_PHYIF16;
-
-	/*
-	 * If using the generic PHY framework, check if the PHY bus
-	 * width is 8-bit and set the phyif appropriately.
-	 */
-	if (hsotg->phy && (phy_get_bus_width(phy) == 8))
-		hsotg->phyif = GUSBCFG_PHYIF8;
-
 	/* usb phy enable */
 	s3c_hsotg_phy_enable(hsotg);
 
-- 
1.9.1


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

* [PATCH 2/6] usb: dwc2/gadget: Fix comment text
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
  2014-09-09  8:44 ` [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-09  8:44 ` [PATCH 3/6] usb: dwc2/gadget: hide some not really needed debug messages Robert Baldyga
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman
  Cc: gregkh, balbi, linux-usb, linux-kernel, Andrzej Pietrasiewicz,
	Robert Baldyga

From: Andrzej Pietrasiewicz <andrzej.p@samsung.com>

Adjust the debug text to the name of the printed variable.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9cbe136..186a3a8 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2935,7 +2935,7 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
 	struct s3c_hsotg *hsotg = to_hsotg(gadget);
 	unsigned long flags = 0;
 
-	dev_dbg(hsotg->dev, "%s: is_in: %d\n", __func__, is_on);
+	dev_dbg(hsotg->dev, "%s: is_on: %d\n", __func__, is_on);
 
 	spin_lock_irqsave(&hsotg->lock, flags);
 	if (is_on) {
-- 
1.9.1


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

* [PATCH 3/6] usb: dwc2/gadget: hide some not really needed debug messages
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
  2014-09-09  8:44 ` [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization Robert Baldyga
  2014-09-09  8:44 ` [PATCH 2/6] usb: dwc2/gadget: Fix comment text Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-09  8:44 ` [PATCH 4/6] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Robert Baldyga
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman
  Cc: gregkh, balbi, linux-usb, linux-kernel, Marek Szyprowski, Robert Baldyga

From: Marek Szyprowski <m.szyprowski@samsung.com>

Some DWC2/s3c-hsotg debug messages are really useless for typical user,
so hide them behind dev_dbg().

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/gadget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 186a3a8..f63858a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2568,7 +2568,7 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
 	u32 epctrl_reg;
 	u32 ctrl;
 
-	dev_info(hsotg->dev, "%s(ep %p)\n", __func__, ep);
+	dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep);
 
 	if (ep == &hsotg->eps[0].ep) {
 		dev_err(hsotg->dev, "%s: called for ep0\n", __func__);
@@ -2626,7 +2626,7 @@ static int s3c_hsotg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
 	struct s3c_hsotg *hs = hs_ep->parent;
 	unsigned long flags;
 
-	dev_info(hs->dev, "ep_dequeue(%p,%p)\n", ep, req);
+	dev_dbg(hs->dev, "ep_dequeue(%p,%p)\n", ep, req);
 
 	spin_lock_irqsave(&hs->lock, flags);
 
-- 
1.9.1


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

* [PATCH 4/6] usb: dwc2/gadget: ensure that all fifos have correct memory buffers
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
                   ` (2 preceding siblings ...)
  2014-09-09  8:44 ` [PATCH 3/6] usb: dwc2/gadget: hide some not really needed debug messages Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-09  8:44 ` [PATCH 5/6] usb: dwc2/gadget: assign TX FIFO dynamically Robert Baldyga
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman
  Cc: gregkh, balbi, linux-usb, linux-kernel, Marek Szyprowski, Robert Baldyga

From: Marek Szyprowski <m.szyprowski@samsung.com>

Print warning if FIFOs are configured in such a way that they don't fit
into the SPRAM available on the s3c hsotg module.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/core.h   |  1 +
 drivers/usb/dwc2/gadget.c | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..067390e 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -194,6 +194,7 @@ struct s3c_hsotg {
 	struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
 
 	u32                     phyif;
+	int			fifo_mem;
 	unsigned int            dedicated_fifos:1;
 	unsigned char           num_of_eps;
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f63858a..bd58756 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -192,6 +192,8 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
 	for (ep = 1; ep <= 15; ep++) {
 		val = addr;
 		val |= size << FIFOSIZE_DEPTH_SHIFT;
+		WARN_ONCE(addr + size > hsotg->fifo_mem,
+			  "insufficient fifo memory");
 		addr += size;
 
 		writel(val, hsotg->regs + DPTXFSIZN(ep));
@@ -3029,19 +3031,22 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
  */
 static void s3c_hsotg_hw_cfg(struct s3c_hsotg *hsotg)
 {
-	u32 cfg2, cfg4;
+	u32 cfg2, cfg3, cfg4;
 	/* check hardware configuration */
 
 	cfg2 = readl(hsotg->regs + 0x48);
 	hsotg->num_of_eps = (cfg2 >> 10) & 0xF;
 
-	dev_info(hsotg->dev, "EPs:%d\n", hsotg->num_of_eps);
+	cfg3 = readl(hsotg->regs + 0x4C);
+	hsotg->fifo_mem = (cfg3 >> 16);
 
 	cfg4 = readl(hsotg->regs + 0x50);
 	hsotg->dedicated_fifos = (cfg4 >> 25) & 1;
 
-	dev_info(hsotg->dev, "%s fifos\n",
-		 hsotg->dedicated_fifos ? "dedicated" : "shared");
+	dev_info(hsotg->dev, "EPs: %d, %s fifos, %d entries in SPRAM\n",
+		 hsotg->num_of_eps,
+		 hsotg->dedicated_fifos ? "dedicated" : "shared",
+		 hsotg->fifo_mem);
 }
 
 /**
@@ -3485,8 +3490,8 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 	s3c_hsotg_phy_enable(hsotg);
 
 	s3c_hsotg_corereset(hsotg);
-	s3c_hsotg_init(hsotg);
 	s3c_hsotg_hw_cfg(hsotg);
+	s3c_hsotg_init(hsotg);
 
 	ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
 				dev_name(dev), hsotg);
-- 
1.9.1


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

* [PATCH 5/6] usb: dwc2/gadget: assign TX FIFO dynamically
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
                   ` (3 preceding siblings ...)
  2014-09-09  8:44 ` [PATCH 4/6] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-09  8:44 ` [PATCH 6/6] usb: dwc2/gadget: disable clock when it's not needed Robert Baldyga
  2014-09-10 20:34 ` [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Greg KH
  6 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman; +Cc: gregkh, balbi, linux-usb, linux-kernel, Robert Baldyga

Because we have not enough memory to have each TX FIFO of size at least
3072 bytes (the maximum single packet size with 3 transactions per
microframe), we create four FIFOs of lenght 1024, and four of length
3072 bytes, and assing them to endpoints dynamically according to
maxpacket size value of given endpoint.

Up to now there were initialized 16 TX FIFOs, but we use only 8 IN
endpoints, so we can split available memory for 8 FIFOs to have more
memory for each one.

It needed to do some small modifications in few places in code, because
there was assumption that TX FIFO numbers assigned to endpoints are the
same as the endpoint numbers, which is not true since we have dynamic
FIFO assigning.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/core.h   |  2 ++
 drivers/usb/dwc2/gadget.c | 80 +++++++++++++++++++++++++++++------------------
 2 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 067390e..3b4bd4c 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -139,6 +139,7 @@ struct s3c_hsotg_ep {
 	unsigned int            last_load;
 	unsigned int            fifo_load;
 	unsigned short          fifo_size;
+	unsigned short		fifo_index;
 
 	unsigned char           dir_in;
 	unsigned char           index;
@@ -197,6 +198,7 @@ struct s3c_hsotg {
 	int			fifo_mem;
 	unsigned int            dedicated_fifos:1;
 	unsigned char           num_of_eps;
+	u32			fifo_map;
 
 	struct dentry           *debug_root;
 	struct dentry           *debug_file;
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bd58756..29d7561 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -182,14 +182,29 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
 
 	/* start at the end of the GNPTXFSIZ, rounded up */
 	addr = 2048 + 1024;
-	size = 768;
 
 	/*
-	 * currently we allocate TX FIFOs for all possible endpoints,
-	 * and assume that they are all the same size.
+	 * Because we have not enough memory to have each TX FIFO of size at
+	 * least 3072 bytes (the maximum single packet size), we create four
+	 * FIFOs of lenght 1024, and four of length 3072 bytes, and assing
+	 * them to endpoints dynamically according to maxpacket size value of
+	 * given endpoint.
 	 */
 
-	for (ep = 1; ep <= 15; ep++) {
+	/* 256*4=1024 bytes FIFO length */
+	size = 256;
+	for (ep = 1; ep <= 4; ep++) {
+		val = addr;
+		val |= size << FIFOSIZE_DEPTH_SHIFT;
+		WARN_ONCE(addr + size > hsotg->fifo_mem,
+			  "insufficient fifo memory");
+		addr += size;
+
+		writel(val, hsotg->regs + DPTXFSIZN(ep));
+	}
+	/* 768*4=3072 bytes FIFO length */
+	size = 768;
+	for (ep = 5; ep <= 8; ep++) {
 		val = addr;
 		val |= size << FIFOSIZE_DEPTH_SHIFT;
 		WARN_ONCE(addr + size > hsotg->fifo_mem,
@@ -1834,7 +1849,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
 		if (dir_in) {
 			int epctl = readl(hsotg->regs + epctl_reg);
 
-			s3c_hsotg_txfifo_flush(hsotg, idx);
+			s3c_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index);
 
 			if ((epctl & DXEPCTL_STALL) &&
 				(epctl & DXEPCTL_EPTYPE_BULK)) {
@@ -1983,6 +1998,7 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
 			      int result, bool force)
 {
 	struct s3c_hsotg_req *req, *treq;
+	unsigned size;
 
 	list_for_each_entry_safe(req, treq, &ep->queue, queue) {
 		/*
@@ -1996,9 +2012,11 @@ static void kill_all_requests(struct s3c_hsotg *hsotg,
 		s3c_hsotg_complete_request(hsotg, ep, req,
 					   result);
 	}
-	if (hsotg->dedicated_fifos)
-		if ((readl(hsotg->regs + DTXFSTS(ep->index)) & 0xffff) * 4 < 3072)
-			s3c_hsotg_txfifo_flush(hsotg, ep->index);
+	if (!hsotg->dedicated_fifos)
+		return;
+	size = (readl(hsotg->regs + DTXFSTS(ep->index)) & 0xffff) * 4;
+	if (size < ep->fifo_size)
+		s3c_hsotg_txfifo_flush(hsotg, ep->fifo_index);
 }
 
 /**
@@ -2439,6 +2457,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
 	u32 epctrl;
 	u32 mps;
 	int dir_in;
+	int i, val, size;
 	int ret = 0;
 
 	dev_dbg(hsotg->dev,
@@ -2511,17 +2530,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
 		break;
 
 	case USB_ENDPOINT_XFER_INT:
-		if (dir_in) {
-			/*
-			 * Allocate our TxFNum by simply using the index
-			 * of the endpoint for the moment. We could do
-			 * something better if the host indicates how
-			 * many FIFOs we are expecting to use.
-			 */
-
+		if (dir_in)
 			hs_ep->periodic = 1;
-			epctrl |= DXEPCTL_TXFNUM(index);
-		}
 
 		epctrl |= DXEPCTL_EPTYPE_INTERRUPT;
 		break;
@@ -2535,8 +2545,25 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
 	 * if the hardware has dedicated fifos, we must give each IN EP
 	 * a unique tx-fifo even if it is non-periodic.
 	 */
-	if (dir_in && hsotg->dedicated_fifos)
-		epctrl |= DXEPCTL_TXFNUM(index);
+	if (dir_in && hsotg->dedicated_fifos) {
+		size = hs_ep->ep.maxpacket*hs_ep->mc;
+		for (i = 1; i <= 8; ++i) {
+			if (hsotg->fifo_map & (1<<i))
+				continue;
+			val = readl(hsotg->regs + DPTXFSIZN(i));
+			val = (val >> FIFOSIZE_DEPTH_SHIFT)*4;
+			if (val < size)
+				continue;
+			hsotg->fifo_map |= 1<<i;
+
+			epctrl |= DXEPCTL_TXFNUM(i);
+			hs_ep->fifo_index = i;
+			hs_ep->fifo_size = val;
+			break;
+		}
+		if (i == 8)
+			return -ENOMEM;
+	}
 
 	/* for non control endpoints, set PID to D0 */
 	if (index)
@@ -2583,6 +2610,9 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep)
 	/* terminate all requests with shutdown */
 	kill_all_requests(hsotg, hs_ep, -ESHUTDOWN, false);
 
+	hsotg->fifo_map &= ~(1<<hs_ep->fifo_index);
+	hs_ep->fifo_index = 0;
+	hs_ep->fifo_size = 0;
 
 	ctrl = readl(hsotg->regs + epctrl_reg);
 	ctrl &= ~DXEPCTL_EPENA;
@@ -2974,7 +3004,6 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
 				       struct s3c_hsotg_ep *hs_ep,
 				       int epnum)
 {
-	u32 ptxfifo;
 	char *dir;
 
 	if (epnum == 0)
@@ -3003,15 +3032,6 @@ static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
 	hs_ep->ep.ops = &s3c_hsotg_ep_ops;
 
 	/*
-	 * Read the FIFO size for the Periodic TX FIFO, even if we're
-	 * an OUT endpoint, we may as well do this if in future the
-	 * code is changed to make each endpoint's direction changeable.
-	 */
-
-	ptxfifo = readl(hsotg->regs + DPTXFSIZN(epnum));
-	hs_ep->fifo_size = FIFOSIZE_DEPTH_GET(ptxfifo) * 4;
-
-	/*
 	 * if we're using dma, we need to set the next-endpoint pointer
 	 * to be something valid.
 	 */
-- 
1.9.1


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

* [PATCH 6/6] usb: dwc2/gadget: disable clock when it's not needed
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
                   ` (4 preceding siblings ...)
  2014-09-09  8:44 ` [PATCH 5/6] usb: dwc2/gadget: assign TX FIFO dynamically Robert Baldyga
@ 2014-09-09  8:44 ` Robert Baldyga
  2014-09-10 20:34 ` [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Greg KH
  6 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-09  8:44 UTC (permalink / raw)
  To: Paul.Zimmerman; +Cc: gregkh, balbi, linux-usb, linux-kernel, Robert Baldyga

When device is stopped or suspended clock is not needed so we
can disable it for this time.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/dwc2/gadget.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 29d7561..94f7a3f 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2893,6 +2893,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
 	hsotg->gadget.dev.of_node = hsotg->dev->of_node;
 	hsotg->gadget.speed = USB_SPEED_UNKNOWN;
 
+	clk_enable(hsotg->clk);
+
 	ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
 				    hsotg->supplies);
 	if (ret) {
@@ -2941,6 +2943,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 
 	regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
+	clk_disable(hsotg->clk);
+
 	return 0;
 }
 
@@ -2972,8 +2976,10 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
 	spin_lock_irqsave(&hsotg->lock, flags);
 	if (is_on) {
 		s3c_hsotg_phy_enable(hsotg);
+		clk_enable(hsotg->clk);
 		s3c_hsotg_core_init(hsotg);
 	} else {
+		clk_disable(hsotg->clk);
 		s3c_hsotg_phy_disable(hsotg);
 	}
 
@@ -3636,6 +3642,7 @@ static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state)
 
 		ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
 					     hsotg->supplies);
+		clk_disable(hsotg->clk);
 	}
 
 	return ret;
@@ -3650,6 +3657,8 @@ static int s3c_hsotg_resume(struct platform_device *pdev)
 	if (hsotg->driver) {
 		dev_info(hsotg->dev, "resuming usb gadget %s\n",
 			 hsotg->driver->driver.name);
+
+		clk_enable(hsotg->clk);
 		ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
 				      hsotg->supplies);
 	}
-- 
1.9.1


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

* Re: [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver
  2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
                   ` (5 preceding siblings ...)
  2014-09-09  8:44 ` [PATCH 6/6] usb: dwc2/gadget: disable clock when it's not needed Robert Baldyga
@ 2014-09-10 20:34 ` Greg KH
  2014-09-18  9:56   ` Robert Baldyga
  6 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2014-09-10 20:34 UTC (permalink / raw)
  To: Robert Baldyga; +Cc: Paul.Zimmerman, balbi, linux-usb, linux-kernel

On Tue, Sep 09, 2014 at 10:44:51AM +0200, Robert Baldyga wrote:
> Hi,
> 
> I have splitted my patchset "usb: dwc2/gadget: fix series" into two series.
> This patch series contains improvements for dwc2/gadget driver. It's intended
> for 3.18.
> 
> Andrzej Pietrasiewicz (1):
>   usb: dwc2/gadget: Fix comment text
> 
> Kamil Debski (1):
>   usb: dwc2/gadget: move phy bus legth initialization
> 
> Marek Szyprowski (2):
>   usb: dwc2/gadget: hide some not really needed debug messages
>   usb: dwc2/gadget: ensure that all fifos have correct memory buffers
> 
> Robert Baldyga (2):
>   usb: dwc2/gadget: assign TX FIFO dynamically
>   usb: dwc2/gadget: disable clock when it's not needed
> 
>  drivers/usb/dwc2/core.h   |   3 ++
>  drivers/usb/dwc2/gadget.c | 132 +++++++++++++++++++++++++++++-----------------
>  2 files changed, 86 insertions(+), 49 deletions(-)

As these depend on your previous changes, I'll wait until after those
get merged into Linus's tree before applying them.  Probably sometime
next week.

thanks,

greg k-h

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

* Re: [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver
  2014-09-10 20:34 ` [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Greg KH
@ 2014-09-18  9:56   ` Robert Baldyga
  0 siblings, 0 replies; 11+ messages in thread
From: Robert Baldyga @ 2014-09-18  9:56 UTC (permalink / raw)
  To: Greg KH; +Cc: Paul.Zimmerman, balbi, linux-usb, linux-kernel

Hi Greg,

On 09/10/2014 10:34 PM, Greg KH wrote:
> On Tue, Sep 09, 2014 at 10:44:51AM +0200, Robert Baldyga wrote:
>> Hi,
>>
>> I have splitted my patchset "usb: dwc2/gadget: fix series" into two series.
>> This patch series contains improvements for dwc2/gadget driver. It's intended
>> for 3.18.
>>
>> Andrzej Pietrasiewicz (1):
>>   usb: dwc2/gadget: Fix comment text
>>
>> Kamil Debski (1):
>>   usb: dwc2/gadget: move phy bus legth initialization
>>
>> Marek Szyprowski (2):
>>   usb: dwc2/gadget: hide some not really needed debug messages
>>   usb: dwc2/gadget: ensure that all fifos have correct memory buffers
>>
>> Robert Baldyga (2):
>>   usb: dwc2/gadget: assign TX FIFO dynamically
>>   usb: dwc2/gadget: disable clock when it's not needed
>>
>>  drivers/usb/dwc2/core.h   |   3 ++
>>  drivers/usb/dwc2/gadget.c | 132 +++++++++++++++++++++++++++++-----------------
>>  2 files changed, 86 insertions(+), 49 deletions(-)
> 
> As these depend on your previous changes, I'll wait until after those
> get merged into Linus's tree before applying them.  Probably sometime
> next week.

As my first patch series already got merged into Linus' tree, I would
like to remind you about my second patch set :)

Thanks
Robert Baldyga

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

* Re: [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization
  2014-09-09  8:44 ` [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization Robert Baldyga
@ 2014-09-25 12:26   ` Marek Szyprowski
  2014-09-25 12:38     ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Marek Szyprowski @ 2014-09-25 12:26 UTC (permalink / raw)
  To: Robert Baldyga, Paul.Zimmerman
  Cc: gregkh, balbi, linux-usb, linux-kernel, Kamil Debski

Hi Greg and Paul,

On 2014-09-09 10:44, Robert Baldyga wrote:
> From: Kamil Debski <k.debski@samsung.com>
>
> This patch moves the part of code that initializes the PHY bus width.
> This results in simpler code and removes the need to check whether
> the Generic PHY Framework is used.

I've noticed that patches from this patchset have been finally merged to
usb-next tree, but I cannot find this patch there. Is there any reason for
dropping it?

> Signed-off-by: Kamil Debski <k.debski@samsung.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
>   drivers/usb/dwc2/gadget.c | 22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index ce6071d..9cbe136 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3392,6 +3392,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>   	if (!hsotg)
>   		return -ENOMEM;
>   
> +	/* Set default UTMI width */
> +	hsotg->phyif = GUSBCFG_PHYIF16;
> +
>   	/*
>   	 * Attempt to find a generic PHY, then look for an old style
>   	 * USB PHY, finally fall back to pdata
> @@ -3410,8 +3413,15 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>   			hsotg->plat = plat;
>   		} else
>   			hsotg->uphy = uphy;
> -	} else
> +	} else {
>   		hsotg->phy = phy;
> +		/*
> +		 * If using the generic PHY framework, check if the PHY bus
> +		 * width is 8-bit and set the phyif appropriately.
> +		 */
> +		if (phy_get_bus_width(phy) == 8)
> +			hsotg->phyif = GUSBCFG_PHYIF8;
> +	}
>   
>   	hsotg->dev = dev;
>   
> @@ -3471,16 +3481,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>   		goto err_supplies;
>   	}
>   
> -	/* Set default UTMI width */
> -	hsotg->phyif = GUSBCFG_PHYIF16;
> -
> -	/*
> -	 * If using the generic PHY framework, check if the PHY bus
> -	 * width is 8-bit and set the phyif appropriately.
> -	 */
> -	if (hsotg->phy && (phy_get_bus_width(phy) == 8))
> -		hsotg->phyif = GUSBCFG_PHYIF8;
> -
>   	/* usb phy enable */
>   	s3c_hsotg_phy_enable(hsotg);
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

* Re: [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization
  2014-09-25 12:26   ` Marek Szyprowski
@ 2014-09-25 12:38     ` Greg KH
  0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2014-09-25 12:38 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Robert Baldyga, Paul.Zimmerman, balbi, linux-usb, linux-kernel,
	Kamil Debski

On Thu, Sep 25, 2014 at 02:26:58PM +0200, Marek Szyprowski wrote:
> Hi Greg and Paul,
> 
> On 2014-09-09 10:44, Robert Baldyga wrote:
> >From: Kamil Debski <k.debski@samsung.com>
> >
> >This patch moves the part of code that initializes the PHY bus width.
> >This results in simpler code and removes the need to check whether
> >the Generic PHY Framework is used.
> 
> I've noticed that patches from this patchset have been finally merged to
> usb-next tree, but I cannot find this patch there. Is there any reason for
> dropping it?

Ugh, did I miss it somehow?

Yes I did, sorry about that, now applied...

thanks for picking this out.

greg k-h

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

end of thread, other threads:[~2014-09-25 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09  8:44 [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Robert Baldyga
2014-09-09  8:44 ` [PATCH 1/6] usb: dwc2/gadget: move phy bus legth initialization Robert Baldyga
2014-09-25 12:26   ` Marek Szyprowski
2014-09-25 12:38     ` Greg KH
2014-09-09  8:44 ` [PATCH 2/6] usb: dwc2/gadget: Fix comment text Robert Baldyga
2014-09-09  8:44 ` [PATCH 3/6] usb: dwc2/gadget: hide some not really needed debug messages Robert Baldyga
2014-09-09  8:44 ` [PATCH 4/6] usb: dwc2/gadget: ensure that all fifos have correct memory buffers Robert Baldyga
2014-09-09  8:44 ` [PATCH 5/6] usb: dwc2/gadget: assign TX FIFO dynamically Robert Baldyga
2014-09-09  8:44 ` [PATCH 6/6] usb: dwc2/gadget: disable clock when it's not needed Robert Baldyga
2014-09-10 20:34 ` [PATCH 0/6] usb: dwc2/gadget: improvements for gadget driver Greg KH
2014-09-18  9:56   ` Robert Baldyga

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).