extcon: palmas: Option to disable ID/VBUS detection based on platform
Subsystems (3)
PATCH v3 1/1 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.
Change from V2:
- Remove the changes on platform strcuture.
- Move the palma_usb allocation before DT parsing.
- remove the mem allocation of pdata as it is not used.
Note:
- This was the 4th patch of the series. ALready 3 pacthes are applied and hence sending this 4th patch only. This has the fix suggested by Chanwoo.
.../devicetree/bindings/extcon/extcon-palmas.txt | 2 + drivers/extcon/extcon-palmas.c | 87 ++++++++++++-------- include/linux/mfd/palmas.h | 3 + 3 files changed, 58 insertions(+), 34 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,enable-id-detection: Perform ID detection. + - ti,enable-vbus-detection: Perform VBUS detection. palmas-usb { compatible = "ti,twl6035-usb", "ti,palmas-usb";
drivers/extcon/extcon-palmas.c +53 -34
133 lines not on this page · raw message
include/linux/mfd/palmas.h +3 -0
@@ -377,6 +377,9 @@ struct palmas_usb {int vbus_irq;enum palmas_usb_state linkstat; +int wakeup; +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
Chanwoo Choi
maintainerHi Laxman,
Quoted 21 lines
static int
palmas_usb_probe(struct platform_device *pdev)(quoted diff) +9
-6@@ -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");
Review static int palmas_usb_probe(struct platform_device *pdev) · line 161
Quoted 10 lines
(quoted diff) +7
-1+ } 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
drivers/extcon/extcon-palmas.c +4 -6
@@ -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
Quoted 27 lines · Chanwoo Choi
Hi Laxman,
Quoted 25 lines
static int
palmas_usb_probe(struct platform_device *pdev)(quoted diff) +13
-6@@ -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;
Quoted 9 lines
Review static int palmas_usb_probe(struct platform_device *pdev) · line 161
Quoted 6 lines
(quoted diff) +3
-1} 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.
Chanwoo Choi
maintainerQuoted 35 lines · Laxman Dewangan
Quoted 25 lines · Chanwoo Choi
Hi Laxman,
Quoted 23 lines
static int
palmas_usb_probe(struct platform_device *pdev)(quoted diff) +13
-4@@ -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;Quoted 9 lines
Review static int palmas_usb_probe(struct platform_device *pdev) · line 161
Quoted 6 lines
(quoted diff) +3
-1} 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.
Quoted 4 lines
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