devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] usb: added palmas-usb driver and a few misc fixes
@ 2013-03-05 14:21 Kishon Vijay Abraham I
  2013-03-05 14:21 ` [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work Kishon Vijay Abraham I
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2013-03-05 14:21 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon, s-guiriec,
	gg, sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

Added palmas-usb driver which is mainly used as comparator driver to
detect vbus/id events when a USB cable is connected and passes on the
event information to omap glue (dwc3-omap.c)

The other fixes include setting dma_mask for dwc3 device since device
tree doesn't fill dma_mask, returning EPROBE_DEFER if probe has not yet
called and replace *_* with *-* in property names in musb glue since
that is the usual convention followed.

Graeme Gregory (1):
  USB: Palmas OTG Transceiver Driver

Kishon Vijay Abraham I (3):
  usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to
    work
  usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet
    executed
  usb: musb: omap2430: replace *_* with *-* in property names

 Documentation/devicetree/bindings/usb/omap-usb.txt |   12 +-
 .../devicetree/bindings/usb/twlxxxx-usb.txt        |   15 +
 drivers/usb/dwc3/dwc3-omap.c                       |   17 +-
 drivers/usb/musb/omap2430.c                        |    6 +-
 drivers/usb/otg/Kconfig                            |    6 +
 drivers/usb/otg/Makefile                           |    1 +
 drivers/usb/otg/palmas-usb.c                       |  399 ++++++++++++++++++++
 include/linux/mfd/palmas.h                         |    7 +-
 include/linux/usb/dwc3-omap.h                      |    6 +-
 9 files changed, 454 insertions(+), 15 deletions(-)
 create mode 100644 drivers/usb/otg/palmas-usb.c

-- 
1.7.10.4

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

* [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work
  2013-03-05 14:21 [PATCH 0/4] usb: added palmas-usb driver and a few misc fixes Kishon Vijay Abraham I
@ 2013-03-05 14:21 ` Kishon Vijay Abraham I
       [not found]   ` <1362493320-13913-2-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
  2013-03-05 14:21 ` [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed Kishon Vijay Abraham I
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2013-03-05 14:21 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon, s-guiriec,
	gg, sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

While creating the child devices, *of_platform_populate* sets only
coherent_dma_mask but USBHCD sets *uses_dma* (determines whether the
controller is DMA'able) based on dma_mask. So If we haven't explicitly set
dma_mask, the HCD thinks the controller is not DMA'able and the
controller will fail. So explicity set dma_mask for dwc3 after
*of_platform_populate*.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 35b9673..19c6e72 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -277,6 +277,14 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
 	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, 0x00);
 }
 
+static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
+
+static int dwc3_omap_set_dmamask(struct device *dev, void *c)
+{
+	dev->dma_mask = &dwc3_omap_dma_mask;
+	return 0;
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct device_node	*node = pdev->dev.of_node;
@@ -381,6 +389,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	device_for_each_child(&pdev->dev, NULL, dwc3_omap_set_dmamask);
+
 	return 0;
 }
 
-- 
1.7.10.4


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

