extcon: palmas: clean-up/fixes and suspend/resume susupport
Subsystems (3)
v2 cover extcon: palmas: clean-up/fixes and suspend/resume susupport
This patch series does following:
- Remove unused member from extcon palmas structure.
- Fix to support of detecting cable properly with multiple insert/removal.
- Add support for suspend/resume functionlaity and wakup from suspend.
- Option to select/de-select the ID or VBUS detection.
Changes from V1:
- Correct the display message.
- Add ack from Graeme
Laxman Dewangan (4):
extcon: palmas: remove unused member from palams_usb structure
extcon: palmas: enable ID_GND and ID_FLOAT detection always
extcon: palams: add support for suspend/resume
extcon: palmas: Option to disable ID/VBUS detection based on platform
.../devicetree/bindings/extcon/extcon-palmas.txt | 2 + drivers/extcon/extcon-palmas.c | 111 ++++++++++++++------ include/linux/mfd/palmas.h | 9 +- 3 files changed, 86 insertions(+), 36 deletions(-)
PATCH v2 4/4 extcon: palmas: Option to disable ID/VBUS detection based on platform
Based on system design, platform needs to detect the VBUS or ID or both. Provide option to select this through platform data to disable part of cable detection through palmas-usb.
---
No changes from V1.
.../devicetree/bindings/extcon/extcon-palmas.txt | 2 + drivers/extcon/extcon-palmas.c | 65 +++++++++++++------- include/linux/mfd/palmas.h | 4 + 3 files changed, 48 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/extcon/extcon-palmas.txt +2 -0
@@ -6,6 +6,8 @@ Required Properties: Optional Properties: - ti,wakeup : To enable the wakeup comparator in probe + - ti,disable-id-detection: Do not perform ID detection. + - ti,disable-vbus-detection: Do not pwerform VBUS detection. palmas-usb { compatible = "ti,twl6035-usb", "ti,palmas-usb";
drivers/extcon/extcon-palmas.c +42 -23
107 lines not on this page · raw message
include/linux/mfd/palmas.h +4 -0
@@ -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)
Signature · 1 line
1.7.1.1
PATCH v2 2/4 extcon: palmas: enable ID_GND and ID_FLOAT detection always
In reply to Laxman DewanganWhen 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.
---
Changes from V1:
- Corrected the print message to have more meaningful.
drivers/extcon/extcon-palmas.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-)
drivers/extcon/extcon-palmas.c +11 -13
@@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)if (palmas_usb->linkstat !=PALMAS_USB_STATE_VBUS ) { palmas_usb->linkstat =PALMAS_USB_STATE_VBUS ;extcon_set_cable_state (&palmas_usb->edev,"USB" , true); +dev_info (palmas_usb->dev,"USB cable is attached\n" ); }else {dev_dbg (palmas_usb->dev,"Spurious connect event detected\n" );
@@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)if (palmas_usb->linkstat ==PALMAS_USB_STATE_VBUS ) { palmas_usb->linkstat =PALMAS_USB_STATE_DISCONNECT ;extcon_set_cable_state (&palmas_usb->edev,"USB" , false); +dev_info (palmas_usb->dev,"USB cable is detached\n" ); }else {dev_dbg (palmas_usb->dev,"Spurious disconnect event detected\n" );
@@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)if (set &PALMAS_USB_ID_INT_SRC_ID_GND ) {palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE , -PALMAS_USB_ID_INT_EN_HI_SET , -PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT ); -palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE , -PALMAS_USB_ID_INT_EN_HI_CLR , -PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND ); -palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE ,PALMAS_USB_ID_INT_LATCH_CLR ,PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND ); palmas_usb->linkstat =PALMAS_USB_STATE_ID ;extcon_set_cable_state (&palmas_usb->edev,"USB-HOST" , true); +dev_info (palmas_usb->dev,"HOST cable is attached\n" ); }else if (set &PALMAS_USB_ID_INT_SRC_ID_FLOAT ) {palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE , -PALMAS_USB_ID_INT_EN_HI_SET , -PALMAS_USB_ID_INT_EN_HI_SET_ID_GND ); -palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE , -PALMAS_USB_ID_INT_EN_HI_CLR , -PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT ); -palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE ,PALMAS_USB_ID_INT_LATCH_CLR ,PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT ); palmas_usb->linkstat =PALMAS_USB_STATE_DISCONNECT ;extcon_set_cable_state (&palmas_usb->edev,"USB-HOST" , false); +dev_info (palmas_usb->dev,"HOST cable is detached\n" ); + }else if ((palmas_usb->linkstat ==PALMAS_USB_STATE_ID ) && + (!(set &PALMAS_USB_ID_INT_SRC_ID_GND ))) { + palmas_usb->linkstat =PALMAS_USB_STATE_DISCONNECT ; +extcon_set_cable_state (&palmas_usb->edev,"USB-HOST" , false); +dev_info (palmas_usb->dev,"HOST cable is detached\n" ); }return IRQ_HANDLED ;
@@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)palmas_write (palmas_usb->palmas,PALMAS_USB_OTG_BASE ,PALMAS_USB_ID_INT_EN_HI_SET , -PALMAS_USB_ID_INT_EN_HI_SET_ID_GND ); +PALMAS_USB_ID_INT_EN_HI_SET_ID_GND | +PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT );palmas_vbus_irq_handler (palmas_usb->vbus_irq, palmas_usb);
Signature · 1 line
1.7.1.1
PATCH v2 3/4 extcon: palams: add support for suspend/resume
In reply to Laxman DewanganAdd suspend/resume callbacks and support for wakeup from suspend on USB HOST or USB Device cable insertion or removal.
---
No changes from V1.
drivers/extcon/extcon-palmas.c | 38 +++++++++++++++++++++++++++++++++++--- 1 files changed, 35 insertions(+), 3 deletions(-)
drivers/extcon/extcon-palmas.c +35 -3
@@ -182,7 +182,8 @@ static int palmas_usb_probe(struct platform_device *pdev) status =devm_request_threaded_irq (palmas_usb->dev, palmas_usb->id_irq,NULL , palmas_id_irq_handler, -IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING , +IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | +IRQF_ONESHOT |IRQF_EARLY_RESUME ,"palmas_usb_id" , palmas_usb);if (status <0 ) { dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -192,7 +193,8 @@ static int palmas_usb_probe(struct platform_device *pdev) status =devm_request_threaded_irq (palmas_usb->dev, palmas_usb->vbus_irq,NULL , palmas_vbus_irq_handler, -IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING , +IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | +IRQF_ONESHOT |IRQF_EARLY_RESUME ,"palmas_usb_vbus" , palmas_usb);if (status <0 ) { dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
@@ -201,7 +203,7 @@ static int palmas_usb_probe(struct platform_device *pdev) }palmas_enable_irq (palmas_usb); - +device_set_wakeup_capable (&pdev->dev, true);return 0 ; fail_extcon:
@@ -219,6 +221,35 @@ static int palmas_usb_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM_SLEEP +static int palmas_usb_suspend (struct device *dev) +{ +struct palmas_usb *palmas_usb =dev_get_drvdata (dev); + +if (device_may_wakeup (dev)) { +enable_irq_wake (palmas_usb->vbus_irq); +enable_irq_wake (palmas_usb->id_irq); + } +return 0 ; +} + +static int palmas_usb_resume (struct device *dev) +{ +struct palmas_usb *palmas_usb =dev_get_drvdata (dev); + +if (device_may_wakeup (dev)) { +disable_irq_wake (palmas_usb->vbus_irq); +disable_irq_wake (palmas_usb->id_irq); + } +return 0 ; +}; +#endif + +static const struct dev_pm_ops palmas_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (palmas_usb_suspend, + palmas_usb_resume) +}; +static struct of_device_id of_palmas_match_tbl[] = { { .compatible ="ti,palmas-usb" , }, { .compatible ="ti,twl6035-usb" , },
@@ -232,6 +263,7 @@ static struct platform_driver palmas_usb_driver = { .name = "palmas-usb", .of_match_table = of_palmas_match_tbl, .owner = THIS_MODULE, + .pm = &palmas_pm_ops, }, };
Signature · 1 line
1.7.1.1
PATCH v2 1/4 extcon: palmas: remove unused member from palams_usb structure
In reply to Laxman DewanganRemove unused member vbus_enable and set_vbus_work from palmas_usb as these members are not used in drivers.
---
No changes from V1.
include/linux/mfd/palmas.h | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
include/linux/mfd/palmas.h +0 -5
@@ -371,16 +371,11 @@ struct palmas_usb {struct extcon_dev edev; -/* used to set vbus, in atomic path */ -struct work_struct set_vbus_work; -int id_otg_irq;int id_irq;int vbus_otg_irq;int vbus_irq; -int vbus_enable; -enum palmas_usb_state linkstat; };
Signature · 1 line
1.7.1.1
Chanwoo Choi
maintainerRe: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
In reply to Laxman DewanganHi Laxman,
Quoted 19 lines · Laxman Dewangan
Based on system design, platform needs to detect the VBUS or ID or both. Provide option to select this through platform data to disable part of cable detection through palmas-usb.
Signed-off-by Laxman Dewangan <[email protected]>Acked-by Graeme Gregory <[email protected]>---
No changes from V1..../devicetree/bindings/extcon/extcon-palmas.txt | 2 + drivers/extcon/extcon-palmas.c | 65 +++++++++++++------- include/linux/mfd/palmas.h | 4 + 3 files changed, 48 insertions(+), 23 deletions(-)Documentation/devicetree/bindings/extcon/extcon-palmas.txt +0
-0
Documentation/devicetree/bindings/extcon/extcon-palmas.txt Required Properties: · line 10
Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-palmas.txt +2
-0@@ -6,6 +6,8 @@ Required Properties: Optional Properties: - ti,wakeup : To enable the wakeup comparator in probe + - ti,disable-id-detection: Do not perform ID detection. + - ti,disable-vbus-detection: Do not pwerform VBUS detection.
Fix typo.
- pwerform -> perform
Quoted 135 lines
Documentation/devicetree/bindings/extcon/extcon-palmas.txt +0
-0palmas-usb { compatible = "ti,twl6035-usb", "ti,palmas-usb";drivers/extcon/extcon-palmas.c +42
-23@@ -122,11 +122,14 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb)PALMAS_USB_ID_INT_EN_HI_SET_ID_GND | PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); -palmas_vbus_irq_handler (palmas_usb->vbus_irq, palmas_usb); +if (palmas_usb->enable_vbus_detection) +palmas_vbus_irq_handler (palmas_usb->vbus_irq, palmas_usb);/* cold plug for host mode needs this delay */ -msleep (30 ); -palmas_id_irq_handler (palmas_usb->id_irq, palmas_usb); +if (palmas_usb->enable_id_detection) { +msleep (30 ); +palmas_id_irq_handler (palmas_usb->id_irq, palmas_usb); + } }static int palmas_usb_probe (struct platform_device *pdev)@@ -144,6 +147,10 @@ static int palmas_usb_probe(struct platform_device *pdev)return -ENOMEM ; pdata->wakeup =of_property_read_bool (node,"ti,wakeup" ); + pdata->disable_id_detection =of_property_read_bool (node, +"ti,disable-id-detection" ); + pdata->disable_vbus_detection =of_property_read_bool (node, +"ti,disable-vbus-detection" ); }else if (!pdata) {return -EINVAL ; }@@ -154,6 +161,8 @@ static int palmas_usb_probe(struct platform_device *pdev) palmas->usb = palmas_usb; palmas_usb->palmas = palmas; + palmas_usb->enable_vbus_detection = !pdata->disable_vbus_detection; + palmas_usb->enable_id_detection = !pdata->disable_id_detection; palmas_usb->dev = &pdev->dev;@@ -180,26 +189,32 @@ static int palmas_usb_probe(struct platform_device *pdev)return status; } - status =devm_request_threaded_irq (palmas_usb->dev, palmas_usb->id_irq, -NULL , palmas_id_irq_handler, -IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | -IRQF_ONESHOT |IRQF_EARLY_RESUME , -"palmas_usb_id" , palmas_usb); -if (status <0 ) { -dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , +if (palmas_usb->enable_id_detection) { + status =devm_request_threaded_irq (palmas_usb->dev, + palmas_usb->id_irq, +NULL , palmas_id_irq_handler, +IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | +IRQF_ONESHOT |IRQF_EARLY_RESUME , +"palmas_usb_id" , palmas_usb); +if (status <0 ) { +dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , palmas_usb->id_irq, status); - goto fail_extcon; + goto fail_extcon; + } } - status =devm_request_threaded_irq (palmas_usb->dev, - palmas_usb->vbus_irq,NULL , palmas_vbus_irq_handler, -IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | -IRQF_ONESHOT |IRQF_EARLY_RESUME , -"palmas_usb_vbus" , palmas_usb); -if (status <0 ) { -dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , +if (palmas_usb->enable_vbus_detection) { + status =devm_request_threaded_irq (palmas_usb->dev, + palmas_usb->vbus_irq,NULL , + palmas_vbus_irq_handler, +IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING | +IRQF_ONESHOT |IRQF_EARLY_RESUME , +"palmas_usb_vbus" , palmas_usb); +if (status <0 ) { +dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , palmas_usb->vbus_irq, status); - goto fail_extcon; + goto fail_extcon; + } }palmas_enable_irq (palmas_usb);@@ -227,8 +242,10 @@ static int palmas_usb_suspend(struct device *dev)struct palmas_usb *palmas_usb =dev_get_drvdata (dev);if (device_may_wakeup (dev)) { -enable_irq_wake (palmas_usb->vbus_irq); -enable_irq_wake (palmas_usb->id_irq); +if (palmas_usb->enable_vbus_detection) +enable_irq_wake (palmas_usb->vbus_irq); +if (palmas_usb->enable_id_detection) +enable_irq_wake (palmas_usb->id_irq); }return 0 ; }@@ -238,8 +255,10 @@ static int palmas_usb_resume(struct device *dev)struct palmas_usb *palmas_usb =dev_get_drvdata (dev);if (device_may_wakeup (dev)) { -disable_irq_wake (palmas_usb->vbus_irq); -disable_irq_wake (palmas_usb->id_irq); +if (palmas_usb->enable_vbus_detection) +disable_irq_wake (palmas_usb->vbus_irq); +if (palmas_usb->enable_id_detection) +disable_irq_wake (palmas_usb->id_irq); }return 0 ; };include/linux/mfd/palmas.h +2
-0@@ -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 {
include/linux/mfd/palmas.h struct palmas_usb { · line 386
Quoted 8 lines
include/linux/mfd/palmas.h +2
-0@@ -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
Chanwoo Choi
maintainerQuoted 10 lines · Laxman Dewangan
This patch series does following:
- Remove unused member from extcon palmas structure.
- Fix to support of detecting cable properly with multiple insert/removal.
- Add support for suspend/resume functionlaity and wakup from suspend.
- Option to select/de-select the ID or VBUS detection.Changes from V1:
- Correct the display message.
- Add ack from Graeme
Quoted 6 lines
Laxman Dewangan (4):
extcon: palmas: remove unused member frompalams_usbstructure
extcon: palmas: enableID_GNDandID_FLOATdetection 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
Chanwoo Choi
maintainerRe: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
In reply to Laxman DewanganHi Laxman,
Quoted 24 lines
drivers/extcon/extcon-palmas.c +1
-12@@ -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,
drivers/extcon/extcon-palmas.c static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) · line 106
Quoted 10 lines
drivers/extcon/extcon-palmas.c +6
-0PALMAS_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
Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
In reply to Chanwoo ChoiQuoted 9 lines · Chanwoo Choi
Hi Laxman,
Quoted 6 lines · Laxman Dewangan
Should you define duplicate meaning variables in each other structure?
-disable_vbus_detection-enable_vbus_detection
-disable_id_detection-enable_id_detectionI think that it isn' efficient code. I'd like you to simplify this patch by using only one variable instead of duplicate meaning variables.
Originally this patch came form TI and not sure that they are using the both cable detection or only single type. For Nvidia Tegra platform, on some design, we are using only ID detection and hence this option get added.
I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.
On other structure, I use as other way to use in rest of code to make logic as
if (palmas_usb->enable_id_detction)
xxx.
rathar than
if (!palmas_usb->disable_id_detction)
xxx.
On rest of code, do now wan to use the pdata.
Quoted 17 lines · Chanwoo Choi
Quoted 10 lines · Laxman Dewangan
This patch series does following:
- Remove unused member from extcon palmas structure.
- Fix to support of detecting cable properly with multiple insert/removal.
- Add support for suspend/resume functionlaity and wakup from suspend.
- Option to select/de-select the ID or VBUS detection.Changes from V1:
- Correct the display message.
- Add ack from GraemeQuoted 6 lines
Laxman Dewangan (4):
extcon: palmas: remove unused member frompalams_usbstructure
extcon: palmas: enableID_GNDandID_FLOATdetection always
extcon: palams: add support for suspend/resume
extcon: palmas: Option to disable ID/VBUS detection based on platform
Quoted 4 lines
Patch 1/2/3 is only applied on extcon-linus branch.
I replied about patch4.
Thank you very much for taking care.
Working on Patch4.
Thanks,
Laxman
Re: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always
In reply to Chanwoo ChoiQuoted 39 lines · Chanwoo Choi
Hi Laxman,
Quoted 24 lines
drivers/extcon/extcon-palmas.c +1
-12@@ -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,drivers/extcon/extcon-palmas.c static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) · line 106
Quoted 10 lines
drivers/extcon/extcon-palmas.c +6
-0PALMAS_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.
Quoted 1 line
"HOST cable is ..." -> "USB-HOST cable is"
Thank you very much for correction and more meaningful message.
Thanks,
Laxman
Chanwoo Choi
maintainerRe: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
In reply to Laxman DewanganQuoted 8 lines · Laxman Dewangan
Quoted 7 lines · Chanwoo Choi
Hi Laxman,
Quoted 4 lines · Laxman Dewangan
Should you define duplicate meaning variables in each other structure?
-disable_vbus_detection-enable_vbus_detection
-disable_id_detection-enable_id_detection
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 7 lines
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.
Quoted 7 lines
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;
}Re: [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform
Quoted 39 lines · Chanwoo Choi
Quoted 8 lines · Laxman Dewangan
On Wednesday 10 July 2013 12:25 PM, Chanwoo Choi wrote:
I did not like to break the TI design/code and hence added the option such that if there is no initialisation of this member or dts entry then assume it as the cable detection is enabled. Hence it need explicitly entry for disable the cable type detction. This is what for platform data structure.On other structure, I use as other way to use in rest of code to make logic as
if (
palmas_usb->enable_id_detction)
xxx.Quoted 7 lines
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_usbwithout variables in structpalmas_platform_databecause extcon-palmas driver store only the pointer of 'structpalmas_usb' todev->p->driver_databy usingplatform_set_drvdata().It is meaning to use 'struct
palmas_usb' on other function except forpalmas_usb_probe()inextcon-palmas.c.
Quoted 11 lines
if (node && !pdata) {
...
palmas_usb->wakeup = of_property_red_bool(node, "ti,wakeup);
palmas_usb->enable_vbus_detection = of_property_red_bool(node, "ti,enable_vbus_detection);
palmas_usb->enable_id_detection = of_property_red_bool(node, "ti,enable_id_detection);
} else (!pdata) {
palmas_usb->wakeup = true;
palmas_usb->enable_vbus_detection = true;
palmas_usb->enable_id_detection = true;
}Thanks for detail explanation.
I agree with you on this code. This code support the option if driver is invoked from DT and assume true always if it is from board file.
As all Tegra platforms have been moved to the DTS, I do not see any issue on this change.
I will post the new version of this change (patch 4/4) as all others are already merged.