Re: [PATCH v6] usb: dwc3: use extcon fwrk to receive connect/disconnect

2013-07-15 Thread Chanwoo Choi
On 07/16/2013 12:51 AM, Felipe Balbi wrote:
 On Mon, Jul 15, 2013 at 09:09:02PM +0530, 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 kis...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 This patch should be applied after all of the extcon patchset will be applied
 because this patch has dependency of extcon patch related to DT.
 http://goo.gl/Tu3qW

 Changes from v5:
 * rebased to 3.11-rc1
 Changes from v4:
 * checked the return values of extcon_register_interest and print an error
 message. Note that I dint do return since there might be cases where
 one of USB (device mode) or USB-HOST (host mode) might succeed.
 * Added depends on of EXTCON in usb_dwc3. Only some platforms might
 be using EXTCON, but inorder to avoid compilation errors, added
 depends on
 Changes from v3:
 * did #include of of_extcon.h after Chanwoo resent the patch separating
 extcon-class.c from of_extcon.c
 Changes from v2:
 * updated the Documentation with dwc3 dt binding information.
 * used of_extcon_get_extcon_dev to get extcon device from device tree data.
 Changes from v1:
 * regulator enable/disable is now done here instead of palmas-usb as some 
 users
 of palmas-usb wont need regulator.
  Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/dwc3-omap.c   |  125 
 +---
  3 files changed, 112 insertions(+), 19 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
 b/Documentation/devicetree/bindings/usb/omap-usb.txt
 index 57e71f6..9088ab0 100644
 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
 +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
 @@ -53,6 +53,11 @@ OMAP DWC3 GLUE
 It should be set to 1 for HW mode and 2 for SW mode.
   - ranges: the child address space are mapped 1:1 onto the parent address 
 space
  
 +Optional Properties:
 + - extcon : phandle for the extcon device omap dwc3 uses to detect
 +   connect/disconnect events.
 + - vbus-supply : phandle to the regulator device tree node if needed.
 +
  Sub-nodes:
  The dwc3 core should be added as subnode to omap dwc3 glue.
  - dwc3 :
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index 757aa18..08a9fab 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -1,6 +1,7 @@
  config USB_DWC3
  tristate DesignWare USB3 DRD Core Support
  depends on (USB || USB_GADGET)  GENERIC_HARDIRQS
 +depends on EXTCON
 
 can you rebase this on top of 'testing' branch. I have a patch there
 which give glue layers their own Kconfig symbols. If you do that, I can
 queue this patch myself for v3.12, unless we have dependencies on other
 patches which aren't in mainline, in which case, I'd ask to simply
 remove this Kconfig change for now.
 

Dear Felipe and Kishon,

We have some confusion about applying this patch.

I already applied this patch on extcon-next branch for v3.12. This patch has 
the dependency on below extcon patch.
[PATCH] usb: dwc3: use extcon fwrk to receive connect/disconnect
- 
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=68517aac722c8c3e0c153b3ede40aace25cb66fa
[PATCH] extcon: Add an API to get extcon device from dt node
- 
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=cb28faede03de7abe82336c3648771a01f5fe225

If Felipe would apply this patch usb.git for v3.12, I think you should include 
extcon patch together.
[PATCH] extcon: Add an API to get extcon device from dt node
- 
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/commit/?h=extcon-nextid=cb28faede03de7abe82336c3648771a01f5fe225

The dependency related to patch cause this confusion.
What is your opinion?

Thanks,
Chanwoo Choi

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform

2013-07-10 Thread Chanwoo Choi
 |
 + 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




___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport

2013-07-10 Thread Chanwoo Choi
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

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always

2013-07-10 Thread Chanwoo Choi
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

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform

2013-07-10 Thread Chanwoo Choi
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;
}







___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V3] extcon: palmas: Option to disable ID/VBUS detection based on platform

2013-07-10 Thread Chanwoo Choi
Hi Laxman,

  static int palmas_usb_probe(struct platform_device *pdev)
 @@ -137,20 +140,26 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
   struct palmas_usb *palmas_usb;
   int status;
  
 - if (node  !pdata) {
 - pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL);
 -
 - if (!pdata)
 - return -ENOMEM;
 + palmas_usb = devm_kzalloc(pdev-dev, sizeof(*palmas_usb), GFP_KERNEL);
 + if (!palmas_usb)
 + return -ENOMEM;
  
 - pdata-wakeup = of_property_read_bool(node, ti,wakeup);
 + if (node  !pdata) {
 + palmas_usb-wakeup = of_property_read_bool(node, ti,wakeup);
 + palmas_usb-enable_id_detection = of_property_read_bool(node,
 + ti,enable-id-detection);
 + palmas_usb-enable_vbus_detection = of_property_read_bool(node,
 + ti,enable-vbus-detection);
 + } else if (pdata) {
 + palmas_usb-wakeup = pdata-wakeup;
 + palmas_usb-enable_id_detection = true;
 + palmas_usb-enable_vbus_detection = true;
   } else if (!pdata) {
 - return -EINVAL;
 + palmas_usb-wakeup = true;
 + palmas_usb-enable_id_detection = true;
 + palmas_usb-enable_vbus_detection = true;
   }

I think we could modify it as following patch to remove duplicate line.
If you agree about below modification, I will apply your patch with following 
patch.

index 5c218d2..56909cc 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -150,16 +150,14 @@ static int palmas_usb_probe(struct platform_device *pdev)
ti,enable-id-detection);
palmas_usb-enable_vbus_detection = of_property_read_bool(node,
ti,enable-vbus-detection);
-   } else if (pdata) {
-   palmas_usb-wakeup = pdata-wakeup;
-   palmas_usb-enable_id_detection = true;
-   palmas_usb-enable_vbus_detection = true;
-   } else if (!pdata) {
+   } else {
palmas_usb-wakeup = true;
palmas_usb-enable_id_detection = true;
palmas_usb-enable_vbus_detection = true;
-   }
 
+   if (pdata)
+   palmas_usb-wakeup = pdata-wakeup;
+   }
 
palmas-usb = palmas_usb;
palmas_usb-palmas = palmas;


Thanks,
Chanwoo Choi


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH V3] extcon: palmas: Option to disable ID/VBUS detection based on platform

2013-07-10 Thread Chanwoo Choi
On 07/11/2013 12:08 PM, Laxman Dewangan wrote:
 On Thursday 11 July 2013 08:12 AM, Chanwoo Choi wrote:
 Hi Laxman,

   static int palmas_usb_probe(struct platform_device *pdev)
 @@ -137,20 +140,26 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
   struct palmas_usb *palmas_usb;
   int status;
   -if (node  !pdata) {
 -pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL);
 -
 -if (!pdata)
 -return -ENOMEM;
 +palmas_usb = devm_kzalloc(pdev-dev, sizeof(*palmas_usb), GFP_KERNEL);
 +if (!palmas_usb)
 +return -ENOMEM;
   -pdata-wakeup = of_property_read_bool(node, ti,wakeup);
 +if (node  !pdata) {
 +palmas_usb-wakeup = of_property_read_bool(node, ti,wakeup);
 +palmas_usb-enable_id_detection = of_property_read_bool(node,
 +ti,enable-id-detection);
 +palmas_usb-enable_vbus_detection = of_property_read_bool(node,
 +ti,enable-vbus-detection);
 +} else if (pdata) {
 +palmas_usb-wakeup = pdata-wakeup;
 +palmas_usb-enable_id_detection = true;
 +palmas_usb-enable_vbus_detection = true;
   } else if (!pdata) {
 -return -EINVAL;
 +palmas_usb-wakeup = true;
 +palmas_usb-enable_id_detection = true;
 +palmas_usb-enable_vbus_detection = true;
   }
 I think we could modify it as following patch to remove duplicate line.
 If you agree about below modification, I will apply your patch with 
 following patch.

 I am fine with this and this looks simple and straight.
 
 I have seen some patches/discussion from TI to remove the platform data 
 support at all and hence removing from here in future will be very simple.
 

