All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport
@ 2013-07-10  6:15 ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

This patch series does following:
- Remove unused member from extcon palmas structure.
- Fix to support of detecting cable properly with multiple insert/removal.
- Add support for suspend/resume functionlaity and wakup from suspend.
- Option to select/de-select the ID or VBUS detection.

Changes from V1:
- Correct the display message.
- Add ack from Graeme

Laxman Dewangan (4):
  extcon: palmas: remove unused member from palams_usb structure
  extcon: palmas: enable ID_GND and ID_FLOAT detection always
  extcon: palams: add support for suspend/resume
  extcon: palmas: Option to disable ID/VBUS detection based on platform

 .../devicetree/bindings/extcon/extcon-palmas.txt   |    2 +
 drivers/extcon/extcon-palmas.c                     |  111 ++++++++++++++------
 include/linux/mfd/palmas.h                         |    9 +-
 3 files changed, 86 insertions(+), 36 deletions(-)


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

* [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport
@ 2013-07-10  6:15 ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

This patch series does following:
- Remove unused member from extcon palmas structure.
- Fix to support of detecting cable properly with multiple insert/removal.
- Add support for suspend/resume functionlaity and wakup from suspend.
- Option to select/de-select the ID or VBUS detection.

Changes from V1:
- Correct the display message.
- Add ack from Graeme

Laxman Dewangan (4):
  extcon: palmas: remove unused member from palams_usb structure
  extcon: palmas: enable ID_GND and ID_FLOAT detection always
  extcon: palams: add support for suspend/resume
  extcon: palmas: Option to disable ID/VBUS detection based on platform

 .../devicetree/bindings/extcon/extcon-palmas.txt   |    2 +
 drivers/extcon/extcon-palmas.c                     |  111 ++++++++++++++------
 include/linux/mfd/palmas.h                         |    9 +-
 3 files changed, 86 insertions(+), 36 deletions(-)


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

* [PATCH V2 1/4] extcon: palmas: remove unused member from palams_usb structure
@ 2013-07-10  6:15   ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

Remove unused member vbus_enable and set_vbus_work from palmas_usb
as these members are not used in drivers.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
No changes from V1.

 include/linux/mfd/palmas.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 1a8dd7a..03c22ca 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -371,16 +371,11 @@ struct palmas_usb {
 
 	struct extcon_dev edev;
 
-	/* used to set vbus, in atomic path */
-	struct work_struct set_vbus_work;
-
 	int id_otg_irq;
 	int id_irq;
 	int vbus_otg_irq;
 	int vbus_irq;
 
-	int vbus_enable;
-
 	enum palmas_usb_state linkstat;
 };
 
-- 
1.7.1.1


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

* [PATCH V2 1/4] extcon: palmas: remove unused member from palams_usb structure
@ 2013-07-10  6:15   ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi-Sze3O3UU22JBDgjK7y7TUQ, myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ
  Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, kishon-l0cyMroinI0,
	Laxman Dewangan, gg-kDsPt+C1G03kYMGBc/C6ZA

Remove unused member vbus_enable and set_vbus_work from palmas_usb
as these members are not used in drivers.

Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Acked-by: Graeme Gregory <gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>
---
No changes from V1.

 include/linux/mfd/palmas.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 1a8dd7a..03c22ca 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -371,16 +371,11 @@ struct palmas_usb {
 
 	struct extcon_dev edev;
 
-	/* used to set vbus, in atomic path */
-	struct work_struct set_vbus_work;
-
 	int id_otg_irq;
 	int id_irq;
 	int vbus_otg_irq;
 	int vbus_irq;
 
-	int vbus_enable;
-
 	enum palmas_usb_state linkstat;
 };
 
-- 
1.7.1.1

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

* [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
  2013-07-10  6:15 ` Laxman Dewangan
@ 2013-07-10  6:15   ` Laxman Dewangan
  -1 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

When integrating driver with Tegra platform, it is found that
the ID pins get detected only once after booting system and
further removal and re-insert does not detect the ID pin.

Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT
always  and clearing the status on LATCH register which actually
occurred.

Also if interrupt occurs with line status as zero then based on
previous status, set the cable state.

Add debug prints to display the cable state when any cable
insertion/removal happen.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
Changes from V1:
- Corrected the print message to have more meaningful.

 drivers/extcon/extcon-palmas.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index b752a0a..33254d9 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
 		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
 			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
 			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+			dev_info(palmas_usb->dev, "USB cable is attached\n");
 		} else {
 			dev_dbg(palmas_usb->dev,
 				"Spurious connect event detected\n");
@@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
 		if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) {
 			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
 			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+			dev_info(palmas_usb->dev, "USB cable is detached\n");
 		} else {
 			dev_dbg(palmas_usb->dev,
 				"Spurious disconnect event detected\n");
@@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
 
 	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);
+		dev_info(palmas_usb->dev, "HOST cable is attached\n");
 	} 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);
+		dev_info(palmas_usb->dev, "HOST cable is detached\n");
+	} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) &&
+				(!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+		dev_info(palmas_usb->dev, "HOST cable is detached\n");
 	}
 
 	return IRQ_HANDLED;
@@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
 
 	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_USB_ID_INT_EN_HI_SET_ID_GND |
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
 
 	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
 
-- 
1.7.1.1


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

