extcon: arizona: support inverted jack detect switch
Subsystems (3)
PATCH 1/1 extcon: arizona: support inverted jack detect switch
Add pdata option for inverted jack detect switch that opens when jack is inserted.
--- drivers/extcon/extcon-arizona.c | 29 +++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 24 insertions(+), 8 deletions(-)
drivers/extcon/extcon-arizona.c +21 -8
@@ -962,10 +962,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)if (arizona->pdata.jd_gpio5) { mask =ARIZONA_MICD_CLAMP_STS ; - present =0 ; +if (arizona->pdata.jd_invert) + present =ARIZONA_MICD_CLAMP_STS ; +else + present =0 ; }else { mask =ARIZONA_JD1_STS ; - present =ARIZONA_JD1_STS ; +if (arizona->pdata.jd_invert) + present =0 ; +else + present =ARIZONA_JD1_STS ; } ret =regmap_read (arizona->regmap,ARIZONA_AOD_IRQ_RAW_STATUS , &val);
@@ -1096,6 +1102,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)struct arizona_pdata *pdata = &arizona->pdata;struct arizona_extcon_info *info;unsigned int val; +unsigned int clamp_mode;int jack_irq_fall, jack_irq_rise;int ret, mode, i, j;
@@ -1302,16 +1309,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)regmap_write (arizona->regmap,ARIZONA_GPIO5_CTRL , val); -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x9 ); +if (arizona->pdata.jd_invert) + clamp_mode =0xb ; +else + clamp_mode =0x9 ; }else { -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x4 ); +if (arizona->pdata.jd_invert) + clamp_mode =0x5 ; +else + clamp_mode =0x4 ; }regmap_update_bits (arizona->regmap, +ARIZONA_MICD_CLAMP_CONTROL , +ARIZONA_MICD_CLAMP_MODE_MASK , clamp_mode); + +regmap_update_bits (arizona->regmap,ARIZONA_JACK_DETECT_DEBOUNCE ,ARIZONA_MICD_CLAMP_DB ,ARIZONA_MICD_CLAMP_DB );
include/linux/mfd/arizona/pdata.h +3 -0
@@ -127,6 +127,9 @@ struct arizona_pdata {/** Internal pull on GPIO5 is disabled when used for jack detection */ bool jd_gpio5_nopull; +/** set to true if jackdet contact opens on insert */ +bool jd_invert; +/** Use the headphone detect circuit to identify the accessory */ bool hpdet_acc_id;
Signature · 1 line
1.7.2.5
Quoted 7 lines · Richard Fitzgerald
Add pdata option for inverted jack detect switch that opens when jack is inserted.
Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/extcon/extcon-arizona.c | 29 +++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++
For the MFD part:
Quoted 76 lines
2 files changed, 24 insertions(+), 8 deletions(-)drivers/extcon/extcon-arizona.c +21
-8@@ -962,10 +962,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)if (arizona->pdata.jd_gpio5) { mask =ARIZONA_MICD_CLAMP_STS ; - present =0 ; +if (arizona->pdata.jd_invert) + present =ARIZONA_MICD_CLAMP_STS ; +else + present =0 ; }else { mask =ARIZONA_JD1_STS ; - present =ARIZONA_JD1_STS ; +if (arizona->pdata.jd_invert) + present =0 ; +else + present =ARIZONA_JD1_STS ; } ret =regmap_read (arizona->regmap,ARIZONA_AOD_IRQ_RAW_STATUS , &val);@@ -1096,6 +1102,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)struct arizona_pdata *pdata = &arizona->pdata;struct arizona_extcon_info *info;unsigned int val; +unsigned int clamp_mode;int jack_irq_fall, jack_irq_rise;int ret, mode, i, j;@@ -1302,16 +1309,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)regmap_write (arizona->regmap,ARIZONA_GPIO5_CTRL , val); -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x9 ); +if (arizona->pdata.jd_invert) + clamp_mode =0xb ; +else + clamp_mode =0x9 ; }else { -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x4 ); +if (arizona->pdata.jd_invert) + clamp_mode =0x5 ; +else + clamp_mode =0x4 ; }regmap_update_bits (arizona->regmap, +ARIZONA_MICD_CLAMP_CONTROL , +ARIZONA_MICD_CLAMP_MODE_MASK , clamp_mode); + +regmap_update_bits (arizona->regmap,ARIZONA_JACK_DETECT_DEBOUNCE ,ARIZONA_MICD_CLAMP_DB ,ARIZONA_MICD_CLAMP_DB );include/linux/mfd/arizona/pdata.h +3
-0@@ -127,6 +127,9 @@ struct arizona_pdata {/** Internal pull on GPIO5 is disabled when used for jack detection */ bool jd_gpio5_nopull; +/** set to true if jackdet contact opens on insert */ +bool jd_invert; +/** Use the headphone detect circuit to identify the accessory */ bool hpdet_acc_id;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Chanwoo Choi
maintainerHi Richard,
Quoted 41 lines · Richard Fitzgerald
Add pdata option for inverted jack detect switch that opens when jack is inserted.
Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/extcon/extcon-arizona.c | 29 +++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 24 insertions(+), 8 deletions(-)drivers/extcon/extcon-arizona.c +9
-2@@ -962,10 +962,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)if (arizona->pdata.jd_gpio5) { mask =ARIZONA_MICD_CLAMP_STS ; - present =0 ; +if (arizona->pdata.jd_invert) + present =ARIZONA_MICD_CLAMP_STS ; +else + present =0 ; }else { mask =ARIZONA_JD1_STS ; - present =ARIZONA_JD1_STS ; +if (arizona->pdata.jd_invert) + present =0 ; +else + present =ARIZONA_JD1_STS ; } ret =regmap_read (arizona->regmap,ARIZONA_AOD_IRQ_RAW_STATUS , &val);@@ -1096,6 +1102,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)struct arizona_pdata *pdata = &arizona->pdata;struct arizona_extcon_info *info;unsigned int val; +unsigned int clamp_mode;int jack_irq_fall, jack_irq_rise;int ret, mode, i, j;
drivers/extcon/extcon-arizona.c static int arizona_extcon_probe(struct platform_device *pdev) · line 1313
Quoted 8 lines
drivers/extcon/extcon-arizona.c +2
-3@@ -1302,16 +1309,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)regmap_write (arizona->regmap,ARIZONA_GPIO5_CTRL , val); -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x9 ); +if (arizona->pdata.jd_invert) + clamp_mode =0xb ;
What is meaning of '0xb'?
I prefer to use defined constant instead of using hex value directly.
For exmaple,
#define XXX_CLAMP_MODE 0xb
drivers/extcon/extcon-arizona.c static int arizona_extcon_probe(struct platform_device *pdev) · line 1315
Quoted 2 lines
drivers/extcon/extcon-arizona.c +2
-0+else + clamp_mode =0x9 ;
ditto.
drivers/extcon/extcon-arizona.c static int arizona_extcon_probe(struct platform_device *pdev) · line 1318
Quoted 6 lines
drivers/extcon/extcon-arizona.c +2
-3}else { -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x4 ); +if (arizona->pdata.jd_invert) + clamp_mode =0x5 ;
ditto.
drivers/extcon/extcon-arizona.c static int arizona_extcon_probe(struct platform_device *pdev) · line 1320
Quoted 2 lines
drivers/extcon/extcon-arizona.c +2
-0+else + clamp_mode =0x4 ;
ditto.
Quoted 16 lines
drivers/extcon/extcon-arizona.c +4
-0}regmap_update_bits (arizona->regmap, +ARIZONA_MICD_CLAMP_CONTROL , +ARIZONA_MICD_CLAMP_MODE_MASK , clamp_mode); + +regmap_update_bits (arizona->regmap,ARIZONA_JACK_DETECT_DEBOUNCE ,ARIZONA_MICD_CLAMP_DB ,ARIZONA_MICD_CLAMP_DB );include/linux/mfd/arizona/pdata.h +0
-0
include/linux/mfd/arizona/pdata.h struct arizona_pdata { · line 135
Quoted 9 lines
include/linux/mfd/arizona/pdata.h +3
-0@@ -127,6 +127,9 @@ struct arizona_pdata {/** Internal pull on GPIO5 is disabled when used for jack detection */ bool jd_gpio5_nopull; +/** set to true if jackdet contact opens on insert */ +bool jd_invert; +/** Use the headphone detect circuit to identify the accessory */ bool hpdet_acc_id;
Thanks,
Chanwoo Choi
Add config option for inverted jack detect switch that opens when jack is inserted.
--- drivers/extcon/extcon-arizona.c | 34 ++++++++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 29 insertions(+), 8 deletions(-)
drivers/extcon/extcon-arizona.c +26 -8
@@ -39,6 +39,11 @@#define ARIZONA_ACCDET_MODE_HPL 1#define ARIZONA_ACCDET_MODE_HPR 2 +#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4 +#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5 +#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9 +#define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb +#define ARIZONA_HPDET_MAX 10000#define HPDET_DEBOUNCE 500
@@ -962,10 +967,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)if (arizona->pdata.jd_gpio5) { mask =ARIZONA_MICD_CLAMP_STS ; - present =0 ; +if (arizona->pdata.jd_invert) + present =ARIZONA_MICD_CLAMP_STS ; +else + present =0 ; }else { mask =ARIZONA_JD1_STS ; - present =ARIZONA_JD1_STS ; +if (arizona->pdata.jd_invert) + present =0 ; +else + present =ARIZONA_JD1_STS ; } ret =regmap_read (arizona->regmap,ARIZONA_AOD_IRQ_RAW_STATUS , &val);
@@ -1096,6 +1107,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)struct arizona_pdata *pdata = &arizona->pdata;struct arizona_extcon_info *info;unsigned int val; +unsigned int clamp_mode;int jack_irq_fall, jack_irq_rise;int ret, mode, i, j;
@@ -1302,16 +1314,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)regmap_write (arizona->regmap,ARIZONA_GPIO5_CTRL , val); -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x9 ); +if (arizona->pdata.jd_invert) + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDH_GP5H ; +else + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDL_GP5H ; }else { -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x4 ); +if (arizona->pdata.jd_invert) + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDH ; +else + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDL ; }regmap_update_bits (arizona->regmap, +ARIZONA_MICD_CLAMP_CONTROL , +ARIZONA_MICD_CLAMP_MODE_MASK , clamp_mode); + +regmap_update_bits (arizona->regmap,ARIZONA_JACK_DETECT_DEBOUNCE ,ARIZONA_MICD_CLAMP_DB ,ARIZONA_MICD_CLAMP_DB );
include/linux/mfd/arizona/pdata.h +3 -0
@@ -127,6 +127,9 @@ struct arizona_pdata {/** Internal pull on GPIO5 is disabled when used for jack detection */ bool jd_gpio5_nopull; +/** set to true if jackdet contact opens on insert */ +bool jd_invert; +/** Use the headphone detect circuit to identify the accessory */ bool hpdet_acc_id;
Signature · 1 line
1.7.2.5
Quoted 4 lines
Add config option for inverted jack detect switch that opens when jack is inserted.
Signed-off-by Richard Fitzgerald <[email protected]>
I already Acked this. Don't forget to carry that forward to mitigate adding unnecessary delay to acceptance.
Quoted 91 lines
--- drivers/extcon/extcon-arizona.c | 34 ++++++++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 29 insertions(+), 8 deletions(-)drivers/extcon/extcon-arizona.c +26
-8@@ -39,6 +39,11 @@#define ARIZONA_ACCDET_MODE_HPL 1#define ARIZONA_ACCDET_MODE_HPR 2 +#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4 +#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5 +#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9 +#define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb +#define ARIZONA_HPDET_MAX 10000#define HPDET_DEBOUNCE 500@@ -962,10 +967,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)if (arizona->pdata.jd_gpio5) { mask =ARIZONA_MICD_CLAMP_STS ; - present =0 ; +if (arizona->pdata.jd_invert) + present =ARIZONA_MICD_CLAMP_STS ; +else + present =0 ; }else { mask =ARIZONA_JD1_STS ; - present =ARIZONA_JD1_STS ; +if (arizona->pdata.jd_invert) + present =0 ; +else + present =ARIZONA_JD1_STS ; } ret =regmap_read (arizona->regmap,ARIZONA_AOD_IRQ_RAW_STATUS , &val);@@ -1096,6 +1107,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)struct arizona_pdata *pdata = &arizona->pdata;struct arizona_extcon_info *info;unsigned int val; +unsigned int clamp_mode;int jack_irq_fall, jack_irq_rise;int ret, mode, i, j;@@ -1302,16 +1314,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)regmap_write (arizona->regmap,ARIZONA_GPIO5_CTRL , val); -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x9 ); +if (arizona->pdata.jd_invert) + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDH_GP5H ; +else + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDL_GP5H ; }else { -regmap_update_bits (arizona->regmap, -ARIZONA_MICD_CLAMP_CONTROL , -ARIZONA_MICD_CLAMP_MODE_MASK ,0x4 ); +if (arizona->pdata.jd_invert) + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDH ; +else + clamp_mode =ARIZONA_MICD_CLAMP_MODE_JDL ; }regmap_update_bits (arizona->regmap, +ARIZONA_MICD_CLAMP_CONTROL , +ARIZONA_MICD_CLAMP_MODE_MASK , clamp_mode); + +regmap_update_bits (arizona->regmap,ARIZONA_JACK_DETECT_DEBOUNCE ,ARIZONA_MICD_CLAMP_DB ,ARIZONA_MICD_CLAMP_DB );include/linux/mfd/arizona/pdata.h +3
-0@@ -127,6 +127,9 @@ struct arizona_pdata {/** Internal pull on GPIO5 is disabled when used for jack detection */ bool jd_gpio5_nopull; +/** set to true if jackdet contact opens on insert */ +bool jd_invert; +/** Use the headphone detect circuit to identify the accessory */ bool hpdet_acc_id;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 8 lines · Richard Fitzgerald
Add config option for inverted jack detect switch that opens when jack is inserted.
Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/extcon/extcon-arizona.c | 34 ++++++++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 +++ 2 files changed, 29 insertions(+), 8 deletions(-)
Applied.
Thanks,
Chanwoo Choi