This patch is applied on extcon-linus branch.

Thanks,
Chanwoo Choi

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always

2013-07-09 Thread Chanwoo Choi
Hi Laxman,

On 07/09/2013 10:04 PM, Laxman Dewangan wrote:
 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 ldewan...@nvidia.com
 ---
  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..587034b 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 state: TRUE\n);

I prfer following info message when USB cable is inserted.
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 state: FALSE\n);

ditto.
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 state: TRUE\n);

ditto.
dev_info(palmas_usb-dev, USB-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 state: FALSE\n);

ditto.
dev_info(palmas_usb-dev, USB-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 state: FALSE\n);

dev_info(palmas_usb-dev, USB-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);
  
 

I you would modify info message, anything else is good.

Thanks,
Chanwoo Choi
___
devicetree-discuss mailing

Re: [PATCH 1/2] extcon: palmas: rename device tree binding matching with file name

2013-07-07 Thread Chanwoo Choi
On 07/05/2013 10:59 PM, Laxman Dewangan wrote:
 The driver name is extcon/extcon-palmas.c and hence renaming the
 device tree binding document to extcon-palmas.txt.
 
 Signed-off-by: Laxman Dewangan ldewan...@nvidia.com
 ---
  .../extcon/{extcon-twl.txt = extcon-palmas.txt}   |0
  1 files changed, 0 insertions(+), 0 deletions(-)
  rename Documentation/devicetree/bindings/extcon/{extcon-twl.txt = 
 extcon-palmas.txt} (100%)
 
 diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 similarity index 100%
 rename from Documentation/devicetree/bindings/extcon/extcon-twl.txt
 rename to Documentation/devicetree/bindings/extcon/extcon-palmas.txt
 

Applied patch1 and patch2.

You can check it on following git repo:
- git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git (extcon-linus)

Thanks,
Chanwoo Choi
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v5] usb: dwc3: use extcon fwrk to receive connect/disconnect