* [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
@ 2013-07-10  6:15   ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

When integrating driver with Tegra platform, it is found that
the ID pins get detected only once after booting system and
further removal and re-insert does not detect the ID pin.

Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT
always  and clearing the status on LATCH register which actually
occurred.

Also if interrupt occurs with line status as zero then based on
previous status, set the cable state.

Add debug prints to display the cable state when any cable
insertion/removal happen.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
Changes from V1:
- Corrected the print message to have more meaningful.

 drivers/extcon/extcon-palmas.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index b752a0a..33254d9 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
 		if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) {
 			palmas_usb->linkstat = PALMAS_USB_STATE_VBUS;
 			extcon_set_cable_state(&palmas_usb->edev, "USB", true);
+			dev_info(palmas_usb->dev, "USB cable is attached\n");
 		} else {
 			dev_dbg(palmas_usb->dev,
 				"Spurious connect event detected\n");
@@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
 		if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) {
 			palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
 			extcon_set_cable_state(&palmas_usb->edev, "USB", false);
+			dev_info(palmas_usb->dev, "USB cable is detached\n");
 		} else {
 			dev_dbg(palmas_usb->dev,
 				"Spurious disconnect event detected\n");
@@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
 
 	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);
+		dev_info(palmas_usb->dev, "HOST cable is attached\n");
 	} 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);
+		dev_info(palmas_usb->dev, "HOST cable is detached\n");
+	} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) &&
+				(!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
+		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
+		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
+		dev_info(palmas_usb->dev, "HOST cable is detached\n");
 	}
 
 	return IRQ_HANDLED;
@@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
 
 	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_USB_ID_INT_EN_HI_SET_ID_GND |
+		PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
 
 	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
 
-- 
1.7.1.1

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

* [PATCH V2 3/4] extcon: palams: add support for suspend/resume
  2013-07-10  6:15 ` Laxman Dewangan
@ 2013-07-10  6:15   ` Laxman Dewangan
  -1 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

Add suspend/resume callbacks and support for wakeup from
suspend on USB HOST or USB Device cable insertion or removal.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
No changes from V1.

 drivers/extcon/extcon-palmas.c |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 33254d9..dc7ebf3 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -182,7 +182,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
 			NULL, palmas_id_irq_handler,
-			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+			IRQF_ONESHOT | IRQF_EARLY_RESUME,
 			"palmas_usb_id", palmas_usb);
 	if (status < 0) {
 		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -192,7 +193,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	status = devm_request_threaded_irq(palmas_usb->dev,
 			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
-			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+			IRQF_ONESHOT | IRQF_EARLY_RESUME,
 			"palmas_usb_vbus", palmas_usb);
 	if (status < 0) {
 		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -201,7 +203,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
 	}
 
 	palmas_enable_irq(palmas_usb);
-
+	device_set_wakeup_capable(&pdev->dev, true);
 	return 0;
 
 fail_extcon:
@@ -219,6 +221,35 @@ static int palmas_usb_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int palmas_usb_suspend(struct device *dev)
+{
+	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev)) {
+		enable_irq_wake(palmas_usb->vbus_irq);
+		enable_irq_wake(palmas_usb->id_irq);
+	}
+	return 0;
+}
+
+static int palmas_usb_resume(struct device *dev)
+{
+	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev)) {
+		disable_irq_wake(palmas_usb->vbus_irq);
+		disable_irq_wake(palmas_usb->id_irq);
+	}
+	return 0;
+};
+#endif
+
+static const struct dev_pm_ops palmas_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(palmas_usb_suspend,
+				palmas_usb_resume)
+};
+
 static struct of_device_id of_palmas_match_tbl[] = {
 	{ .compatible = "ti,palmas-usb", },
 	{ .compatible = "ti,twl6035-usb", },
@@ -232,6 +263,7 @@ static struct platform_driver palmas_usb_driver = {
 		.name = "palmas-usb",
 		.of_match_table = of_palmas_match_tbl,
 		.owner = THIS_MODULE,
+		.pm = &palmas_pm_ops,
 	},
 };
 
-- 
1.7.1.1


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

* [PATCH V2 3/4] extcon: palams: add support for suspend/resume
@ 2013-07-10  6:15   ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

Add suspend/resume callbacks and support for wakeup from
suspend on USB HOST or USB Device cable insertion or removal.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
No changes from V1.

 drivers/extcon/extcon-palmas.c |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 33254d9..dc7ebf3 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -182,7 +182,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq,
 			NULL, palmas_id_irq_handler,
-			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+			IRQF_ONESHOT | IRQF_EARLY_RESUME,
 			"palmas_usb_id", palmas_usb);
 	if (status < 0) {
 		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -192,7 +193,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	status = devm_request_threaded_irq(palmas_usb->dev,
 			palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler,
-			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+			IRQF_ONESHOT | IRQF_EARLY_RESUME,
 			"palmas_usb_vbus", palmas_usb);
 	if (status < 0) {
 		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -201,7 +203,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
 	}
 
 	palmas_enable_irq(palmas_usb);
-
+	device_set_wakeup_capable(&pdev->dev, true);
 	return 0;
 
 fail_extcon:
@@ -219,6 +221,35 @@ static int palmas_usb_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int palmas_usb_suspend(struct device *dev)
+{
+	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev)) {
+		enable_irq_wake(palmas_usb->vbus_irq);
+		enable_irq_wake(palmas_usb->id_irq);
+	}
+	return 0;
+}
+
+static int palmas_usb_resume(struct device *dev)
+{
+	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev)) {
+		disable_irq_wake(palmas_usb->vbus_irq);
+		disable_irq_wake(palmas_usb->id_irq);
+	}
+	return 0;
+};
+#endif
+
+static const struct dev_pm_ops palmas_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(palmas_usb_suspend,
+				palmas_usb_resume)
+};
+
 static struct of_device_id of_palmas_match_tbl[] = {
 	{ .compatible = "ti,palmas-usb", },
 	{ .compatible = "ti,twl6035-usb", },
@@ -232,6 +263,7 @@ static struct platform_driver palmas_usb_driver = {
 		.name = "palmas-usb",
 		.of_match_table = of_palmas_match_tbl,
 		.owner = THIS_MODULE,
+		.pm = &palmas_pm_ops,
 	},
 };
 
-- 
1.7.1.1

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

