linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/0] usb: musb bugfixes
@ 2013-10-16 12:51 Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 1/4] usb: musb: gadget, stay IDLE without gadget driver Markus Pargmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-10-16 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

the series contains two bugfixes and some debugfs file operations for dsps
similar to the musb core regdump debugfs file.

Regards,

Markus Pargmann

Changes in v3:
- Using debugfs_reg32 for regdump debug file
- Added a patch to replace kzalloc with devm_kzalloc
- otg->gadget_driver NULL pointer handling was replaced by a musb_g_reset
  patch to force IDLE states when no gadget driver is loaded.


Markus Pargmann (4):
      usb: musb: gadget, stay IDLE without gadget driver
      usb: musb: Bugfix of_node assignment
      usb: musb: dsps, debugfs files
      usb: musb: dsps, use devm_kzalloc

 drivers/usb/musb/musb_core.c   | 15 ++++++++---
 drivers/usb/musb/musb_dsps.c   | 60 +++++++++++++++++++++++++++++++++++++++---
 drivers/usb/musb/musb_gadget.c | 14 ++++++++--
 3 files changed, 79 insertions(+), 10 deletions(-)

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

* [PATCH v3 1/4] usb: musb: gadget, stay IDLE without gadget driver
  2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
@ 2013-10-16 12:51 ` Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 2/4] usb: musb: Bugfix of_node assignment Markus Pargmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-10-16 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

If there is no gadget driver musb should stay in B_IDLE state.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/usb/musb/musb_core.c   |  3 ---
 drivers/usb/musb/musb_gadget.c | 14 ++++++++++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 18e877f..7d40dec 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -831,12 +831,9 @@ b_host:
 			case OTG_STATE_B_WAIT_ACON:
 				dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
 					usb_otg_state_string(musb->xceiv->state));
-				musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
 				musb_g_reset(musb);
 				break;
 			case OTG_STATE_B_IDLE:
-				musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
-				/* FALLTHROUGH */
 			case OTG_STATE_B_PERIPHERAL:
 				musb_g_reset(musb);
 				break;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index b19ed21..fddda5d 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -2113,10 +2113,20 @@ __acquires(musb->lock)
 	 * or else after HNP, as A-Device
 	 */
 	if (devctl & MUSB_DEVCTL_BDEVICE) {
-		musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+		if (!musb->gadget_driver) {
+			musb->is_active = 0;
+			musb->xceiv->state = OTG_STATE_B_IDLE;
+		} else {
+			musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+		}
 		musb->g.is_a_peripheral = 0;
 	} else {
-		musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+		if (!musb->gadget_driver) {
+			musb->is_active = 0;
+			musb->xceiv->state = OTG_STATE_A_IDLE;
+		} else {
+			musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+		}
 		musb->g.is_a_peripheral = 1;
 	}
 
-- 
1.8.4.rc3

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

* [PATCH v3 2/4] usb: musb: Bugfix of_node assignment
  2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 1/4] usb: musb: gadget, stay IDLE without gadget driver Markus Pargmann
@ 2013-10-16 12:51 ` Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 3/4] usb: musb: dsps, debugfs files Markus Pargmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-10-16 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

It is not safe to assign the of_node to a device without driver. The
device is matched against a list of drivers and the of_node could lead
to a DT match with the parent driver.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/usb/musb/musb_core.c | 12 +++++++++++-
 drivers/usb/musb/musb_dsps.c |  1 -
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 7d40dec..651cce0 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1958,6 +1958,7 @@ static int musb_probe(struct platform_device *pdev)
 	int		irq = platform_get_irq_byname(pdev, "mc");
 	struct resource	*iomem;
 	void __iomem	*base;
+	int ret;
 
 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!iomem || irq <= 0)
@@ -1967,7 +1968,16 @@ static int musb_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	return musb_init_controller(dev, irq, base);
+	if (dev->parent)
+		dev->of_node = dev->parent->of_node;
+
+	ret = musb_init_controller(dev, irq, base);
+	if (ret) {
+		dev->of_node = NULL;
+		return ret;
+	}
+
+	return 0;
 }
 
 static int musb_remove(struct platform_device *pdev)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index bd4138d..189e52c 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -483,7 +483,6 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
 	musb->dev.parent		= dev;
 	musb->dev.dma_mask		= &musb_dmamask;
 	musb->dev.coherent_dma_mask	= musb_dmamask;
-	musb->dev.of_node		= of_node_get(dn);
 
 	glue->musb = musb;
 
-- 
1.8.4.rc3

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

* [PATCH v3 3/4] usb: musb: dsps, debugfs files
  2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 1/4] usb: musb: gadget, stay IDLE without gadget driver Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 2/4] usb: musb: Bugfix of_node assignment Markus Pargmann