* [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
  2013-03-05 14:21 [PATCH 0/4] usb: added palmas-usb driver and a few misc fixes Kishon Vijay Abraham I
  2013-03-05 14:21 ` [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work Kishon Vijay Abraham I
@ 2013-03-05 14:21 ` Kishon Vijay Abraham I
  2013-03-05 14:56   ` Felipe Balbi
       [not found] ` <1362493320-13913-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
  2013-03-05 14:22 ` [PATCH 4/4] usb: musb: omap2430: replace *_* with *-* in property names Kishon Vijay Abraham I
  3 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2013-03-05 14:21 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon, s-guiriec,
	gg, sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
dwc3-omap has not yet been executed or failed.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
 include/linux/usb/dwc3-omap.h |    6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 19c6e72..9428f4e 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
-void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 {
 	u32			val;
 	struct dwc3_omap	*omap = _omap;
 
+	if (!omap)
+		return -EPROBE_DEFER;
+
 	switch (status) {
 	case OMAP_DWC3_ID_GROUND:
 		dev_dbg(omap->dev, "ID GND\n");
@@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 		dev_dbg(omap->dev, "ID float\n");
 	}
 
-	return;
+	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
 
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
index 51eae14..5615f4d 100644
--- a/include/linux/usb/dwc3-omap.h
+++ b/include/linux/usb/dwc3-omap.h
@@ -19,11 +19,11 @@ enum omap_dwc3_vbus_id_status {
 };
 
 #if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
-extern void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
+extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
 #else
-static inline void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 {
-	return;
+	return -ENODEV;
 }
 #endif
 
-- 
1.7.10.4


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

* [PATCH 3/4] USB: Palmas OTG Transceiver Driver
       [not found] ` <1362493320-13913-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
@ 2013-03-05 14:21   ` Kishon Vijay Abraham I
  2013-03-05 16:48     ` Stephen Warren
  0 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2013-03-05 14:21 UTC (permalink / raw)
  To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, rob-VoJi6FS/r0vR7s880joybQ,
	balbi-l0cyMroinI0, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	kishon-l0cyMroinI0, s-guiriec-l0cyMroinI0,
	gg-kDsPt+C1G03kYMGBc/C6ZA, sameo-VuQAYsv1563Yd54FQh9/CA,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

From: Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>

This is the driver for the OTG transceiver built into the Palmas chip. It
handles the various USB OTG events that can be generated by cable
insertion/removal.

Signed-off-by: Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>
Signed-off-by: Moiz Sonasath <m-sonasath-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ruchika Kharwar <ruchika-l0cyMroinI0@public.gmane.org>
Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
Signed-off-by: Sebastien Guiriec <s-guiriec-l0cyMroinI0@public.gmane.org>
---
This driver is contributed by a lot of people fixing various issues that
came along. All the fixes has been squashed into this single patch.
I've included their *Signed-off-by*.
 .../devicetree/bindings/usb/twlxxxx-usb.txt        |   15 +
 drivers/usb/otg/Kconfig                            |    6 +
 drivers/usb/otg/Makefile                           |    1 +
 drivers/usb/otg/palmas-usb.c                       |  399 ++++++++++++++++++++
 include/linux/mfd/palmas.h                         |    7 +-
 5 files changed, 427 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/otg/palmas-usb.c

diff --git a/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt b/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
index 36b9aed..6d941ef 100644
--- a/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
@@ -38,3 +38,18 @@ twl4030-usb {
 	usb3v1-supply = <&vusb3v1>;
 	usb_mode = <1>;
 };
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+ - ti,no_control_vbus: if the platform wishes its own vbus control
+
+palmas-usb {
+	compatible = "ti,palmas-usb";
+	vbus-supply = <&smps10_reg>;
+	ti,wakeup;
+};
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 37962c9..5b40e04 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -138,4 +138,10 @@ config USB_MV_OTG
 
 	  To compile this driver as a module, choose M here.
 
+config PALMAS_USB
+	tristate "Palmas USB Transceiver Driver"
+	depends on MFD_PALMAS
+	help
+	  Enable this to support the Palmas OTG transceiver
+
 endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index a844b8d..7ae90ba 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -22,3 +22,4 @@ fsl_usb2_otg-objs		:= fsl_otg.o otg_fsm.o
 obj-$(CONFIG_FSL_USB2_OTG)	+= fsl_usb2_otg.o
 obj-$(CONFIG_USB_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
+obj-$(CONFIG_PALMAS_USB)	+= palmas-usb.o
diff --git a/drivers/usb/otg/palmas-usb.c b/drivers/usb/otg/palmas-usb.c
new file mode 100644
index 0000000..1bd8d7e
--- /dev/null
+++ b/drivers/usb/otg/palmas-usb.c
@@ -0,0 +1,399 @@
+/*
+ * Palmas USB transceiver driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Author: Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>
+ * Author: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/usb/omap_usb.h>
+#include <linux/usb/dwc3-omap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/err.h>
+#include <linux/notifier.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+static int palmas_usb_read(struct palmas *palmas, unsigned int reg,
+		unsigned int *dest)
+{
+	unsigned int addr;
+	int slave;
+
+	slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+	addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+	return regmap_read(palmas->regmap[slave], addr, dest);
+}
+
+static int palmas_usb_write(struct palmas *palmas, unsigned int reg,
+		unsigned int data)
+{
+	unsigned int addr;
+	int slave;
+
+	slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+	addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+	return regmap_write(palmas->regmap[slave], addr, data);
+}
+
+static void palmas_usb_wakeup(struct palmas *palmas, int enable)
+{
+	if (enable)
+		palmas_usb_write(palmas, PALMAS_USB_WAKEUP,
+				PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
+	else
+		palmas_usb_write(palmas, PALMAS_USB_WAKEUP, 0);
+}
+
+static ssize_t palmas_usb_vbus_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	unsigned long		flags;
+	int			ret = -EINVAL;
+	struct palmas_usb	*palmas_usb = dev_get_drvdata(dev);
+
+	spin_lock_irqsave(&palmas_usb->lock, flags);
+
+	switch (palmas_usb->linkstat) {
+	case OMAP_DWC3_VBUS_VALID:
+	       ret = snprintf(buf, PAGE_SIZE, "vbus\n");
+	       break;
+	case OMAP_DWC3_ID_GROUND:
+	       ret = snprintf(buf, PAGE_SIZE, "id\n");
+	       break;
+	case OMAP_DWC3_ID_FLOAT:
+	case OMAP_DWC3_VBUS_OFF:
+	       ret = snprintf(buf, PAGE_SIZE, "none\n");
+	       break;
+	default:
+	       ret = snprintf(buf, PAGE_SIZE, "UNKNOWN\n");
+	}
+	spin_unlock_irqrestore(&palmas_usb->lock, flags);
+
+	return ret;
+}
+static DEVICE_ATTR(vbus, 0444, palmas_usb_vbus_show, NULL);
+
+static irqreturn_t palmas_vbus_wakeup_irq(int irq, void *_palmas_usb)
+{
+	struct palmas_usb *palmas_usb = _palmas_usb;
+	enum omap_dwc3_vbus_id_status status = OMAP_DWC3_UNKNOWN;
+	int slave;
+	unsigned int vbus_line_state, addr;
+
+	slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
+	addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE,
+			PALMAS_INT3_LINE_STATE);
+
+	regmap_read(palmas_usb->palmas->regmap[slave], addr, &vbus_line_state);
+
+	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
+		if (palmas_usb->linkstat != OMAP_DWC3_VBUS_VALID) {
+			if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+				regulator_enable(palmas_usb->vbus_reg);
+			status = OMAP_DWC3_VBUS_VALID;
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious connect event detected\n");
+		}
+	} else if (!(vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS)) {
+		if (palmas_usb->linkstat == OMAP_DWC3_VBUS_VALID) {
+			if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+				regulator_disable(palmas_usb->vbus_reg);
+			status = OMAP_DWC3_VBUS_OFF;
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious disconnect event detected\n");
+		}
+	}
+
+	palmas_usb->linkstat = status;
+	if (status != OMAP_DWC3_UNKNOWN)
+		return dwc3_omap_mailbox(status);
+
+	return IRQ_NONE;
+}
+
+static irqreturn_t palmas_id_wakeup_irq(int irq, void *_palmas_usb)
+{
+	enum omap_dwc3_vbus_id_status status = OMAP_DWC3_UNKNOWN;
+	unsigned int		set;
+	struct palmas_usb	*palmas_usb = _palmas_usb;
+
+	palmas_usb_read(palmas_usb->palmas, PALMAS_USB_ID_INT_LATCH_SET, &set);
+
+	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_enable(palmas_usb->vbus_reg);
+		palmas_usb_write(palmas_usb->palmas,
+					PALMAS_USB_ID_INT_EN_HI_SET,
+					PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+		palmas_usb_write(palmas_usb->palmas,
+					PALMAS_USB_ID_INT_EN_HI_CLR,
+					PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		status = OMAP_DWC3_ID_GROUND;
+	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+		palmas_usb_write(palmas_usb->palmas,
+					PALMAS_USB_ID_INT_EN_HI_SET,
+					PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+		palmas_usb_write(palmas_usb->palmas,
+					PALMAS_USB_ID_INT_EN_HI_CLR,
+					PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		if (!IS_ERR_OR_NULL(palmas_usb->vbus_reg))
+			regulator_disable(palmas_usb->vbus_reg);
+		status = OMAP_DWC3_ID_FLOAT;
+	}
+
+	palmas_usb->linkstat = status;
+	if (status != OMAP_DWC3_UNKNOWN)
+		return dwc3_omap_mailbox(status);
+
+	return IRQ_NONE;
+}
+
+static int palmas_enable_irq(struct palmas_usb *palmas_usb)
+{
+	int ret;
+
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_VBUS_CTRL_SET,
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
+
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_ID_CTRL_SET,
+			PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+
+	ret = palmas_vbus_wakeup_irq(palmas_usb->irq4, palmas_usb);
+
+	if (palmas_usb->linkstat == OMAP_DWC3_UNKNOWN)
+		ret = palmas_id_wakeup_irq(palmas_usb->irq2, palmas_usb);
+
+	return ret;
+}
+
+static void palmas_set_vbus_work(struct work_struct *data)
+{
+	struct palmas_usb *palmas_usb = container_of(data, struct palmas_usb,
+								set_vbus_work);
+
+	if (IS_ERR_OR_NULL(palmas_usb->vbus_reg)) {
+		dev_err(palmas_usb->dev, "invalid regulator\n");
+		return;
+	}
+
+	/*
+	 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
+	 * register. This enables boost mode.
+	 */
+
+	if (palmas_usb->vbus_enable)
+		regulator_enable(palmas_usb->vbus_reg);
+	else
+		regulator_disable(palmas_usb->vbus_reg);
+}
+
+static int palmas_set_vbus(struct phy_companion *comparator, bool enabled)
+{
+	struct palmas_usb *palmas_usb = comparator_to_palmas(comparator);
+
+	palmas_usb->vbus_enable = enabled;
+	schedule_work(&palmas_usb->set_vbus_work);
+
+	return 0;
+}
+
+static int palmas_start_srp(struct phy_companion *comparator)
+{
+	struct palmas_usb *palmas_usb = comparator_to_palmas(comparator);
+
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_VBUS_CTRL_SET,
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_DISCHRG |
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_VBUS_CTRL_SET,
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+
+	mdelay(100);
+
+	palmas_usb_write(palmas_usb->palmas, PALMAS_USB_VBUS_CTRL_CLR,
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+			PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS);
+
+	return 0;
+}
+
+static void palmas_dt_to_pdata(struct device_node *node,
+		struct palmas_usb_platform_data *pdata)
+{
+	pdata->no_control_vbus = of_property_read_bool(node,
+					"ti,no_control_vbus");
+	pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+}
+
+static int palmas_usb_probe(struct platform_device *pdev)
+{
+	u32 ret;
+	struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
+	struct palmas_usb_platform_data	*pdata = pdev->dev.platform_data;
+	struct device_node *node = pdev->dev.of_node;
+	struct palmas_usb *palmas_usb;
+	int status;
+
+	if (node && !pdata) {
+		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+
+		if (!pdata)
+			return -ENOMEM;
+
+		palmas_dt_to_pdata(node, pdata);
+	}
+
+	if (!pdata)
+		return -EINVAL;
+
+	palmas_usb = devm_kzalloc(&pdev->dev, sizeof(*palmas_usb), GFP_KERNEL);
+	if (!palmas_usb)
+		return -ENOMEM;
+
+	palmas->usb		= palmas_usb;
+	palmas_usb->palmas	= palmas;
+
+	palmas_usb->dev		= &pdev->dev;
+
+	palmas_usb->irq1 = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_OTG_IRQ);
+	palmas_usb->irq2 = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_IRQ);
+	palmas_usb->irq3 = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_OTG_IRQ);
+	palmas_usb->irq4 = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_IRQ);
+
+	palmas_usb->comparator.set_vbus	= palmas_set_vbus;
+	palmas_usb->comparator.start_srp = palmas_start_srp;
+
+	ret = omap_usb2_set_comparator(&palmas_usb->comparator);
+	if (ret == -ENODEV) {
+		dev_dbg(&pdev->dev, "phy not ready, deferring probe");
+		return -EPROBE_DEFER;
+	}
+
+	palmas_usb_wakeup(palmas, pdata->wakeup);
+
+	/* init spinlock for workqueue */
+	spin_lock_init(&palmas_usb->lock);
+
+	if (!pdata->no_control_vbus) {
+		palmas_usb->vbus_reg = devm_regulator_get(&pdev->dev, "vbus");
+		if (IS_ERR(palmas_usb->vbus_reg)) {
+			dev_err(&pdev->dev, "vbus init failed\n");
+			return PTR_ERR(palmas_usb->vbus_reg);
+		}
+	}
+
+	platform_set_drvdata(pdev, palmas_usb);
+
+	if (device_create_file(&pdev->dev, &dev_attr_vbus))
+		dev_warn(&pdev->dev, "could not create sysfs file\n");
+
+	/* init spinlock for workqueue */
+	spin_lock_init(&palmas_usb->lock);
+
+	INIT_WORK(&palmas_usb->set_vbus_work, palmas_set_vbus_work);
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->irq2,
+			NULL, palmas_id_wakeup_irq,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->irq2, status);
+		goto fail_irq;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->irq4,
+			NULL, palmas_vbus_wakeup_irq,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->irq4, status);
+		goto fail_irq;
+	}
+
+	dev_info(&pdev->dev, "Initialized Palmas USB module\n");
+
+	status = palmas_enable_irq(palmas_usb);
+	if (status < 0) {
+		dev_dbg(&pdev->dev, "enable irq failed\n");
+		goto fail_irq;
+	}
+
+	return 0;
+
+fail_irq:
+	cancel_work_sync(&palmas_usb->set_vbus_work);
+	device_remove_file(palmas_usb->dev, &dev_attr_vbus);
+
+	return status;
+}
+
+static int palmas_usb_remove(struct platform_device *pdev)
+{
+	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
+
+	device_remove_file(palmas_usb->dev, &dev_attr_vbus);
+	cancel_work_sync(&palmas_usb->set_vbus_work);
+
+	return 0;
+}
+
+static struct of_device_id of_palmas_match_tbl[] = {
+	{ .compatible = "ti,palmas-usb", },
+	{ /* end */ }
+};
+
+static struct platform_driver palmas_usb_driver = {
+	.probe = palmas_usb_probe,
+	.remove = palmas_usb_remove,
+	.driver = {
+		.name = "palmas-usb",
+		.of_match_table = of_palmas_match_tbl,
+		.owner = THIS_MODULE,
+	},
+};
+
+module_platform_driver(palmas_usb_driver);
+
+MODULE_ALIAS("platform:palmas-usb");
+MODULE_AUTHOR("Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>");
+MODULE_DESCRIPTION("Palmas USB transceiver driver");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index a4d13d7..f1c936c 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -19,6 +19,9 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/usb/dwc3-omap.h>
+#include <linux/platform_data/dwc3-omap.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -341,6 +344,8 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
+	struct phy_companion comparator;
+
 	/* for vbus reporting with irqs disabled */
 	spinlock_t lock;
 
