All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] palmas usb driver
@ 2013-05-24 14:31 ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

This patch series adds driver for palmas usb which is used to detect
attach/detach events of usb device and usb host.

[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
is added in this patch series itself. The revision history is added
in the patch comments section.

A checkpatch warning "WARNING: static const char * array should
probably be static const char * const"is ignored since it introduces a
compilation warning.

Graeme Gregory (2):
  drivers: regulator: palmas: add an API to set/clear the switch bit on
    SMPS10
  extcon: Palmas Extcon Driver

Kishon Vijay Abraham I (1):
  usb: dwc3: use extcon fwrk to receive connect/disconnect notification

 .../devicetree/bindings/extcon/extcon-twl.txt      |  16 +
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 341 +++++++++++++++++++++
 drivers/regulator/palmas-regulator.c               |  26 ++
 drivers/usb/dwc3/dwc3-omap.c                       |  80 +++--
 include/linux/mfd/palmas.h                         |  27 +-
 include/linux/usb/dwc3-omap.h                      |  30 --
 8 files changed, 470 insertions(+), 58 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c
 delete mode 100644 include/linux/usb/dwc3-omap.h

-- 
1.8.1.2


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

* [PATCH 0/3] palmas usb driver
@ 2013-05-24 14:31 ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

This patch series adds driver for palmas usb which is used to detect
attach/detach events of usb device and usb host.

[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
is added in this patch series itself. The revision history is added
in the patch comments section.

A checkpatch warning "WARNING: static const char * array should
probably be static const char * const"is ignored since it introduces a
compilation warning.

Graeme Gregory (2):
  drivers: regulator: palmas: add an API to set/clear the switch bit on
    SMPS10
  extcon: Palmas Extcon Driver

Kishon Vijay Abraham I (1):
  usb: dwc3: use extcon fwrk to receive connect/disconnect notification

 .../devicetree/bindings/extcon/extcon-twl.txt      |  16 +
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 341 +++++++++++++++++++++
 drivers/regulator/palmas-regulator.c               |  26 ++
 drivers/usb/dwc3/dwc3-omap.c                       |  80 +++--
 include/linux/mfd/palmas.h                         |  27 +-
 include/linux/usb/dwc3-omap.h                      |  30 --
 8 files changed, 470 insertions(+), 58 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c
 delete mode 100644 include/linux/usb/dwc3-omap.h

-- 
1.8.1.2

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

* [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
  2013-05-24 14:31 ` Kishon Vijay Abraham I
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

Added an API to set/clear the switch bit on SMPS10 which can be used by
palmas usb. The switch bit should be set in order for palmas to
supply VBUS and is needed when OMAP is acting as USB HOST.

Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
 include/linux/mfd/palmas.h           |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 92ceed0..d57ab55 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
 	return ret;
 }
 
+/**
+ * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
+ * @param palmas pointer to the palmas mfd structure
+ * @param sw boolean to indicate switch status
+ *
+ * There is not a way to represent this function within the regulator
+ * framework. This sets/clears the switch of SMPS10 so SMPS10_OUT1 and
+ * SMPS10_OUT2 are shorted together.
+ */
+int palmas_set_switch_smps10(struct palmas *palmas, int sw)
+{
+	unsigned int reg;
+
+	palmas_smps_read(palmas, PALMAS_SMPS10_CTRL, &reg);
+
+	if (sw)
+		reg |= SMPS10_SWITCH_EN;
+	else
+		reg &= ~SMPS10_SWITCH_EN;
+
+	palmas_smps_write(palmas, PALMAS_SMPS10_CTRL, reg);
+
+	return 0;
+}
+EXPORT_SYMBOL(palmas_set_switch_smps10);
+
 static struct regulator_ops palmas_ops_smps = {
 	.is_enabled		= palmas_is_enabled_smps,
 	.enable			= palmas_enable_smps,
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 8f21daf..6df375d 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -404,6 +404,8 @@ enum usb_irq_events {
 	N_PALMAS_USB_VOTG_SESS_VLD,
 };
 
+extern int palmas_set_switch_smps10(struct palmas *palmas, int sw);
+
 /* defines so we can store the mux settings */
 #define PALMAS_GPIO_0_MUXED					(1 << 0)
 #define PALMAS_GPIO_1_MUXED					(1 << 1)
-- 
1.8.1.2


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

* [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

Added an API to set/clear the switch bit on SMPS10 which can be used by
palmas usb. The switch bit should be set in order for palmas to
supply VBUS and is needed when OMAP is acting as USB HOST.

Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
 include/linux/mfd/palmas.h           |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 92ceed0..d57ab55 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
 	return ret;
 }
 
+/**
+ * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
+ * @param palmas pointer to the palmas mfd structure
+ * @param sw boolean to indicate switch status
+ *
+ * There is not a way to represent this function within the regulator
+ * framework. This sets/clears the switch of SMPS10 so SMPS10_OUT1 and
+ * SMPS10_OUT2 are shorted together.
+ */
+int palmas_set_switch_smps10(struct palmas *palmas, int sw)
+{
+	unsigned int reg;
+
+	palmas_smps_read(palmas, PALMAS_SMPS10_CTRL, &reg);
+
+	if (sw)
+		reg |= SMPS10_SWITCH_EN;
+	else
+		reg &= ~SMPS10_SWITCH_EN;
+
+	palmas_smps_write(palmas, PALMAS_SMPS10_CTRL, reg);
+
+	return 0;
+}
+EXPORT_SYMBOL(palmas_set_switch_smps10);
+
 static struct regulator_ops palmas_ops_smps = {
 	.is_enabled		= palmas_is_enabled_smps,
 	.enable			= palmas_enable_smps,
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 8f21daf..6df375d 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -404,6 +404,8 @@ enum usb_irq_events {
 	N_PALMAS_USB_VOTG_SESS_VLD,
 };
 
+extern int palmas_set_switch_smps10(struct palmas *palmas, int sw);
+
 /* defines so we can store the mux settings */
 #define PALMAS_GPIO_0_MUXED					(1 << 0)
 #define PALMAS_GPIO_1_MUXED					(1 << 1)
-- 
1.8.1.2


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

* [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-24 14:31 ` Kishon Vijay Abraham I
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

This is the driver for the USB comparator 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@slimlogic.co.uk>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: George Cherian <george.cherian@ti.com>
[kishon@ti.com: adapted palmas usb driver to use the extcon framework]
Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
---
Changes from v4:
* removed no_control_vbus property (to be used if the platform wants to use
its own vbus control.
* removed unnecessary headers
* moved the palmas_usb_state to palmas.h
* misc cleanups
*A checkpatch warning "WARNING: static const char * array should
 probably be static const char * const"is ignored since it introduces a
 compilation warning.
Changes from v3:
* adapted the driver to extcon framework (so moved to drivers/extcon)
* removed palmas_usb_(write/read) and replaced all calls with
  palmas_(read/write).
* ignored a checkpatch warning in the line 
	static const char *palmas_extcon_cable[] = {
  as it seemed to be incorrect?
* removed all references to OMAP in this driver.
* couldn't test this driver with mainline as omap5 panda is not booting
  with mainline.
* A comment to change to platform_get_irq from regmap is not done as I felt
  the data should come from regmap in this case. Graeme?
Changes from v2:
* Moved the driver to drivers/usb/phy/
* Added a bit more explanation in Kconfig
 .../devicetree/bindings/extcon/extcon-twl.txt      |  16 +
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 341 +++++++++++++++++++++
 include/linux/mfd/palmas.h                         |  25 +-
 5 files changed, 380 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c

diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
new file mode 100644
index 0000000..8ffdeed
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
@@ -0,0 +1,15 @@
+EXTCON FOR TWL CHIPS
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+
+palmas-usb {
+       compatible = "ti,twl6035-usb", "ti,palmas-usb";
+       vbus-supply = <&smps10_reg>;
+       ti,wakeup;
+};
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 3297301..63f454e 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -53,4 +53,11 @@ config EXTCON_ARIZONA
 	  with Wolfson Arizona devices. These are audio CODECs with
 	  advanced audio accessory detection support.
 
+config EXTCON_PALMAS
+	tristate "Palmas USB EXTCON support"
+	depends on MFD_PALMAS
+	help
+	  Say Y here to enable support for USB peripheral and USB host
+	  detection by palmas usb.
+
 endif # MULTISTATE_SWITCH
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index f98a3c4..540e2c3 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
 obj-$(CONFIG_EXTCON_MAX8997)	+= extcon-max8997.o
 obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
+obj-$(CONFIG_EXTCON_PALMAS)	+= extcon-palmas.o
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
new file mode 100644
index 0000000..9e613e9
--- /dev/null
+++ b/drivers/extcon/extcon-palmas.c
@@ -0,0 +1,341 @@
+/*
+ * 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@slimlogic.co.uk>
+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK <hemahk@ti.com>
+ *
+ * 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/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/err.h>
+#include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+static const char *palmas_extcon_cable[] = {
+	[0] = "USB",
+	[1] = "USB-HOST",
+	NULL,
+};
+
+static const int mutually_exclusive[] = {0x3, 0x0};
+
+static void palmas_usb_wakeup(struct palmas *palmas, int enable)
+{
+	if (enable)
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP,
+			PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
+	else
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP, 0);
+}
+
+static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
+{
+	int ret;
+	struct palmas_usb *palmas_usb = _palmas_usb;
+	unsigned int vbus_line_state;
+
+	palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE,
+		PALMAS_INT3_LINE_STATE, &vbus_line_state);
+
+	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
+		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
+			if (palmas_usb->vbus_reg) {
+				ret = regulator_enable(palmas_usb->vbus_reg);
+				if (ret) {
+					dev_dbg(palmas_usb->dev,
+						"regulator enable failed\n");
+					goto ret0;
+				}
+			}
+			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+		} 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 == PALMAS_USB_STATE_VBUS) {
+			if (palmas_usb->vbus_reg)
+				regulator_disable(palmas_usb->vbus_reg);
+			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious disconnect event detected\n");
+		}
+	}
+
+ret0:
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
+{
+	int			ret;
+	unsigned int		set;
+	struct palmas_usb	*palmas_usb = _palmas_usb;
+
+	palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_LATCH_SET, &set);
+
+	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+		palmas_set_switch_smps10(palmas_usb->palmas, 1);
+		if (palmas_usb->vbus_reg) {
+			ret = regulator_enable(palmas_usb->vbus_reg);
+			if (ret) {
+				dev_dbg(palmas_usb->dev,
+					"regulator enable failed\n");
+				goto ret0;
+			}
+		}
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_usb->linkstat = PALMAS_USB_STATE_ID;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
+	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		if (palmas_usb->vbus_reg)
+			regulator_disable(palmas_usb->vbus_reg);
+		palmas_set_switch_smps10(palmas_usb->palmas, 0);
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+	}
+
+ret0:
+	return IRQ_HANDLED;
+}
+
+static void palmas_enable_irq(struct palmas_usb *palmas_usb)
+{
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_EN_HI_SET,
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+
+	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+
+	/* cold plug for host mode needs this delay */
+	msleep(30);
+	palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+}
+
+static void palmas_set_vbus_work(struct work_struct *data)
+{
+	int ret;
+	struct palmas_usb *palmas_usb = container_of(data, struct palmas_usb,
+								set_vbus_work);
+
+	/*
+	 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
+	 * register. This enables boost mode.
+	 */
+
+	if (palmas_usb->vbus_enable) {
+		ret = regulator_enable(palmas_usb->vbus_reg);
+		if (ret)
+			dev_dbg(palmas_usb->dev, "regulator enable failed\n");
+	} 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_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET, PALMAS_USB_VBUS_CTRL_SET_VBUS_DISCHRG
+		| PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+
+	msleep(100);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_CLR,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS);
+
+	return 0;
+}
+
+static int palmas_usb_probe(struct platform_device *pdev)
+{
+	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;
+
+		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+	}
+
+	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->id_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_OTG_IRQ);
+	palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_IRQ);
+	palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_OTG_IRQ);
+	palmas_usb->vbus_irq = 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;
+
+	palmas_usb_wakeup(palmas, pdata->wakeup);
+
+	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);
+	}
+
+	INIT_WORK(&palmas_usb->set_vbus_work, palmas_set_vbus_work);
+
+	platform_set_drvdata(pdev, palmas_usb);
+
+	palmas_usb->edev.name = "palmas-usb";
+	palmas_usb->edev.supported_cable = palmas_extcon_cable;
+	palmas_usb->edev.mutually_exclusive = mutually_exclusive;
+
+	status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
+	if (status) {
+		dev_err(&pdev->dev, "failed to register extcon device\n");
+		goto fail_irq;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
+			NULL, palmas_id_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_id", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->id_irq, status);
+		goto fail_extcon;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev,
+			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_vbus", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->vbus_irq, status);
+		goto fail_extcon;
+	}
+
+	palmas_enable_irq(palmas_usb);
+
+	return 0;
+
+fail_extcon:
+	extcon_dev_unregister(&palmas_usb->edev);
+
+fail_irq:
+	cancel_work_sync(&palmas_usb->set_vbus_work);
+
+	return status;
+}
+
+static int palmas_usb_remove(struct platform_device *pdev)
+{
+	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
+
+		cancel_work_sync(&palmas_usb->set_vbus_work);
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return 0;
+}
+
+static struct of_device_id of_palmas_match_tbl[] = {
+	{ .compatible = "ti,palmas-usb", },
+	{ .compatible = "ti,twl6035-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@slimlogic.co.uk>");
+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 6df375d..eb4846b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,6 +20,8 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/extcon.h>
+#include <linux/usb/phy_companion.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -37,6 +39,12 @@ struct palmas_gpadc;
 struct palmas_resource;
 struct palmas_usb;
 
+enum palmas_usb_state {
+	PALMAS_USB_STATE_DISCONNECT,
+	PALMAS_USB_STATE_VBUS,
+	PALMAS_USB_STATE_ID,
+};
+
 struct palmas {
 	struct device *dev;
 
@@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
 };
 
 struct palmas_usb_platform_data {
-	/* Set this if platform wishes its own vbus control */
-	int no_control_vbus;
-
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
 };
@@ -350,22 +355,22 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
-	/* for vbus reporting with irqs disabled */
-	spinlock_t lock;
+	struct extcon_dev edev;
+	struct phy_companion comparator;
 
 	struct regulator *vbus_reg;
 
 	/* used to set vbus, in atomic path */
 	struct work_struct set_vbus_work;
 
-	int irq1;
-	int irq2;
-	int irq3;
-	int irq4;
+	int id_otg_irq;
+	int id_irq;
+	int vbus_otg_irq;
+	int vbus_irq;
 
 	int vbus_enable;
 
-	u8 linkstat;
+	enum palmas_usb_state linkstat;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.8.1.2


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

* [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

This is the driver for the USB comparator 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@slimlogic.co.uk>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: George Cherian <george.cherian@ti.com>
[kishon@ti.com: adapted palmas usb driver to use the extcon framework]
Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
---
Changes from v4:
* removed no_control_vbus property (to be used if the platform wants to use
its own vbus control.
* removed unnecessary headers
* moved the palmas_usb_state to palmas.h
* misc cleanups
*A checkpatch warning "WARNING: static const char * array should
 probably be static const char * const"is ignored since it introduces a
 compilation warning.
Changes from v3:
* adapted the driver to extcon framework (so moved to drivers/extcon)
* removed palmas_usb_(write/read) and replaced all calls with
  palmas_(read/write).
* ignored a checkpatch warning in the line 
	static const char *palmas_extcon_cable[] = {
  as it seemed to be incorrect?
* removed all references to OMAP in this driver.
* couldn't test this driver with mainline as omap5 panda is not booting
  with mainline.
* A comment to change to platform_get_irq from regmap is not done as I felt
  the data should come from regmap in this case. Graeme?
Changes from v2:
* Moved the driver to drivers/usb/phy/
* Added a bit more explanation in Kconfig
 .../devicetree/bindings/extcon/extcon-twl.txt      |  16 +
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 341 +++++++++++++++++++++
 include/linux/mfd/palmas.h                         |  25 +-
 5 files changed, 380 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c

diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
new file mode 100644
index 0000000..8ffdeed
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
@@ -0,0 +1,15 @@
+EXTCON FOR TWL CHIPS
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+
+palmas-usb {
+       compatible = "ti,twl6035-usb", "ti,palmas-usb";
+       vbus-supply = <&smps10_reg>;
+       ti,wakeup;
+};
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 3297301..63f454e 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -53,4 +53,11 @@ config EXTCON_ARIZONA
 	  with Wolfson Arizona devices. These are audio CODECs with
 	  advanced audio accessory detection support.
 
+config EXTCON_PALMAS
+	tristate "Palmas USB EXTCON support"
+	depends on MFD_PALMAS
+	help
+	  Say Y here to enable support for USB peripheral and USB host
+	  detection by palmas usb.
+
 endif # MULTISTATE_SWITCH
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index f98a3c4..540e2c3 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
 obj-$(CONFIG_EXTCON_MAX8997)	+= extcon-max8997.o
 obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
+obj-$(CONFIG_EXTCON_PALMAS)	+= extcon-palmas.o
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
new file mode 100644
index 0000000..9e613e9
--- /dev/null
+++ b/drivers/extcon/extcon-palmas.c
@@ -0,0 +1,341 @@
+/*
+ * 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@slimlogic.co.uk>
+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK <hemahk@ti.com>
+ *
+ * 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/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/usb/phy_companion.h>
+#include <linux/err.h>
+#include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+static const char *palmas_extcon_cable[] = {
+	[0] = "USB",
+	[1] = "USB-HOST",
+	NULL,
+};
+
+static const int mutually_exclusive[] = {0x3, 0x0};
+
+static void palmas_usb_wakeup(struct palmas *palmas, int enable)
+{
+	if (enable)
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP,
+			PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
+	else
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP, 0);
+}
+
+static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
+{
+	int ret;
+	struct palmas_usb *palmas_usb = _palmas_usb;
+	unsigned int vbus_line_state;
+
+	palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE,
+		PALMAS_INT3_LINE_STATE, &vbus_line_state);
+
+	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
+		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
+			if (palmas_usb->vbus_reg) {
+				ret = regulator_enable(palmas_usb->vbus_reg);
+				if (ret) {
+					dev_dbg(palmas_usb->dev,
+						"regulator enable failed\n");
+					goto ret0;
+				}
+			}
+			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+		} 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 == PALMAS_USB_STATE_VBUS) {
+			if (palmas_usb->vbus_reg)
+				regulator_disable(palmas_usb->vbus_reg);
+			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious disconnect event detected\n");
+		}
+	}
+
+ret0:
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
+{
+	int			ret;
+	unsigned int		set;
+	struct palmas_usb	*palmas_usb = _palmas_usb;
+
+	palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_LATCH_SET, &set);
+
+	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+		palmas_set_switch_smps10(palmas_usb->palmas, 1);
+		if (palmas_usb->vbus_reg) {
+			ret = regulator_enable(palmas_usb->vbus_reg);
+			if (ret) {
+				dev_dbg(palmas_usb->dev,
+					"regulator enable failed\n");
+				goto ret0;
+			}
+		}
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_usb->linkstat = PALMAS_USB_STATE_ID;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
+	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		if (palmas_usb->vbus_reg)
+			regulator_disable(palmas_usb->vbus_reg);
+		palmas_set_switch_smps10(palmas_usb->palmas, 0);
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+	}
+
+ret0:
+	return IRQ_HANDLED;
+}
+
+static void palmas_enable_irq(struct palmas_usb *palmas_usb)
+{
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_EN_HI_SET,
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+
+	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+
+	/* cold plug for host mode needs this delay */
+	msleep(30);
+	palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+}
+
+static void palmas_set_vbus_work(struct work_struct *data)
+{
+	int ret;
+	struct palmas_usb *palmas_usb = container_of(data, struct palmas_usb,
+								set_vbus_work);
+
+	/*
+	 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
+	 * register. This enables boost mode.
+	 */
+
+	if (palmas_usb->vbus_enable) {
+		ret = regulator_enable(palmas_usb->vbus_reg);
+		if (ret)
+			dev_dbg(palmas_usb->dev, "regulator enable failed\n");
+	} 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_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET, PALMAS_USB_VBUS_CTRL_SET_VBUS_DISCHRG
+		| PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
+
+	msleep(100);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_CLR,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS);
+
+	return 0;
+}
+
+static int palmas_usb_probe(struct platform_device *pdev)
+{
+	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;
+
+		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+	}
+
+	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->id_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_OTG_IRQ);
+	palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_IRQ);
+	palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_OTG_IRQ);
+	palmas_usb->vbus_irq = 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;
+
+	palmas_usb_wakeup(palmas, pdata->wakeup);
+
+	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);
+	}
+
+	INIT_WORK(&palmas_usb->set_vbus_work, palmas_set_vbus_work);
+
+	platform_set_drvdata(pdev, palmas_usb);
+
+	palmas_usb->edev.name = "palmas-usb";
+	palmas_usb->edev.supported_cable = palmas_extcon_cable;
+	palmas_usb->edev.mutually_exclusive = mutually_exclusive;
+
+	status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
+	if (status) {
+		dev_err(&pdev->dev, "failed to register extcon device\n");
+		goto fail_irq;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
+			NULL, palmas_id_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_id", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->id_irq, status);
+		goto fail_extcon;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev,
+			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_vbus", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->vbus_irq, status);
+		goto fail_extcon;
+	}
+
+	palmas_enable_irq(palmas_usb);
+
+	return 0;
+
+fail_extcon:
+	extcon_dev_unregister(&palmas_usb->edev);
+
+fail_irq:
+	cancel_work_sync(&palmas_usb->set_vbus_work);
+
+	return status;
+}
+
+static int palmas_usb_remove(struct platform_device *pdev)
+{
+	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
+
+		cancel_work_sync(&palmas_usb->set_vbus_work);
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return 0;
+}
+
+static struct of_device_id of_palmas_match_tbl[] = {
+	{ .compatible = "ti,palmas-usb", },
+	{ .compatible = "ti,twl6035-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@slimlogic.co.uk>");
+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 6df375d..eb4846b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,6 +20,8 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/extcon.h>
+#include <linux/usb/phy_companion.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -37,6 +39,12 @@ struct palmas_gpadc;
 struct palmas_resource;
 struct palmas_usb;
 
+enum palmas_usb_state {
+	PALMAS_USB_STATE_DISCONNECT,
+	PALMAS_USB_STATE_VBUS,
+	PALMAS_USB_STATE_ID,
+};
+
 struct palmas {
 	struct device *dev;
 
@@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
 };
 
 struct palmas_usb_platform_data {
-	/* Set this if platform wishes its own vbus control */
-	int no_control_vbus;
-
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
 };
@@ -350,22 +355,22 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
-	/* for vbus reporting with irqs disabled */
-	spinlock_t lock;
+	struct extcon_dev edev;
+	struct phy_companion comparator;
 
 	struct regulator *vbus_reg;
 
 	/* used to set vbus, in atomic path */
 	struct work_struct set_vbus_work;
 
-	int irq1;
-	int irq2;
-	int irq3;
-	int irq4;
+	int id_otg_irq;
+	int id_irq;
+	int vbus_otg_irq;
+	int vbus_irq;
 
 	int vbus_enable;
 
-	u8 linkstat;
+	enum palmas_usb_state linkstat;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.8.1.2


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

* [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
  2013-05-24 14:31 ` Kishon Vijay Abraham I
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

Modified dwc3-omap to receive connect and disconnect notification using
extcon framework. Also did the necessary cleanups required after
adapting to extcon framework.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c  | 80 +++++++++++++++++++++++++++++++++----------
 include/linux/usb/dwc3-omap.h | 30 ----------------
 2 files changed, 62 insertions(+), 48 deletions(-)
 delete mode 100644 include/linux/usb/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 34638b9..771f936 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,13 +43,13 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
-#include <linux/usb/dwc3-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/extcon.h>
 
 #include <linux/usb/otg.h>
 
@@ -124,9 +124,19 @@ struct dwc3_omap {
 	u32			utmi_otg_status;
 
 	u32			dma_status:1;
+
+	struct extcon_specific_cable_nb extcon_vbus_dev;
+	struct extcon_specific_cable_nb extcon_id_dev;
+	struct notifier_block	vbus_nb;
+	struct notifier_block	id_nb;
 };
 
-static struct dwc3_omap		*_omap;
+enum omap_dwc3_vbus_id_status {
+	OMAP_DWC3_ID_FLOAT,
+	OMAP_DWC3_ID_GROUND,
+	OMAP_DWC3_VBUS_OFF,
+	OMAP_DWC3_VBUS_VALID,
+};
 
 static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
 {
@@ -138,13 +148,10 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
-int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
+	enum omap_dwc3_vbus_id_status status)
 {
-	u32			val;
-	struct dwc3_omap	*omap = _omap;
-
-	if (!omap)
-		return -EPROBE_DEFER;
+	u32	val;
 
 	switch (status) {
 	case OMAP_DWC3_ID_GROUND:
@@ -185,12 +192,9 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 		break;
 
 	default:
-		dev_dbg(omap->dev, "ID float\n");
+		dev_dbg(omap->dev, "invalid state\n");
 	}
-
-	return 0;
 }
-EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
 
 static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
 {
@@ -282,6 +286,32 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
 
 static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
 
+static int dwc3_omap_id_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT);
+
+	return NOTIFY_DONE;
+}
+
+static int dwc3_omap_vbus_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF);
+
+	return NOTIFY_DONE;
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct device_node	*node = pdev->dev.of_node;
@@ -289,6 +319,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	struct dwc3_omap	*omap;
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
+	struct extcon_dev	*edev;
 
 	int			ret = -ENOMEM;
 	int			irq;
@@ -330,19 +361,25 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	edev = extcon_get_extcon_dev("palmas-usb");
+	if (!edev) {
+		dev_dbg(dev, "couldn't get extcon device\n");
+		return -EPROBE_DEFER;
+	}
+
 	spin_lock_init(&omap->lock);
 
 	omap->dev	= dev;
 	omap->irq	= irq;
 	omap->base	= base;
+	omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
+	extcon_register_interest(&omap->extcon_vbus_dev, "palmas-usb", "USB",
+		&omap->vbus_nb);
+	omap->id_nb.notifier_call = dwc3_omap_id_notifier;
+	extcon_register_interest(&omap->extcon_id_dev, "palmas-usb", "USB-HOST",
+		&omap->id_nb);
 	dev->dma_mask	= &dwc3_omap_dma_mask;
 
-	/*
-	 * REVISIT if we ever have two instances of the wrapper, we will be
-	 * in big trouble
-	 */
-	_omap	= omap;
-
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
@@ -387,6 +424,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	if (extcon_get_cable_state(edev, "USB") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	if (extcon_get_cable_state(edev, "USB-HOST") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+
 	return 0;
 }
 
@@ -394,6 +436,8 @@ static int dwc3_omap_remove(struct platform_device *pdev)
 {
 	struct dwc3_omap	*omap = platform_get_drvdata(pdev);
 
+	extcon_unregister_interest(&omap->extcon_vbus_dev);
+	extcon_unregister_interest(&omap->extcon_id_dev);
 	dwc3_omap_disable_irqs(omap);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
deleted file mode 100644
index 5615f4d..0000000
--- a/include/linux/usb/dwc3-omap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2013 by Texas Instruments
- *
- * The Inventra Controller Driver for Linux is free software; you
- * can redistribute it and/or modify it under the terms of the GNU
- * General Public License version 2 as published by the Free Software
- * Foundation.
- */
-
-#ifndef __DWC3_OMAP_H__
-#define __DWC3_OMAP_H__
-
-enum omap_dwc3_vbus_id_status {
-	OMAP_DWC3_UNKNOWN = 0,
-	OMAP_DWC3_ID_GROUND,
-	OMAP_DWC3_ID_FLOAT,
-	OMAP_DWC3_VBUS_VALID,
-	OMAP_DWC3_VBUS_OFF,
-};
-
-#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
-extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
-#else
-static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
-{
-	return -ENODEV;
-}
-#endif
-
-#endif	/* __DWC3_OMAP_H__ */
-- 
1.8.1.2


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

* [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-24 14:31   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-24 14:31 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

Modified dwc3-omap to receive connect and disconnect notification using
extcon framework. Also did the necessary cleanups required after
adapting to extcon framework.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c  | 80 +++++++++++++++++++++++++++++++++----------
 include/linux/usb/dwc3-omap.h | 30 ----------------
 2 files changed, 62 insertions(+), 48 deletions(-)
 delete mode 100644 include/linux/usb/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 34638b9..771f936 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,13 +43,13 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
-#include <linux/usb/dwc3-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/extcon.h>
 
 #include <linux/usb/otg.h>
 
@@ -124,9 +124,19 @@ struct dwc3_omap {
 	u32			utmi_otg_status;
 
 	u32			dma_status:1;
+
+	struct extcon_specific_cable_nb extcon_vbus_dev;
+	struct extcon_specific_cable_nb extcon_id_dev;
+	struct notifier_block	vbus_nb;
+	struct notifier_block	id_nb;
 };
 
-static struct dwc3_omap		*_omap;
+enum omap_dwc3_vbus_id_status {
+	OMAP_DWC3_ID_FLOAT,
+	OMAP_DWC3_ID_GROUND,
+	OMAP_DWC3_VBUS_OFF,
+	OMAP_DWC3_VBUS_VALID,
+};
 
 static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
 {
@@ -138,13 +148,10 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
-int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
+	enum omap_dwc3_vbus_id_status status)
 {
-	u32			val;
-	struct dwc3_omap	*omap = _omap;
-
-	if (!omap)
-		return -EPROBE_DEFER;
+	u32	val;
 
 	switch (status) {
 	case OMAP_DWC3_ID_GROUND:
@@ -185,12 +192,9 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 		break;
 
 	default:
-		dev_dbg(omap->dev, "ID float\n");
+		dev_dbg(omap->dev, "invalid state\n");
 	}
-
-	return 0;
 }
-EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
 
 static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
 {
@@ -282,6 +286,32 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
 
 static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
 
+static int dwc3_omap_id_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT);
+
+	return NOTIFY_DONE;
+}
+
+static int dwc3_omap_vbus_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF);
+
+	return NOTIFY_DONE;
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct device_node	*node = pdev->dev.of_node;
@@ -289,6 +319,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	struct dwc3_omap	*omap;
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
+	struct extcon_dev	*edev;
 
 	int			ret = -ENOMEM;
 	int			irq;
@@ -330,19 +361,25 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	edev = extcon_get_extcon_dev("palmas-usb");
+	if (!edev) {
+		dev_dbg(dev, "couldn't get extcon device\n");
+		return -EPROBE_DEFER;
+	}
+
 	spin_lock_init(&omap->lock);
 
 	omap->dev	= dev;
 	omap->irq	= irq;
 	omap->base	= base;
+	omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
+	extcon_register_interest(&omap->extcon_vbus_dev, "palmas-usb", "USB",
+		&omap->vbus_nb);
+	omap->id_nb.notifier_call = dwc3_omap_id_notifier;
+	extcon_register_interest(&omap->extcon_id_dev, "palmas-usb", "USB-HOST",
+		&omap->id_nb);
 	dev->dma_mask	= &dwc3_omap_dma_mask;
 
-	/*
-	 * REVISIT if we ever have two instances of the wrapper, we will be
-	 * in big trouble
-	 */
-	_omap	= omap;
-
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
@@ -387,6 +424,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	if (extcon_get_cable_state(edev, "USB") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	if (extcon_get_cable_state(edev, "USB-HOST") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+
 	return 0;
 }
 
@@ -394,6 +436,8 @@ static int dwc3_omap_remove(struct platform_device *pdev)
 {
 	struct dwc3_omap	*omap = platform_get_drvdata(pdev);
 
+	extcon_unregister_interest(&omap->extcon_vbus_dev);
+	extcon_unregister_interest(&omap->extcon_id_dev);
 	dwc3_omap_disable_irqs(omap);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
deleted file mode 100644
index 5615f4d..0000000
--- a/include/linux/usb/dwc3-omap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2013 by Texas Instruments
- *
- * The Inventra Controller Driver for Linux is free software; you
- * can redistribute it and/or modify it under the terms of the GNU
- * General Public License version 2 as published by the Free Software
- * Foundation.
- */
-
-#ifndef __DWC3_OMAP_H__
-#define __DWC3_OMAP_H__
-
-enum omap_dwc3_vbus_id_status {
-	OMAP_DWC3_UNKNOWN = 0,
-	OMAP_DWC3_ID_GROUND,
-	OMAP_DWC3_ID_FLOAT,
-	OMAP_DWC3_VBUS_VALID,
-	OMAP_DWC3_VBUS_OFF,
-};
-
-#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
-extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
-#else
-static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
-{
-	return -ENODEV;
-}
-#endif
-
-#endif	/* __DWC3_OMAP_H__ */
-- 
1.8.1.2


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

* Re: [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
@ 2013-05-24 15:09     ` Sergei Shtylyov
  0 siblings, 0 replies; 50+ messages in thread
From: Sergei Shtylyov @ 2013-05-24 15:09 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hello.

On 24-05-2013 18:31, Kishon Vijay Abraham I wrote:

> From: Graeme Gregory <gg@slimlogic.co.uk>

> Added an API to set/clear the switch bit on SMPS10 which can be used by
> palmas usb. The switch bit should be set in order for palmas to
> supply VBUS and is needed when OMAP is acting as USB HOST.

> Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>   drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
>   include/linux/mfd/palmas.h           |  2 ++
>   2 files changed, 28 insertions(+)

> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 92ceed0..d57ab55 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
>   	return ret;
>   }
>
> +/**
> + * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
> + * @param palmas pointer to the palmas mfd structure
> + * @param sw boolean to indicate switch status

    Please follow the kernel-doc style described in 
Documentation/kernel-doc-nano-HOWTO.txt.

[...]

WBR, Sergei


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

* Re: [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
@ 2013-05-24 15:09     ` Sergei Shtylyov
  0 siblings, 0 replies; 50+ messages in thread
From: Sergei Shtylyov @ 2013-05-24 15:09 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	cw00.choi-Sze3O3UU22JBDgjK7y7TUQ, balbi-l0cyMroinI0,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, gg-kDsPt+C1G03kYMGBc/C6ZA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, rob-VoJi6FS/r0vR7s880joybQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA

Hello.

On 24-05-2013 18:31, Kishon Vijay Abraham I wrote:

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

> Added an API to set/clear the switch bit on SMPS10 which can be used by
> palmas usb. The switch bit should be set in order for palmas to
> supply VBUS and is needed when OMAP is acting as USB HOST.

> Signed-off-by: Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>
> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
> ---
>   drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
>   include/linux/mfd/palmas.h           |  2 ++
>   2 files changed, 28 insertions(+)

> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 92ceed0..d57ab55 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
>   	return ret;
>   }
>
> +/**
> + * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
> + * @param palmas pointer to the palmas mfd structure
> + * @param sw boolean to indicate switch status

    Please follow the kernel-doc style described in 
Documentation/kernel-doc-nano-HOWTO.txt.

[...]

WBR, Sergei

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

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

* Re: [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
  2013-05-24 14:31   ` Kishon Vijay Abraham I
@ 2013-05-25 17:00     ` Laxman Dewangan
  -1 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-25 17:00 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Kishon/Graeme,

On Friday 24 May 2013 08:01 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> Added an API to set/clear the switch bit on SMPS10 which can be used by
> palmas usb. The switch bit should be set in order for palmas to
> supply VBUS and is needed when OMAP is acting as USB HOST.
>
> Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>   drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
>   include/linux/mfd/palmas.h           |  2 ++
>   2 files changed, 28 insertions(+)
>
> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 92ceed0..d57ab55 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
>   	return ret;
>   }
>   
> +/**
> + * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
> + * @param palmas pointer to the palmas mfd structure
> + * @param sw boolean to indicate switch status
> + *
> + * There is not a way to represent this function within the regulator
> + * framework. This sets/clears the switch of SMPS10 so SMPS10_OUT1 and
> + * SMPS10_OUT2 are shorted together.
> + */
>

As per datasheet, SMPS10 has 2 outputs, OUT1 and OUT2.
OUT2 is always available either through parasitic diode or bypass switch 
or boost mode. It can not be off at all.
OUT2 can be enable/disable through the switch bit.

The smps10 regulator is implemented  enable/disable on which it just 
enable/disable boost mode.
I think this is not proper control, actually we should control OUT1 
switch on regulator enable/disable of the smps10.

And hence in this case, we will not need this API.

Otherwise it will difficult to use this api outside of palmas.

In tegra platform, we have connected the USB-VBUS supply from 
SMPS10-OUT1 and usb driver control the vbus enabled/disable and so it 
can not call this API. This functionality need to be exposed through the 
regulator only.



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

* Re: [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10
@ 2013-05-25 17:00     ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-25 17:00 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Kishon/Graeme,

On Friday 24 May 2013 08:01 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> Added an API to set/clear the switch bit on SMPS10 which can be used by
> palmas usb. The switch bit should be set in order for palmas to
> supply VBUS and is needed when OMAP is acting as USB HOST.
>
> Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>   drivers/regulator/palmas-regulator.c | 26 ++++++++++++++++++++++++++
>   include/linux/mfd/palmas.h           |  2 ++
>   2 files changed, 28 insertions(+)
>
> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 92ceed0..d57ab55 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -465,6 +465,32 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
>   	return ret;
>   }
>   
> +/**
> + * palmas_set_switch_smps10() - set or clear the switch bit on SMPS10
> + * @param palmas pointer to the palmas mfd structure
> + * @param sw boolean to indicate switch status
> + *
> + * There is not a way to represent this function within the regulator
> + * framework. This sets/clears the switch of SMPS10 so SMPS10_OUT1 and
> + * SMPS10_OUT2 are shorted together.
> + */
>

As per datasheet, SMPS10 has 2 outputs, OUT1 and OUT2.
OUT2 is always available either through parasitic diode or bypass switch 
or boost mode. It can not be off at all.
OUT2 can be enable/disable through the switch bit.

The smps10 regulator is implemented  enable/disable on which it just 
enable/disable boost mode.
I think this is not proper control, actually we should control OUT1 
switch on regulator enable/disable of the smps10.

And hence in this case, we will not need this API.

Otherwise it will difficult to use this api outside of palmas.

In tegra platform, we have connected the USB-VBUS supply from 
SMPS10-OUT1 and usb driver control the vbus enabled/disable and so it 
can not call this API. This functionality need to be exposed through the 
regulator only.



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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-24 14:31   ` Kishon Vijay Abraham I
@ 2013-05-25 17:10     ` Laxman Dewangan
  -1 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-25 17:10 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Graeme/Kishon,

On Friday 24 May 2013 08:01 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> This is the driver for the USB comparator built into the palmas chip. It
> handles the various USB OTG events that can be generated by cable
> insertion/removal.


I have following feedback on this driver to use this on Tegra platform:
1. Can we have very simple driver for detecting VBUS and ID and just 
generate notification. No VBUS control logic or lots of  USB related 
configurations?
2. We will need the VBUS control as optional if it is require for TI 
platform. Currently it is mandatory and hence it is not suite in our 
context.
3. There is VBUS control (enabled/disable) in VBUS detection also. When 
palma detect the VBUS then why actually it need to enable VBUS as VBUS 
is already supplied by HOST? It may be only need when palma detect the 
ID pin and maybe want to enable VBUS but again VBUS control 
(enable/disable) should be part of USB driver, out of extcon driver.




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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-25 17:10     ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-25 17:10 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Graeme/Kishon,

On Friday 24 May 2013 08:01 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> This is the driver for the USB comparator built into the palmas chip. It
> handles the various USB OTG events that can be generated by cable
> insertion/removal.


I have following feedback on this driver to use this on Tegra platform:
1. Can we have very simple driver for detecting VBUS and ID and just 
generate notification. No VBUS control logic or lots of  USB related 
configurations?
2. We will need the VBUS control as optional if it is require for TI 
platform. Currently it is mandatory and hence it is not suite in our 
context.
3. There is VBUS control (enabled/disable) in VBUS detection also. When 
palma detect the VBUS then why actually it need to enable VBUS as VBUS 
is already supplied by HOST? It may be only need when palma detect the 
ID pin and maybe want to enable VBUS but again VBUS control 
(enable/disable) should be part of USB driver, out of extcon driver.




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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-24 14:31   ` Kishon Vijay Abraham I
  (?)
  (?)
@ 2013-05-27  5:34   ` Chanwoo Choi
  2013-05-27  5:54       ` Kishon Vijay Abraham I
  -1 siblings, 1 reply; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-27  5:34 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Kishon,

I have some comment about this patch
and upload modified patch to following repository (extcon-for-palmas).
- http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c

This patchset include patch related to other module
,so I need your opinion to apply this patchset to git repository.

On 05/24/2013 11:31 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> This is the driver for the USB comparator 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@slimlogic.co.uk>
> Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
> Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Signed-off-by: George Cherian <george.cherian@ti.com>
> [kishon@ti.com: adapted palmas usb driver to use the extcon framework]
> Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
> ---
> Changes from v4:
> * removed no_control_vbus property (to be used if the platform wants to use
> its own vbus control.
> * removed unnecessary headers
> * moved the palmas_usb_state to palmas.h
> * misc cleanups
> *A checkpatch warning "WARNING: static const char * array should
>  probably be static const char * const"is ignored since it introduces a
>  compilation warning.
> Changes from v3:
> * adapted the driver to extcon framework (so moved to drivers/extcon)
> * removed palmas_usb_(write/read) and replaced all calls with
>   palmas_(read/write).
> * ignored a checkpatch warning in the line 
> 	static const char *palmas_extcon_cable[] = {
>   as it seemed to be incorrect?
> * removed all references to OMAP in this driver.
> * couldn't test this driver with mainline as omap5 panda is not booting
>   with mainline.
> * A comment to change to platform_get_irq from regmap is not done as I felt
>   the data should come from regmap in this case. Graeme?
> Changes from v2:
> * Moved the driver to drivers/usb/phy/
> * Added a bit more explanation in Kconfig
>  .../devicetree/bindings/extcon/extcon-twl.txt      |  16 +
>  drivers/extcon/Kconfig                             |   7 +
>  drivers/extcon/Makefile                            |   1 +
>  drivers/extcon/extcon-palmas.c                     | 341 +++++++++++++++++++++
>  include/linux/mfd/palmas.h                         |  25 +-
>  5 files changed, 380 insertions(+), 10 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
>  create mode 100644 drivers/extcon/extcon-palmas.c
>
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
> new file mode 100644
> index 0000000..8ffdeed
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
> @@ -0,0 +1,15 @@
> +EXTCON FOR TWL CHIPS
> +
> +PALMAS USB COMPARATOR
> +Required Properties:
> + - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
> + - vbus-supply : phandle to the regulator device tree node.
> +
> +Optional Properties:
> + - ti,wakeup : To enable the wakeup comparator in probe
> +
> +palmas-usb {
> +       compatible = "ti,twl6035-usb", "ti,palmas-usb";
> +       vbus-supply = <&smps10_reg>;
> +       ti,wakeup;
> +};
> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> index 3297301..63f454e 100644
> --- a/drivers/extcon/Kconfig
> +++ b/drivers/extcon/Kconfig
> @@ -53,4 +53,11 @@ config EXTCON_ARIZONA
>  	  with Wolfson Arizona devices. These are audio CODECs with
>  	  advanced audio accessory detection support.
>  
> +config EXTCON_PALMAS
> +	tristate "Palmas USB EXTCON support"
> +	depends on MFD_PALMAS
You should add REGULATOR_PALMAS dependency because
palmas_set_switch_smps10() is defined in palmas regulator driver.

+    depends on MFD_PALMAS && REGULATOR_PALMAS

> +	help
> +	  Say Y here to enable support for USB peripheral and USB host
> +	  detection by palmas usb.
> +
>  endif # MULTISTATE_SWITCH
> diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
> index f98a3c4..540e2c3 100644
> --- a/drivers/extcon/Makefile
> +++ b/drivers/extcon/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
>  obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
>  obj-$(CONFIG_EXTCON_MAX8997)	+= extcon-max8997.o
>  obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
> +obj-$(CONFIG_EXTCON_PALMAS)	+= extcon-palmas.o
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> new file mode 100644
> index 0000000..9e613e9
> --- /dev/null
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -0,0 +1,341 @@
> +/*
> + * 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@slimlogic.co.uk>
> + * Author: Kishon Vijay Abraham I <kishon@ti.com>
> + *
> + * Based on twl6030_usb.c
> + *
> + * Author: Hema HK <hemahk@ti.com>
> + *
> + * 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/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/usb/phy_companion.h>
> +#include <linux/err.h>
> +#include <linux/mfd/palmas.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +
> +static const char *palmas_extcon_cable[] = {
> +	[0] = "USB",
> +	[1] = "USB-HOST",
> +	NULL,
> +};
> +
> +static const int mutually_exclusive[] = {0x3, 0x0};
> +
> +static void palmas_usb_wakeup(struct palmas *palmas, int enable)
> +{
> +	if (enable)
> +		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP,
> +			PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
> +	else
> +		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP, 0);
> +}
> +
> +static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
> +{
> +	int ret;
> +	struct palmas_usb *palmas_usb = _palmas_usb;
> +	unsigned int vbus_line_state;
> +
> +	palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE,
> +		PALMAS_INT3_LINE_STATE, &vbus_line_state);
> +
> +	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
> +		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
> +			if (palmas_usb->vbus_reg) {
> +				ret = regulator_enable(palmas_usb->vbus_reg);
> +				if (ret) {
> +					dev_dbg(palmas_usb->dev,
> +						"regulator enable failed\n");
> +					goto ret0;

I prefer to use consistent name of goto statement becuase you use
'fail_' prefix in palmas_usb_probe()
-                    goto ret0;
+                    goto fail;

> +				}
> +			}
> +			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
> +			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
> +		} 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 == PALMAS_USB_STATE_VBUS) {
> +			if (palmas_usb->vbus_reg)
> +				regulator_disable(palmas_usb->vbus_reg);
> +			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
> +			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
> +		} else {
> +			dev_dbg(palmas_usb->dev,
> +				"Spurious disconnect event detected\n");
> +		}
> +	}
> +
> +ret0:
ditto.

-ret0:
+fail:
> +	return IRQ_HANDLED;
> +}
> +
> +static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
> +{
> +	int			ret;
> +	unsigned int		set;
> +	struct palmas_usb	*palmas_usb = _palmas_usb;
You should use space instead of tab when defined local variables.

+    int ret;
+    unsigned int set;
+    struct palmas_usb *palmas_usb = _palmas_usb;

> +
> +	palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_ID_INT_LATCH_SET, &set);
> +
> +	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
> +		palmas_set_switch_smps10(palmas_usb->palmas, 1);
> +		if (palmas_usb->vbus_reg) {
> +			ret = regulator_enable(palmas_usb->vbus_reg);
> +			if (ret) {
> +				dev_dbg(palmas_usb->dev,
> +					"regulator enable failed\n");
> +				goto ret0;

ditto.

> +			}
> +		}
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_EN_HI_SET,
> +			PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_EN_HI_CLR,
> +			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_LATCH_CLR,
> +			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
> +		palmas_usb->linkstat = PALMAS_USB_STATE_ID;
> +		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
> +	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_EN_HI_SET,
> +			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_EN_HI_CLR,
> +			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
> +		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +			PALMAS_USB_ID_INT_LATCH_CLR,
> +			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
> +		if (palmas_usb->vbus_reg)
> +			regulator_disable(palmas_usb->vbus_reg);
> +		palmas_set_switch_smps10(palmas_usb->palmas, 0);
> +		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
> +		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
> +	}
> +
> +ret0:

ditto.

> +	return IRQ_HANDLED;
> +}
> +
> +static void palmas_enable_irq(struct palmas_usb *palmas_usb)
> +{
> +	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_VBUS_CTRL_SET,
> +		PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
> +
> +	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
> +
> +	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_ID_INT_EN_HI_SET,
> +		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
> +
> +	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
> +
> +	/* cold plug for host mode needs this delay */
> +	msleep(30);
> +	palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
> +}
> +
> +static void palmas_set_vbus_work(struct work_struct *data)
> +{
> +	int ret;
> +	struct palmas_usb *palmas_usb = container_of(data, struct palmas_usb,
> +								set_vbus_work);
> +
> +	/*
> +	 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
> +	 * register. This enables boost mode.
> +	 */
> +
> +	if (palmas_usb->vbus_enable) {
> +		ret = regulator_enable(palmas_usb->vbus_reg);
> +		if (ret)
> +			dev_dbg(palmas_usb->dev, "regulator enable failed\n");
> +	} 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_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_VBUS_CTRL_SET, PALMAS_USB_VBUS_CTRL_SET_VBUS_DISCHRG
> +		| PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
> +	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_VBUS_CTRL_SET,
> +		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
> +		PALMAS_USB_VBUS_CTRL_SET_VBUS_IADP_SINK);
> +
> +	msleep(100);
> +
> +	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
> +		PALMAS_USB_VBUS_CTRL_CLR,
> +		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS |
> +		PALMAS_USB_VBUS_CTRL_SET_VBUS_CHRG_VSYS);
> +
> +	return 0;
> +}
> +
> +static int palmas_usb_probe(struct platform_device *pdev)
> +{
> +	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;
> +
> +		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
> +	}
> +
> +	if (!pdata)
> +		return -EINVAL;
I think that if condition of first if statement is true,
second if statement is unnecessary. So, I prefer
to modify if/else statement as following:

+	} else 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;

You should use space instead of tab when assign some value to variables.

+	palmas->usb = palmas_usb;
+	palmas_usb->palmas = palmas;
+
+	palmas_usb->dev= &pdev->dev;


> +
> +	palmas_usb->id_otg_irq = regmap_irq_get_virq(palmas->irq_data,
> +						PALMAS_ID_OTG_IRQ);
> +	palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data,
> +						PALMAS_ID_IRQ);
> +	palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
> +						PALMAS_VBUS_OTG_IRQ);
> +	palmas_usb->vbus_irq = 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;
> +
> +	palmas_usb_wakeup(palmas, pdata->wakeup);
> +
> +	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);
> +	}
> +
> +	INIT_WORK(&palmas_usb->set_vbus_work, palmas_set_vbus_work);
> +
> +	platform_set_drvdata(pdev, palmas_usb);
> +
> +	palmas_usb->edev.name = "palmas-usb";
> +	palmas_usb->edev.supported_cable = palmas_extcon_cable;
> +	palmas_usb->edev.mutually_exclusive = mutually_exclusive;
> +
> +	status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
> +	if (status) {
> +		dev_err(&pdev->dev, "failed to register extcon device\n");
> +		goto fail_irq;
> +	}
> +
> +	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
> +			NULL, palmas_id_irq_handler,
> +			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> +			"palmas_usb_id", palmas_usb);
> +	if (status < 0) {
> +		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
> +					palmas_usb->id_irq, status);
> +		goto fail_extcon;
> +	}
> +
> +	status = devm_request_threaded_irq(palmas_usb->dev,
> +			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
> +			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> +			"palmas_usb_vbus", palmas_usb);
> +	if (status < 0) {
> +		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
> +					palmas_usb->vbus_irq, status);
> +		goto fail_extcon;
> +	}
> +
> +	palmas_enable_irq(palmas_usb);
> +
> +	return 0;
> +
> +fail_extcon:
> +	extcon_dev_unregister(&palmas_usb->edev);
> +
> +fail_irq:
> +	cancel_work_sync(&palmas_usb->set_vbus_work);
> +
> +	return status;
> +}
> +
> +static int palmas_usb_remove(struct platform_device *pdev)
> +{
> +	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
> +
> +		cancel_work_sync(&palmas_usb->set_vbus_work);
> +	extcon_dev_unregister(&palmas_usb->edev);
> +
> +	return 0;
> +}
> +
> +static struct of_device_id of_palmas_match_tbl[] = {
> +	{ .compatible = "ti,palmas-usb", },
> +	{ .compatible = "ti,twl6035-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@slimlogic.co.uk>");
> +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 6df375d..eb4846b 100644
> --- a/include/linux/mfd/palmas.h
> +++ b/include/linux/mfd/palmas.h
> @@ -20,6 +20,8 @@
>  #include <linux/leds.h>
>  #include <linux/regmap.h>
>  #include <linux/regulator/driver.h>
> +#include <linux/extcon.h>
> +#include <linux/usb/phy_companion.h>
>  
>  #define PALMAS_NUM_CLIENTS		3
>  
> @@ -37,6 +39,12 @@ struct palmas_gpadc;
>  struct palmas_resource;
>  struct palmas_usb;
>  
> +enum palmas_usb_state {
> +	PALMAS_USB_STATE_DISCONNECT,
> +	PALMAS_USB_STATE_VBUS,
> +	PALMAS_USB_STATE_ID,
> +};
> +
>  struct palmas {
>  	struct device *dev;
>  
> @@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
>  };
>  
>  struct palmas_usb_platform_data {
> -	/* Set this if platform wishes its own vbus control */
> -	int no_control_vbus;
> -
>  	/* Do we enable the wakeup comparator on probe */
>  	int wakeup;
>  };
> @@ -350,22 +355,22 @@ struct palmas_usb {
>  	struct palmas *palmas;
>  	struct device *dev;
>  
> -	/* for vbus reporting with irqs disabled */
> -	spinlock_t lock;
> +	struct extcon_dev edev;
> +	struct phy_companion comparator;
>  
>  	struct regulator *vbus_reg;
>  
>  	/* used to set vbus, in atomic path */
>  	struct work_struct set_vbus_work;
>  
> -	int irq1;
> -	int irq2;
> -	int irq3;
> -	int irq4;
> +	int id_otg_irq;
> +	int id_irq;
> +	int vbus_otg_irq;
> +	int vbus_irq;
>  
>  	int vbus_enable;
>  
> -	u8 linkstat;
> +	enum palmas_usb_state linkstat;
>  };
>  
>  #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)


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

* Re: [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
  2013-05-24 14:31   ` Kishon Vijay Abraham I
  (?)
@ 2013-05-27  5:38   ` Chanwoo Choi
  -1 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-27  5:38 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On 05/24/2013 11:31 PM, Kishon Vijay Abraham I wrote:
> Modified dwc3-omap to receive connect and disconnect notification using
> extcon framework. Also did the necessary cleanups required after
> adapting to extcon framework.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/dwc3/dwc3-omap.c  | 80 +++++++++++++++++++++++++++++++++----------
>  include/linux/usb/dwc3-omap.h | 30 ----------------
>  2 files changed, 62 insertions(+), 48 deletions(-)
>  delete mode 100644 include/linux/usb/dwc3-omap.h
>
>
I check the code about extcon framework.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Thanks,
Chanwoo Choi

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  5:54       ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  5:54 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi,

On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
> Hi Kishon,
>
> I have some comment about this patch
> and upload modified patch to following repository (extcon-for-palmas).
> - http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>
> This patchset include patch related to other module
> ,so I need your opinion to apply this patchset to git repository.

yeah.. Still there is some confusion with palmas_set_switch_smps10(). I 
think we can remove it for now and add it separately later. By this at 
least we can have device mode fully functional in OMAP5. What do you think?

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  5:54       ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  5:54 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, gg-kDsPt+C1G03kYMGBc/C6ZA

Hi,

On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
> Hi Kishon,
>
> I have some comment about this patch
> and upload modified patch to following repository (extcon-for-palmas).
> - http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>
> This patchset include patch related to other module
> ,so I need your opinion to apply this patchset to git repository.

yeah.. Still there is some confusion with palmas_set_switch_smps10(). I 
think we can remove it for now and add it separately later. By this at 
least we can have device mode fully functional in OMAP5. What do you think?

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-27  5:54       ` Kishon Vijay Abraham I
  (?)
@ 2013-05-27  6:08       ` Chanwoo Choi
  2013-05-27  6:22           ` Laxman Dewangan
  -1 siblings, 1 reply; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-27  6:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>> Hi Kishon,
>>
>> I have some comment about this patch
>> and upload modified patch to following repository (extcon-for-palmas).
>> - http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>
>> This patchset include patch related to other module
>> ,so I need your opinion to apply this patchset to git repository.
>
> yeah.. Still there is some confusion with palmas_set_switch_smps10(). I think we can remove it for now and add it separately later. By this at least we can have device mode fully functional in OMAP5. What do you think?
>

 I agree your opinion.

But, I propose some fixes about palmas_set_switch_smps10().
I dont' prefer to call global function in exton-palmas.c from palmas-regulator.c.
So, Why don't you use regulator consumer instead of global function?
You can register specific regulator for enabling or disabling SMPS10_SWITCH_EN
and then control SMPS10_SWITCH_EN bit through regulator framework in extcon-palmas.c
without calling global function.

Thanks,
Chanwoo Choi


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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-27  6:08       ` Chanwoo Choi
@ 2013-05-27  6:22           ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:22 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Kishon Vijay Abraham I, myungjoo.ham, balbi, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>> Hi Kishon,
>>>
>>> I have some comment about this patch
>>> and upload modified patch to following repository (extcon-for-palmas).
>>> - http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>
>>> This patchset include patch related to other module
>>> ,so I need your opinion to apply this patchset to git repository.
>> yeah.. Still there is some confusion with palmas_set_switch_smps10(). I think we can remove it for now and add it separately later. By this at least we can have device mode fully functional in OMAP5. What do you think?
>>
>   I agree your opinion.
>
> But, I propose some fixes about palmas_set_switch_smps10().
> I dont' prefer to call global function in exton-palmas.c from palmas-regulator.c.
> So, Why don't you use regulator consumer instead of global function?
> You can register specific regulator for enabling or disabling SMPS10_SWITCH_EN
> and then control SMPS10_SWITCH_EN bit through regulator framework in extcon-palmas.c
> without calling global function.

Along with this, I also like to make the VBUS regulator control to be 
optional here. Currently it is mandatory.

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:22           ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:22 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Kishon Vijay Abraham I, myungjoo.ham, balbi, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>> Hi Kishon,
>>>
>>> I have some comment about this patch
>>> and upload modified patch to following repository (extcon-for-palmas).
>>> - http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>
>>> This patchset include patch related to other module
>>> ,so I need your opinion to apply this patchset to git repository.
>> yeah.. Still there is some confusion with palmas_set_switch_smps10(). I think we can remove it for now and add it separately later. By this at least we can have device mode fully functional in OMAP5. What do you think?
>>
>   I agree your opinion.
>
> But, I propose some fixes about palmas_set_switch_smps10().
> I dont' prefer to call global function in exton-palmas.c from palmas-regulator.c.
> So, Why don't you use regulator consumer instead of global function?
> You can register specific regulator for enabling or disabling SMPS10_SWITCH_EN
> and then control SMPS10_SWITCH_EN bit through regulator framework in extcon-palmas.c
> without calling global function.

Along with this, I also like to make the VBUS regulator control to be 
optional here. Currently it is mandatory.

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:31             ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  6:31 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi,

On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>> Hi Kishon,
>>>>
>>>> I have some comment about this patch
>>>> and upload modified patch to following repository (extcon-for-palmas).
>>>> -
>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>
>>>>
>>>> This patchset include patch related to other module
>>>> ,so I need your opinion to apply this patchset to git repository.
>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>> I think we can remove it for now and add it separately later. By this
>>> at least we can have device mode fully functional in OMAP5. What do
>>> you think?
>>>
>>   I agree your opinion.
>>
>> But, I propose some fixes about palmas_set_switch_smps10().
>> I dont' prefer to call global function in exton-palmas.c from
>> palmas-regulator.c.
>> So, Why don't you use regulator consumer instead of global function?
>> You can register specific regulator for enabling or disabling
>> SMPS10_SWITCH_EN
>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>> extcon-palmas.c
>> without calling global function.
>
> Along with this, I also like to make the VBUS regulator control to be
> optional here. Currently it is mandatory.

But dint you just tell on my v4 of this patch that you don’t require this.
http://www.spinics.net/lists/linux-doc/msg10638.html

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:31             ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  6:31 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chanwoo Choi,
	broonie-DgEjT+Ai2ygdnm+yROfE0A,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, gg-kDsPt+C1G03kYMGBc/C6ZA

Hi,

On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>> Hi Kishon,
>>>>
>>>> I have some comment about this patch
>>>> and upload modified patch to following repository (extcon-for-palmas).
>>>> -
>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>
>>>>
>>>> This patchset include patch related to other module
>>>> ,so I need your opinion to apply this patchset to git repository.
>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>> I think we can remove it for now and add it separately later. By this
>>> at least we can have device mode fully functional in OMAP5. What do
>>> you think?
>>>
>>   I agree your opinion.
>>
>> But, I propose some fixes about palmas_set_switch_smps10().
>> I dont' prefer to call global function in exton-palmas.c from
>> palmas-regulator.c.
>> So, Why don't you use regulator consumer instead of global function?
>> You can register specific regulator for enabling or disabling
>> SMPS10_SWITCH_EN
>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>> extcon-palmas.c
>> without calling global function.
>
> Along with this, I also like to make the VBUS regulator control to be
> optional here. Currently it is mandatory.

But dint you just tell on my v4 of this patch that you don’t require this.
http://www.spinics.net/lists/linux-doc/msg10638.html

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-27  6:31             ` Kishon Vijay Abraham I
@ 2013-05-27  6:36               ` Laxman Dewangan
  -1 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:36 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>> Hi,
>>>>
>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>> Hi Kishon,
>>>>>
>>>>> I have some comment about this patch
>>>>> and upload modified patch to following repository (extcon-for-palmas).
>>>>> -
>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>
>>>>>
>>>>> This patchset include patch related to other module
>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>> I think we can remove it for now and add it separately later. By this
>>>> at least we can have device mode fully functional in OMAP5. What do
>>>> you think?
>>>>
>>>    I agree your opinion.
>>>
>>> But, I propose some fixes about palmas_set_switch_smps10().
>>> I dont' prefer to call global function in exton-palmas.c from
>>> palmas-regulator.c.
>>> So, Why don't you use regulator consumer instead of global function?
>>> You can register specific regulator for enabling or disabling
>>> SMPS10_SWITCH_EN
>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>> extcon-palmas.c
>>> without calling global function.
>> Along with this, I also like to make the VBUS regulator control to be
>> optional here. Currently it is mandatory.
> But dint you just tell on my v4 of this patch that you don’t require this.
> http://www.spinics.net/lists/linux-doc/msg10638.html

In V4, I said remove this VBUS control and my mean was to remove all 
regulator calls for VBUS enabled/disable.
I saw you just remove the platform data option to have this control and 
made VBUS mandatory.

Probably some gap here.

In tegra platform, we dont need VBUS regualtor control from extcon.



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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:36               ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:36 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>> Hi,
>>>>
>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>> Hi Kishon,
>>>>>
>>>>> I have some comment about this patch
>>>>> and upload modified patch to following repository (extcon-for-palmas).
>>>>> -
>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>
>>>>>
>>>>> This patchset include patch related to other module
>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>> I think we can remove it for now and add it separately later. By this
>>>> at least we can have device mode fully functional in OMAP5. What do
>>>> you think?
>>>>
>>>    I agree your opinion.
>>>
>>> But, I propose some fixes about palmas_set_switch_smps10().
>>> I dont' prefer to call global function in exton-palmas.c from
>>> palmas-regulator.c.
>>> So, Why don't you use regulator consumer instead of global function?
>>> You can register specific regulator for enabling or disabling
>>> SMPS10_SWITCH_EN
>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>> extcon-palmas.c
>>> without calling global function.
>> Along with this, I also like to make the VBUS regulator control to be
>> optional here. Currently it is mandatory.
> But dint you just tell on my v4 of this patch that you don’t require this.
> http://www.spinics.net/lists/linux-doc/msg10638.html

In V4, I said remove this VBUS control and my mean was to remove all 
regulator calls for VBUS enabled/disable.
I saw you just remove the platform data option to have this control and 
made VBUS mandatory.

Probably some gap here.

In tegra platform, we dont need VBUS regualtor control from extcon.



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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:41                 ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  6:41 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi,

On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>> Hi,
>>>>>
>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>> Hi Kishon,
>>>>>>
>>>>>> I have some comment about this patch
>>>>>> and upload modified patch to following repository
>>>>>> (extcon-for-palmas).
>>>>>> -
>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>
>>>>>>
>>>>>>
>>>>>> This patchset include patch related to other module
>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>>> I think we can remove it for now and add it separately later. By this
>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>> you think?
>>>>>
>>>>    I agree your opinion.
>>>>
>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>> I dont' prefer to call global function in exton-palmas.c from
>>>> palmas-regulator.c.
>>>> So, Why don't you use regulator consumer instead of global function?
>>>> You can register specific regulator for enabling or disabling
>>>> SMPS10_SWITCH_EN
>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>> extcon-palmas.c
>>>> without calling global function.
>>> Along with this, I also like to make the VBUS regulator control to be
>>> optional here. Currently it is mandatory.
>> But dint you just tell on my v4 of this patch that you don’t require
>> this.
>> http://www.spinics.net/lists/linux-doc/msg10638.html
>
> In V4, I said remove this VBUS control and my mean was to remove all
> regulator calls for VBUS enabled/disable.
> I saw you just remove the platform data option to have this control and
> made VBUS mandatory.
>
> Probably some gap here.

Indeed..
I think then we should stick back to how it was with my v4 or else it 
would break OMAP. The regulator calls can't be moved anywhere else as it 
is specific to PALMAS.

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:41                 ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  6:41 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chanwoo Choi,
	broonie-DgEjT+Ai2ygdnm+yROfE0A,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, gg-kDsPt+C1G03kYMGBc/C6ZA

Hi,

On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>> Hi,
>>>>>
>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>> Hi Kishon,
>>>>>>
>>>>>> I have some comment about this patch
>>>>>> and upload modified patch to following repository
>>>>>> (extcon-for-palmas).
>>>>>> -
>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>
>>>>>>
>>>>>>
>>>>>> This patchset include patch related to other module
>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>>> I think we can remove it for now and add it separately later. By this
>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>> you think?
>>>>>
>>>>    I agree your opinion.
>>>>
>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>> I dont' prefer to call global function in exton-palmas.c from
>>>> palmas-regulator.c.
>>>> So, Why don't you use regulator consumer instead of global function?
>>>> You can register specific regulator for enabling or disabling
>>>> SMPS10_SWITCH_EN
>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>> extcon-palmas.c
>>>> without calling global function.
>>> Along with this, I also like to make the VBUS regulator control to be
>>> optional here. Currently it is mandatory.
>> But dint you just tell on my v4 of this patch that you don’t require
>> this.
>> http://www.spinics.net/lists/linux-doc/msg10638.html
>
> In V4, I said remove this VBUS control and my mean was to remove all
> regulator calls for VBUS enabled/disable.
> I saw you just remove the platform data option to have this control and
> made VBUS mandatory.
>
> Probably some gap here.

Indeed..
I think then we should stick back to how it was with my v4 or else it 
would break OMAP. The regulator calls can't be moved anywhere else as it 
is specific to PALMAS.

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
  2013-05-27  6:41                 ` Kishon Vijay Abraham I
@ 2013-05-27  6:56                   ` Laxman Dewangan
  -1 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 12:11 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
>> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>>> Hi Kishon,
>>>>>>>
>>>>>>> I have some comment about this patch
>>>>>>> and upload modified patch to following repository
>>>>>>> (extcon-for-palmas).
>>>>>>> -
>>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> This patchset include patch related to other module
>>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>>>> I think we can remove it for now and add it separately later. By this
>>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>>> you think?
>>>>>>
>>>>>     I agree your opinion.
>>>>>
>>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>>> I dont' prefer to call global function in exton-palmas.c from
>>>>> palmas-regulator.c.
>>>>> So, Why don't you use regulator consumer instead of global function?
>>>>> You can register specific regulator for enabling or disabling
>>>>> SMPS10_SWITCH_EN
>>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>>> extcon-palmas.c
>>>>> without calling global function.
>>>> Along with this, I also like to make the VBUS regulator control to be
>>>> optional here. Currently it is mandatory.
>>> But dint you just tell on my v4 of this patch that you don’t require
>>> this.
>>> http://www.spinics.net/lists/linux-doc/msg10638.html
>> In V4, I said remove this VBUS control and my mean was to remove all
>> regulator calls for VBUS enabled/disable.
>> I saw you just remove the platform data option to have this control and
>> made VBUS mandatory.
>>
>> Probably some gap here.
> Indeed..
> I think then we should stick back to how it was with my v4 or else it
> would break OMAP. The regulator calls can't be moved anywhere else as it
> is specific to PALMAS.
>

I was thinking that extcon driver just detect the cable type and notify 
to the client. After cable detection, the next level of configuration 
should be done in the respective client.

On Tegra platform,  for ID pin detection, Tegra SOC is capable of detect 
the ID pin presence or Palma is capable. Depending on the board design, 
how the ID pin routed from USB connector to PMIC or to Tegra, we enable 
corresponding detection logic.
Once the USB driver got notification for ID pin presence (by any means), 
the enabling of VBUS (as the Tegra will work as Host now and need to 
supply VBUS), is done in USB driver.
Not sure about the OMAP here.


So in above context, I really do not want to have the VBUS control on 
extcon driver from Tegra context. If it is require in OMAP context then 
please make it as optional so that we can satisfy for Tegra and Omap 
platform.


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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  6:56                   ` Laxman Dewangan
  0 siblings, 0 replies; 50+ messages in thread
From: Laxman Dewangan @ 2013-05-27  6:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Monday 27 May 2013 12:11 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
>> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>>> Hi Kishon,
>>>>>>>
>>>>>>> I have some comment about this patch
>>>>>>> and upload modified patch to following repository
>>>>>>> (extcon-for-palmas).
>>>>>>> -
>>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> This patchset include patch related to other module
>>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>>> yeah.. Still there is some confusion with palmas_set_switch_smps10().
>>>>>> I think we can remove it for now and add it separately later. By this
>>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>>> you think?
>>>>>>
>>>>>     I agree your opinion.
>>>>>
>>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>>> I dont' prefer to call global function in exton-palmas.c from
>>>>> palmas-regulator.c.
>>>>> So, Why don't you use regulator consumer instead of global function?
>>>>> You can register specific regulator for enabling or disabling
>>>>> SMPS10_SWITCH_EN
>>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>>> extcon-palmas.c
>>>>> without calling global function.
>>>> Along with this, I also like to make the VBUS regulator control to be
>>>> optional here. Currently it is mandatory.
>>> But dint you just tell on my v4 of this patch that you don’t require
>>> this.
>>> http://www.spinics.net/lists/linux-doc/msg10638.html
>> In V4, I said remove this VBUS control and my mean was to remove all
>> regulator calls for VBUS enabled/disable.
>> I saw you just remove the platform data option to have this control and
>> made VBUS mandatory.
>>
>> Probably some gap here.
> Indeed..
> I think then we should stick back to how it was with my v4 or else it
> would break OMAP. The regulator calls can't be moved anywhere else as it
> is specific to PALMAS.
>

I was thinking that extcon driver just detect the cable type and notify 
to the client. After cable detection, the next level of configuration 
should be done in the respective client.

On Tegra platform,  for ID pin detection, Tegra SOC is capable of detect 
the ID pin presence or Palma is capable. Depending on the board design, 
how the ID pin routed from USB connector to PMIC or to Tegra, we enable 
corresponding detection logic.
Once the USB driver got notification for ID pin presence (by any means), 
the enabling of VBUS (as the Tegra will work as Host now and need to 
supply VBUS), is done in USB driver.
Not sure about the OMAP here.


So in above context, I really do not want to have the VBUS control on 
extcon driver from Tegra context. If it is require in OMAP context then 
please make it as optional so that we can satisfy for Tegra and Omap 
platform.


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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  9:24                     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  9:24 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: Chanwoo Choi, myungjoo.ham, balbi, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi,

On Monday 27 May 2013 12:26 PM, Laxman Dewangan wrote:
> On Monday 27 May 2013 12:11 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
>>> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>>>> Hi,
>>>>
>>>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>>>> Hi Kishon,
>>>>>>>>
>>>>>>>> I have some comment about this patch
>>>>>>>> and upload modified patch to following repository
>>>>>>>> (extcon-for-palmas).
>>>>>>>> -
>>>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> This patchset include patch related to other module
>>>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>>>> yeah.. Still there is some confusion with
>>>>>>> palmas_set_switch_smps10().
>>>>>>> I think we can remove it for now and add it separately later. By
>>>>>>> this
>>>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>>>> you think?
>>>>>>>
>>>>>>     I agree your opinion.
>>>>>>
>>>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>>>> I dont' prefer to call global function in exton-palmas.c from
>>>>>> palmas-regulator.c.
>>>>>> So, Why don't you use regulator consumer instead of global function?
>>>>>> You can register specific regulator for enabling or disabling
>>>>>> SMPS10_SWITCH_EN
>>>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>>>> extcon-palmas.c
>>>>>> without calling global function.
>>>>> Along with this, I also like to make the VBUS regulator control to be
>>>>> optional here. Currently it is mandatory.
>>>> But dint you just tell on my v4 of this patch that you don’t require
>>>> this.
>>>> http://www.spinics.net/lists/linux-doc/msg10638.html
>>> In V4, I said remove this VBUS control and my mean was to remove all
>>> regulator calls for VBUS enabled/disable.
>>> I saw you just remove the platform data option to have this control and
>>> made VBUS mandatory.
>>>
>>> Probably some gap here.
>> Indeed..
>> I think then we should stick back to how it was with my v4 or else it
>> would break OMAP. The regulator calls can't be moved anywhere else as it
>> is specific to PALMAS.
>>
>
> I was thinking that extcon driver just detect the cable type and notify
> to the client. After cable detection, the next level of configuration
> should be done in the respective client.
>
> On Tegra platform,  for ID pin detection, Tegra SOC is capable of detect
> the ID pin presence or Palma is capable. Depending on the board design,
> how the ID pin routed from USB connector to PMIC or to Tegra, we enable
> corresponding detection logic.
> Once the USB driver got notification for ID pin presence (by any means),
> the enabling of VBUS (as the Tegra will work as Host now and need to
> supply VBUS), is done in USB driver.
> Not sure about the OMAP here.

I think I got your point here. Will check and send a patch.

Thanks
Kishon

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

* Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver
@ 2013-05-27  9:24                     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27  9:24 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chanwoo Choi,
	broonie-DgEjT+Ai2ygdnm+yROfE0A,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, gg-kDsPt+C1G03kYMGBc/C6ZA

Hi,

On Monday 27 May 2013 12:26 PM, Laxman Dewangan wrote:
> On Monday 27 May 2013 12:11 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Monday 27 May 2013 12:06 PM, Laxman Dewangan wrote:
>>> On Monday 27 May 2013 12:01 PM, Kishon Vijay Abraham I wrote:
>>>> Hi,
>>>>
>>>> On Monday 27 May 2013 11:52 AM, Laxman Dewangan wrote:
>>>>> On Monday 27 May 2013 11:38 AM, Chanwoo Choi wrote:
>>>>>> On 05/27/2013 02:54 PM, Kishon Vijay Abraham I wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> On Monday 27 May 2013 11:04 AM, Chanwoo Choi wrote:
>>>>>>>> Hi Kishon,
>>>>>>>>
>>>>>>>> I have some comment about this patch
>>>>>>>> and upload modified patch to following repository
>>>>>>>> (extcon-for-palmas).
>>>>>>>> -
>>>>>>>> http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-for-palmas&id=f2b7cb80699cbe1a5fd6c97ef2c600915f8d7f2c
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> This patchset include patch related to other module
>>>>>>>> ,so I need your opinion to apply this patchset to git repository.
>>>>>>> yeah.. Still there is some confusion with
>>>>>>> palmas_set_switch_smps10().
>>>>>>> I think we can remove it for now and add it separately later. By
>>>>>>> this
>>>>>>> at least we can have device mode fully functional in OMAP5. What do
>>>>>>> you think?
>>>>>>>
>>>>>>     I agree your opinion.
>>>>>>
>>>>>> But, I propose some fixes about palmas_set_switch_smps10().
>>>>>> I dont' prefer to call global function in exton-palmas.c from
>>>>>> palmas-regulator.c.
>>>>>> So, Why don't you use regulator consumer instead of global function?
>>>>>> You can register specific regulator for enabling or disabling
>>>>>> SMPS10_SWITCH_EN
>>>>>> and then control SMPS10_SWITCH_EN bit through regulator framework in
>>>>>> extcon-palmas.c
>>>>>> without calling global function.
>>>>> Along with this, I also like to make the VBUS regulator control to be
>>>>> optional here. Currently it is mandatory.
>>>> But dint you just tell on my v4 of this patch that you don’t require
>>>> this.
>>>> http://www.spinics.net/lists/linux-doc/msg10638.html
>>> In V4, I said remove this VBUS control and my mean was to remove all
>>> regulator calls for VBUS enabled/disable.
>>> I saw you just remove the platform data option to have this control and
>>> made VBUS mandatory.
>>>
>>> Probably some gap here.
>> Indeed..
>> I think then we should stick back to how it was with my v4 or else it
>> would break OMAP. The regulator calls can't be moved anywhere else as it
>> is specific to PALMAS.
>>
>
> I was thinking that extcon driver just detect the cable type and notify
> to the client. After cable detection, the next level of configuration
> should be done in the respective client.
>
> On Tegra platform,  for ID pin detection, Tegra SOC is capable of detect
> the ID pin presence or Palma is capable. Depending on the board design,
> how the ID pin routed from USB connector to PMIC or to Tegra, we enable
> corresponding detection logic.
> Once the USB driver got notification for ID pin presence (by any means),
> the enabling of VBUS (as the Tegra will work as Host now and need to
> supply VBUS), is done in USB driver.
> Not sure about the OMAP here.

I think I got your point here. Will check and send a patch.

Thanks
Kishon

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

* [PATCH v6] extcon: Palmas Extcon Driver
  2013-05-24 14:31 ` Kishon Vijay Abraham I
@ 2013-05-27 13:33   ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27 13:33 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

This is the driver for the USB comparator 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@slimlogic.co.uk>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: George Cherian <george.cherian@ti.com>
[kishon@ti.com: adapted palmas usb driver to use the extcon framework]
Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
Changes from v5:
* removed regulator calls from palmas-usb as some platforms wont need it.
These are now done in dwc3-omap.c as it is needed for OMAP.
* removed all references to phy_companion as none of it is validated (SRP)
and all of them were currently unreachable code.

Changes from v4:
* removed no_control_vbus property (to be used if the platform wants to use
its own vbus control.
* removed unnecessary headers
* moved the palmas_usb_state to palmas.h
* misc cleanups
*A checkpatch warning "WARNING: static const char * array should
 probably be static const char * const"is ignored since it introduces a
 compilation warning.

Changes from v3:
* adapted the driver to extcon framework (so moved to drivers/extcon)
* removed palmas_usb_(write/read) and replaced all calls with
  palmas_(read/write).
* ignored a checkpatch warning in the line 
	static const char *palmas_extcon_cable[] = {
  as it seemed to be incorrect?
* removed all references to OMAP in this driver.
* couldn't test this driver with mainline as omap5 panda is not booting
  with mainline.
* A comment to change to platform_get_irq from regmap is not done as I felt
  the data should come from regmap in this case.

Changes from v2:
* Moved the driver to drivers/usb/phy/
* Added a bit more explanation in Kconfig

 .../devicetree/bindings/extcon/extcon-twl.txt      |  15 ++
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 246 +++++++++++++++++++++
 include/linux/mfd/palmas.h                         |  26 ++-
 5 files changed, 283 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c

diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
new file mode 100644
index 0000000..58f531a
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
@@ -0,0 +1,15 @@
+EXTCON FOR TWL CHIPS
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+
+palmas-usb {
+       compatible = "ti,twl6035-usb", "ti,palmas-usb";
+       vbus-supply = <&smps10_reg>;
+       ti,wakeup;
+};
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 3297301..63f454e 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -53,4 +53,11 @@ config EXTCON_ARIZONA
 	  with Wolfson Arizona devices. These are audio CODECs with
 	  advanced audio accessory detection support.
 
+config EXTCON_PALMAS
+	tristate "Palmas USB EXTCON support"
+	depends on MFD_PALMAS
+	help
+	  Say Y here to enable support for USB peripheral and USB host
+	  detection by palmas usb.
+
 endif # MULTISTATE_SWITCH
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index f98a3c4..540e2c3 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
 obj-$(CONFIG_EXTCON_MAX8997)	+= extcon-max8997.o
 obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
+obj-$(CONFIG_EXTCON_PALMAS)	+= extcon-palmas.o
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
new file mode 100644
index 0000000..b752a0a
--- /dev/null
+++ b/drivers/extcon/extcon-palmas.c
@@ -0,0 +1,246 @@
+/*
+ * 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@slimlogic.co.uk>
+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK <hemahk@ti.com>
+ *
+ * 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/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+static const char *palmas_extcon_cable[] = {
+	[0] = "USB",
+	[1] = "USB-HOST",
+	NULL,
+};
+
+static const int mutually_exclusive[] = {0x3, 0x0};
+
+static void palmas_usb_wakeup(struct palmas *palmas, int enable)
+{
+	if (enable)
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP,
+			PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
+	else
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP, 0);
+}
+
+static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
+{
+	struct palmas_usb *palmas_usb = _palmas_usb;
+	unsigned int vbus_line_state;
+
+	palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE,
+		PALMAS_INT3_LINE_STATE, &vbus_line_state);
+
+	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
+		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
+			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+		} 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 == PALMAS_USB_STATE_VBUS) {
+			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious disconnect event detected\n");
+		}
+	}
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
+{
+	unsigned int set;
+	struct palmas_usb *palmas_usb = _palmas_usb;
+
+	palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_LATCH_SET, &set);
+
+	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_usb->linkstat = PALMAS_USB_STATE_ID;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
+	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static void palmas_enable_irq(struct palmas_usb *palmas_usb)
+{
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_EN_HI_SET,
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+
+	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+
+	/* cold plug for host mode needs this delay */
+	msleep(30);
+	palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+}
+
+static int palmas_usb_probe(struct platform_device *pdev)
+{
+	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;
+
+		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+	} else 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->id_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_OTG_IRQ);
+	palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_IRQ);
+	palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_OTG_IRQ);
+	palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_IRQ);
+
+	palmas_usb_wakeup(palmas, pdata->wakeup);
+
+	platform_set_drvdata(pdev, palmas_usb);
+
+	palmas_usb->edev.name = "palmas-usb";
+	palmas_usb->edev.supported_cable = palmas_extcon_cable;
+	palmas_usb->edev.mutually_exclusive = mutually_exclusive;
+
+	status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
+	if (status) {
+		dev_err(&pdev->dev, "failed to register extcon device\n");
+		return status;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
+			NULL, palmas_id_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_id", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->id_irq, status);
+		goto fail_extcon;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev,
+			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_vbus", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->vbus_irq, status);
+		goto fail_extcon;
+	}
+
+	palmas_enable_irq(palmas_usb);
+
+	return 0;
+
+fail_extcon:
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return status;
+}
+
+static int palmas_usb_remove(struct platform_device *pdev)
+{
+	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
+
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return 0;
+}
+
+static struct of_device_id of_palmas_match_tbl[] = {
+	{ .compatible = "ti,palmas-usb", },
+	{ .compatible = "ti,twl6035-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@slimlogic.co.uk>");
+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 8f21daf..9b81b2b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,6 +20,8 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/extcon.h>
+#include <linux/usb/phy_companion.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -37,6 +39,12 @@ struct palmas_gpadc;
 struct palmas_resource;
 struct palmas_usb;
 
+enum palmas_usb_state {
+	PALMAS_USB_STATE_DISCONNECT,
+	PALMAS_USB_STATE_VBUS,
+	PALMAS_USB_STATE_ID,
+};
+
 struct palmas {
 	struct device *dev;
 
@@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
 };
 
 struct palmas_usb_platform_data {
-	/* Set this if platform wishes its own vbus control */
-	int no_control_vbus;
-
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
 };
@@ -350,22 +355,19 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
-	/* for vbus reporting with irqs disabled */
-	spinlock_t lock;
-
-	struct regulator *vbus_reg;
+	struct extcon_dev edev;
 
 	/* used to set vbus, in atomic path */
 	struct work_struct set_vbus_work;
 
-	int irq1;
-	int irq2;
-	int irq3;
-	int irq4;
+	int id_otg_irq;
+	int id_irq;
+	int vbus_otg_irq;
+	int vbus_irq;
 
 	int vbus_enable;
 
-	u8 linkstat;
+	enum palmas_usb_state linkstat;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.8.1.2


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

* [PATCH v6] extcon: Palmas Extcon Driver
@ 2013-05-27 13:33   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27 13:33 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

From: Graeme Gregory <gg@slimlogic.co.uk>

This is the driver for the USB comparator 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@slimlogic.co.uk>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: George Cherian <george.cherian@ti.com>
[kishon@ti.com: adapted palmas usb driver to use the extcon framework]
Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
Changes from v5:
* removed regulator calls from palmas-usb as some platforms wont need it.
These are now done in dwc3-omap.c as it is needed for OMAP.
* removed all references to phy_companion as none of it is validated (SRP)
and all of them were currently unreachable code.

Changes from v4:
* removed no_control_vbus property (to be used if the platform wants to use
its own vbus control.
* removed unnecessary headers
* moved the palmas_usb_state to palmas.h
* misc cleanups
*A checkpatch warning "WARNING: static const char * array should
 probably be static const char * const"is ignored since it introduces a
 compilation warning.

Changes from v3:
* adapted the driver to extcon framework (so moved to drivers/extcon)
* removed palmas_usb_(write/read) and replaced all calls with
  palmas_(read/write).
* ignored a checkpatch warning in the line 
	static const char *palmas_extcon_cable[] = {
  as it seemed to be incorrect?
* removed all references to OMAP in this driver.
* couldn't test this driver with mainline as omap5 panda is not booting
  with mainline.
* A comment to change to platform_get_irq from regmap is not done as I felt
  the data should come from regmap in this case.

Changes from v2:
* Moved the driver to drivers/usb/phy/
* Added a bit more explanation in Kconfig

 .../devicetree/bindings/extcon/extcon-twl.txt      |  15 ++
 drivers/extcon/Kconfig                             |   7 +
 drivers/extcon/Makefile                            |   1 +
 drivers/extcon/extcon-palmas.c                     | 246 +++++++++++++++++++++
 include/linux/mfd/palmas.h                         |  26 ++-
 5 files changed, 283 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
 create mode 100644 drivers/extcon/extcon-palmas.c

diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
new file mode 100644
index 0000000..58f531a
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
@@ -0,0 +1,15 @@
+EXTCON FOR TWL CHIPS
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+
+palmas-usb {
+       compatible = "ti,twl6035-usb", "ti,palmas-usb";
+       vbus-supply = <&smps10_reg>;
+       ti,wakeup;
+};
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 3297301..63f454e 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -53,4 +53,11 @@ config EXTCON_ARIZONA
 	  with Wolfson Arizona devices. These are audio CODECs with
 	  advanced audio accessory detection support.
 
+config EXTCON_PALMAS
+	tristate "Palmas USB EXTCON support"
+	depends on MFD_PALMAS
+	help
+	  Say Y here to enable support for USB peripheral and USB host
+	  detection by palmas usb.
+
 endif # MULTISTATE_SWITCH
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index f98a3c4..540e2c3 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
 obj-$(CONFIG_EXTCON_MAX8997)	+= extcon-max8997.o
 obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
+obj-$(CONFIG_EXTCON_PALMAS)	+= extcon-palmas.o
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
new file mode 100644
index 0000000..b752a0a
--- /dev/null
+++ b/drivers/extcon/extcon-palmas.c
@@ -0,0 +1,246 @@
+/*
+ * 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@slimlogic.co.uk>
+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK <hemahk@ti.com>
+ *
+ * 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/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/mfd/palmas.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+static const char *palmas_extcon_cable[] = {
+	[0] = "USB",
+	[1] = "USB-HOST",
+	NULL,
+};
+
+static const int mutually_exclusive[] = {0x3, 0x0};
+
+static void palmas_usb_wakeup(struct palmas *palmas, int enable)
+{
+	if (enable)
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP,
+			PALMAS_USB_WAKEUP_ID_WK_UP_COMP);
+	else
+		palmas_write(palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_WAKEUP, 0);
+}
+
+static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
+{
+	struct palmas_usb *palmas_usb = _palmas_usb;
+	unsigned int vbus_line_state;
+
+	palmas_read(palmas_usb->palmas, PALMAS_INTERRUPT_BASE,
+		PALMAS_INT3_LINE_STATE, &vbus_line_state);
+
+	if (vbus_line_state & PALMAS_INT3_LINE_STATE_VBUS) {
+		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
+			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+		} 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 == PALMAS_USB_STATE_VBUS) {
+			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+		} else {
+			dev_dbg(palmas_usb->dev,
+				"Spurious disconnect event detected\n");
+		}
+	}
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
+{
+	unsigned int set;
+	struct palmas_usb *palmas_usb = _palmas_usb;
+
+	palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_LATCH_SET, &set);
+
+	if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
+		palmas_usb->linkstat = PALMAS_USB_STATE_ID;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
+	} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_SET,
+			PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_EN_HI_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+			PALMAS_USB_ID_INT_LATCH_CLR,
+			PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static void palmas_enable_irq(struct palmas_usb *palmas_usb)
+{
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_VBUS_CTRL_SET,
+		PALMAS_USB_VBUS_CTRL_SET_VBUS_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_CTRL_SET, PALMAS_USB_ID_CTRL_SET_ID_ACT_COMP);
+
+	palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
+		PALMAS_USB_ID_INT_EN_HI_SET,
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND);
+
+	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+
+	/* cold plug for host mode needs this delay */
+	msleep(30);
+	palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+}
+
+static int palmas_usb_probe(struct platform_device *pdev)
+{
+	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;
+
+		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+	} else 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->id_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_OTG_IRQ);
+	palmas_usb->id_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_ID_IRQ);
+	palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_OTG_IRQ);
+	palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
+						PALMAS_VBUS_IRQ);
+
+	palmas_usb_wakeup(palmas, pdata->wakeup);
+
+	platform_set_drvdata(pdev, palmas_usb);
+
+	palmas_usb->edev.name = "palmas-usb";
+	palmas_usb->edev.supported_cable = palmas_extcon_cable;
+	palmas_usb->edev.mutually_exclusive = mutually_exclusive;
+
+	status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev);
+	if (status) {
+		dev_err(&pdev->dev, "failed to register extcon device\n");
+		return status;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
+			NULL, palmas_id_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_id", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->id_irq, status);
+		goto fail_extcon;
+	}
+
+	status = devm_request_threaded_irq(palmas_usb->dev,
+			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			"palmas_usb_vbus", palmas_usb);
+	if (status < 0) {
+		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+					palmas_usb->vbus_irq, status);
+		goto fail_extcon;
+	}
+
+	palmas_enable_irq(palmas_usb);
+
+	return 0;
+
+fail_extcon:
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return status;
+}
+
+static int palmas_usb_remove(struct platform_device *pdev)
+{
+	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
+
+	extcon_dev_unregister(&palmas_usb->edev);
+
+	return 0;
+}
+
+static struct of_device_id of_palmas_match_tbl[] = {
+	{ .compatible = "ti,palmas-usb", },
+	{ .compatible = "ti,twl6035-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@slimlogic.co.uk>");
+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 8f21daf..9b81b2b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,6 +20,8 @@
 #include <linux/leds.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
+#include <linux/extcon.h>
+#include <linux/usb/phy_companion.h>
 
 #define PALMAS_NUM_CLIENTS		3
 
@@ -37,6 +39,12 @@ struct palmas_gpadc;
 struct palmas_resource;
 struct palmas_usb;
 
+enum palmas_usb_state {
+	PALMAS_USB_STATE_DISCONNECT,
+	PALMAS_USB_STATE_VBUS,
+	PALMAS_USB_STATE_ID,
+};
+
 struct palmas {
 	struct device *dev;
 
@@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
 };
 
 struct palmas_usb_platform_data {
-	/* Set this if platform wishes its own vbus control */
-	int no_control_vbus;
-
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
 };
@@ -350,22 +355,19 @@ struct palmas_usb {
 	struct palmas *palmas;
 	struct device *dev;
 
-	/* for vbus reporting with irqs disabled */
-	spinlock_t lock;
-
-	struct regulator *vbus_reg;
+	struct extcon_dev edev;
 
 	/* used to set vbus, in atomic path */
 	struct work_struct set_vbus_work;
 
-	int irq1;
-	int irq2;
-	int irq3;
-	int irq4;
+	int id_otg_irq;
+	int id_irq;
+	int vbus_otg_irq;
+	int vbus_irq;
 
 	int vbus_enable;
 
-	u8 linkstat;
+	enum palmas_usb_state linkstat;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.8.1.2


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

* [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-27 13:35   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27 13:35 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: grant.likely, rob.herring, rob, gregkh, george.cherian, kishon, sameo

Modified dwc3-omap to receive connect and disconnect notification using
extcon framework. Also did the necessary cleanups required after
adapting to extcon framework.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
Changes from v1:
* regulator enable/disable is now done here instead of palmas-usb as some users
of palmas-usb wont need regulator.
 drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
 include/linux/usb/dwc3-omap.h |  30 ------------
 2 files changed, 85 insertions(+), 48 deletions(-)
 delete mode 100644 include/linux/usb/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 34638b9..158f903 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,13 +43,14 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
-#include <linux/usb/dwc3-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/extcon.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/usb/otg.h>
 
@@ -124,9 +125,21 @@ struct dwc3_omap {
 	u32			utmi_otg_status;
 
 	u32			dma_status:1;
+
+	struct extcon_specific_cable_nb extcon_vbus_dev;
+	struct extcon_specific_cable_nb extcon_id_dev;
+	struct notifier_block	vbus_nb;
+	struct notifier_block	id_nb;
+
+	struct regulator	*vbus_reg;
 };
 
-static struct dwc3_omap		*_omap;
+enum omap_dwc3_vbus_id_status {
+	OMAP_DWC3_ID_FLOAT,
+	OMAP_DWC3_ID_GROUND,
+	OMAP_DWC3_VBUS_OFF,
+	OMAP_DWC3_VBUS_VALID,
+};
 
 static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
 {
@@ -138,18 +151,21 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
-int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
+	enum omap_dwc3_vbus_id_status status)
 {
-	u32			val;
-	struct dwc3_omap	*omap = _omap;
-
-	if (!omap)
-		return -EPROBE_DEFER;
+	int	ret;
+	u32	val;
 
 	switch (status) {
 	case OMAP_DWC3_ID_GROUND:
 		dev_dbg(omap->dev, "ID GND\n");
 
+		ret = regulator_enable(omap->vbus_reg);
+		if (ret) {
+			dev_dbg(omap->dev, "regulator enable failed\n");
+			return;
+		}
 		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 		val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
 				| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
@@ -162,6 +178,11 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 	case OMAP_DWC3_VBUS_VALID:
 		dev_dbg(omap->dev, "VBUS Connect\n");
 
+		ret = regulator_enable(omap->vbus_reg);
+		if (ret) {
+			dev_dbg(omap->dev, "regulator enable failed\n");
+			return;
+		}
 		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 		val &= ~USBOTGSS_UTMI_OTG_STATUS_SESSEND;
 		val |= USBOTGSS_UTMI_OTG_STATUS_IDDIG
@@ -182,15 +203,13 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 		val |= USBOTGSS_UTMI_OTG_STATUS_SESSEND
 				| USBOTGSS_UTMI_OTG_STATUS_IDDIG;
 		dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
+		regulator_disable(omap->vbus_reg);
 		break;
 
 	default:
-		dev_dbg(omap->dev, "ID float\n");
+		dev_dbg(omap->dev, "invalid state\n");
 	}
-
-	return 0;
 }
-EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
 
 static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
 {
@@ -282,6 +301,32 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
 
 static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
 
+static int dwc3_omap_id_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT);
+
+	return NOTIFY_DONE;
+}
+
+static int dwc3_omap_vbus_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF);
+
+	return NOTIFY_DONE;
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct device_node	*node = pdev->dev.of_node;
@@ -289,6 +334,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	struct dwc3_omap	*omap;
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
+	struct extcon_dev	*edev;
+	struct regulator	*vbus_reg;
 
 	int			ret = -ENOMEM;
 	int			irq;
@@ -330,19 +377,32 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	edev = extcon_get_extcon_dev("palmas-usb");
+	if (!edev) {
+		dev_dbg(dev, "couldn't get extcon device\n");
+		return -EPROBE_DEFER;
+	}
+
+	vbus_reg = devm_regulator_get(&pdev->dev, "vbus");
+	if (IS_ERR(vbus_reg)) {
+		dev_err(dev, "vbus init failed\n");
+		return PTR_ERR(vbus_reg);
+	}
+
 	spin_lock_init(&omap->lock);
 
 	omap->dev	= dev;
 	omap->irq	= irq;
 	omap->base	= base;
+	omap->vbus_reg	= vbus_reg;
+	omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
+	extcon_register_interest(&omap->extcon_vbus_dev, "palmas-usb", "USB",
+		&omap->vbus_nb);
+	omap->id_nb.notifier_call = dwc3_omap_id_notifier;
+	extcon_register_interest(&omap->extcon_id_dev, "palmas-usb", "USB-HOST",
+		&omap->id_nb);
 	dev->dma_mask	= &dwc3_omap_dma_mask;
 
-	/*
-	 * REVISIT if we ever have two instances of the wrapper, we will be
-	 * in big trouble
-	 */
-	_omap	= omap;
-
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
@@ -387,6 +447,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	if (extcon_get_cable_state(edev, "USB") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	if (extcon_get_cable_state(edev, "USB-HOST") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+
 	return 0;
 }
 
@@ -394,6 +459,8 @@ static int dwc3_omap_remove(struct platform_device *pdev)
 {
 	struct dwc3_omap	*omap = platform_get_drvdata(pdev);
 
+	extcon_unregister_interest(&omap->extcon_vbus_dev);
+	extcon_unregister_interest(&omap->extcon_id_dev);
 	dwc3_omap_disable_irqs(omap);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
deleted file mode 100644
index 5615f4d..0000000
--- a/include/linux/usb/dwc3-omap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2013 by Texas Instruments
- *
- * The Inventra Controller Driver for Linux is free software; you
- * can redistribute it and/or modify it under the terms of the GNU
- * General Public License version 2 as published by the Free Software
- * Foundation.
- */
-
-#ifndef __DWC3_OMAP_H__
-#define __DWC3_OMAP_H__
-
-enum omap_dwc3_vbus_id_status {
-	OMAP_DWC3_UNKNOWN = 0,
-	OMAP_DWC3_ID_GROUND,
-	OMAP_DWC3_ID_FLOAT,
-	OMAP_DWC3_VBUS_VALID,
-	OMAP_DWC3_VBUS_OFF,
-};
-
-#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
-extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
-#else
-static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
-{
-	return -ENODEV;
-}
-#endif
-
-#endif	/* __DWC3_OMAP_H__ */
-- 
1.8.1.2


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

* [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-27 13:35   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-27 13:35 UTC (permalink / raw)
  To: myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	cw00.choi-Sze3O3UU22JBDgjK7y7TUQ, balbi-l0cyMroinI0,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, gg-kDsPt+C1G03kYMGBc/C6ZA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, kishon-l0cyMroinI0,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A

Modified dwc3-omap to receive connect and disconnect notification using
extcon framework. Also did the necessary cleanups required after
adapting to extcon framework.

Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
Acked-by: Chanwoo Choi <cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes from v1:
* regulator enable/disable is now done here instead of palmas-usb as some users
of palmas-usb wont need regulator.
 drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
 include/linux/usb/dwc3-omap.h |  30 ------------
 2 files changed, 85 insertions(+), 48 deletions(-)
 delete mode 100644 include/linux/usb/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 34638b9..158f903 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,13 +43,14 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
-#include <linux/usb/dwc3-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/extcon.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/usb/otg.h>
 
@@ -124,9 +125,21 @@ struct dwc3_omap {
 	u32			utmi_otg_status;
 
 	u32			dma_status:1;
+
+	struct extcon_specific_cable_nb extcon_vbus_dev;
+	struct extcon_specific_cable_nb extcon_id_dev;
+	struct notifier_block	vbus_nb;
+	struct notifier_block	id_nb;
+
+	struct regulator	*vbus_reg;
 };
 
-static struct dwc3_omap		*_omap;
+enum omap_dwc3_vbus_id_status {
+	OMAP_DWC3_ID_FLOAT,
+	OMAP_DWC3_ID_GROUND,
+	OMAP_DWC3_VBUS_OFF,
+	OMAP_DWC3_VBUS_VALID,
+};
 
 static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
 {
@@ -138,18 +151,21 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
-int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
+	enum omap_dwc3_vbus_id_status status)
 {
-	u32			val;
-	struct dwc3_omap	*omap = _omap;
-
-	if (!omap)
-		return -EPROBE_DEFER;
+	int	ret;
+	u32	val;
 
 	switch (status) {
 	case OMAP_DWC3_ID_GROUND:
 		dev_dbg(omap->dev, "ID GND\n");
 
+		ret = regulator_enable(omap->vbus_reg);
+		if (ret) {
+			dev_dbg(omap->dev, "regulator enable failed\n");
+			return;
+		}
 		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 		val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
 				| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
@@ -162,6 +178,11 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 	case OMAP_DWC3_VBUS_VALID:
 		dev_dbg(omap->dev, "VBUS Connect\n");
 
+		ret = regulator_enable(omap->vbus_reg);
+		if (ret) {
+			dev_dbg(omap->dev, "regulator enable failed\n");
+			return;
+		}
 		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 		val &= ~USBOTGSS_UTMI_OTG_STATUS_SESSEND;
 		val |= USBOTGSS_UTMI_OTG_STATUS_IDDIG
@@ -182,15 +203,13 @@ int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
 		val |= USBOTGSS_UTMI_OTG_STATUS_SESSEND
 				| USBOTGSS_UTMI_OTG_STATUS_IDDIG;
 		dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
+		regulator_disable(omap->vbus_reg);
 		break;
 
 	default:
-		dev_dbg(omap->dev, "ID float\n");
+		dev_dbg(omap->dev, "invalid state\n");
 	}
-
-	return 0;
 }
-EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
 
 static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
 {
@@ -282,6 +301,32 @@ static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
 
 static u64 dwc3_omap_dma_mask = DMA_BIT_MASK(32);
 
+static int dwc3_omap_id_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT);
+
+	return NOTIFY_DONE;
+}
+
+static int dwc3_omap_vbus_notifier(struct notifier_block *nb,
+	unsigned long event, void *ptr)
+{
+	struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb);
+
+	if (event)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	else
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF);
+
+	return NOTIFY_DONE;
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct device_node	*node = pdev->dev.of_node;
@@ -289,6 +334,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	struct dwc3_omap	*omap;
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
+	struct extcon_dev	*edev;
+	struct regulator	*vbus_reg;
 
 	int			ret = -ENOMEM;
 	int			irq;
@@ -330,19 +377,32 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	edev = extcon_get_extcon_dev("palmas-usb");
+	if (!edev) {
+		dev_dbg(dev, "couldn't get extcon device\n");
+		return -EPROBE_DEFER;
+	}
+
+	vbus_reg = devm_regulator_get(&pdev->dev, "vbus");
+	if (IS_ERR(vbus_reg)) {
+		dev_err(dev, "vbus init failed\n");
+		return PTR_ERR(vbus_reg);
+	}
+
 	spin_lock_init(&omap->lock);
 
 	omap->dev	= dev;
 	omap->irq	= irq;
 	omap->base	= base;
+	omap->vbus_reg	= vbus_reg;
+	omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
+	extcon_register_interest(&omap->extcon_vbus_dev, "palmas-usb", "USB",
+		&omap->vbus_nb);
+	omap->id_nb.notifier_call = dwc3_omap_id_notifier;
+	extcon_register_interest(&omap->extcon_id_dev, "palmas-usb", "USB-HOST",
+		&omap->id_nb);
 	dev->dma_mask	= &dwc3_omap_dma_mask;
 
-	/*
-	 * REVISIT if we ever have two instances of the wrapper, we will be
-	 * in big trouble
-	 */
-	_omap	= omap;
-
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
@@ -387,6 +447,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	if (extcon_get_cable_state(edev, "USB") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
+	if (extcon_get_cable_state(edev, "USB-HOST") == true)
+		dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
+
 	return 0;
 }
 
@@ -394,6 +459,8 @@ static int dwc3_omap_remove(struct platform_device *pdev)
 {
 	struct dwc3_omap	*omap = platform_get_drvdata(pdev);
 
+	extcon_unregister_interest(&omap->extcon_vbus_dev);
+	extcon_unregister_interest(&omap->extcon_id_dev);
 	dwc3_omap_disable_irqs(omap);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
deleted file mode 100644
index 5615f4d..0000000
--- a/include/linux/usb/dwc3-omap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2013 by Texas Instruments
- *
- * The Inventra Controller Driver for Linux is free software; you
- * can redistribute it and/or modify it under the terms of the GNU
- * General Public License version 2 as published by the Free Software
- * Foundation.
- */
-
-#ifndef __DWC3_OMAP_H__
-#define __DWC3_OMAP_H__
-
-enum omap_dwc3_vbus_id_status {
-	OMAP_DWC3_UNKNOWN = 0,
-	OMAP_DWC3_ID_GROUND,
-	OMAP_DWC3_ID_FLOAT,
-	OMAP_DWC3_VBUS_VALID,
-	OMAP_DWC3_VBUS_OFF,
-};
-
-#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
-extern int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
-#else
-static inline int dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
-{
-	return -ENODEV;
-}
-#endif
-
-#endif	/* __DWC3_OMAP_H__ */
-- 
1.8.1.2

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

* Re: [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-28  2:24     ` Chanwoo Choi
  0 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-28  2:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On 05/27/2013 10:35 PM, Kishon Vijay Abraham I wrote:
> Modified dwc3-omap to receive connect and disconnect notification using
> extcon framework. Also did the necessary cleanups required after
> adapting to extcon framework.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
> Changes from v1:
> * regulator enable/disable is now done here instead of palmas-usb as some users
> of palmas-usb wont need regulator.
>  drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
>  include/linux/usb/dwc3-omap.h |  30 ------------
>  2 files changed, 85 insertions(+), 48 deletions(-)
>  delete mode 100644 include/linux/usb/dwc3-omap.h
I think that usb or other maintainer have to confirm this patch
for applying extcon-next branch.

Thanks,
Chanwoo Choi

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

* Re: [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-28  2:24     ` Chanwoo Choi
  0 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-28  2:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, gg-kDsPt+C1G03kYMGBc/C6ZA

On 05/27/2013 10:35 PM, Kishon Vijay Abraham I wrote:
> Modified dwc3-omap to receive connect and disconnect notification using
> extcon framework. Also did the necessary cleanups required after
> adapting to extcon framework.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
> Acked-by: Chanwoo Choi <cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
> Changes from v1:
> * regulator enable/disable is now done here instead of palmas-usb as some users
> of palmas-usb wont need regulator.
>  drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
>  include/linux/usb/dwc3-omap.h |  30 ------------
>  2 files changed, 85 insertions(+), 48 deletions(-)
>  delete mode 100644 include/linux/usb/dwc3-omap.h
I think that usb or other maintainer have to confirm this patch
for applying extcon-next branch.

Thanks,
Chanwoo Choi

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

* Re: [PATCH v6] extcon: Palmas Extcon Driver
  2013-05-27 13:33   ` Kishon Vijay Abraham I
  (?)
@ 2013-05-28  2:51   ` Chanwoo Choi
  -1 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-28  2:51 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On 05/27/2013 10:33 PM, Kishon Vijay Abraham I wrote:
> From: Graeme Gregory <gg@slimlogic.co.uk>
>
> This is the driver for the USB comparator 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@slimlogic.co.uk>
> Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
> Signed-off-by: Ruchika Kharwar <ruchika@ti.com>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> Signed-off-by: George Cherian <george.cherian@ti.com>
> [kishon@ti.com: adapted palmas usb driver to use the extcon framework]
> Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
> ---
> Changes from v5:
> * removed regulator calls from palmas-usb as some platforms wont need it.
> These are now done in dwc3-omap.c as it is needed for OMAP.
> * removed all references to phy_companion as none of it is validated (SRP)
> and all of them were currently unreachable code.
>
> Changes from v4:
> * removed no_control_vbus property (to be used if the platform wants to use
> its own vbus control.
> * removed unnecessary headers
> * moved the palmas_usb_state to palmas.h
> * misc cleanups
> *A checkpatch warning "WARNING: static const char * array should
>  probably be static const char * const"is ignored since it introduces a
>  compilation warning.
>
> Changes from v3:
> * adapted the driver to extcon framework (so moved to drivers/extcon)
> * removed palmas_usb_(write/read) and replaced all calls with
>   palmas_(read/write).
> * ignored a checkpatch warning in the line 
> 	static const char *palmas_extcon_cable[] = {
>   as it seemed to be incorrect?
> * removed all references to OMAP in this driver.
> * couldn't test this driver with mainline as omap5 panda is not booting
>   with mainline.
> * A comment to change to platform_get_irq from regmap is not done as I felt
>   the data should come from regmap in this case.
>
> Changes from v2:
> * Moved the driver to drivers/usb/phy/
> * Added a bit more explanation in Kconfig
>
>  .../devicetree/bindings/extcon/extcon-twl.txt      |  15 ++
>  drivers/extcon/Kconfig                             |   7 +
>  drivers/extcon/Makefile                            |   1 +
>  drivers/extcon/extcon-palmas.c                     | 246 +++++++++++++++++++++
>  include/linux/mfd/palmas.h                         |  26 ++-
>  5 files changed, 283 insertions(+), 12 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
>  create mode 100644 drivers/extcon/extcon-palmas.c
Applied only this patch.

you can check on following git repository:
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next

Thanks,
Chanwoo Choi


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

* Re: [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-28  5:27       ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-28  5:27 UTC (permalink / raw)
  To: Chanwoo Choi, balbi
  Cc: myungjoo.ham, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

On Tuesday 28 May 2013 07:54 AM, Chanwoo Choi wrote:
> On 05/27/2013 10:35 PM, Kishon Vijay Abraham I wrote:
>> Modified dwc3-omap to receive connect and disconnect notification using
>> extcon framework. Also did the necessary cleanups required after
>> adapting to extcon framework.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>> Changes from v1:
>> * regulator enable/disable is now done here instead of palmas-usb as some users
>> of palmas-usb wont need regulator.
>>   drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
>>   include/linux/usb/dwc3-omap.h |  30 ------------
>>   2 files changed, 85 insertions(+), 48 deletions(-)
>>   delete mode 100644 include/linux/usb/dwc3-omap.h
> I think that usb or other maintainer have to confirm this patch
> for applying extcon-next branch.

Ok. I'll check with Felipe.

Thanks
Kishon

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

* Re: [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
@ 2013-05-28  5:27       ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-28  5:27 UTC (permalink / raw)
  To: Chanwoo Choi, balbi-l0cyMroinI0
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, gg-kDsPt+C1G03kYMGBc/C6ZA

On Tuesday 28 May 2013 07:54 AM, Chanwoo Choi wrote:
> On 05/27/2013 10:35 PM, Kishon Vijay Abraham I wrote:
>> Modified dwc3-omap to receive connect and disconnect notification using
>> extcon framework. Also did the necessary cleanups required after
>> adapting to extcon framework.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
>> Acked-by: Chanwoo Choi <cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
>> ---
>> Changes from v1:
>> * regulator enable/disable is now done here instead of palmas-usb as some users
>> of palmas-usb wont need regulator.
>>   drivers/usb/dwc3/dwc3-omap.c  | 103 ++++++++++++++++++++++++++++++++++--------
>>   include/linux/usb/dwc3-omap.h |  30 ------------
>>   2 files changed, 85 insertions(+), 48 deletions(-)
>>   delete mode 100644 include/linux/usb/dwc3-omap.h
> I think that usb or other maintainer have to confirm this patch
> for applying extcon-next branch.

Ok. I'll check with Felipe.

Thanks
Kishon

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

* Re: [PATCH 0/3] palmas usb driver
@ 2013-05-28 17:35   ` Felipe Balbi
  0 siblings, 0 replies; 50+ messages in thread
From: Felipe Balbi @ 2013-05-28 17:35 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, cw00.choi, balbi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

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

On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> This patch series adds driver for palmas usb which is used to detect
> attach/detach events of usb device and usb host.
> 
> [PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> is added in this patch series itself. The revision history is added
> in the patch comments section.
> 
> A checkpatch warning "WARNING: static const char * array should
> probably be static const char * const"is ignored since it introduces a
> compilation warning.
> 
> Graeme Gregory (2):
>   drivers: regulator: palmas: add an API to set/clear the switch bit on
>     SMPS10
>   extcon: Palmas Extcon Driver
> 
> Kishon Vijay Abraham I (1):
>   usb: dwc3: use extcon fwrk to receive connect/disconnect notification


There were some comments to this series, what will happen with it ? Any
new versions coming ?

-- 
balbi

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

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

* Re: [PATCH 0/3] palmas usb driver
@ 2013-05-28 17:35   ` Felipe Balbi
  0 siblings, 0 replies; 50+ messages in thread
From: Felipe Balbi @ 2013-05-28 17:35 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, balbi-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	cw00.choi-Sze3O3UU22JBDgjK7y7TUQ,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA, gg-kDsPt+C1G03kYMGBc/C6ZA,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ


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

On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> This patch series adds driver for palmas usb which is used to detect
> attach/detach events of usb device and usb host.
> 
> [PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> is added in this patch series itself. The revision history is added
> in the patch comments section.
> 
> A checkpatch warning "WARNING: static const char * array should
> probably be static const char * const"is ignored since it introduces a
> compilation warning.
> 
> Graeme Gregory (2):
>   drivers: regulator: palmas: add an API to set/clear the switch bit on
>     SMPS10
>   extcon: Palmas Extcon Driver
> 
> Kishon Vijay Abraham I (1):
>   usb: dwc3: use extcon fwrk to receive connect/disconnect notification


There were some comments to this series, what will happen with it ? Any
new versions coming ?

-- 
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] 50+ messages in thread

* Re: [PATCH 0/3] palmas usb driver
@ 2013-05-29  6:06     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-29  6:06 UTC (permalink / raw)
  To: balbi
  Cc: myungjoo.ham, cw00.choi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

Hi Felipe,

On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
>> This patch series adds driver for palmas usb which is used to detect
>> attach/detach events of usb device and usb host.
>>
>> [PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
>> is added in this patch series itself. The revision history is added
>> in the patch comments section.
>>
>> A checkpatch warning "WARNING: static const char * array should
>> probably be static const char * const"is ignored since it introduces a
>> compilation warning.
>>
>> Graeme Gregory (2):
>>    drivers: regulator: palmas: add an API to set/clear the switch bit on
>>      SMPS10
>>    extcon: Palmas Extcon Driver
>>
>> Kishon Vijay Abraham I (1):
>>    usb: dwc3: use extcon fwrk to receive connect/disconnect notification
>
>
> There were some comments to this series, what will happen with it ? Any
> new versions coming ?

I've already sent new versions. Palmas Extcon Driver is already queued 
in extcon-next.
Chanwoo can take this patch in his tree after your ACK. [PATCH v2] usb: 
dwc3: use extcon fwrk to receive connect/disconnect notification.

Thanks
Kishon

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

* Re: [PATCH 0/3] palmas usb driver
@ 2013-05-29  6:06     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 50+ messages in thread
From: Kishon Vijay Abraham I @ 2013-05-29  6:06 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	cw00.choi-Sze3O3UU22JBDgjK7y7TUQ, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, gg-kDsPt+C1G03kYMGBc/C6ZA

Hi Felipe,

On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
>> This patch series adds driver for palmas usb which is used to detect
>> attach/detach events of usb device and usb host.
>>
>> [PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
>> is added in this patch series itself. The revision history is added
>> in the patch comments section.
>>
>> A checkpatch warning "WARNING: static const char * array should
>> probably be static const char * const"is ignored since it introduces a
>> compilation warning.
>>
>> Graeme Gregory (2):
>>    drivers: regulator: palmas: add an API to set/clear the switch bit on
>>      SMPS10
>>    extcon: Palmas Extcon Driver
>>
>> Kishon Vijay Abraham I (1):
>>    usb: dwc3: use extcon fwrk to receive connect/disconnect notification
>
>
> There were some comments to this series, what will happen with it ? Any
> new versions coming ?

I've already sent new versions. Palmas Extcon Driver is already queued 
in extcon-next.
Chanwoo can take this patch in his tree after your ACK. [PATCH v2] usb: 
dwc3: use extcon fwrk to receive connect/disconnect notification.

Thanks
Kishon

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

* Re: [PATCH 0/3] palmas usb driver
  2013-05-29  6:06     ` Kishon Vijay Abraham I
@ 2013-05-29 17:38       ` Felipe Balbi
  -1 siblings, 0 replies; 50+ messages in thread
From: Felipe Balbi @ 2013-05-29 17:38 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: balbi, myungjoo.ham, cw00.choi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

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

Hi,

On Wed, May 29, 2013 at 11:36:01AM +0530, Kishon Vijay Abraham I wrote:
> Hi Felipe,
> 
> On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> >On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> >>This patch series adds driver for palmas usb which is used to detect
> >>attach/detach events of usb device and usb host.
> >>
> >>[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> >>is added in this patch series itself. The revision history is added
> >>in the patch comments section.
> >>
> >>A checkpatch warning "WARNING: static const char * array should
> >>probably be static const char * const"is ignored since it introduces a
> >>compilation warning.
> >>
> >>Graeme Gregory (2):
> >>   drivers: regulator: palmas: add an API to set/clear the switch bit on
> >>     SMPS10
> >>   extcon: Palmas Extcon Driver
> >>
> >>Kishon Vijay Abraham I (1):
> >>   usb: dwc3: use extcon fwrk to receive connect/disconnect notification
> >
> >
> >There were some comments to this series, what will happen with it ? Any
> >new versions coming ?
> 
> I've already sent new versions. Palmas Extcon Driver is already
> queued in extcon-next.
> Chanwoo can take this patch in his tree after your ACK. [PATCH v2]
> usb: dwc3: use extcon fwrk to receive connect/disconnect
> notification.

alright, thanks for the note, here it is:


Acked-by: Felipe Balbi <balbi@ti.com>


-- 
balbi

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

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

* Re: [PATCH 0/3] palmas usb driver
@ 2013-05-29 17:38       ` Felipe Balbi
  0 siblings, 0 replies; 50+ messages in thread
From: Felipe Balbi @ 2013-05-29 17:38 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: balbi, myungjoo.ham, cw00.choi, ldewangan, gg, lgirdwood,
	broonie, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo

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

Hi,

On Wed, May 29, 2013 at 11:36:01AM +0530, Kishon Vijay Abraham I wrote:
> Hi Felipe,
> 
> On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> >On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> >>This patch series adds driver for palmas usb which is used to detect
> >>attach/detach events of usb device and usb host.
> >>
> >>[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> >>is added in this patch series itself. The revision history is added
> >>in the patch comments section.
> >>
> >>A checkpatch warning "WARNING: static const char * array should
> >>probably be static const char * const"is ignored since it introduces a
> >>compilation warning.
> >>
> >>Graeme Gregory (2):
> >>   drivers: regulator: palmas: add an API to set/clear the switch bit on
> >>     SMPS10
> >>   extcon: Palmas Extcon Driver
> >>
> >>Kishon Vijay Abraham I (1):
> >>   usb: dwc3: use extcon fwrk to receive connect/disconnect notification
> >
> >
> >There were some comments to this series, what will happen with it ? Any
> >new versions coming ?
> 
> I've already sent new versions. Palmas Extcon Driver is already
> queued in extcon-next.
> Chanwoo can take this patch in his tree after your ACK. [PATCH v2]
> usb: dwc3: use extcon fwrk to receive connect/disconnect
> notification.

alright, thanks for the note, here it is:


Acked-by: Felipe Balbi <balbi@ti.com>


-- 
balbi

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

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

* Re: [PATCH 0/3] palmas usb driver
       [not found]       ` <20130529173851.GC21290-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
@ 2013-05-30  2:17         ` Chanwoo Choi
  2013-05-30  2:44         ` Chanwoo Choi
  2013-05-30  2:46         ` Chanwoo Choi
  2 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-30  2:17 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, Kishon Vijay Abraham I,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ, Greg KH,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, gg-kDsPt+C1G03kYMGBc/C6ZA


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

On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:

> Hi,
>
> On Wed, May 29, 2013 at 11:36:01AM +0530, Kishon Vijay Abraham I wrote:
> > Hi Felipe,
> >
> > On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> > >On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> > >>This patch series adds driver for palmas usb which is used to detect
> > >>attach/detach events of usb device and usb host.
> > >>
> > >>[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> > >>is added in this patch series itself. The revision history is added
> > >>in the patch comments section.
> > >>
> > >>A checkpatch warning "WARNING: static const char * array should
> > >>probably be static const char * const"is ignored since it introduces a
> > >>compilation warning.
> > >>
> > >>Graeme Gregory (2):
> > >>   drivers: regulator: palmas: add an API to set/clear the switch bit
> on
> > >>     SMPS10
> > >>   extcon: Palmas Extcon Driver
> > >>
> > >>Kishon Vijay Abraham I (1):
> > >>   usb: dwc3: use extcon fwrk to receive connect/disconnect
> notification
> > >
> > >
> > >There were some comments to this series, what will happen with it ? Any
> > >new versions coming ?
> >
> > I've already sent new versions. Palmas Extcon Driver is already
> > queued in extcon-next.
> > Chanwoo can take this patch in his tree after your ACK. [PATCH v2]
> > usb: dwc3: use extcon fwrk to receive connect/disconnect
> > notification.
>
> alright, thanks for the note, here it is:
>
>
> Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>
>
OK, I applied this patchset on extcon-next branch
and I will send pull-request to GregKH.

You can check on following git repository:
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next

Thanks,
Chanwoo Choi

[-- Attachment #1.2: Type: text/html, Size: 2859 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] 50+ messages in thread

* Re: [PATCH 0/3] palmas usb driver
       [not found]       ` <20130529173851.GC21290-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
  2013-05-30  2:17         ` Chanwoo Choi
@ 2013-05-30  2:44         ` Chanwoo Choi
  2013-05-30  2:46         ` Chanwoo Choi
  2 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-30  2:44 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Liam Girdwood, Rob Herring,
	Kishon Vijay Abraham I, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Laxman Dewangan, myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ, Greg KH,
	Grant Likely, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	gg-kDsPt+C1G03kYMGBc/C6ZA


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

On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:

> Hi,
>
> On Wed, May 29, 2013 at 11:36:01AM +0530, Kishon Vijay Abraham I wrote:
> > Hi Felipe,
> >
> > On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> > >On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> > >>This patch series adds driver for palmas usb which is used to detect
> > >>attach/detach events of usb device and usb host.
> > >>
> > >>[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> > >>is added in this patch series itself. The revision history is added
> > >>in the patch comments section.
> > >>
> > >>A checkpatch warning "WARNING: static const char * array should
> > >>probably be static const char * const"is ignored since it introduces a
> > >>compilation warning.
> > >>
> > >>Graeme Gregory (2):
> > >>   drivers: regulator: palmas: add an API to set/clear the switch bit
> on
> > >>     SMPS10
> > >>   extcon: Palmas Extcon Driver
> > >>
> > >>Kishon Vijay Abraham I (1):
> > >>   usb: dwc3: use extcon fwrk to receive connect/disconnect
> notification
> > >
> > >
> > >There were some comments to this series, what will happen with it ? Any
> > >new versions coming ?
> >
> > I've already sent new versions. Palmas Extcon Driver is already
> > queued in extcon-next.
> > Chanwoo can take this patch in his tree after your ACK. [PATCH v2]
> > usb: dwc3: use extcon fwrk to receive connect/disconnect
> > notification.
>
> alright, thanks for the note, here it is:
>
>
> Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>
>
OK, I applied this patchset on extcon-next branch
and I will send pull-request to GregKH.

You can check on following git repository:
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next

Thanks,
Chanwoo Choi

[-- Attachment #1.2: Type: text/html, Size: 2875 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] 50+ messages in thread

* Re: [PATCH 0/3] palmas usb driver
       [not found]       ` <20130529173851.GC21290-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
  2013-05-30  2:17         ` Chanwoo Choi
  2013-05-30  2:44         ` Chanwoo Choi
@ 2013-05-30  2:46         ` Chanwoo Choi
  2 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-30  2:46 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: george.cherian-l0cyMroinI0, sameo-VuQAYsv1563Yd54FQh9/CA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Liam Girdwood, Rob Herring,
	Kishon Vijay Abraham I, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Laxman Dewangan, myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ, Greg KH,
	Grant Likely, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	gg-kDsPt+C1G03kYMGBc/C6ZA


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

On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:

> Hi,
>
> On Wed, May 29, 2013 at 11:36:01AM +0530, Kishon Vijay Abraham I wrote:
> > Hi Felipe,
> >
> > On Tuesday 28 May 2013 11:05 PM, Felipe Balbi wrote:
> > >On Fri, May 24, 2013 at 08:01:33PM +0530, Kishon Vijay Abraham I wrote:
> > >>This patch series adds driver for palmas usb which is used to detect
> > >>attach/detach events of usb device and usb host.
> > >>
> > >>[PATCH v5 2/3] extcon: Palmas Extcon Driver which was sent previously
> > >>is added in this patch series itself. The revision history is added
> > >>in the patch comments section.
> > >>
> > >>A checkpatch warning "WARNING: static const char * array should
> > >>probably be static const char * const"is ignored since it introduces a
> > >>compilation warning.
> > >>
> > >>Graeme Gregory (2):
> > >>   drivers: regulator: palmas: add an API to set/clear the switch bit
> on
> > >>     SMPS10
> > >>   extcon: Palmas Extcon Driver
> > >>
> > >>Kishon Vijay Abraham I (1):
> > >>   usb: dwc3: use extcon fwrk to receive connect/disconnect
> notification
> > >
> > >
> > >There were some comments to this series, what will happen with it ? Any
> > >new versions coming ?
> >
> > I've already sent new versions. Palmas Extcon Driver is already
> > queued in extcon-next.
> > Chanwoo can take this patch in his tree after your ACK. [PATCH v2]
> > usb: dwc3: use extcon fwrk to receive connect/disconnect
> > notification.
>
> alright, thanks for the note, here it is:
>
>
> Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>
>
> --
> balbi
>

OK, I applied this patchset on extcon-next branch
and I will send pull-request to GregKH.

You can check on following git repository:
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next

Thanks,
Chanwoo Choi

[-- Attachment #1.2: Type: text/html, Size: 2899 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] 50+ messages in thread

* Re: [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
  2013-05-24 14:31   ` Kishon Vijay Abraham I
  (?)
  (?)
@ 2013-05-30 23:45   ` Chanwoo Choi
  -1 siblings, 0 replies; 50+ messages in thread
From: Chanwoo Choi @ 2013-05-30 23:45 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: myungjoo.ham, balbi, ldewangan, gg, lgirdwood, broonie,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, grant.likely, rob.herring, rob, gregkh,
	george.cherian, sameo


On 05/24/2013 11:31 PM, Kishon Vijay Abraham I wrote:
> Modified dwc3-omap to receive connect and disconnect notification using
> extcon framework. Also did the necessary cleanups required after
> adapting to extcon framework.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/dwc3/dwc3-omap.c  | 80 +++++++++++++++++++++++++++++++++----------
>  include/linux/usb/dwc3-omap.h | 30 ----------------
>  2 files changed, 62 insertions(+), 48 deletions(-)
>  delete mode 100644 include/linux/usb/dwc3-omap.h

Hi Kishon,

Thi patch is suspended until fix following build error.
(If kernel builds extcon fwr as module, dwc3-omap.c happen error message)

---
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon extcon-next
head:   30f5d6ea2561c2a54e40b1e8e8f9bb30e064e01b
commit: 30f5d6ea2561c2a54e40b1e8e8f9bb30e064e01b [3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification
config: i386-randconfig-x14-0530 (attached as .config)

All error/warnings:

   drivers/built-in.o: In function `dwc3_omap_remove':
   dwc3-omap.c:(.text+0x8c0fa): undefined reference to `extcon_unregister_interest'
   dwc3-omap.c:(.text+0x8c102): undefined reference to `extcon_unregister_interest'
   drivers/built-in.o: In function `dwc3_omap_probe':
   dwc3-omap.c:(.text+0x8c5e6): undefined reference to `extcon_get_extcon_dev'
   dwc3-omap.c:(.text+0x8c6a4): undefined reference to `extcon_register_interest'
   dwc3-omap.c:(.text+0x8c6c9): undefined reference to `extcon_register_interest'
   dwc3-omap.c:(.text+0x8c831): undefined reference to `extcon_get_cable_state'
   dwc3-omap.c:(.text+0x8c851): undefined reference to `extcon_get_cable_state'
---

Also, I missed a issue of this patch. If h/w target use other USB device
instead of "palmas-usb", dwc-omap.c driver won't be operating.
So, I propose two method about this issue.
First, we can get extcon device name through platform data or dt.
Two, When use extcon_register_interest() to register notifier block,
NULL pointer pass to extcon_register_interest() instead of specific extcon
device name(palmas-usb). If extcon_register_interest() check NULL
pointer of extcon device name parameter, extcon fwr will find previous
registered extcon device and then register notifier block of consumer
device driver(dwc3-omap.c) to previous registered extcon device.

> +	edev = extcon_get_extcon_dev("palmas-usb");
> +	if (!edev) {
> +		dev_dbg(dev, "couldn't get extcon device\n");
> +		return -EPROBE_DEFER;
> +	}
> +
>  	spin_lock_init(&omap->lock);
>  
>  	omap->dev	= dev;
>  	omap->irq	= irq;
>  	omap->base	= base;
> +	omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
> +	extcon_register_interest(&omap->extcon_vbus_dev, "palmas-usb", "USB",
> +		&omap->vbus_nb);
> +	omap->id_nb.notifier_call = dwc3_omap_id_notifier;
> +	extcon_register_interest(&omap->extcon_id_dev, "palmas-usb", "USB-HOST",
> +		&omap->id_nb);
>  	dev->dma_mask	= &dwc3_omap_dma_mask;
>  
> +

Thanks,
Chanwoo Choi


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

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

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-24 14:31 [PATCH 0/3] palmas usb driver Kishon Vijay Abraham I
2013-05-24 14:31 ` Kishon Vijay Abraham I
2013-05-24 14:31 ` [PATCH 1/3] drivers: regulator: palmas: add an API to set/clear the switch bit on SMPS10 Kishon Vijay Abraham I
2013-05-24 14:31   ` Kishon Vijay Abraham I
2013-05-24 15:09   ` Sergei Shtylyov
2013-05-24 15:09     ` Sergei Shtylyov
2013-05-25 17:00   ` Laxman Dewangan
2013-05-25 17:00     ` Laxman Dewangan
2013-05-24 14:31 ` [PATCH v5 2/3] extcon: Palmas Extcon Driver Kishon Vijay Abraham I
2013-05-24 14:31   ` Kishon Vijay Abraham I
2013-05-25 17:10   ` Laxman Dewangan
2013-05-25 17:10     ` Laxman Dewangan
2013-05-27  5:34   ` Chanwoo Choi
2013-05-27  5:54     ` Kishon Vijay Abraham I
2013-05-27  5:54       ` Kishon Vijay Abraham I
2013-05-27  6:08       ` Chanwoo Choi
2013-05-27  6:22         ` Laxman Dewangan
2013-05-27  6:22           ` Laxman Dewangan
2013-05-27  6:31           ` Kishon Vijay Abraham I
2013-05-27  6:31             ` Kishon Vijay Abraham I
2013-05-27  6:36             ` Laxman Dewangan
2013-05-27  6:36               ` Laxman Dewangan
2013-05-27  6:41               ` Kishon Vijay Abraham I
2013-05-27  6:41                 ` Kishon Vijay Abraham I
2013-05-27  6:56                 ` Laxman Dewangan
2013-05-27  6:56                   ` Laxman Dewangan
2013-05-27  9:24                   ` Kishon Vijay Abraham I
2013-05-27  9:24                     ` Kishon Vijay Abraham I
2013-05-24 14:31 ` [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification Kishon Vijay Abraham I
2013-05-24 14:31   ` Kishon Vijay Abraham I
2013-05-27  5:38   ` Chanwoo Choi
2013-05-30 23:45   ` Chanwoo Choi
2013-05-27 13:33 ` [PATCH v6] extcon: Palmas Extcon Driver Kishon Vijay Abraham I
2013-05-27 13:33   ` Kishon Vijay Abraham I
2013-05-28  2:51   ` Chanwoo Choi
2013-05-27 13:35 ` [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification Kishon Vijay Abraham I
2013-05-27 13:35   ` Kishon Vijay Abraham I
2013-05-28  2:24   ` Chanwoo Choi
2013-05-28  2:24     ` Chanwoo Choi
2013-05-28  5:27     ` Kishon Vijay Abraham I
2013-05-28  5:27       ` Kishon Vijay Abraham I
2013-05-28 17:35 ` [PATCH 0/3] palmas usb driver Felipe Balbi
2013-05-28 17:35   ` Felipe Balbi
2013-05-29  6:06   ` Kishon Vijay Abraham I
2013-05-29  6:06     ` Kishon Vijay Abraham I
2013-05-29 17:38     ` Felipe Balbi
2013-05-29 17:38       ` Felipe Balbi
     [not found]       ` <20130529173851.GC21290-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-05-30  2:17         ` Chanwoo Choi
2013-05-30  2:44         ` Chanwoo Choi
2013-05-30  2:46         ` Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.