@ 2013-10-16 12:51 ` Markus Pargmann
  2013-10-16 12:51 ` [PATCH v3 4/4] usb: musb: dsps, use devm_kzalloc Markus Pargmann
  2013-11-05 11:11 ` [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-10-16 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

debugfs files to show the contents of important dsps registers.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/usb/musb/musb_dsps.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 189e52c..0680f0e 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -46,6 +46,8 @@
 #include <linux/of_irq.h>
 #include <linux/usb/of.h>
 
+#include <linux/debugfs.h>
+
 #include "musb_core.h"
 
 static const struct of_device_id musb_dsps_of_match[];
@@ -119,6 +121,27 @@ struct dsps_glue {
 	const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
 	struct timer_list timer;	/* otg_workaround timer */
 	unsigned long last_timer;    /* last timer data for each instance */
+
+	struct debugfs_regset32 regset;
+	struct dentry *dbgfs_root;
+};
+
+static const struct debugfs_reg32 dsps_musb_regs[] = {
+	{ "revision",		0x00 },
+	{ "control",		0x14 },
+	{ "status",		0x18 },
+	{ "eoi",		0x24 },
+	{ "intr0_stat",		0x30 },
+	{ "intr1_stat",		0x34 },
+	{ "intr0_set",		0x38 },
+	{ "intr1_set",		0x3c },
+	{ "txmode",		0x70 },
+	{ "rxmode",		0x74 },
+	{ "autoreq",		0xd0 },
+	{ "srpfixtime",		0xd4 },
+	{ "tdown",		0xd8 },
+	{ "phy_utmi",		0xe0 },
+	{ "mode",		0xe8 },
 };
 
 /**
@@ -348,6 +371,30 @@ out:
 	return ret;
 }
 
+static int dsps_musb_dbg_init(struct musb *musb, struct dsps_glue *glue)
+{
+	struct dentry *root;
+	struct dentry *file;
+	char buf[128];
+
+	sprintf(buf, "%s.dsps", dev_name(musb->controller));
+	root = debugfs_create_dir(buf, NULL);
+	if (!root)
+		return -ENOMEM;
+	glue->dbgfs_root = root;
+
+	glue->regset.regs = dsps_musb_regs;
+	glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs);
+	glue->regset.base = musb->ctrl_base;
+
+	file = debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset);
+	if (!file) {
+		debugfs_remove_recursive(root);
+		return -ENOMEM;
+	}
+	return 0;
+}
+
 static int dsps_musb_init(struct musb *musb)
 {
 	struct device *dev = musb->controller;
@@ -357,6 +404,7 @@ static int dsps_musb_init(struct musb *musb)
 	void __iomem *reg_base;
 	struct resource *r;
 	u32 rev, val;
+	int ret;
 
 	r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
 	if (!r)
@@ -390,6 +438,10 @@ static int dsps_musb_init(struct musb *musb)
 	val &= ~(1 << wrp->otg_disable);
 	dsps_writel(musb->ctrl_base, wrp->phy_utmi, val);
 
+	ret = dsps_musb_dbg_init(musb, glue);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
@@ -587,6 +639,9 @@ static int dsps_remove(struct platform_device *pdev)
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	kfree(glue);
+
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	return 0;
 }
 
-- 
1.8.4.rc3

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

* [PATCH v3 4/4] usb: musb: dsps, use devm_kzalloc
  2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
                   ` (2 preceding siblings ...)
  2013-10-16 12:51 ` [PATCH v3 3/4] usb: musb: dsps, debugfs files Markus Pargmann
@ 2013-10-16 12:51 ` Markus Pargmann
  2013-11-05 11:11 ` [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-10-16 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/usb/musb/musb_dsps.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 0680f0e..aae017c 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -597,7 +597,7 @@ static int dsps_probe(struct platform_device *pdev)
 	wrp = match->data;
 
 	/* allocate glue */
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "unable to allocate glue memory\n");
 		return -ENOMEM;
@@ -625,7 +625,6 @@ err3:
 	pm_runtime_put(&pdev->dev);
 err2:
 	pm_runtime_disable(&pdev->dev);
-	kfree(glue);
 	return ret;
 }
 
@@ -638,7 +637,6 @@ static int dsps_remove(struct platform_device *pdev)
 	/* disable usbss clocks */
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	kfree(glue);
 
 	debugfs_remove_recursive(glue->dbgfs_root);
 
-- 
1.8.4.rc3

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

* [PATCH v3 0/0] usb: musb bugfixes
  2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
                   ` (3 preceding siblings ...)
  2013-10-16 12:51 ` [PATCH v3 4/4] usb: musb: dsps, use devm_kzalloc Markus Pargmann
@ 2013-11-05 11:11 ` Markus Pargmann
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Pargmann @ 2013-11-05 11:11 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Felipe,

On Wed, Oct 16, 2013 at 02:51:08PM +0200, Markus Pargmann wrote:
> Hi,
> 
> the series contains two bugfixes and some debugfs file operations for dsps
> similar to the musb core regdump debugfs file.

Do you have some time to look at these patches?

Thanks,

Markus Pargmann

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

end of thread, other threads:[~2013-11-05 11:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 12:51 [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann
2013-10-16 12:51 ` [PATCH v3 1/4] usb: musb: gadget, stay IDLE without gadget driver Markus Pargmann
2013-10-16 12:51 ` [PATCH v3 2/4] usb: musb: Bugfix of_node assignment Markus Pargmann
2013-10-16 12:51 ` [PATCH v3 3/4] usb: musb: dsps, debugfs files Markus Pargmann
2013-10-16 12:51 ` [PATCH v3 4/4] usb: musb: dsps, use devm_kzalloc Markus Pargmann
2013-11-05 11:11 ` [PATCH v3 0/0] usb: musb bugfixes Markus Pargmann

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