@@ -356,7 +361,7 @@ struct palmas_usb {
 
 	int vbus_enable;
 
-	u8 linkstat;
+	enum omap_dwc3_vbus_id_status linkstat;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.7.10.4

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

* [PATCH 4/4] usb: musb: omap2430: replace *_* with *-* in property names
  2013-03-05 14:21 [PATCH 0/4] usb: added palmas-usb driver and a few misc fixes Kishon Vijay Abraham I
                   ` (2 preceding siblings ...)
       [not found] ` <1362493320-13913-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
@ 2013-03-05 14:22 ` Kishon Vijay Abraham I
  3 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2013-03-05 14:22 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon, s-guiriec,
	gg, sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

No functional change. Replace *_* with *-* in property names of otg to
follow the general convention.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |   12 ++++++------
 drivers/usb/musb/omap2430.c                        |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 1b9f55f..662f0f1 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -8,10 +8,10 @@ OMAP MUSB GLUE
    and disconnect.
  - multipoint : Should be "1" indicating the musb controller supports
    multipoint. This is a MUSB configuration-specific setting.
- - num_eps : Specifies the number of endpoints. This is also a
+ - num-eps : Specifies the number of endpoints. This is also a
    MUSB configuration-specific setting. Should be set to "16"
- - ram_bits : Specifies the ram address size. Should be set to "12"
- - interface_type : This is a board specific setting to describe the type of
+ - ram-bits : Specifies the ram address size. Should be set to "12"
+ - interface-type : This is a board specific setting to describe the type of
    interface between the controller and the phy. It should be "0" or "1"
    specifying ULPI and UTMI respectively.
  - mode : Should be "3" to represent OTG. "1" signifies HOST and "2"
@@ -29,14 +29,14 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
 	ti,hwmods = "usb_otg_hs";
 	ti,has-mailbox;
 	multipoint = <1>;
-	num_eps = <16>;
-	ram_bits = <12>;
+	num-eps = <16>;
+	ram-bits = <12>;
 	ctrl-module = <&omap_control_usb>;
 };
 
 Board specific device node entry
 &usb_otg_hs {
-	interface_type = <1>;
+	interface-type = <1>;
 	mode = <3>;
 	power = <50>;
 };
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 1762354..dde2802 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -522,10 +522,10 @@ static int omap2430_probe(struct platform_device *pdev)
 		}
 
 		of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
-		of_property_read_u32(np, "interface_type",
+		of_property_read_u32(np, "interface-type",
 						(u32 *)&data->interface_type);
-		of_property_read_u32(np, "num_eps", (u32 *)&config->num_eps);
-		of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits);
+		of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
+		of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
 		of_property_read_u32(np, "power", (u32 *)&pdata->power);
 		config->multipoint = of_property_read_bool(np, "multipoint");
 		pdata->has_mailbox = of_property_read_bool(np,
-- 
1.7.10.4

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

* Re: [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work
       [not found]   ` <1362493320-13913-2-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
@ 2013-03-05 14:54     ` Felipe Balbi
       [not found]       ` <20130305145458.GF12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Balbi @ 2013-03-05 14:54 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, s-guiriec-l0cyMroinI0,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, gg-kDsPt+C1G03kYMGBc/C6ZA


[-- Attachment #1.1: Type: text/plain, Size: 1857 bytes --]

On Tue, Mar 05, 2013 at 07:51:57PM +0530, Kishon Vijay Abraham I wrote:
> While creating the child devices, *of_platform_populate* sets only
> coherent_dma_mask but USBHCD sets *uses_dma* (determines whether the
> controller is DMA'able) based on dma_mask. So If we haven't explicitly set
> dma_mask, the HCD thinks the controller is not DMA'able and the
> controller will fail. So explicity set dma_mask for dwc3 after
> *of_platform_populate*.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
> ---
>  drivers/usb/dwc3/dwc3-omap.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index 35b9673..19c6e72 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -277,6 +277,14 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
>  	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, 0x00);
>  }
>  
> +static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
> +
> +static int dwc3_omap_set_dmamask(struct device *dev, void *c)
> +{
> +	dev->dma_mask = &dwc3_omap_dma_mask;
> +	return 0;
> +}
> +
>  static int dwc3_omap_probe(struct platform_device *pdev)
>  {
>  	struct device_node	*node = pdev->dev.of_node;
> @@ -381,6 +389,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	device_for_each_child(&pdev->dev, NULL, dwc3_omap_set_dmamask);

I don't think this is correct. Child should be setting its own by
copying from parent. In summary I think we should add this to dwc3 core:

dma_set_coherent_mask(&pdev->dev, pdev->dev.parent->coherent_dma_mask);
pdev->dev.dma_mask = pdev->dev.parent->dma_mask;
pdev->dev.dma_parms = pdev->dev.parent->dma_parms;

And add the same thing to xhci-plat.c btw.

-- 
balbi

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
  2013-03-05 14:21 ` [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed Kishon Vijay Abraham I
@ 2013-03-05 14:56   ` Felipe Balbi
       [not found]     ` <20130305145645.GG12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Balbi @ 2013-03-05 14:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: grant.likely, rob.herring, rob, balbi, gregkh, s-guiriec, gg,
	sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

[-- Attachment #1: Type: text/plain, Size: 1301 bytes --]

On Tue, Mar 05, 2013 at 07:51:58PM +0530, Kishon Vijay Abraham I wrote:
> return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
> dwc3-omap has not yet been executed or failed.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
>  include/linux/usb/dwc3-omap.h |    6 +++---
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index 19c6e72..9428f4e 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
>  	writel(value, base + offset);
>  }
>  
> -void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> +int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>  {
>  	u32			val;
>  	struct dwc3_omap	*omap = _omap;
>  
> +	if (!omap)
> +		return -EPROBE_DEFER;
> +
>  	switch (status) {
>  	case OMAP_DWC3_ID_GROUND:
>  		dev_dbg(omap->dev, "ID GND\n");
> @@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>  		dev_dbg(omap->dev, "ID float\n");
>  	}
>  
> -	return;
> +	return IRQ_HANDLED;

IRQ_HANDLED ????

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work
       [not found]       ` <20130305145458.GF12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
@ 2013-03-05 14:59         ` kishon
  2013-03-05 15:11           ` Felipe Balbi
  0 siblings, 1 reply; 14+ messages in thread
From: kishon @ 2013-03-05 14:59 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, s-guiriec-l0cyMroinI0,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, gg-kDsPt+C1G03kYMGBc/C6ZA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, sameo-VuQAYsv1563Yd54FQh9/CA

Hi,

On Tuesday 05 March 2013 08:24 PM, Felipe Balbi wrote:
> On Tue, Mar 05, 2013 at 07:51:57PM +0530, Kishon Vijay Abraham I wrote:
>> While creating the child devices, *of_platform_populate* sets only
>> coherent_dma_mask but USBHCD sets *uses_dma* (determines whether the
>> controller is DMA'able) based on dma_mask. So If we haven't explicitly set
>> dma_mask, the HCD thinks the controller is not DMA'able and the
>> controller will fail. So explicity set dma_mask for dwc3 after
>> *of_platform_populate*.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
>> ---
>>   drivers/usb/dwc3/dwc3-omap.c |   10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
>> index 35b9673..19c6e72 100644
>> --- a/drivers/usb/dwc3/dwc3-omap.c
>> +++ b/drivers/usb/dwc3/dwc3-omap.c
>> @@ -277,6 +277,14 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
>>   	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, 0x00);
>>   }
>>
>> +static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
>> +
>> +static int dwc3_omap_set_dmamask(struct device *dev, void *c)
>> +{
>> +	dev->dma_mask = &dwc3_omap_dma_mask;
>> +	return 0;
>> +}
>> +
>>   static int dwc3_omap_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node	*node = pdev->dev.of_node;
>> @@ -381,6 +389,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
>>   		return ret;
>>   	}
>>
>> +	device_for_each_child(&pdev->dev, NULL, dwc3_omap_set_dmamask);
>
> I don't think this is correct. Child should be setting its own by
> copying from parent. In summary I think we should add this to dwc3 core:
>
> dma_set_coherent_mask(&pdev->dev, pdev->dev.parent->coherent_dma_mask);
> pdev->dev.dma_mask = pdev->dev.parent->dma_mask;
> pdev->dev.dma_parms = pdev->dev.parent->dma_parms;
>
> And add the same thing to xhci-plat.c btw.