2013-06-24 Thread Chanwoo Choi
On 06/21/2013 08:58 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 kis...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 This patch should be applied after all of the extcon patchset will be applied
 because this patch has dependency of extcon patch related to DT.
 http://goo.gl/Tu3qW
 
 Changes from v4:
 * checked the return values of extcon_register_interest and print an error
 message. Note that I dint do return since there might be cases where
 one of USB (device mode) or USB-HOST (host mode) might succeed.
 * Added depends on of EXTCON in usb_dwc3. Only some platforms might
 be using EXTCON, but inorder to avoid compilation errors, added
 depends on
 Changes from v3:
 * did #include of of_extcon.h after Chanwoo resent the patch separating
 extcon-class.c from of_extcon.c
 Changes from v2:
 * updated the Documentation with dwc3 dt binding information.
 * used of_extcon_get_extcon_dev to get extcon device from device tree data.
 Changes from v1:
 * regulator enable/disable is now done here instead of palmas-usb as some 
 users
 of palmas-usb wont need regulator.
 
  Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/dwc3-omap.c   |  125 
 +---
  include/linux/usb/dwc3-omap.h  |   30 -
  4 files changed, 112 insertions(+), 49 deletions(-)
  delete mode 100644 include/linux/usb/dwc3-omap.h
 
 diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
 b/Documentation/devicetree/bindings/usb/omap-usb.txt
 index d4769f3..f1c15f3 100644
 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
 +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
 @@ -53,6 +53,11 @@ OMAP DWC3 GLUE
 It should be set to 1 for HW mode and 2 for SW mode.
   - ranges: the child address space are mapped 1:1 onto the parent address 
 space
  
 +Optional Properties:
 + - extcon : phandle for the extcon device omap dwc3 uses to detect
 +   connect/disconnect events.
 + - vbus-supply : phandle to the regulator device tree node if needed.
 +
  Sub-nodes:
  The dwc3 core should be added as subnode to omap dwc3 glue.
  - dwc3 :
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index 757aa18..08a9fab 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -1,6 +1,7 @@
  config USB_DWC3
   tristate DesignWare USB3 DRD Core Support
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS
 + depends on EXTCON
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
 index f8f76e6..80b5780 100644
 --- a/drivers/usb/dwc3/dwc3-omap.c
 +++ b/drivers/usb/dwc3/dwc3-omap.c
 @@ -43,13 +43,15 @@
  #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/extcon/of_extcon.h
 +#include linux/regulator/consumer.h
  
  #include linux/usb/otg.h
  
 @@ -124,9 +126,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 +152,23 @@ 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);
  
 + if (omap-vbus_reg) {
 + ret = regulator_enable(omap-vbus_reg);
 + if (ret) {
 + dev_dbg(omap-dev, regulator enable

[PATCH v3] extcon: Add an API to get extcon device from dt node

2013-06-18 Thread Chanwoo Choi
From: Kishon Vijay Abraham I kis...@ti.com

Added an API of_extcon_get_extcon_dev() to be used by drivers to get
extcon device in the case of dt boot (this can be used instead of
extcon_get_extcon_dev()).

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Myungjoo Ham myungjoo@samsung.com
---
Changes since v2:
- Add CONFIG_OF_EXTCON to Kconfig
- Use IS_ENABLED() macro to check both CONFIG_EXTCON and CONFIG_EXTCON_MODULE

Changes since v1:
- If edev-name is NULL, dev_name(dev) is used as edev-name.
- Change filename from of-extcon.* to of_extcon.*
- Fix build error when CONFIG_OF is not set
- Add header file(linux/err.h) to of_extcon.c

 drivers/extcon/Kconfig   |  4 +++
 drivers/extcon/Makefile  |  2 ++
 drivers/extcon/extcon-class.c|  3 +-
 drivers/extcon/of_extcon.c   | 64 
 include/linux/extcon/of_extcon.h | 31 +++
 5 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 drivers/extcon/of_extcon.c
 create mode 100644 include/linux/extcon/of_extcon.h

diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 63f454e..f1d54a3 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -14,6 +14,10 @@ if EXTCON
 
 comment Extcon Device Drivers
 
+config OF_EXTCON
+   def_tristate y
+   depends on OF
+
 config EXTCON_GPIO
tristate GPIO extcon support
depends on GPIOLIB
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index 540e2c3..759fdae 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -2,6 +2,8 @@
 # Makefile for external connector class (extcon) devices
 #
 
+obj-$(CONFIG_OF_EXTCON)+= of_extcon.o
+
 obj-$(CONFIG_EXTCON)   += extcon-class.o
 obj-$(CONFIG_EXTCON_GPIO)  += extcon-gpio.o
 obj-$(CONFIG_EXTCON_ADC_JACK)  += extcon-adc-jack.o
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 23f11ea..08509ea 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -602,7 +602,8 @@ int extcon_dev_register(struct extcon_dev *edev, struct 
device *dev)
edev-dev-class = extcon_class;
edev-dev-release = extcon_dev_release;
 
-   dev_set_name(edev-dev, edev-name ? edev-name : dev_name(dev));
+   edev-name = edev-name ? edev-name : dev_name(dev);
+   dev_set_name(edev-dev, edev-name);
 
if (edev-max_supported) {
char buf[10];
diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
new file mode 100644
index 000..72173ec
--- /dev/null
+++ b/drivers/extcon/of_extcon.c
@@ -0,0 +1,64 @@
+/*
+ * OF helpers for External connector (extcon) framework
+ *
+ * Copyright (C) 2013 Texas Instruments, Inc.
+ * Kishon Vijay Abraham I kis...@ti.com
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.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.
+ */
+
+#include linux/module.h
+#include linux/slab.h
+#include linux/err.h
+#include linux/extcon.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/extcon/of_extcon.h
+
+/*
+ * of_extcon_get_extcon_dev - Get the name of extcon device from devicetree
+ * @dev - instance to the given device
+ * @index - index into list of extcon_dev
+ *
+ * return the instance of extcon device
+ */
+struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
+{
+   struct device_node *node;
+   struct extcon_dev *edev;
+   struct platform_device *extcon_parent_dev;
+
+   if (!dev-of_node) {
+   dev_dbg(dev, device does not have a device node entry\n);
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev-of_node, extcon, index);
+   if (!node) {
+   dev_dbg(dev, failed to get phandle in %s node\n,
+   dev-of_node-full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   extcon_parent_dev = of_find_device_by_node(node);
+   if (!extcon_parent_dev) {
+   dev_dbg(dev, unable to find device by node\n);
+   return ERR_PTR(-EPROBE_DEFER);
+   }
+
+   edev = extcon_get_extcon_dev(dev_name(extcon_parent_dev-dev));
+   if (!edev) {
+   dev_dbg(dev, unable to get extcon device : %s\n,
+   dev_name(extcon_parent_dev-dev));
+   return ERR_PTR(-ENODEV);
+   }
+
+   return edev;
+}
+EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
diff --git a/include/linux/extcon/of_extcon.h b/include/linux/extcon/of_extcon.h
new file mode 100644
index 000..0ebfeff
--- /dev/null
+++ b/include/linux/extcon/of_extcon.h
@@ -0,0 +1,31 @@
+/*
+ * OF helpers for External

Re: [PATCH v4] usb: dwc3: use extcon fwrk to receive connect/disconnect

2013-06-16 Thread Chanwoo Choi
-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 = NULL;
  
   int ret = -ENOMEM;
   int irq;
 @@ -330,19 +377,22 @@ static int dwc3_omap_probe(struct platform_device *pdev)
   return -ENOMEM;
   }
  
 + if (of_property_read_bool(node, vbus-supply)) {
 + vbus_reg = devm_regulator_get(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;
   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) {
 @@ -381,14 +431,41 @@ static int dwc3_omap_probe(struct platform_device *pdev)
  
   dwc3_omap_enable_irqs(omap);
  
 + if (of_property_read_bool(node, extcon)) {
 + edev = of_extcon_get_extcon_dev(dev, 0);
 + if (IS_ERR(edev)) {
 + dev_vdbg(dev, couldn't get extcon device\n);
 + ret = PTR_ERR(edev);
 + goto err2;
 + }
 +
 + omap-vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
 + extcon_register_interest(omap-extcon_vbus_dev, edev-name,
 +  USB, omap-vbus_nb);
 + omap-id_nb.notifier_call = dwc3_omap_id_notifier;
 + extcon_register_interest(omap-extcon_id_dev, edev-name,
 +  USB-HOST, omap-id_nb);

I prefer adding exception handling code about return value of 
extcon_register_interest().

 +
 + 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);
 + }
 +
   ret = of_platform_populate(node, NULL, NULL, dev);
   if (ret) {
   dev_err(pdev-dev, failed to create dwc3 core\n);
 - goto err2;
 + goto err3;
   }
  
   return 0;
  
 +err3:
 + if (omap-extcon_vbus_dev.edev)
 + extcon_unregister_interest(omap-extcon_vbus_dev);
 + if (omap-extcon_id_dev.edev)
 + extcon_unregister_interest(omap-extcon_id_dev);
 +
  err2:
   dwc3_omap_disable_irqs(omap);
  
 @@ -405,6 +482,10 @@ static int dwc3_omap_remove(struct platform_device *pdev)
  {
   struct dwc3_omap*omap = platform_get_drvdata(pdev);
  
 + if (omap-extcon_vbus_dev.edev)
 + extcon_unregister_interest(omap-extcon_vbus_dev);
 + if (omap-extcon_id_dev.edev)
 + 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..000
 

It looks good if you add exception handler about return value of 
extcon_register_interest().

Acked-by: Chanwoo Choi cw00.c...@samsung.com

But, we have to apply this patch after all of the extcon patchset(for 3.11) 
will be applied
because this patch has dependency of extcon patch

[PATCH v2] extcon: Add an API to get extcon device from dt node

2013-06-14 Thread Chanwoo Choi
From: Kishon Vijay Abraham I kis...@ti.com

Added an API of_extcon_get_extcon_dev() to be used by drivers to get
extcon device in the case of dt boot (this can be used instead of
extcon_get_extcon_dev()).

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Myungjoo Ham myungjoo@samsung.com
---
Changes since v1:
- If edev-name is NULL, dev_name(dev) is used as edev-name.
- Change filename from of-extcon.* to of_extcon.*
- Fix build error when CONFIG_OF is not set
- Add header file(linux/err.h) to of_extcon.c

 drivers/extcon/Makefile  |  2 ++
 drivers/extcon/extcon-class.c|  3 +-
 drivers/extcon/of_extcon.c   | 64 
 include/linux/extcon/of_extcon.h | 30 +++
 4 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 drivers/extcon/of_extcon.c
 create mode 100644 include/linux/extcon/of_extcon.h

diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index 540e2c3..83468f7 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -2,6 +2,8 @@
 # Makefile for external connector class (extcon) devices
 #
 
+obj-$(CONFIG_OF)   += of_extcon.o
+
 obj-$(CONFIG_EXTCON)   += extcon-class.o
 obj-$(CONFIG_EXTCON_GPIO)  += extcon-gpio.o
 obj-$(CONFIG_EXTCON_ADC_JACK)  += extcon-adc-jack.o
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 23f11ea..08509ea 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -602,7 +602,8 @@ int extcon_dev_register(struct extcon_dev *edev, struct 
device *dev)
edev-dev-class = extcon_class;
edev-dev-release = extcon_dev_release;
 
-   dev_set_name(edev-dev, edev-name ? edev-name : dev_name(dev));
+   edev-name = edev-name ? edev-name : dev_name(dev);
+   dev_set_name(edev-dev, edev-name);
 
if (edev-max_supported) {
char buf[10];
diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
new file mode 100644
index 000..72173ec
--- /dev/null
+++ b/drivers/extcon/of_extcon.c
@@ -0,0 +1,64 @@
+/*
+ * OF helpers for External connector (extcon) framework
+ *
+ * Copyright (C) 2013 Texas Instruments, Inc.
+ * Kishon Vijay Abraham I kis...@ti.com
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.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.
+ */
+
+#include linux/module.h
+#include linux/slab.h
+#include linux/err.h
+#include linux/extcon.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/extcon/of_extcon.h
+
+/*
+ * of_extcon_get_extcon_dev - Get the name of extcon device from devicetree
+ * @dev - instance to the given device
+ * @index - index into list of extcon_dev
+ *
+ * return the instance of extcon device
+ */
+struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
+{
+   struct device_node *node;
+   struct extcon_dev *edev;
+   struct platform_device *extcon_parent_dev;
+
+   if (!dev-of_node) {
+   dev_dbg(dev, device does not have a device node entry\n);
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev-of_node, extcon, index);
+   if (!node) {
+   dev_dbg(dev, failed to get phandle in %s node\n,
+   dev-of_node-full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   extcon_parent_dev = of_find_device_by_node(node);
+   if (!extcon_parent_dev) {
+   dev_dbg(dev, unable to find device by node\n);
+   return ERR_PTR(-EPROBE_DEFER);
+   }
+
+   edev = extcon_get_extcon_dev(dev_name(extcon_parent_dev-dev));
+   if (!edev) {
+   dev_dbg(dev, unable to get extcon device : %s\n,
+   dev_name(extcon_parent_dev-dev));
+   return ERR_PTR(-ENODEV);
+   }
+
+   return edev;
+}
+EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
diff --git a/include/linux/extcon/of_extcon.h b/include/linux/extcon/of_extcon.h
new file mode 100644
index 000..462f071
--- /dev/null
+++ b/include/linux/extcon/of_extcon.h
@@ -0,0 +1,30 @@
+/*
+ * OF helpers for External connector (extcon) framework
+ *
+ * Copyright (C) 2013 Texas Instruments, Inc.
+ * Kishon Vijay Abraham I kis...@ti.com
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.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.
+ */
+
+#ifndef __LINUX_OF_EXTCON_H
+#define __LINUX_OF_EXTCON_H

Re: [PATCH v2] extcon: Add an API to get extcon device from dt node

2013-06-14 Thread Chanwoo Choi
On 06/14/2013 05:36 PM, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Friday 14 June 2013 12:45 PM, Chanwoo Choi wrote:
 From: Kishon Vijay Abraham I kis...@ti.com

 Added an API of_extcon_get_extcon_dev() to be used by drivers to get
 extcon device in the case of dt boot (this can be used instead of
 extcon_get_extcon_dev()).

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 Signed-off-by: Myungjoo Ham myungjoo@samsung.com
 ---
 Changes since v1:
 - If edev-name is NULL, dev_name(dev) is used as edev-name.
 - Change filename from of-extcon.* to of_extcon.*
 - Fix build error when CONFIG_OF is not set
 - Add header file(linux/err.h) to of_extcon.c

   drivers/extcon/Makefile  |  2 ++
   drivers/extcon/extcon-class.c|  3 +-
   drivers/extcon/of_extcon.c   | 64 
 
   include/linux/extcon/of_extcon.h | 30 +++
   4 files changed, 98 insertions(+), 1 deletion(-)
   create mode 100644 drivers/extcon/of_extcon.c
   create mode 100644 include/linux/extcon/of_extcon.h

 diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
 index 540e2c3..83468f7 100644
 --- a/drivers/extcon/Makefile
 +++ b/drivers/extcon/Makefile
 @@ -2,6 +2,8 @@
   # Makefile for external connector class (extcon) devices
   #

 +obj-$(CONFIG_OF)+= of_extcon.o
 +
   obj-$(CONFIG_EXTCON)+= extcon-class.o
   obj-$(CONFIG_EXTCON_GPIO)+= extcon-gpio.o
   obj-$(CONFIG_EXTCON_ADC_JACK)+= extcon-adc-jack.o
 diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
 index 23f11ea..08509ea 100644
 --- a/drivers/extcon/extcon-class.c
 +++ b/drivers/extcon/extcon-class.c
 @@ -602,7 +602,8 @@ int extcon_dev_register(struct extcon_dev *edev, struct 
 device *dev)
   edev-dev-class = extcon_class;
   edev-dev-release = extcon_dev_release;

 -dev_set_name(edev-dev, edev-name ? edev-name : dev_name(dev));
 +edev-name = edev-name ? edev-name : dev_name(dev);
 +dev_set_name(edev-dev, edev-name);

   if (edev-max_supported) {
   char buf[10];
 diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
 new file mode 100644
 index 000..72173ec
 --- /dev/null
 +++ b/drivers/extcon/of_extcon.c
 @@ -0,0 +1,64 @@
 +/*
 + * OF helpers for External connector (extcon) framework
 + *
 + * Copyright (C) 2013 Texas Instruments, Inc.
 + * Kishon Vijay Abraham I kis...@ti.com
 + *
 + * Copyright (C) 2013 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.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.
 + */
 +
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/err.h
 +#include linux/extcon.h
 +#include linux/of.h
 +#include linux/of_platform.h
 +#include linux/extcon/of_extcon.h
 +
 +/*
 + * of_extcon_get_extcon_dev - Get the name of extcon device from devicetree
 + * @dev - instance to the given device
 + * @index - index into list of extcon_dev
 + *
 + * return the instance of extcon device
 + */
 +struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
 +{
 +struct device_node *node;
 +struct extcon_dev *edev;
 +struct platform_device *extcon_parent_dev;
 +
 +if (!dev-of_node) {
 +dev_dbg(dev, device does not have a device node entry\n);
 +return ERR_PTR(-EINVAL);
 +}
 +
 +node = of_parse_phandle(dev-of_node, extcon, index);
 +if (!node) {
 +dev_dbg(dev, failed to get phandle in %s node\n,
 +dev-of_node-full_name);
 +return ERR_PTR(-ENODEV);
 +}
 +
 +extcon_parent_dev = of_find_device_by_node(node);
 +if (!extcon_parent_dev) {
 +dev_dbg(dev, unable to find device by node\n);
 +return ERR_PTR(-EPROBE_DEFER);
 +}
 +
 +edev = extcon_get_extcon_dev(dev_name(extcon_parent_dev-dev));
 +if (!edev) {
 +dev_dbg(dev, unable to get extcon device : %s\n,
 +dev_name(extcon_parent_dev-dev));
 +return ERR_PTR(-ENODEV);
 +}
 +
 +return edev;
 +}
 +EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
 diff --git a/include/linux/extcon/of_extcon.h 
 b/include/linux/extcon/of_extcon.h
 new file mode 100644
 index 000..462f071
 --- /dev/null
 +++ b/include/linux/extcon/of_extcon.h
 @@ -0,0 +1,30 @@
 +/*
 + * OF helpers for External connector (extcon) framework
 + *
 + * Copyright (C) 2013 Texas Instruments, Inc.
 + * Kishon Vijay Abraham I kis...@ti.com
 + *
 + * Copyright (C) 2013 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.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

Re: [PATCH] extcon: Add an API to get extcon device from dt node

2013-06-13 Thread Chanwoo Choi
On 06/12/2013 03:55 PM, Kishon Vijay Abraham I wrote:
 Hi Chanwoo Choi,
 
 On Wednesday 12 June 2013 07:09 AM, Chanwoo Choi wrote:
 From: Kishon Vijay Abraham I kis...@ti.com

 Added an API of_extcon_get_extcon_dev() to be used by drivers to get
 extcon device in the case of dt boot (this can be used instead of
 extcon_get_extcon_dev()).

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 Signed-off-by: Myungjoo Ham myungjoo@samsung.com
 ---
   drivers/extcon/Makefile  |  3 +++
   drivers/extcon/of-extcon.c   | 56 
 
   include/linux/extcon/of-extcon.h | 30 +
   3 files changed, 89 insertions(+)
   create mode 100644 drivers/extcon/of-extcon.c
   create mode 100644 include/linux/extcon/of-extcon.h

 diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
 index 540e2c3..39cdf95 100644
 --- a/drivers/extcon/Makefile
 +++ b/drivers/extcon/Makefile
 @@ -2,9 +2,12 @@
   # Makefile for external connector class (extcon) devices
   #

 +obj-$(CONFIG_OF)+= of-extcon.o
 +
   obj-$(CONFIG_EXTCON)+= extcon-class.o
   obj-$(CONFIG_EXTCON_GPIO)+= extcon-gpio.o
   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
 diff --git a/drivers/extcon/of-extcon.c b/drivers/extcon/of-extcon.c
 new file mode 100644
 index 000..29f82b4
 --- /dev/null
 +++ b/drivers/extcon/of-extcon.c
 @@ -0,0 +1,56 @@
 +/*
 + * OF helpers for External connector (extcon) framework
 + *
 + * Copyright (C) 2013 Texas Instruments, Inc.
 + * Kishon Vijay Abraham I kis...@ti.com
 + *
 + * Copyright (C) 2013 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.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.
 + */
 +
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/extcon.h
 +#include linux/of.h
 +#include linux/of_platform.h
 +#include linux/extcon/of-extcon.h
 +
 +struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
 +{
 +struct device_node *node;
 +struct extcon_dev *edev;
 +struct platform_device *extcon_parent_dev;
 +
 +if (!dev-of_node) {
 +dev_dbg(dev, device does not have a device node entry\n);
 +return ERR_PTR(-EINVAL);
 +}
 +
 +node = of_parse_phandle(dev-of_node, extcon, index);
 +if (!node) {
 +dev_dbg(dev, failed to get phandle in %s node\n,
 +dev-of_node-full_name);
 +return ERR_PTR(-ENODEV);
 +}
 +
 +extcon_parent_dev = of_find_device_by_node(node);
 +if (!extcon_parent_dev) {
 +dev_dbg(dev, unable to find device by node\n);
 +return ERR_PTR(-EPROBE_DEFER);
 +}
 +
 +edev = extcon_get_extcon_dev(dev_name(extcon_parent_dev-dev));
 
 In order to get this working, I needed a small fix in extcon_dev_register
 
 -   dev_set_name(edev-dev, edev-name ? edev-name : dev_name(dev));
 +   edev-name = edev-name ? edev-name : dev_name(dev);
 +   dev_set_name(edev-dev, edev-name);
 

OK, I added it on this patch.

 Also using extcon_get_extcon_dev here requires the extcon driver not to set 
 edev.name since we use *dev_name* here. Hence I recommend using my initial 
 class iterative approach. Anyway its your call. Let me know if have to float 
 a new version of the patch (either the iterative approach or having the fix I 
 mentioned in extcon_dev_register).

I prefer to imprement of_extcon_get_extcon_dev() separately from extcon core.

I will resend modified patch with your comment of extcon_dev_register() at once.

Thanks,
Chanwoo Choi
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/5] dwc3: omap: adapt dwc3 to use extcon framework

2013-06-11 Thread Chanwoo Choi
Hi Kishon,

Sorry for late reply.

I applied patch1,2 on extcon-linus branch.
- 
http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-linus

But, I have comment of patch 3 about dt API. I send comment on patch 3 mailing 
thread.

Thanks,
Chanwoo Choi

On 06/04/2013 01:13 AM, Kishon Vijay Abraham I wrote:
 The first three patches deals with cleanup of extcon inorder to get
 through compilation without any issues. It also adds an API to get
 extcon device from dt node which I felt was missing.

 The next two patches deals with adapt dwc3 to use extcon framework.
 The 4th patch (usb: dwc3: omap: improve error handling of dwc3_omap_probe)
 should have ideally been sent to Felipe, however since
 there will be merge conflicts with the 5th patch
 (usb: dwc3: use extcon fwrk to receive connect/disconnect)
 in this series, I've sent in the same series.

 Once this patch series get merged, dwc3 in omap would be functional
 in device mode. However there is still some discussion on modelling
 SMPS10 regulator. Once that gets finalized, dwc3 should be functional
 in host mode as well.

 Kishon Vijay Abraham I (5):
   extcon: Add an API to get extcon device from dt node
   extcon: Kconfig: Make extcon config type as bool
   extcon: add EXPORT_SYMBOL_GPL for exported functions
   usb: dwc3: omap: improve error handling of dwc3_omap_probe
   usb: dwc3: use extcon fwrk to receive connect/disconnect

  Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
  drivers/extcon/Kconfig |2 +-
  drivers/extcon/extcon-class.c  |   42 +++
  drivers/usb/dwc3/dwc3-omap.c   |  133 
 
  include/linux/extcon.h |8 ++
  include/linux/usb/dwc3-omap.h  |   30 -
  6 files changed, 168 insertions(+), 52 deletions(-)
  delete mode 100644 include/linux/usb/dwc3-omap.h


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/5] dwc3: omap: adapt dwc3 to use extcon framework

2013-06-11 Thread Chanwoo Choi
Hi Kishon,

I confused patch number. I applied patch2,3 on extcon-linus branch.

  extcon: Kconfig: Make extcon config type as bool
  extcon: add EXPORT_SYMBOL_GPL for exported functions


And I will reply comment about patch1 soon.

  extcon: Add an API to get extcon device from dt node


Thanks,
Chanwoo Choi



On Wed, Jun 12, 2013 at 9:54 AM, Chanwoo Choi cw00.c...@samsung.com wrote:

 Hi Kishon,

 Sorry for late reply.

 I applied patch1,2 on extcon-linus branch.
 -
 http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-linus

 But, I have comment of patch 3 about dt API. I send comment on patch 3
 mailing thread.

 Thanks,
 Chanwoo Choi

 On 06/04/2013 01:13 AM, Kishon Vijay Abraham I wrote:
  The first three patches deals with cleanup of extcon inorder to get
  through compilation without any issues. It also adds an API to get
  extcon device from dt node which I felt was missing.
 
  The next two patches deals with adapt dwc3 to use extcon framework.
  The 4th patch (usb: dwc3: omap: improve error handling of
 dwc3_omap_probe)
  should have ideally been sent to Felipe, however since
  there will be merge conflicts with the 5th patch
  (usb: dwc3: use extcon fwrk to receive connect/disconnect)
  in this series, I've sent in the same series.
 
  Once this patch series get merged, dwc3 in omap would be functional
  in device mode. However there is still some discussion on modelling
  SMPS10 regulator. Once that gets finalized, dwc3 should be functional
  in host mode as well.
 
  Kishon Vijay Abraham I (5):
extcon: Add an API to get extcon device from dt node
extcon: Kconfig: Make extcon config type as bool
extcon: add EXPORT_SYMBOL_GPL for exported functions
usb: dwc3: omap: improve error handling of dwc3_omap_probe
usb: dwc3: use extcon fwrk to receive connect/disconnect
 
   Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
   drivers/extcon/Kconfig |2 +-
   drivers/extcon/extcon-class.c  |   42 +++
   drivers/usb/dwc3/dwc3-omap.c   |  133
 
   include/linux/extcon.h |8 ++
   include/linux/usb/dwc3-omap.h  |   30 -
   6 files changed, 168 insertions(+), 52 deletions(-)
   delete mode 100644 include/linux/usb/dwc3-omap.h
 

 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/5] dwc3: omap: adapt dwc3 to use extcon framework

2013-06-11 Thread Chanwoo Choi
Hi Kishon,

I confused patch number. I applied patch2,3 on extcon-linus branch.

  extcon: Kconfig: Make extcon config type as bool
  extcon: add EXPORT_SYMBOL_GPL for exported functions


And I will reply comment about patch1 soon.

  extcon: Add an API to get extcon device from dt node


Thanks,
Chanwoo Choi

On 06/04/2013 01:13 AM, Kishon Vijay Abraham I wrote:
 The first three patches deals with cleanup of extcon inorder to get
 through compilation without any issues. It also adds an API to get
 extcon device from dt node which I felt was missing.

 The next two patches deals with adapt dwc3 to use extcon framework.
 The 4th patch (usb: dwc3: omap: improve error handling of dwc3_omap_probe)
 should have ideally been sent to Felipe, however since
 there will be merge conflicts with the 5th patch
 (usb: dwc3: use extcon fwrk to receive connect/disconnect)
 in this series, I've sent in the same series.

 Once this patch series get merged, dwc3 in omap would be functional
 in device mode. However there is still some discussion on modelling
 SMPS10 regulator. Once that gets finalized, dwc3 should be functional
 in host mode as well.

 Kishon Vijay Abraham I (5):
   extcon: Add an API to get extcon device from dt node
   extcon: Kconfig: Make extcon config type as bool
   extcon: add EXPORT_SYMBOL_GPL for exported functions
   usb: dwc3: omap: improve error handling of dwc3_omap_probe
   usb: dwc3: use extcon fwrk to receive connect/disconnect

  Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
  drivers/extcon/Kconfig |2 +-
  drivers/extcon/extcon-class.c  |   42 +++
  drivers/usb/dwc3/dwc3-omap.c   |  133 
 
  include/linux/extcon.h |8 ++
  include/linux/usb/dwc3-omap.h  |   30 -
  6 files changed, 168 insertions(+), 52 deletions(-)
  delete mode 100644 include/linux/usb/dwc3-omap.h


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 1/5] extcon: Add an API to get extcon device from dt node

2013-06-11 Thread Chanwoo Choi
Hi Kishon,

On 06/04/2013 01:13 AM, Kishon Vijay Abraham I wrote:
 Added an API of_extcon_get_extcon_dev() to be used by drivers to get
 extcon device in the case of dt boot (this can be used instead of
 extcon_get_extcon_dev()).

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/extcon/extcon-class.c |   40 
  include/linux/extcon.h|8 
  2 files changed, 48 insertions(+)

I don't prefer that add of helper API in extcon core. I want to add
new of helper file as drivers/extcon/of-extcon.c.
So, I add drivers/extcon/of-extcon.c and include/linux/extcon/of-extcon.h
based on your this patch. I will send modified patch at once.

 diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
 index 60adc04..265d549 100644
 --- a/drivers/extcon/extcon-class.c
 +++ b/drivers/extcon/extcon-class.c
 @@ -31,6 +31,7 @@
  #include linux/extcon.h
  #include linux/slab.h
  #include linux/sysfs.h
 +#include linux/of_platform.h
  
  /*
   * extcon_cable_name suggests the standard cable names for commonly used
 @@ -392,6 +393,45 @@ int extcon_set_cable_state(struct extcon_dev *edev,
  }
  EXPORT_SYMBOL_GPL(extcon_set_cable_state);
  
 +struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
 +{
 + struct class_dev_iter iter;
 + struct device *extcon_dev;
 + struct device_node *node;
 + struct platform_device *extcon_parent_dev;
 +
 + if (!dev-of_node) {
 + dev_dbg(dev, device does not have a device node entry\n);
 + return ERR_PTR(-EINVAL);
 + }
 +
 + node = of_parse_phandle(dev-of_node, extcon, index);
 + if (!node) {
 + dev_dbg(dev, failed to get phandle in %s node\n,
 + dev-of_node-full_name);
 + return ERR_PTR(-ENODEV);
 + }
 +
 + extcon_parent_dev = of_find_device_by_node(node);
 + if (!extcon_parent_dev) {
 + dev_dbg(dev, unable to find device by node\n);
 + return ERR_PTR(-EPROBE_DEFER);
 + }
 +
 + class_dev_iter_init(iter, extcon_class, NULL, NULL);
 + while ((extcon_dev = class_dev_iter_next(iter))) {
 + if (extcon_dev-parent != extcon_parent_dev-dev)
 + continue;
 +
 + class_dev_iter_exit(iter);
 + return dev_get_drvdata(extcon_dev);
 + }
 +
 + class_dev_iter_exit(iter);

Use extcon_get_extcon_dev() instead of using class_dev_iter_init/exit()

 + return ERR_PTR(-ENODEV);
 +}
 +EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
 +
  /**
   * extcon_get_extcon_dev() - Get the extcon device instance from the name
   * @extcon_name: The extcon name provided with extcon_dev_register()
 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
 index fcb51c8..3858bb9 100644
 --- a/include/linux/extcon.h
 +++ b/include/linux/extcon.h
 @@ -182,6 +182,8 @@ struct extcon_specific_cable_nb {
   */
  extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev);
  extern void extcon_dev_unregister(struct extcon_dev *edev);
 +extern struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev,
 + int index);
  extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
  
  /*
 @@ -292,6 +294,12 @@ static inline int extcon_set_cable_state(struct 
 extcon_dev *edev,
   return 0;
  }
  
 +static inline struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev,
 + int index)
 +{
 + return NULL;
 +}
 +
  static inline struct extcon_dev *extcon_get_extcon_dev(const char 
 *extcon_name)
  {
   return NULL;

Thanks,
Chanwoo Choi






___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH] extcon: Add an API to get extcon device from dt node

2013-06-11 Thread Chanwoo Choi
From: Kishon Vijay Abraham I kis...@ti.com

Added an API of_extcon_get_extcon_dev() to be used by drivers to get
extcon device in the case of dt boot (this can be used instead of
extcon_get_extcon_dev()).

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Myungjoo Ham myungjoo@samsung.com
---
 drivers/extcon/Makefile  |  3 +++
 drivers/extcon/of-extcon.c   | 56 
 include/linux/extcon/of-extcon.h | 30 +
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/extcon/of-extcon.c
 create mode 100644 include/linux/extcon/of-extcon.h

diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index 540e2c3..39cdf95 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -2,9 +2,12 @@
 # Makefile for external connector class (extcon) devices
 #
 
+obj-$(CONFIG_OF)   += of-extcon.o
+
 obj-$(CONFIG_EXTCON)   += extcon-class.o
 obj-$(CONFIG_EXTCON_GPIO)  += extcon-gpio.o
 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
diff --git a/drivers/extcon/of-extcon.c b/drivers/extcon/of-extcon.c
new file mode 100644
index 000..29f82b4
--- /dev/null
+++ b/drivers/extcon/of-extcon.c
@@ -0,0 +1,56 @@
+/*
+ * OF helpers for External connector (extcon) framework
+ *
+ * Copyright (C) 2013 Texas Instruments, Inc.
+ * Kishon Vijay Abraham I kis...@ti.com
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.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.
+ */
+
+#include linux/module.h
+#include linux/slab.h
+#include linux/extcon.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/extcon/of-extcon.h
+
+struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
+{
+   struct device_node *node;
+   struct extcon_dev *edev;
+   struct platform_device *extcon_parent_dev;
+
+   if (!dev-of_node) {
+   dev_dbg(dev, device does not have a device node entry\n);
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev-of_node, extcon, index);
+   if (!node) {
+   dev_dbg(dev, failed to get phandle in %s node\n,
+   dev-of_node-full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   extcon_parent_dev = of_find_device_by_node(node);
+   if (!extcon_parent_dev) {
+   dev_dbg(dev, unable to find device by node\n);
+   return ERR_PTR(-EPROBE_DEFER);
+   }
+
+   edev = extcon_get_extcon_dev(dev_name(extcon_parent_dev-dev));
+   if (!edev) {
+   dev_dbg(dev, unable to get extcon device : %s\n,
+   dev_name(extcon_parent_dev-dev));
+   return ERR_PTR(-ENODEV);
+   }
+
+   return edev;
+}
+EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
diff --git a/include/linux/extcon/of-extcon.h b/include/linux/extcon/of-extcon.h
new file mode 100644
index 000..77d01ba
--- /dev/null
+++ b/include/linux/extcon/of-extcon.h
@@ -0,0 +1,30 @@
+/*
+ * OF helpers for External connector (extcon) framework
+ *
+ * Copyright (C) 2013 Texas Instruments, Inc.
+ * Kishon Vijay Abraham I kis...@ti.com
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.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.
+ */
+
+#ifndef __LINUX_OF_EXTCON_H
+#define __LINUX_OF_EXTCON_H
+
+#if defined(CONFIG_OF)
+extern struct extcon_dev
+   *of_extcon_get_extcon_dev(struct device *dev, int index);
+#else
+static inline struct extcon_dev
+   *of_extcon_get_extcon_dev(struct device *dev, int index);
+{
+   return NULL;
+}
+#endif /* CONFIG_OF */
+
+#endif /* __LINUX_OF_EXTCON_H */
-- 
1.8.0

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification

2013-05-30 Thread Chanwoo Choi

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 kis...@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

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/3] palmas usb driver

2013-05-29 Thread Chanwoo Choi
On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi ba...@ti.com 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 * constis 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 ba...@ti.com


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
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/3] palmas usb driver

2013-05-29 Thread Chanwoo Choi
On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi ba...@ti.com 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 * constis 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 ba...@ti.com


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
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 0/3] palmas usb driver

2013-05-29 Thread Chanwoo Choi
On Thu, May 30, 2013 at 2:38 AM, Felipe Balbi ba...@ti.com 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 * constis 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 ba...@ti.com


 --
 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
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver

2013-05-27 Thread Chanwoo Choi
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-palmasid=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

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v2] usb: dwc3: use extcon fwrk to receive connect/disconnect notification

2013-05-27 Thread Chanwoo Choi
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 kis...@ti.com
 Acked-by: Chanwoo Choi cw00.c...@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
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v6] extcon: Palmas Extcon Driver

2013-05-27 Thread Chanwoo Choi
On 05/27/2013 10:33 PM, Kishon Vijay Abraham I wrote:
 From: Graeme Gregory g...@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 g...@slimlogic.co.uk
 Signed-off-by: Moiz Sonasath m-sonas...@ti.com
 Signed-off-by: Ruchika Kharwar ruch...@ti.com
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Signed-off-by: George Cherian george.cher...@ti.com
 [kis...@ti.com: adapted palmas usb driver to use the extcon framework]
 Signed-off-by: Sebastien Guiriec s-guir...@ti.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 Signed-off-by: Myungjoo Ham myungjoo@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 * constis 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

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v5 2/3] extcon: Palmas Extcon Driver