* [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
  2013-07-10  6:15 ` Laxman Dewangan
@ 2013-07-10  6:15   ` Laxman Dewangan
  -1 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

Based on system design, platform needs to detect the VBUS or ID or
both. Provide option to select this through platform data to
disable part of cable detection through palmas-usb.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
No changes from V1.

 .../devicetree/bindings/extcon/extcon-palmas.txt   |    2 +
 drivers/extcon/extcon-palmas.c                     |   65 +++++++++++++-------
 include/linux/mfd/palmas.h                         |    4 +
 3 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index f110e75..8e593ec 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -6,6 +6,8 @@ Required Properties:
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
+ - ti,disable-id-detection: Do not perform ID detection.
+ - ti,disable-vbus-detection: Do not pwerform VBUS detection.
 
 palmas-usb {
        compatible = "ti,twl6035-usb", "ti,palmas-usb";
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index dc7ebf3..4747d11 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -122,11 +122,14 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
 		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND |
 		PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
 
-	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+	if (palmas_usb->enable_vbus_detection)
+		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);
+	if (palmas_usb->enable_id_detection) {
+		msleep(30);
+		palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+	}
 }
 
 static int palmas_usb_probe(struct platform_device *pdev)
@@ -144,6 +147,10 @@ static int palmas_usb_probe(struct platform_device *pdev)
 			return -ENOMEM;
 
 		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+		pdata->disable_id_detection = of_property_read_bool(node,
+						"ti,disable-id-detection");
+		pdata->disable_vbus_detection = of_property_read_bool(node,
+						"ti,disable-vbus-detection");
 	} else if (!pdata) {
 		return -EINVAL;
 	}
@@ -154,6 +161,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	palmas->usb = palmas_usb;
 	palmas_usb->palmas = palmas;
+	palmas_usb->enable_vbus_detection = !pdata->disable_vbus_detection;
+	palmas_usb->enable_id_detection =  !pdata->disable_id_detection;
 
 	palmas_usb->dev	 = &pdev->dev;
 
@@ -180,26 +189,32 @@ static int palmas_usb_probe(struct platform_device *pdev)
 		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 |
-			IRQF_ONESHOT | IRQF_EARLY_RESUME,
-			"palmas_usb_id", palmas_usb);
-	if (status < 0) {
-		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+	if (palmas_usb->enable_id_detection) {
+		status = devm_request_threaded_irq(palmas_usb->dev,
+				palmas_usb->id_irq,
+				NULL, palmas_id_irq_handler,
+				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+				IRQF_ONESHOT | IRQF_EARLY_RESUME,
+				"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;
+			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 |
-			IRQF_ONESHOT | IRQF_EARLY_RESUME,
-			"palmas_usb_vbus", palmas_usb);
-	if (status < 0) {
-		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+	if (palmas_usb->enable_vbus_detection) {
+		status = devm_request_threaded_irq(palmas_usb->dev,
+				palmas_usb->vbus_irq, NULL,
+				palmas_vbus_irq_handler,
+				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+				IRQF_ONESHOT | IRQF_EARLY_RESUME,
+				"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;
+			goto fail_extcon;
+		}
 	}
 
 	palmas_enable_irq(palmas_usb);
@@ -227,8 +242,10 @@ static int palmas_usb_suspend(struct device *dev)
 	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
 
 	if (device_may_wakeup(dev)) {
-		enable_irq_wake(palmas_usb->vbus_irq);
-		enable_irq_wake(palmas_usb->id_irq);
+		if (palmas_usb->enable_vbus_detection)
+			enable_irq_wake(palmas_usb->vbus_irq);
+		if (palmas_usb->enable_id_detection)
+			enable_irq_wake(palmas_usb->id_irq);
 	}
 	return 0;
 }
@@ -238,8 +255,10 @@ static int palmas_usb_resume(struct device *dev)
 	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
 
 	if (device_may_wakeup(dev)) {
-		disable_irq_wake(palmas_usb->vbus_irq);
-		disable_irq_wake(palmas_usb->id_irq);
+		if (palmas_usb->enable_vbus_detection)
+			disable_irq_wake(palmas_usb->vbus_irq);
+		if (palmas_usb->enable_id_detection)
+			disable_irq_wake(palmas_usb->id_irq);
 	}
 	return 0;
 };
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 03c22ca..d9ef94c 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -204,6 +204,8 @@ struct palmas_pmic_platform_data {
 struct palmas_usb_platform_data {
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
+	bool disable_vbus_detection;
+	bool disable_id_detection;
 };
 
 struct palmas_resource_platform_data {
@@ -377,6 +379,8 @@ struct palmas_usb {
 	int vbus_irq;
 
 	enum palmas_usb_state linkstat;
+	bool enable_vbus_detection;
+	bool enable_id_detection;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.7.1.1


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

* [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
@ 2013-07-10  6:15   ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  6:15 UTC (permalink / raw)
  To: cw00.choi, myungjoo.ham
  Cc: devicetree-discuss, rob, linux-doc, linux-kernel, kishon, gg,
	Laxman Dewangan

Based on system design, platform needs to detect the VBUS or ID or
both. Provide option to select this through platform data to
disable part of cable detection through palmas-usb.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
---
No changes from V1.

 .../devicetree/bindings/extcon/extcon-palmas.txt   |    2 +
 drivers/extcon/extcon-palmas.c                     |   65 +++++++++++++-------
 include/linux/mfd/palmas.h                         |    4 +
 3 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
index f110e75..8e593ec 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
@@ -6,6 +6,8 @@ Required Properties:
 
 Optional Properties:
  - ti,wakeup : To enable the wakeup comparator in probe
+ - ti,disable-id-detection: Do not perform ID detection.
+ - ti,disable-vbus-detection: Do not pwerform VBUS detection.
 
 palmas-usb {
        compatible = "ti,twl6035-usb", "ti,palmas-usb";
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index dc7ebf3..4747d11 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -122,11 +122,14 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
 		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND |
 		PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
 
-	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
+	if (palmas_usb->enable_vbus_detection)
+		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);
+	if (palmas_usb->enable_id_detection) {
+		msleep(30);
+		palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
+	}
 }
 
 static int palmas_usb_probe(struct platform_device *pdev)
@@ -144,6 +147,10 @@ static int palmas_usb_probe(struct platform_device *pdev)
 			return -ENOMEM;
 
 		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
+		pdata->disable_id_detection = of_property_read_bool(node,
+						"ti,disable-id-detection");
+		pdata->disable_vbus_detection = of_property_read_bool(node,
+						"ti,disable-vbus-detection");
 	} else if (!pdata) {
 		return -EINVAL;
 	}
@@ -154,6 +161,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	palmas->usb = palmas_usb;
 	palmas_usb->palmas = palmas;
+	palmas_usb->enable_vbus_detection = !pdata->disable_vbus_detection;
+	palmas_usb->enable_id_detection =  !pdata->disable_id_detection;
 
 	palmas_usb->dev	 = &pdev->dev;
 
@@ -180,26 +189,32 @@ static int palmas_usb_probe(struct platform_device *pdev)
 		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 |
-			IRQF_ONESHOT | IRQF_EARLY_RESUME,
-			"palmas_usb_id", palmas_usb);
-	if (status < 0) {
-		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+	if (palmas_usb->enable_id_detection) {
+		status = devm_request_threaded_irq(palmas_usb->dev,
+				palmas_usb->id_irq,
+				NULL, palmas_id_irq_handler,
+				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+				IRQF_ONESHOT | IRQF_EARLY_RESUME,
+				"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;
+			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 |
-			IRQF_ONESHOT | IRQF_EARLY_RESUME,
-			"palmas_usb_vbus", palmas_usb);
-	if (status < 0) {
-		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
+	if (palmas_usb->enable_vbus_detection) {
+		status = devm_request_threaded_irq(palmas_usb->dev,
+				palmas_usb->vbus_irq, NULL,
+				palmas_vbus_irq_handler,
+				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
+				IRQF_ONESHOT | IRQF_EARLY_RESUME,
+				"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;
+			goto fail_extcon;
+		}
 	}
 
 	palmas_enable_irq(palmas_usb);
@@ -227,8 +242,10 @@ static int palmas_usb_suspend(struct device *dev)
 	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
 
 	if (device_may_wakeup(dev)) {
-		enable_irq_wake(palmas_usb->vbus_irq);
-		enable_irq_wake(palmas_usb->id_irq);
+		if (palmas_usb->enable_vbus_detection)
+			enable_irq_wake(palmas_usb->vbus_irq);
+		if (palmas_usb->enable_id_detection)
+			enable_irq_wake(palmas_usb->id_irq);
 	}
 	return 0;
 }
@@ -238,8 +255,10 @@ static int palmas_usb_resume(struct device *dev)
 	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
 
 	if (device_may_wakeup(dev)) {
-		disable_irq_wake(palmas_usb->vbus_irq);
-		disable_irq_wake(palmas_usb->id_irq);
+		if (palmas_usb->enable_vbus_detection)
+			disable_irq_wake(palmas_usb->vbus_irq);
+		if (palmas_usb->enable_id_detection)
+			disable_irq_wake(palmas_usb->id_irq);
 	}
 	return 0;
 };
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 03c22ca..d9ef94c 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -204,6 +204,8 @@ struct palmas_pmic_platform_data {
 struct palmas_usb_platform_data {
 	/* Do we enable the wakeup comparator on probe */
 	int wakeup;
+	bool disable_vbus_detection;
+	bool disable_id_detection;
 };
 
 struct palmas_resource_platform_data {
@@ -377,6 +379,8 @@ struct palmas_usb {
 	int vbus_irq;
 
 	enum palmas_usb_state linkstat;
+	bool enable_vbus_detection;
+	bool enable_id_detection;
 };
 
 #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
-- 
1.7.1.1

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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
  2013-07-10  6:15   ` Laxman Dewangan
  (?)
@ 2013-07-10  6:55   ` Chanwoo Choi
  2013-07-10  7:13       ` Laxman Dewangan
  -1 siblings, 1 reply; 23+ messages in thread
From: Chanwoo Choi @ 2013-07-10  6:55 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

Hi Laxman, 

On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
> Based on system design, platform needs to detect the VBUS or ID or
> both. Provide option to select this through platform data to
> disable part of cable detection through palmas-usb.
> 
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
> ---
> No changes from V1.
> 
>  .../devicetree/bindings/extcon/extcon-palmas.txt   |    2 +
>  drivers/extcon/extcon-palmas.c                     |   65 +++++++++++++-------
>  include/linux/mfd/palmas.h                         |    4 +
>  3 files changed, 48 insertions(+), 23 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
> index f110e75..8e593ec 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
> +++ b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
> @@ -6,6 +6,8 @@ Required Properties:
>  
>  Optional Properties:
>   - ti,wakeup : To enable the wakeup comparator in probe
> + - ti,disable-id-detection: Do not perform ID detection.
> + - ti,disable-vbus-detection: Do not pwerform VBUS detection.

Fix typo.
- pwerform -> perform

>  
>  palmas-usb {
>         compatible = "ti,twl6035-usb", "ti,palmas-usb";
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index dc7ebf3..4747d11 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -122,11 +122,14 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)
>  		PALMAS_USB_ID_INT_EN_HI_SET_ID_GND |
>  		PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT);
>  
> -	palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb);
> +	if (palmas_usb->enable_vbus_detection)
> +		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);
> +	if (palmas_usb->enable_id_detection) {
> +		msleep(30);
> +		palmas_id_irq_handler(palmas_usb->id_irq, palmas_usb);
> +	}
>  }
>  
>  static int palmas_usb_probe(struct platform_device *pdev)
> @@ -144,6 +147,10 @@ static int palmas_usb_probe(struct platform_device *pdev)
>  			return -ENOMEM;
>  
>  		pdata->wakeup = of_property_read_bool(node, "ti,wakeup");
> +		pdata->disable_id_detection = of_property_read_bool(node,
> +						"ti,disable-id-detection");
> +		pdata->disable_vbus_detection = of_property_read_bool(node,
> +						"ti,disable-vbus-detection");
>  	} else if (!pdata) {
>  		return -EINVAL;
>  	}
> @@ -154,6 +161,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
>  
>  	palmas->usb = palmas_usb;
>  	palmas_usb->palmas = palmas;
> +	palmas_usb->enable_vbus_detection = !pdata->disable_vbus_detection;
> +	palmas_usb->enable_id_detection =  !pdata->disable_id_detection;
>  
>  	palmas_usb->dev	 = &pdev->dev;
>  
> @@ -180,26 +189,32 @@ static int palmas_usb_probe(struct platform_device *pdev)
>  		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 |
> -			IRQF_ONESHOT | IRQF_EARLY_RESUME,
> -			"palmas_usb_id", palmas_usb);
> -	if (status < 0) {
> -		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
> +	if (palmas_usb->enable_id_detection) {
> +		status = devm_request_threaded_irq(palmas_usb->dev,
> +				palmas_usb->id_irq,
> +				NULL, palmas_id_irq_handler,
> +				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
> +				IRQF_ONESHOT | IRQF_EARLY_RESUME,
> +				"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;
> +			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 |
> -			IRQF_ONESHOT | IRQF_EARLY_RESUME,
> -			"palmas_usb_vbus", palmas_usb);
> -	if (status < 0) {
> -		dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
> +	if (palmas_usb->enable_vbus_detection) {
> +		status = devm_request_threaded_irq(palmas_usb->dev,
> +				palmas_usb->vbus_irq, NULL,
> +				palmas_vbus_irq_handler,
> +				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
> +				IRQF_ONESHOT | IRQF_EARLY_RESUME,
> +				"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;
> +			goto fail_extcon;
> +		}
>  	}
>  
>  	palmas_enable_irq(palmas_usb);
> @@ -227,8 +242,10 @@ static int palmas_usb_suspend(struct device *dev)
>  	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
>  
>  	if (device_may_wakeup(dev)) {
> -		enable_irq_wake(palmas_usb->vbus_irq);
> -		enable_irq_wake(palmas_usb->id_irq);
> +		if (palmas_usb->enable_vbus_detection)
> +			enable_irq_wake(palmas_usb->vbus_irq);
> +		if (palmas_usb->enable_id_detection)
> +			enable_irq_wake(palmas_usb->id_irq);
>  	}
>  	return 0;
>  }
> @@ -238,8 +255,10 @@ static int palmas_usb_resume(struct device *dev)
>  	struct palmas_usb *palmas_usb = dev_get_drvdata(dev);
>  
>  	if (device_may_wakeup(dev)) {
> -		disable_irq_wake(palmas_usb->vbus_irq);
> -		disable_irq_wake(palmas_usb->id_irq);
> +		if (palmas_usb->enable_vbus_detection)
> +			disable_irq_wake(palmas_usb->vbus_irq);
> +		if (palmas_usb->enable_id_detection)
> +			disable_irq_wake(palmas_usb->id_irq);
>  	}
>  	return 0;
>  };
> diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
> index 03c22ca..d9ef94c 100644
> --- a/include/linux/mfd/palmas.h
> +++ b/include/linux/mfd/palmas.h
> @@ -204,6 +204,8 @@ struct palmas_pmic_platform_data {
>  struct palmas_usb_platform_data {
>  	/* Do we enable the wakeup comparator on probe */
>  	int wakeup;
> +	bool disable_vbus_detection;
> +	bool disable_id_detection;
>  };
>  
>  struct palmas_resource_platform_data {
> @@ -377,6 +379,8 @@ struct palmas_usb {
>  	int vbus_irq;
>  
>  	enum palmas_usb_state linkstat;
> +	bool enable_vbus_detection;
> +	bool enable_id_detection;
>  };
>  
>  #define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
> 

Should you define duplicate meaning variables in each other structure?
- disable_vbus_detection - enable_vbus_detection
- disable_id_detection - enable_id_detection

I think that it isn' efficient code. I'd like you to simplify this patch
by using only one variable instead of duplicate meaning variables.

Cheers,
Chanwoo Choi





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

* Re: [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport
  2013-07-10  6:15 ` Laxman Dewangan
                   ` (4 preceding siblings ...)
  (?)
@ 2013-07-10  6:57 ` Chanwoo Choi
  2013-07-10  7:14     ` Laxman Dewangan
  -1 siblings, 1 reply; 23+ messages in thread
From: Chanwoo Choi @ 2013-07-10  6:57 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
> This patch series does following:
> - Remove unused member from extcon palmas structure.
> - Fix to support of detecting cable properly with multiple insert/removal.
> - Add support for suspend/resume functionlaity and wakup from suspend.
> - Option to select/de-select the ID or VBUS detection.
> 
> Changes from V1:
> - Correct the display message.
> - Add ack from Graeme
> 
> Laxman Dewangan (4):
>   extcon: palmas: remove unused member from palams_usb structure
>   extcon: palmas: enable ID_GND and ID_FLOAT detection always
>   extcon: palams: add support for suspend/resume
>   extcon: palmas: Option to disable ID/VBUS detection based on platform
> 

Patch 1/2/3 is only applied on extcon-linus branch.

I replied about patch4.

Thanks,
Chanwoo Choi


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

* Re: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
  2013-07-10  6:15   ` Laxman Dewangan
  (?)
@ 2013-07-10  7:02   ` Chanwoo Choi
  2013-07-10  7:16       ` Laxman Dewangan
  -1 siblings, 1 reply; 23+ messages in thread
From: Chanwoo Choi @ 2013-07-10  7:02 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

Hi Laxman,

> @@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
>  
>  	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);
> +		dev_info(palmas_usb->dev, "HOST cable is attached\n");
>  	} 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);
> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
> +	} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) &&
> +				(!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
> +		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
> +		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
>  	}

After I modify info message when USB-HOST cable is attached or detached
as following mesesage, I applied this patch.

"HOST cable is ..." -> "USB-HOST cable is"

Thanks,
Chanwoo Choi


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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
  2013-07-10  6:55   ` Chanwoo Choi
@ 2013-07-10  7:13       ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:13 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
> Hi Laxman,
>
> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>> Should you define duplicate meaning variables in each other structure?
>> - disable_vbus_detection - enable_vbus_detection
>> - disable_id_detection - enable_id_detection
>>
>> I think that it isn' efficient code. I'd like you to simplify this patch
>> by using only one variable instead of duplicate meaning variables.

Originally this patch came form TI and not sure that they are using the 
both cable detection or only single type.
For Nvidia Tegra platform, on some design, we are using only ID 
detection and hence this option get added.

I did not like to break the TI design/code and hence added the option 
such that if there is no initialisation of this member or dts entry then 
assume it as the cable detection is enabled. Hence it need explicitly 
entry for disable the cable type detction. This is what for platform 
data structure.

On other structure, I use as other way to use in rest of code to make 
logic as

if (palmas_usb->enable_id_detction)
    xxx.

rathar than

if (!palmas_usb->disable_id_detction)
    xxx.


On rest of code, do now wan to use the pdata.


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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
@ 2013-07-10  7:13       ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:13 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
> Hi Laxman,
>
> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>> Should you define duplicate meaning variables in each other structure?
>> - disable_vbus_detection - enable_vbus_detection
>> - disable_id_detection - enable_id_detection
>>
>> I think that it isn' efficient code. I'd like you to simplify this patch
>> by using only one variable instead of duplicate meaning variables.

Originally this patch came form TI and not sure that they are using the 
both cable detection or only single type.
For Nvidia Tegra platform, on some design, we are using only ID 
detection and hence this option get added.

I did not like to break the TI design/code and hence added the option 
such that if there is no initialisation of this member or dts entry then 
assume it as the cable detection is enabled. Hence it need explicitly 
entry for disable the cable type detction. This is what for platform 
data structure.

On other structure, I use as other way to use in rest of code to make 
logic as

if (palmas_usb->enable_id_detction)
    xxx.

rathar than

if (!palmas_usb->disable_id_detction)
    xxx.


On rest of code, do now wan to use the pdata.


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

* Re: [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport
  2013-07-10  6:57 ` [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport Chanwoo Choi
@ 2013-07-10  7:14     ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:14 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:27 PM, Chanwoo Choi wrote:
> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>> This patch series does following:
>> - Remove unused member from extcon palmas structure.
>> - Fix to support of detecting cable properly with multiple insert/removal.
>> - Add support for suspend/resume functionlaity and wakup from suspend.
>> - Option to select/de-select the ID or VBUS detection.
>>
>> Changes from V1:
>> - Correct the display message.
>> - Add ack from Graeme
>>
>> Laxman Dewangan (4):
>>    extcon: palmas: remove unused member from palams_usb structure
>>    extcon: palmas: enable ID_GND and ID_FLOAT detection always
>>    extcon: palams: add support for suspend/resume
>>    extcon: palmas: Option to disable ID/VBUS detection based on platform
>>
> Patch 1/2/3 is only applied on extcon-linus branch.
>
> I replied about patch4.
>
Thank you very much for taking care.
Working on Patch4.

Thanks,
Laxman

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

* Re: [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport
@ 2013-07-10  7:14     ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:14 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:27 PM, Chanwoo Choi wrote:
> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>> This patch series does following:
>> - Remove unused member from extcon palmas structure.
>> - Fix to support of detecting cable properly with multiple insert/removal.
>> - Add support for suspend/resume functionlaity and wakup from suspend.
>> - Option to select/de-select the ID or VBUS detection.
>>
>> Changes from V1:
>> - Correct the display message.
>> - Add ack from Graeme
>>
>> Laxman Dewangan (4):
>>    extcon: palmas: remove unused member from palams_usb structure
>>    extcon: palmas: enable ID_GND and ID_FLOAT detection always
>>    extcon: palams: add support for suspend/resume
>>    extcon: palmas: Option to disable ID/VBUS detection based on platform
>>
> Patch 1/2/3 is only applied on extcon-linus branch.
>
> I replied about patch4.
>
Thank you very much for taking care.
Working on Patch4.

Thanks,
Laxman

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

* Re: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
  2013-07-10  7:02   ` Chanwoo Choi
@ 2013-07-10  7:16       ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:16 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:32 PM, Chanwoo Choi wrote:
> Hi Laxman,
>
>> @@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
>>   
>>   	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);
>> +		dev_info(palmas_usb->dev, "HOST cable is attached\n");
>>   	} 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);
>> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
>> +	} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) &&
>> +				(!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
>> +		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
>> +		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
>> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
>>   	}
> After I modify info message when USB-HOST cable is attached or detached
> as following mesesage, I applied this patch.
>
> "HOST cable is ..." -> "USB-HOST cable is"

Thank you very much for correction and more meaningful message.

Thanks,
Laxman


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

* Re: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
@ 2013-07-10  7:16       ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  7:16 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 12:32 PM, Chanwoo Choi wrote:
> Hi Laxman,
>
>> @@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
>>   
>>   	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);
>> +		dev_info(palmas_usb->dev, "HOST cable is attached\n");
>>   	} 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);
>> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
>> +	} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) &&
>> +				(!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) {
>> +		palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
>> +		extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
>> +		dev_info(palmas_usb->dev, "HOST cable is detached\n");
>>   	}
> After I modify info message when USB-HOST cable is attached or detached
> as following mesesage, I applied this patch.
>
> "HOST cable is ..." -> "USB-HOST cable is"

Thank you very much for correction and more meaningful message.

Thanks,
Laxman


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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
  2013-07-10  7:13       ` Laxman Dewangan
@ 2013-07-10  7:34         ` Chanwoo Choi
  -1 siblings, 0 replies; 23+ messages in thread
From: Chanwoo Choi @ 2013-07-10  7:34 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On 07/10/2013 04:13 PM, Laxman Dewangan wrote:
> On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
>> Hi Laxman,
>>
>> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>>> Should you define duplicate meaning variables in each other structure?
>>> - disable_vbus_detection - enable_vbus_detection
>>> - disable_id_detection - enable_id_detection
>>>
>>> I think that it isn' efficient code. I'd like you to simplify this patch
>>> by using only one variable instead of duplicate meaning variables.
> 
> Originally this patch came form TI and not sure that they are using the both cable detection or only single type.
> For Nvidia Tegra platform, on some design, we are using only ID detection and hence this option get added.
> 

I agree that user can determine whether specific irq is used or not according to dt data.


> I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.
> 
> On other structure, I use as other way to use in rest of code to make logic as
> 
> if (palmas_usb->enable_id_detction)
>    xxx.
> 
> rathar than
> 
> if (!palmas_usb->disable_id_detction)
>    xxx.
> 
> 
> On rest of code, do now wan to use the pdata.

This patch store same meaning to two different variables which are included in different structure.
If we try to change the state of vbus/id detection on runtime, we have to modify two variables.
I think it isn't right.

struct palmas_platform_data {
	....
	bool disable_vbus_detection;
	bool disable_id_detection;
};

struct palmas_usb {
	...
	bool enable_vbus_detection;
	bool enable_id_detection;
};

You could only use the variables in struct palmas_usb without variables in struct palmas_platform_data
because extcon-palmas driver store only the pointer of 'struct palmas_usb' to dev->p->driver_data
by using platform_set_drvdata().

It is meaning to use 'struct palmas_usb' on other function except for palmas_usb_probe() in extcon-palmas.c.


if (node && !pdata) {
	...
	palmas_usb->wakeup = of_property_red_bool(node, "ti,wakeup);
	palmas_usb->enable_vbus_detection = of_property_red_bool(node, "ti,enable_vbus_detection);
	palmas_usb->enable_id_detection = of_property_red_bool(node, "ti,enable_id_detection);
} else (!pdata) {
	palmas_usb->wakeup = true;
	palmas_usb->enable_vbus_detection = true;
	palmas_usb->enable_id_detection = true;
}








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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
@ 2013-07-10  7:34         ` Chanwoo Choi
  0 siblings, 0 replies; 23+ messages in thread
From: Chanwoo Choi @ 2013-07-10  7:34 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On 07/10/2013 04:13 PM, Laxman Dewangan wrote:
> On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
>> Hi Laxman,
>>
>> On 07/10/2013 03:15 PM, Laxman Dewangan wrote:
>>> Should you define duplicate meaning variables in each other structure?
>>> - disable_vbus_detection - enable_vbus_detection
>>> - disable_id_detection - enable_id_detection
>>>
>>> I think that it isn' efficient code. I'd like you to simplify this patch
>>> by using only one variable instead of duplicate meaning variables.
> 
> Originally this patch came form TI and not sure that they are using the both cable detection or only single type.
> For Nvidia Tegra platform, on some design, we are using only ID detection and hence this option get added.
> 

I agree that user can determine whether specific irq is used or not according to dt data.


> I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.
> 
> On other structure, I use as other way to use in rest of code to make logic as
> 
> if (palmas_usb->enable_id_detction)
>    xxx.
> 
> rathar than
> 
> if (!palmas_usb->disable_id_detction)
>    xxx.
> 
> 
> On rest of code, do now wan to use the pdata.

This patch store same meaning to two different variables which are included in different structure.
If we try to change the state of vbus/id detection on runtime, we have to modify two variables.
I think it isn't right.

struct palmas_platform_data {
	....
	bool disable_vbus_detection;
	bool disable_id_detection;
};

struct palmas_usb {
	...
	bool enable_vbus_detection;
	bool enable_id_detection;
};

You could only use the variables in struct palmas_usb without variables in struct palmas_platform_data
because extcon-palmas driver store only the pointer of 'struct palmas_usb' to dev->p->driver_data
by using platform_set_drvdata().

It is meaning to use 'struct palmas_usb' on other function except for palmas_usb_probe() in extcon-palmas.c.


if (node && !pdata) {
	...
	palmas_usb->wakeup = of_property_red_bool(node, "ti,wakeup);
	palmas_usb->enable_vbus_detection = of_property_red_bool(node, "ti,enable_vbus_detection);
	palmas_usb->enable_id_detection = of_property_red_bool(node, "ti,enable_id_detection);
} else (!pdata) {
	palmas_usb->wakeup = true;
	palmas_usb->enable_vbus_detection = true;
	palmas_usb->enable_id_detection = true;
}








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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
  2013-07-10  7:34         ` Chanwoo Choi
@ 2013-07-10  8:42           ` Laxman Dewangan
  -1 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  8:42 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 01:04 PM, Chanwoo Choi wrote:
> On 07/10/2013 04:13 PM, Laxman Dewangan wrote:
>> On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
>> I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.
>>
>> On other structure, I use as other way to use in rest of code to make logic as
>>
>> if (palmas_usb->enable_id_detction)
>>     xxx.
>>
>> rathar than
>>
>> if (!palmas_usb->disable_id_detction)
>>     xxx.
>>
>>
>> On rest of code, do now wan to use the pdata.
> This patch store same meaning to two different variables which are included in different structure.
> If we try to change the state of vbus/id detection on runtime, we have to modify two variables.
> I think it isn't right.
>
> struct palmas_platform_data {
> 	....
> 	bool disable_vbus_detection;
> 	bool disable_id_detection;
> };
>
> struct palmas_usb {
> 	...
> 	bool enable_vbus_detection;
> 	bool enable_id_detection;
> };
>
> You could only use the variables in struct palmas_usb without variables in struct palmas_platform_data
> because extcon-palmas driver store only the pointer of 'struct palmas_usb' to dev->p->driver_data
> by using platform_set_drvdata().
>
> It is meaning to use 'struct palmas_usb' on other function except for palmas_usb_probe() in extcon-palmas.c.
>
>
> if (node && !pdata) {
> 	...
> 	palmas_usb->wakeup = of_property_red_bool(node, "ti,wakeup);
> 	palmas_usb->enable_vbus_detection = of_property_red_bool(node, "ti,enable_vbus_detection);
> 	palmas_usb->enable_id_detection = of_property_red_bool(node, "ti,enable_id_detection);
> } else (!pdata) {
> 	palmas_usb->wakeup = true;
> 	palmas_usb->enable_vbus_detection = true;
> 	palmas_usb->enable_id_detection = true;
> }
>

Thanks for detail explanation.

I agree with you on this code. This code support the option if driver is 
invoked from DT and assume true always if it is from board file.

As all Tegra platforms have been moved to the DTS, I do not see any 
issue on this change.

I will post  the new version of this change (patch 4/4) as all others 
are already merged.


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

* Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
@ 2013-07-10  8:42           ` Laxman Dewangan
  0 siblings, 0 replies; 23+ messages in thread
From: Laxman Dewangan @ 2013-07-10  8:42 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, devicetree-discuss, rob, linux-doc, linux-kernel,
	kishon, gg

On Wednesday 10 July 2013 01:04 PM, Chanwoo Choi wrote:
> On 07/10/2013 04:13 PM, Laxman Dewangan wrote:
>> On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
>> I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.
>>
>> On other structure, I use as other way to use in rest of code to make logic as
>>
>> if (palmas_usb->enable_id_detction)
>>     xxx.
>>
>> rathar than
>>
>> if (!palmas_usb->disable_id_detction)
>>     xxx.
>>
>>
>> On rest of code, do now wan to use the pdata.
> This patch store same meaning to two different variables which are included in different structure.
> If we try to change the state of vbus/id detection on runtime, we have to modify two variables.
> I think it isn't right.
>
> struct palmas_platform_data {
> 	....
> 	bool disable_vbus_detection;
> 	bool disable_id_detection;
> };
>
> struct palmas_usb {
> 	...
> 	bool enable_vbus_detection;
> 	bool enable_id_detection;
> };
>
> You could only use the variables in struct palmas_usb without variables in struct palmas_platform_data
> because extcon-palmas driver store only the pointer of 'struct palmas_usb' to dev->p->driver_data
> by using platform_set_drvdata().
>
> It is meaning to use 'struct palmas_usb' on other function except for palmas_usb_probe() in extcon-palmas.c.
>
>
> if (node && !pdata) {
> 	...
> 	palmas_usb->wakeup = of_property_red_bool(node, "ti,wakeup);
> 	palmas_usb->enable_vbus_detection = of_property_red_bool(node, "ti,enable_vbus_detection);
> 	palmas_usb->enable_id_detection = of_property_red_bool(node, "ti,enable_id_detection);
> } else (!pdata) {
> 	palmas_usb->wakeup = true;
> 	palmas_usb->enable_vbus_detection = true;
> 	palmas_usb->enable_id_detection = true;
> }
>

Thanks for detail explanation.

I agree with you on this code. This code support the option if driver is 
invoked from DT and assume true always if it is from board file.

As all Tegra platforms have been moved to the DTS, I do not see any 
issue on this change.

I will post  the new version of this change (patch 4/4) as all others 
are already merged.

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

end of thread, other threads:[~2013-07-10  8:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-10  6:15 [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport Laxman Dewangan
2013-07-10  6:15 ` Laxman Dewangan
2013-07-10  6:15 ` [PATCH V2 1/4] extcon: palmas: remove unused member from palams_usb structure Laxman Dewangan
2013-07-10  6:15   ` Laxman Dewangan
2013-07-10  6:15 ` [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always Laxman Dewangan
2013-07-10  6:15   ` Laxman Dewangan
2013-07-10  7:02   ` Chanwoo Choi
2013-07-10  7:16     ` Laxman Dewangan
2013-07-10  7:16       ` Laxman Dewangan
2013-07-10  6:15 ` [PATCH V2 3/4] extcon: palams: add support for suspend/resume Laxman Dewangan
2013-07-10  6:15   ` Laxman Dewangan
2013-07-10  6:15 ` [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform Laxman Dewangan
2013-07-10  6:15   ` Laxman Dewangan
2013-07-10  6:55   ` Chanwoo Choi
2013-07-10  7:13     ` Laxman Dewangan
2013-07-10  7:13       ` Laxman Dewangan
2013-07-10  7:34       ` Chanwoo Choi
2013-07-10  7:34         ` Chanwoo Choi
2013-07-10  8:42         ` Laxman Dewangan
2013-07-10  8:42           ` Laxman Dewangan
2013-07-10  6:57 ` [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport Chanwoo Choi
2013-07-10  7:14   ` Laxman Dewangan
2013-07-10  7:14     ` Laxman Dewangan

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.