hmm.. ok.

Thanks
Kishon

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

* Re: [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
       [not found]     ` <20130305145645.GG12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
@ 2013-03-05 15:01       ` kishon
       [not found]         ` <513608E6.3010502-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: kishon @ 2013-03-05 15:01 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, s-guiriec-l0cyMroinI0,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, gg-kDsPt+C1G03kYMGBc/C6ZA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, sameo-VuQAYsv1563Yd54FQh9/CA

Hi,

On Tuesday 05 March 2013 08:26 PM, Felipe Balbi wrote:
> On Tue, Mar 05, 2013 at 07:51:58PM +0530, Kishon Vijay Abraham I wrote:
>> return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
>> dwc3-omap has not yet been executed or failed.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
>> ---
>>   drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
>>   include/linux/usb/dwc3-omap.h |    6 +++---
>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
>> index 19c6e72..9428f4e 100644
>> --- a/drivers/usb/dwc3/dwc3-omap.c
>> +++ b/drivers/usb/dwc3/dwc3-omap.c
>> @@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
>>   	writel(value, base + offset);
>>   }
>>
>> -void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>> +int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>>   {
>>   	u32			val;
>>   	struct dwc3_omap	*omap = _omap;
>>
>> +	if (!omap)
>> +		return -EPROBE_DEFER;
>> +
>>   	switch (status) {
>>   	case OMAP_DWC3_ID_GROUND:
>>   		dev_dbg(omap->dev, "ID GND\n");
>> @@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>>   		dev_dbg(omap->dev, "ID float\n");
>>   	}
>>
>> -	return;
>> +	return IRQ_HANDLED;
>
> IRQ_HANDLED ????

Actually I did it that way since palmas_vbus_wakeup_irq can directly 
return the return value from dwc3_omap_mailbox. If this seems hacky to 
you, I'll change it.

Thanks
Kishon

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

* Re: [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
       [not found]         ` <513608E6.3010502-l0cyMroinI0@public.gmane.org>
@ 2013-03-05 15:06           ` Felipe Balbi
  2013-03-05 15:18             ` kishon
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Balbi @ 2013-03-05 15:06 UTC (permalink / raw)
  To: kishon
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, s-guiriec-l0cyMroinI0,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, balbi-l0cyMroinI0,
	sameo-VuQAYsv1563Yd54FQh9/CA, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	gg-kDsPt+C1G03kYMGBc/C6ZA


[-- Attachment #1.1: Type: text/plain, Size: 1838 bytes --]

On Tue, Mar 05, 2013 at 08:31:58PM +0530, kishon wrote:
> Hi,
> 
> On Tuesday 05 March 2013 08:26 PM, Felipe Balbi wrote:
> >On Tue, Mar 05, 2013 at 07:51:58PM +0530, Kishon Vijay Abraham I wrote:
> >>return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
> >>dwc3-omap has not yet been executed or failed.
> >>
> >>Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
> >>---
> >>  drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
> >>  include/linux/usb/dwc3-omap.h |    6 +++---
> >>  2 files changed, 8 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> >>index 19c6e72..9428f4e 100644
> >>--- a/drivers/usb/dwc3/dwc3-omap.c
> >>+++ b/drivers/usb/dwc3/dwc3-omap.c
> >>@@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
> >>  	writel(value, base + offset);
> >>  }
> >>
> >>-void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>+int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>  {
> >>  	u32			val;
> >>  	struct dwc3_omap	*omap = _omap;
> >>
> >>+	if (!omap)
> >>+		return -EPROBE_DEFER;
> >>+
> >>  	switch (status) {
> >>  	case OMAP_DWC3_ID_GROUND:
> >>  		dev_dbg(omap->dev, "ID GND\n");
> >>@@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>  		dev_dbg(omap->dev, "ID float\n");
> >>  	}
> >>
> >>-	return;
> >>+	return IRQ_HANDLED;
> >
> >IRQ_HANDLED ????
> 
> Actually I did it that way since palmas_vbus_wakeup_irq can directly
> return the return value from dwc3_omap_mailbox. If this seems hacky
> to you, I'll change it.

it does seem hacky :-) Try something like:

ret = dwc3_omap_mailbox();
if (ret)
	print_error();

return IRQ_HANDLED;

-- 
balbi

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work
  2013-03-05 14:59         ` kishon
@ 2013-03-05 15:11           ` Felipe Balbi
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2013-03-05 15:11 UTC (permalink / raw)
  To: kishon
  Cc: balbi, grant.likely, rob.herring, rob, gregkh, s-guiriec, gg,
	sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

[-- Attachment #1: Type: text/plain, Size: 2187 bytes --]

On Tue, Mar 05, 2013 at 08:29:34PM +0530, kishon wrote:
> Hi,
> 
> On Tuesday 05 March 2013 08:24 PM, Felipe Balbi wrote:
> >On Tue, Mar 05, 2013 at 07:51:57PM +0530, Kishon Vijay Abraham I wrote:
> >>While creating the child devices, *of_platform_populate* sets only
> >>coherent_dma_mask but USBHCD sets *uses_dma* (determines whether the
> >>controller is DMA'able) based on dma_mask. So If we haven't explicitly set
> >>dma_mask, the HCD thinks the controller is not DMA'able and the
> >>controller will fail. So explicity set dma_mask for dwc3 after
> >>*of_platform_populate*.
> >>
> >>Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> >>---
> >>  drivers/usb/dwc3/dwc3-omap.c |   10 ++++++++++
> >>  1 file changed, 10 insertions(+)
> >>
> >>diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> >>index 35b9673..19c6e72 100644
> >>--- a/drivers/usb/dwc3/dwc3-omap.c
> >>+++ b/drivers/usb/dwc3/dwc3-omap.c
> >>@@ -277,6 +277,14 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
> >>  	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, 0x00);
> >>  }
> >>
> >>+static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
> >>+
> >>+static int dwc3_omap_set_dmamask(struct device *dev, void *c)
> >>+{
> >>+	dev->dma_mask = &dwc3_omap_dma_mask;
> >>+	return 0;
> >>+}
> >>+
> >>  static int dwc3_omap_probe(struct platform_device *pdev)
> >>  {
> >>  	struct device_node	*node = pdev->dev.of_node;
> >>@@ -381,6 +389,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
> >>  		return ret;
> >>  	}
> >>
> >>+	device_for_each_child(&pdev->dev, NULL, dwc3_omap_set_dmamask);
> >
> >I don't think this is correct. Child should be setting its own by
> >copying from parent. In summary I think we should add this to dwc3 core:
> >
> >dma_set_coherent_mask(&pdev->dev, pdev->dev.parent->coherent_dma_mask);
> >pdev->dev.dma_mask = pdev->dev.parent->dma_mask;
> >pdev->dev.dma_parms = pdev->dev.parent->dma_parms;
> >
> >And add the same thing to xhci-plat.c btw.
> 
> hmm.. ok.

another thing, this means that we can remove similar code from
dwc3-pci.c and dwc3-exynos.c ;-)

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
  2013-03-05 15:06           ` Felipe Balbi
@ 2013-03-05 15:18             ` kishon
       [not found]               ` <51360CC0.9080108-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: kishon @ 2013-03-05 15:18 UTC (permalink / raw)
  To: balbi
  Cc: grant.likely, rob.herring, rob, gregkh, s-guiriec, gg, sameo,
	broonie, ldewangan, devicetree-discuss, linux-doc, linux-kernel,
	linux-usb, linux-omap

Hi,

On Tuesday 05 March 2013 08:36 PM, Felipe Balbi wrote:
> On Tue, Mar 05, 2013 at 08:31:58PM +0530, kishon wrote:
>> Hi,
>>
>> On Tuesday 05 March 2013 08:26 PM, Felipe Balbi wrote:
>>> On Tue, Mar 05, 2013 at 07:51:58PM +0530, Kishon Vijay Abraham I wrote:
>>>> return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
>>>> dwc3-omap has not yet been executed or failed.
>>>>
>>>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>>>> ---
>>>>   drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
>>>>   include/linux/usb/dwc3-omap.h |    6 +++---
>>>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
>>>> index 19c6e72..9428f4e 100644
>>>> --- a/drivers/usb/dwc3/dwc3-omap.c
>>>> +++ b/drivers/usb/dwc3/dwc3-omap.c
>>>> @@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
>>>>   	writel(value, base + offset);
>>>>   }
>>>>
>>>> -void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>>>> +int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>>>>   {
>>>>   	u32			val;
>>>>   	struct dwc3_omap	*omap = _omap;
>>>>
>>>> +	if (!omap)
>>>> +		return -EPROBE_DEFER;
>>>> +
>>>>   	switch (status) {
>>>>   	case OMAP_DWC3_ID_GROUND:
>>>>   		dev_dbg(omap->dev, "ID GND\n");
>>>> @@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
>>>>   		dev_dbg(omap->dev, "ID float\n");
>>>>   	}
>>>>
>>>> -	return;
>>>> +	return IRQ_HANDLED;
>>>
>>> IRQ_HANDLED ????
>>
>> Actually I did it that way since palmas_vbus_wakeup_irq can directly
>> return the return value from dwc3_omap_mailbox. If this seems hacky
>> to you, I'll change it.
>
> it does seem hacky :-) Try something like:
>
> ret = dwc3_omap_mailbox();
> if (ret)
> 	print_error();
>
> return IRQ_HANDLED;

hmm.. But there is one case where palmas_vbus_wakeup_irq should return 
EPROBE_DEFER. In the cold plug case, if palmas gets loaded before 
dwc3-omap, omap in dwc3_omap_mailbox will be NULL. So ideally palmas 
should be probed after dwc3-omap for this case. Returning IRQ_HANDLED or 
IRQ_NONE wont help here.

Thanks
Kishon




>


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

* Re: [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
       [not found]               ` <51360CC0.9080108-l0cyMroinI0@public.gmane.org>