2013-05-26 Thread Chanwoo Choi
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-palmasid=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 g...@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 g...@slimlogic.co.uk
 Signed-off-by: Moiz Sonasath m-sonas...@ti.com
 Signed-off-by: Ruchika Kharwar ruch...@ti.com
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Signed-off-by: George Cherian george.cher...@ti.com
 [kis...@ti.com: adapted palmas usb driver to use the extcon framework]
 Signed-off-by: Sebastien Guiriec s-guir...@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 * constis 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 000..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 000..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.

Re: [PATCH 3/3] usb: dwc3: use extcon fwrk to receive connect/disconnect notification

2013-05-26 Thread Chanwoo Choi
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 kis...@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.c...@samsung.com

Thanks,
Chanwoo Choi
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v4] extcon: Palmas Extcon Driver

2013-05-07 Thread Chanwoo Choi
  PALMAS_USB_STATE_DISCONNECT 0x0
 +#define  PALMAS_USB_STATE_VBUS   BIT(0)
 +#define  PALMAS_USB_STATE_ID BIT(1)
 +
The defined variable in extcon_palmas.h is used only on extcon-palmas.c.
So, I would like to move definition from extcon_palmas.h to extcon-palmas.c
and remove extcon_palmas.h header file.
 +#endif   /* __EXTCON_PALMAS_H__ */
 diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
 index 8f21daf..d671679 100644
 --- a/include/linux/mfd/palmas.h
 +++ b/include/linux/mfd/palmas.h
 @@ -18,8 +18,10 @@
  
  #include linux/usb/otg.h
  #include linux/leds.h
 +#include linux/extcon.h
  #include linux/regmap.h
  #include linux/regulator/driver.h
 +#include linux/usb/phy_companion.h
  
  #define PALMAS_NUM_CLIENTS   3
  
 @@ -349,6 +351,9 @@ struct palmas_resource {
  struct palmas_usb {
   struct palmas *palmas;
   struct device *dev;
 + struct extcon_dev edev;
 +
 + struct phy_companion comparator;
  
   /* for vbus reporting with irqs disabled */
   spinlock_t lock;
 @@ -365,7 +370,8 @@ struct palmas_usb {
  
   int vbus_enable;
  
 - u8 linkstat;
 + int mailboxstat;
 + int linkstat;
  };
  
  #define comparator_to_palmas(x) container_of((x), struct palmas_usb, 
 comparator)

Thanks,
Chanwoo Choi
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v4] extcon: Palmas Extcon Driver

2013-05-07 Thread Chanwoo Choi
On 05/07/2013 03:25 PM, Kishon Vijay Abraham I wrote:
 Hi,

 On Tuesday 07 May 2013 11:40 AM, Chanwoo Choi wrote:
 Hi Kishon,

 I add some opinion about this patch.

 On 05/06/2013 10:17 PM, Kishon Vijay Abraham I wrote:
 From: Graeme Gregory g...@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 g...@slimlogic.co.uk
 Signed-off-by: Moiz Sonasath m-sonas...@ti.com
 Signed-off-by: Ruchika Kharwar ruch...@ti.com
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 [kis...@ti.com: adapted palmas usb driver to use the extcon framework]
 Signed-off-by: Sebastien Guiriec s-guir...@ti.com
 ---
 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  |   17 +
   drivers/extcon/Kconfig |7 +
   drivers/extcon/Makefile|1 +
   drivers/extcon/extcon-palmas.c |  389 
 
   include/linux/extcon/extcon_palmas.h   |   26 ++
   include/linux/mfd/palmas.h |8 +-
   6 files changed, 447 insertions(+), 1 deletion(-)
   create mode 100644 Documentation/devicetree/bindings/extcon/extcon-twl.txt
   create mode 100644 drivers/extcon/extcon-palmas.c
   create mode 100644 include/linux/extcon/extcon_palmas.h

 diff --git a/Documentation/devicetree/bindings/extcon/extcon-twl.txt 
 b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 new file mode 100644
 index 000..a7f6527
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/extcon/extcon-twl.txt
 @@ -0,0 +1,17 @@
 +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
 + - ti,no_control_vbus: if the platform wishes its own vbus control
 +
 +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 5168a13..c881899 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 000..3ef042f
 --- /dev/null
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -0,0 +1,389 @@
 +/*
 + * 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 g...@...mlogic.co.uk
 + * Author: Kishon Vijay Abraham I kis...@...com
 + *
 + * Based on twl6030_usb.c
 + *
 + * Author: Hema HK hem...@...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/init.h
 +#include linux/interrupt.h
 +#include linux/platform_device.h
 +#include linux/io.h

Re: [PATCH v4] extcon: Palmas Extcon Driver

2013-05-07 Thread Chanwoo Choi
On 05/07/2013 03:57 PM, Chanwoo Choi wrote:
 diff --git a/include/linux/extcon/extcon_palmas.h 
 b/include/linux/extcon/extcon_palmas.h
 new file mode 100644
 index 000..a5119c9
 --- /dev/null
 +++ b/include/linux/extcon/extcon_palmas.h
 @@ -0,0 +1,26 @@
 +/*
 + * extcon_palmas.h - palmas extcon driver to detect VBUS or ID events
 + *
 + * 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: Kishon Vijay Abraham I kis...@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.
 + *
 + */
 +
 +#ifndef __EXTCON_PALMAS_H__
 +#define __EXTCON_PALMAS_H__
 +
 +#definePALMAS_USB_STATE_DISCONNECT0x0
 +#definePALMAS_USB_STATE_VBUSBIT(0)
 +#definePALMAS_USB_STATE_IDBIT(1)
 +
 The defined variable in extcon_palmas.h is used only on extcon-palmas.c.
 So, I would like to move definition from extcon_palmas.h to extcon-palmas.c
 and remove extcon_palmas.h header file.
 Actually it has to be used in dwc3-omap.c (that was in a different patch).

 Should detect the state of USB/USB-HOST on dwc3-omap driver?

 If yes, dwc3-omap driver can immediately detect the changed state of 
 USB/USB-HOST
 by using excon_register_interest() function which is defined in extcon-class.c

 I explain simple usage of extcon_register_interest()
 to receive newly state of USB cable on dwc3-omap driver.
 ---
 struct extcon_specific_cable_nb extcon_notifier
 struct notifier_block extcon_notifier;

  /* ... */

 extcon_notifier.notifier_call = omap_extcon_notifier;
 ret = extcon_register_interest(extcon_dev, USB, extcon_notifier);