@ 2013-03-05 15:21                 ` Felipe Balbi
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2013-03-05 15:21 UTC (permalink / raw)
  To: kishon
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, s-guiriec-l0cyMroinI0,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, balbi-l0cyMroinI0,
	sameo-VuQAYsv1563Yd54FQh9/CA, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	gg-kDsPt+C1G03kYMGBc/C6ZA


[-- Attachment #1.1: Type: text/plain, Size: 2720 bytes --]

On Tue, Mar 05, 2013 at 08:48:24PM +0530, kishon wrote:
> Hi,
> 
> On Tuesday 05 March 2013 08:36 PM, Felipe Balbi wrote:
> >On Tue, Mar 05, 2013 at 08:31:58PM +0530, kishon wrote:
> >>Hi,
> >>
> >>On Tuesday 05 March 2013 08:26 PM, Felipe Balbi wrote:
> >>>On Tue, Mar 05, 2013 at 07:51:58PM +0530, Kishon Vijay Abraham I wrote:
> >>>>return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
> >>>>dwc3-omap has not yet been executed or failed.
> >>>>
> >>>>Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
> >>>>---
> >>>>  drivers/usb/dwc3/dwc3-omap.c  |    7 +++++--
> >>>>  include/linux/usb/dwc3-omap.h |    6 +++---
> >>>>  2 files changed, 8 insertions(+), 5 deletions(-)
> >>>>
> >>>>diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> >>>>index 19c6e72..9428f4e 100644
> >>>>--- a/drivers/usb/dwc3/dwc3-omap.c
> >>>>+++ b/drivers/usb/dwc3/dwc3-omap.c
> >>>>@@ -138,11 +138,14 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
> >>>>  	writel(value, base + offset);
> >>>>  }
> >>>>
> >>>>-void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>>>+int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>>>  {
> >>>>  	u32			val;
> >>>>  	struct dwc3_omap	*omap = _omap;
> >>>>
> >>>>+	if (!omap)
> >>>>+		return -EPROBE_DEFER;
> >>>>+
> >>>>  	switch (status) {
> >>>>  	case OMAP_DWC3_ID_GROUND:
> >>>>  		dev_dbg(omap->dev, "ID GND\n");
> >>>>@@ -185,7 +188,7 @@ void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
> >>>>  		dev_dbg(omap->dev, "ID float\n");
> >>>>  	}
> >>>>
> >>>>-	return;
> >>>>+	return IRQ_HANDLED;
> >>>
> >>>IRQ_HANDLED ????
> >>
> >>Actually I did it that way since palmas_vbus_wakeup_irq can directly
> >>return the return value from dwc3_omap_mailbox. If this seems hacky
> >>to you, I'll change it.
> >
> >it does seem hacky :-) Try something like:
> >
> >ret = dwc3_omap_mailbox();
> >if (ret)
> >	print_error();
> >
> >return IRQ_HANDLED;
> 
> hmm.. But there is one case where palmas_vbus_wakeup_irq should
> return EPROBE_DEFER. In the cold plug case, if palmas gets loaded
> before dwc3-omap, omap in dwc3_omap_mailbox will be NULL. So ideally
> palmas should be probed after dwc3-omap for this case. Returning
> IRQ_HANDLED or IRQ_NONE wont help here.

you can return IRQ_HANDLED but don't clear the IRQ status bits, which
will make the IRQ retrigger, right ?

If you return -EPROBE_DEFER from within the IRQ handler, what will
happen ? IRQ subsystem only understands IRQ_NONE, IRQ_WAKE_THREAD, and
IRQ_HANDLED. How do you suppose it will treat -EPROBE_DEFER ?

-- 
balbi

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH 3/4] USB: Palmas OTG Transceiver Driver
  2013-03-05 14:21   ` [PATCH 3/4] USB: Palmas OTG Transceiver Driver Kishon Vijay Abraham I
@ 2013-03-05 16:48     ` Stephen Warren
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Warren @ 2013-03-05 16:48 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: grant.likely, rob.herring, rob, balbi, gregkh, s-guiriec, gg,
	sameo, broonie, ldewangan, devicetree-discuss, linux-doc,
	linux-kernel, linux-usb, linux-omap

On 03/05/2013 07:21 AM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
> 
> This is the driver for the OTG transceiver built into the Palmas chip. It
> handles the various USB OTG events that can be generated by cable

> diff --git a/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt b/Documentation/devicetree/bindings/usb/twlxxxx-usb.txt

> +palmas-usb {
> +	compatible = "ti,palmas-usb";

The example should probably demonstrate best DT practices, and include a
specific chip name in the compatible value too. In other words,
something like:

compatible = "ti,twl12345-usb", "ti,palmas-usb";

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

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

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 14:21 [PATCH 0/4] usb: added palmas-usb driver and a few misc fixes Kishon Vijay Abraham I
2013-03-05 14:21 ` [PATCH 1/4] usb: dwc3: dwc3-omap: set dma_mask for dwc3 inorder for host mode to work Kishon Vijay Abraham I
     [not found]   ` <1362493320-13913-2-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2013-03-05 14:54     ` Felipe Balbi
     [not found]       ` <20130305145458.GF12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-03-05 14:59         ` kishon
2013-03-05 15:11           ` Felipe Balbi
2013-03-05 14:21 ` [PATCH 2/4] usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed Kishon Vijay Abraham I
2013-03-05 14:56   ` Felipe Balbi
     [not found]     ` <20130305145645.GG12123-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-03-05 15:01       ` kishon
     [not found]         ` <513608E6.3010502-l0cyMroinI0@public.gmane.org>
2013-03-05 15:06           ` Felipe Balbi
2013-03-05 15:18             ` kishon
     [not found]               ` <51360CC0.9080108-l0cyMroinI0@public.gmane.org>
2013-03-05 15:21                 ` Felipe Balbi
     [not found] ` <1362493320-13913-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2013-03-05 14:21   ` [PATCH 3/4] USB: Palmas OTG Transceiver Driver Kishon Vijay Abraham I
2013-03-05 16:48     ` Stephen Warren
2013-03-05 14:22 ` [PATCH 4/4] usb: musb: omap2430: replace *_* with *-* in property names Kishon Vijay Abraham I

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