Fix usage of extcon_register_interest() as following:

ret = extcon_register_interest(extcon_dev, NULL, USB, extcon_notifier); 
or
ret = extcon_register_interest(extcon_dev, palmas-usb, USB, 
extcon_notifier);
 /* ... */

 int omap_extcon_notifier(struct notifier_block *self,
 unsigned long event, void 
 *ptr)
 {
 int usb_state;

 usb_state = event;   

 /* if usb_state is 1, PALMAS_USB_STATE_VBUS  */
 /* if usb_state is 0, PALMAS_USB_STATE_DISCONNECT */

 /* TODO */

 }
 ---

 If dwc3-omap driver use extcon_register_interest(), following defined 
 variables
 are able to be removed.
 PALMAS_USB_STATE_DISCONNECT
 PALMAS_USB_STATE_VBUS
 PALMAS_USB_STATE_ID

 Thanks,
 Chanwoo Choi


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 1/2] iio: Update iio_channel_get API to use consumer device pointer as argument

2013-02-11 Thread Chanwoo Choi

On 02/05/2013 05:26 AM, Guenter Roeck wrote:

For iio_channel_get to work with OF based configurations, it needs the
consumer device pointer instead of the consumer device name as argument.

Signed-off-by: Guenter Roeck li...@roeck-us.net
---
  drivers/extcon/extcon-adc-jack.c|3 +--
  drivers/iio/inkern.c|   11 ++-
  drivers/power/generic-adc-battery.c |4 ++--
  drivers/power/lp8788-charger.c  |8 
  include/linux/iio/consumer.h|5 +++--
  5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index eda2a1a..d0233cd 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -135,8 +135,7 @@ static int adc_jack_probe(struct platform_device *pdev)
;
data-num_conditions = i;
  
-	data-chan = iio_channel_get(dev_name(pdev-dev),

-   pdata-consumer_channel);
+   data-chan = iio_channel_get(pdev-dev, pdata-consumer_channel);
if (IS_ERR(data-chan)) {
err = PTR_ERR(data-chan);
goto out;
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index c42aba6..b289915 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -93,7 +93,8 @@ static const struct iio_chan_spec

Ack for drivers/extcon .

Acked-by: Chanwoo Choi cw00.c...@samsung.com

Thanks,
Chanwoo Choi

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss