The newer devices support using a software comparison to determine
whether a 3/4 pole jack is present. Add the registers necessary for
this.
Signed-off-by: Charles Keepax <[email protected]>
---
Hi,
The first two MFD patches and the two extcon patches need to
go through together as there are build dependencies. However
the last documentation update can be treated seperately.
The patches are based of the extcon/extcon-next tree because
that is where most of the changes are but let me know if an
MFD based version would be preferred.
Thanks,
Charles
drivers/mfd/wm5110-tables.c | 2 ++
include/dt-bindings/mfd/arizona.h | 2 ++
include/linux/mfd/arizona/pdata.h | 3 +++
include/linux/mfd/arizona/registers.h | 17 ++++++++++++++---
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index 12cad94..dd27872 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -1807,6 +1807,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
case ARIZONA_MIC_DETECT_1:
case ARIZONA_MIC_DETECT_2:
case ARIZONA_MIC_DETECT_3:
+ case ARIZONA_MIC_DETECT_4:
case ARIZONA_MIC_DETECT_LEVEL_1:
case ARIZONA_MIC_DETECT_LEVEL_2:
case ARIZONA_MIC_DETECT_LEVEL_3:
@@ -2843,6 +2844,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS:
case ARIZONA_MIC_DETECT_3:
+ case ARIZONA_MIC_DETECT_4:
case ARIZONA_HP_CTRL_1L:
case ARIZONA_HP_CTRL_1R:
case ARIZONA_HEADPHONE_DETECT_2:
diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
index 7b2000c..c40f665 100644
--- a/include/dt-bindings/mfd/arizona.h
+++ b/include/dt-bindings/mfd/arizona.h
@@ -107,5 +107,7 @@
#define ARIZONA_ACCDET_MODE_MIC 0
#define ARIZONA_ACCDET_MODE_HPL 1
#define ARIZONA_ACCDET_MODE_HPR 2
+#define ARIZONA_ACCDET_MODE_HPM 4
+#define ARIZONA_ACCDET_MODE_ADC 7
#endif
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 43db4fa..f030a32 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -124,6 +124,9 @@ struct arizona_pdata {
/** Channel to use for headphone detection */
unsigned int hpdet_channel;
+ /** Use software comparison to determine mic presence */
+ bool micd_software_compare;
+
/** Extra debounce timeout used during initial mic detection (ms) */
int micd_detect_debounce;
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index 3499d36..3f3bb2b 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -139,6 +139,7 @@
#define ARIZONA_MIC_DETECT_LEVEL_2 0x2A7
#define ARIZONA_MIC_DETECT_LEVEL_3 0x2A8
#define ARIZONA_MIC_DETECT_LEVEL_4 0x2A9
+#define ARIZONA_MIC_DETECT_4 0x2AB
#define ARIZONA_MIC_NOISE_MIX_CONTROL_1 0x2C3
#define ARIZONA_ISOLATION_CONTROL 0x2CB
#define ARIZONA_JACK_DETECT_ANALOGUE 0x2D3
@@ -2301,9 +2302,9 @@
#define ARIZONA_ACCDET_SRC_MASK 0x2000 /* ACCDET_SRC */
#define ARIZONA_ACCDET_SRC_SHIFT 13 /* ACCDET_SRC */
#define ARIZONA_ACCDET_SRC_WIDTH 1 /* ACCDET_SRC */
-#define ARIZONA_ACCDET_MODE_MASK 0x0003 /* ACCDET_MODE - [1:0] */
-#define ARIZONA_ACCDET_MODE_SHIFT 0 /* ACCDET_MODE - [1:0] */
-#define ARIZONA_ACCDET_MODE_WIDTH 2 /* ACCDET_MODE - [1:0] */
+#define ARIZONA_ACCDET_MODE_MASK 0x0007 /* ACCDET_MODE - [2:0] */
+#define ARIZONA_ACCDET_MODE_SHIFT 0 /* ACCDET_MODE - [2:0] */
+#define ARIZONA_ACCDET_MODE_WIDTH 3 /* ACCDET_MODE - [2:0] */
/*
* R667 (0x29B) - Headphone Detect 1
@@ -2413,6 +2414,16 @@
#define ARIZONA_MICD_STS_WIDTH 1 /* MICD_STS */
/*
+ * R683 (0x2AB) - Mic Detect 4
+ */
+#define ARIZONA_MICDET_ADCVAL_DIFF_MASK 0xFF00 /* MICDET_ADCVAL_DIFF - [15:8] */
+#define ARIZONA_MICDET_ADCVAL_DIFF_SHIFT 8 /* MICDET_ADCVAL_DIFF - [15:8] */
+#define ARIZONA_MICDET_ADCVAL_DIFF_WIDTH 8 /* MICDET_ADCVAL_DIFF - [15:8] */
+#define ARIZONA_MICDET_ADCVAL_MASK 0x007F /* MICDET_ADCVAL - [15:8] */
+#define ARIZONA_MICDET_ADCVAL_SHIFT 0 /* MICDET_ADCVAL - [15:8] */
+#define ARIZONA_MICDET_ADCVAL_WIDTH 7 /* MICDET_ADCVAL - [15:8] */
+
+/*
* R707 (0x2C3) - Mic noise mix control 1
*/
#define ARIZONA_MICMUTE_RATE_MASK 0x7800 /* MICMUTE_RATE - [14:11] */
--
1.7.2.5
Newer devices give users the option to make the 3/4 pole jack
determination using a software comparison rather than a hardware one.
This patch adds support for this functionality.
Signed-off-by: Charles Keepax <[email protected]>
---
drivers/extcon/extcon-arizona.c | 67 +++++++++++++++++++++++++++++++++++---
1 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 4b9f09c..f372156 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -48,6 +48,10 @@
#define HPDET_DEBOUNCE 500
#define DEFAULT_MICD_TIMEOUT 2000
+#define QUICK_HEADPHONE_MAX_OHM 3
+#define MICROPHONE_MIN_OHM 1257
+#define MICROPHONE_MAX_OHM 30000
+
#define MICD_DBTIME_TWO_READINGS 2
#define MICD_DBTIME_FOUR_READINGS 4
@@ -117,12 +121,15 @@ static const struct arizona_micd_range micd_default_ranges[] = {
{ .max = 430, .key = BTN_5 },
};
+/* The number of levels in arizona_micd_levels valid for button thresholds */
+#define ARIZONA_NUM_MICD_BUTTON_LEVELS 64
+
static const int arizona_micd_levels[] = {
3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 34, 36, 39, 41, 44, 46,
49, 52, 54, 57, 60, 62, 65, 67, 70, 73, 75, 78, 81, 83, 89, 94, 100,
105, 111, 116, 122, 127, 139, 150, 161, 173, 186, 196, 209, 220, 245,
270, 295, 321, 348, 375, 402, 430, 489, 550, 614, 681, 752, 903, 1071,
- 1257,
+ 1257, 30000,
};
static const unsigned int arizona_cable[] = {
@@ -270,6 +277,7 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
struct arizona *arizona = info->arizona;
bool change;
int ret;
+ unsigned int mode;
/* Microphone detection can't use idle mode */
pm_runtime_get(info->dev);
@@ -295,9 +303,14 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
regmap_write(arizona->regmap, 0x80, 0x0);
}
+ if (info->detecting && arizona->pdata.micd_software_compare)
+ mode = ARIZONA_ACCDET_MODE_ADC;
+ else
+ mode = ARIZONA_ACCDET_MODE_MIC;
+
regmap_update_bits(arizona->regmap,
ARIZONA_ACCESSORY_DETECT_MODE_1,
- ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
+ ARIZONA_ACCDET_MODE_MASK, mode);
arizona_extcon_pulse_micbias(info);
@@ -804,6 +817,37 @@ static void arizona_micd_detect(struct work_struct *work)
return;
}
+ if (info->detecting && arizona->pdata.micd_software_compare) {
+ /* Must disable MICD before we read the ADCVAL */
+ regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
+ ARIZONA_MICD_ENA, 0);
+ ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_4, &val);
+ if (ret != 0) {
+ dev_err(arizona->dev,
+ "Failed to read MICDET_ADCVAL: %d\n",
+ ret);
+ mutex_unlock(&info->lock);
+ return;
+ }
+
+ dev_dbg(arizona->dev, "MICDET_ADCVAL: %x\n", val);
+
+ val &= ARIZONA_MICDET_ADCVAL_MASK;
+ if (val < ARRAY_SIZE(arizona_micd_levels))
+ val = arizona_micd_levels[val];
+ else
+ val = INT_MAX;
+
+ if (val <= QUICK_HEADPHONE_MAX_OHM)
+ val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_0;
+ else if (val <= MICROPHONE_MIN_OHM)
+ val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_1;
+ else if (val <= MICROPHONE_MAX_OHM)
+ val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_8;
+ else
+ val = ARIZONA_MICD_LVL_8;
+ }
+
for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) {
ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
if (ret != 0) {
@@ -932,10 +976,17 @@ static void arizona_micd_detect(struct work_struct *work)
}
handled:
- if (info->detecting)
+ if (info->detecting) {
+ if (arizona->pdata.micd_software_compare)
+ regmap_update_bits(arizona->regmap,
+ ARIZONA_MIC_DETECT_1,
+ ARIZONA_MICD_ENA,
+ ARIZONA_MICD_ENA);
+
queue_delayed_work(system_power_efficient_wq,
&info->micd_timeout_work,
msecs_to_jiffies(info->micd_timeout));
+ }
pm_runtime_mark_last_busy(info->dev);
mutex_unlock(&info->lock);
@@ -1162,6 +1213,9 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
pdata->micd_force_micbias = device_property_read_bool(arizona->dev,
"wlf,micd-force-micbias");
+ pdata->micd_software_compare = device_property_read_bool(arizona->dev,
+ "wlf,micd-software-compare");
+
return 0;
}
@@ -1335,7 +1389,8 @@ static int arizona_extcon_probe(struct platform_device *pdev)
break;
}
- BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) != 0x40);
+ BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) <
+ ARIZONA_NUM_MICD_BUTTON_LEVELS);
if (arizona->pdata.num_micd_ranges) {
info->micd_ranges = pdata->micd_ranges;
@@ -1368,11 +1423,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
/* Set up all the buttons the user specified */
for (i = 0; i < info->num_micd_ranges; i++) {
- for (j = 0; j < ARRAY_SIZE(arizona_micd_levels); j++)
+ for (j = 0; j < ARIZONA_NUM_MICD_BUTTON_LEVELS; j++)
if (arizona_micd_levels[j] >= info->micd_ranges[i].max)
break;
- if (j == ARRAY_SIZE(arizona_micd_levels)) {
+ if (j == ARIZONA_NUM_MICD_BUTTON_LEVELS) {
dev_err(arizona->dev, "Unsupported MICD level %d\n",
info->micd_ranges[i].max);
ret = -EINVAL;
--
1.7.2.5
The switch is typically used in conjunction with the MICDET clamp in
order to suppress pops and clicks associated with jack insertion.
Signed-off-by: Charles Keepax <[email protected]>
---
drivers/mfd/wm5110-tables.c | 2 ++
include/linux/mfd/arizona/pdata.h | 3 +++
include/linux/mfd/arizona/registers.h | 8 ++++++++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index dd27872..acb3bb2 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -1472,6 +1472,7 @@ static const struct reg_default wm5110_reg_default[] = {
{ 0x00000C04, 0xA101 }, /* R3076 - GPIO5 CTRL */
{ 0x00000C0F, 0x0400 }, /* R3087 - IRQ CTRL 1 */
{ 0x00000C10, 0x1000 }, /* R3088 - GPIO Debounce Config */
+ { 0x00000C18, 0x0000 }, /* R3096 - GP Switch 1 */
{ 0x00000C20, 0x8002 }, /* R3104 - Misc Pad Ctrl 1 */
{ 0x00000C21, 0x8001 }, /* R3105 - Misc Pad Ctrl 2 */
{ 0x00000C22, 0x0000 }, /* R3106 - Misc Pad Ctrl 3 */
@@ -2524,6 +2525,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
case ARIZONA_GPIO5_CTRL:
case ARIZONA_IRQ_CTRL_1:
case ARIZONA_GPIO_DEBOUNCE_CONFIG:
+ case ARIZONA_GP_SWITCH_1:
case ARIZONA_MISC_PAD_CTRL_1:
case ARIZONA_MISC_PAD_CTRL_2:
case ARIZONA_MISC_PAD_CTRL_3:
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index f030a32..e76577b 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -182,6 +182,9 @@ struct arizona_pdata {
/** GPIO for primary IRQ (used for edge triggered emulation) */
int irq_gpio;
+
+ /** General purpose switch control */
+ unsigned int gpsw;
};
#endif
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index 3f3bb2b..e96644c 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -869,6 +869,7 @@
#define ARIZONA_GPIO5_CTRL 0xC04
#define ARIZONA_IRQ_CTRL_1 0xC0F
#define ARIZONA_GPIO_DEBOUNCE_CONFIG 0xC10
+#define ARIZONA_GP_SWITCH_1 0xC18
#define ARIZONA_MISC_PAD_CTRL_1 0xC20
#define ARIZONA_MISC_PAD_CTRL_2 0xC21
#define ARIZONA_MISC_PAD_CTRL_3 0xC22
@@ -4573,6 +4574,13 @@
#define ARIZONA_GP_DBTIME_WIDTH 4 /* GP_DBTIME - [15:12] */
/*
+ * R3096 (0xC18) - GP Switch 1
+ */
+#define ARIZONA_SW1_MODE_MASK 0x0003 /* SW1_MODE - [1:0] */
+#define ARIZONA_SW1_MODE_SHIFT 0 /* SW1_MODE - [1:0] */
+#define ARIZONA_SW1_MODE_WIDTH 2 /* SW1_MODE - [1:0] */
+
+/*
* R3104 (0xC20) - Misc Pad Ctrl 1
*/
#define ARIZONA_LDO1ENA_PD 0x8000 /* LDO1ENA_PD */
--
1.7.2.5
The switch is typically used in conjunction with the MICDET clamp in
order to suppress pops and clicks associated with jack insertion.
Signed-off-by: Charles Keepax <[email protected]>
---
drivers/extcon/extcon-arizona.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index f372156..b48fb29 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1216,6 +1216,8 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
pdata->micd_software_compare = device_property_read_bool(arizona->dev,
"wlf,micd-software-compare");
+ device_property_read_u32(arizona->dev, "wlf,gpsw", &pdata->gpsw);
+
return 0;
}
@@ -1313,6 +1315,10 @@ static int arizona_extcon_probe(struct platform_device *pdev)
info->micd_num_modes = ARRAY_SIZE(micd_default_modes);
}
+ if (arizona->pdata.gpsw > 0)
+ regmap_update_bits(arizona->regmap, ARIZONA_GP_SWITCH_1,
+ ARIZONA_SW1_MODE_MASK, arizona->pdata.gpsw);
+
if (arizona->pdata.micd_pol_gpio > 0) {
if (info->micd_modes[0].gpio)
mode = GPIOF_OUT_INIT_HIGH;
--
1.7.2.5
Signed-off-by: Charles Keepax <[email protected]>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 21 +++++++++++++++++++++
include/dt-bindings/mfd/arizona.h | 5 +++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index a8fee60..b98a11b 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -73,6 +73,27 @@ Optional properties:
If this node is not mentioned or if the value is unknown, then
headphone detection mode is set to HPDETL.
+ - wlf,micd-software-compare : Use a software comparison to determine mic
+ presence
+ - wlf,micd-detect-debounce : Additional software microphone detection
+ debounce specified in milliseconds.
+ - wlf,micd-pol-gpio : GPIO specifier for the GPIO controlling the headset
+ polarity if one exists.
+ - wlf,micd-bias-start-time : Time allowed for MICBIAS to startup prior to
+ performing microphone detection, specified as per the ARIZONA_MICD_TIME_XXX
+ defines.
+ - wlf,micd-rate : Delay between successive microphone detection measurements,
+ specified as per the ARIZONA_MICD_TIME_XXX defines.
+ - wlf,micd-dbtime : Microphone detection hardware debounces specified as the
+ number of measurements to take, valid values being 2 and 4.
+ - wlf,micd-timeout : Timeout for microphone detection, specified in
+ milliseconds.
+ - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone
+ detection.
+
+ - wlf,gpsw : Settings for the general purpose switch, set as one of the
+ ARIZONA_GPSW_XXX defines.
+
- DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
they are being externally supplied. As covered in
Documentation/devicetree/bindings/regulator/regulator.txt
diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
index c40f665..dedf46f 100644
--- a/include/dt-bindings/mfd/arizona.h
+++ b/include/dt-bindings/mfd/arizona.h
@@ -110,4 +110,9 @@
#define ARIZONA_ACCDET_MODE_HPM 4
#define ARIZONA_ACCDET_MODE_ADC 7
+#define ARIZONA_GPSW_OPEN 0
+#define ARIZONA_GPSW_CLOSED 1
+#define ARIZONA_GPSW_CLAMP_ENABLED 2
+#define ARIZONA_GPSW_CLAMP_DISABLED 3
+
#endif
--
1.7.2.5
DT Ack required.
On Tue, 11 Aug 2015, Charles Keepax wrote:
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> Documentation/devicetree/bindings/mfd/arizona.txt | 21 +++++++++++++++++++++
> include/dt-bindings/mfd/arizona.h | 5 +++++
> 2 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index a8fee60..b98a11b 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -73,6 +73,27 @@ Optional properties:
> If this node is not mentioned or if the value is unknown, then
> headphone detection mode is set to HPDETL.
>
> + - wlf,micd-software-compare : Use a software comparison to determine mic
> + presence
> + - wlf,micd-detect-debounce : Additional software microphone detection
> + debounce specified in milliseconds.
> + - wlf,micd-pol-gpio : GPIO specifier for the GPIO controlling the headset
> + polarity if one exists.
> + - wlf,micd-bias-start-time : Time allowed for MICBIAS to startup prior to
> + performing microphone detection, specified as per the ARIZONA_MICD_TIME_XXX
> + defines.
> + - wlf,micd-rate : Delay between successive microphone detection measurements,
> + specified as per the ARIZONA_MICD_TIME_XXX defines.
> + - wlf,micd-dbtime : Microphone detection hardware debounces specified as the
> + number of measurements to take, valid values being 2 and 4.
> + - wlf,micd-timeout : Timeout for microphone detection, specified in
> + milliseconds.
> + - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone
> + detection.
> +
> + - wlf,gpsw : Settings for the general purpose switch, set as one of the
> + ARIZONA_GPSW_XXX defines.
> +
> - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
> they are being externally supplied. As covered in
> Documentation/devicetree/bindings/regulator/regulator.txt
> diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
> index c40f665..dedf46f 100644
> --- a/include/dt-bindings/mfd/arizona.h
> +++ b/include/dt-bindings/mfd/arizona.h
> @@ -110,4 +110,9 @@
> #define ARIZONA_ACCDET_MODE_HPM 4
> #define ARIZONA_ACCDET_MODE_ADC 7
>
> +#define ARIZONA_GPSW_OPEN 0
> +#define ARIZONA_GPSW_CLOSED 1
> +#define ARIZONA_GPSW_CLAMP_ENABLED 2
> +#define ARIZONA_GPSW_CLAMP_DISABLED 3
> +
> #endif
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 11 Aug 2015, Charles Keepax wrote:
> The newer devices support using a software comparison to determine
> whether a 3/4 pole jack is present. Add the registers necessary for
> this.
>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
>
> Hi,
>
> The first two MFD patches and the two extcon patches need to
> go through together as there are build dependencies. However
> the last documentation update can be treated seperately.
>
> The patches are based of the extcon/extcon-next tree because
> that is where most of the changes are but let me know if an
> MFD based version would be preferred.
>
> Thanks,
> Charles
>
> drivers/mfd/wm5110-tables.c | 2 ++
> include/dt-bindings/mfd/arizona.h | 2 ++
> include/linux/mfd/arizona/pdata.h | 3 +++
> include/linux/mfd/arizona/registers.h | 17 ++++++++++++++---
> 4 files changed, 21 insertions(+), 3 deletions(-)
Acked-by: Lee Jones <[email protected]>
> diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
> index 12cad94..dd27872 100644
> --- a/drivers/mfd/wm5110-tables.c
> +++ b/drivers/mfd/wm5110-tables.c
> @@ -1807,6 +1807,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
> case ARIZONA_MIC_DETECT_1:
> case ARIZONA_MIC_DETECT_2:
> case ARIZONA_MIC_DETECT_3:
> + case ARIZONA_MIC_DETECT_4:
> case ARIZONA_MIC_DETECT_LEVEL_1:
> case ARIZONA_MIC_DETECT_LEVEL_2:
> case ARIZONA_MIC_DETECT_LEVEL_3:
> @@ -2843,6 +2844,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
> case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
> case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS:
> case ARIZONA_MIC_DETECT_3:
> + case ARIZONA_MIC_DETECT_4:
> case ARIZONA_HP_CTRL_1L:
> case ARIZONA_HP_CTRL_1R:
> case ARIZONA_HEADPHONE_DETECT_2:
> diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
> index 7b2000c..c40f665 100644
> --- a/include/dt-bindings/mfd/arizona.h
> +++ b/include/dt-bindings/mfd/arizona.h
> @@ -107,5 +107,7 @@
> #define ARIZONA_ACCDET_MODE_MIC 0
> #define ARIZONA_ACCDET_MODE_HPL 1
> #define ARIZONA_ACCDET_MODE_HPR 2
> +#define ARIZONA_ACCDET_MODE_HPM 4
> +#define ARIZONA_ACCDET_MODE_ADC 7
>
> #endif
> diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
> index 43db4fa..f030a32 100644
> --- a/include/linux/mfd/arizona/pdata.h
> +++ b/include/linux/mfd/arizona/pdata.h
> @@ -124,6 +124,9 @@ struct arizona_pdata {
> /** Channel to use for headphone detection */
> unsigned int hpdet_channel;
>
> + /** Use software comparison to determine mic presence */
> + bool micd_software_compare;
> +
> /** Extra debounce timeout used during initial mic detection (ms) */
> int micd_detect_debounce;
>
> diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
> index 3499d36..3f3bb2b 100644
> --- a/include/linux/mfd/arizona/registers.h
> +++ b/include/linux/mfd/arizona/registers.h
> @@ -139,6 +139,7 @@
> #define ARIZONA_MIC_DETECT_LEVEL_2 0x2A7
> #define ARIZONA_MIC_DETECT_LEVEL_3 0x2A8
> #define ARIZONA_MIC_DETECT_LEVEL_4 0x2A9
> +#define ARIZONA_MIC_DETECT_4 0x2AB
> #define ARIZONA_MIC_NOISE_MIX_CONTROL_1 0x2C3
> #define ARIZONA_ISOLATION_CONTROL 0x2CB
> #define ARIZONA_JACK_DETECT_ANALOGUE 0x2D3
> @@ -2301,9 +2302,9 @@
> #define ARIZONA_ACCDET_SRC_MASK 0x2000 /* ACCDET_SRC */
> #define ARIZONA_ACCDET_SRC_SHIFT 13 /* ACCDET_SRC */
> #define ARIZONA_ACCDET_SRC_WIDTH 1 /* ACCDET_SRC */
> -#define ARIZONA_ACCDET_MODE_MASK 0x0003 /* ACCDET_MODE - [1:0] */
> -#define ARIZONA_ACCDET_MODE_SHIFT 0 /* ACCDET_MODE - [1:0] */
> -#define ARIZONA_ACCDET_MODE_WIDTH 2 /* ACCDET_MODE - [1:0] */
> +#define ARIZONA_ACCDET_MODE_MASK 0x0007 /* ACCDET_MODE - [2:0] */
> +#define ARIZONA_ACCDET_MODE_SHIFT 0 /* ACCDET_MODE - [2:0] */
> +#define ARIZONA_ACCDET_MODE_WIDTH 3 /* ACCDET_MODE - [2:0] */
>
> /*
> * R667 (0x29B) - Headphone Detect 1
> @@ -2413,6 +2414,16 @@
> #define ARIZONA_MICD_STS_WIDTH 1 /* MICD_STS */
>
> /*
> + * R683 (0x2AB) - Mic Detect 4
> + */
> +#define ARIZONA_MICDET_ADCVAL_DIFF_MASK 0xFF00 /* MICDET_ADCVAL_DIFF - [15:8] */
> +#define ARIZONA_MICDET_ADCVAL_DIFF_SHIFT 8 /* MICDET_ADCVAL_DIFF - [15:8] */
> +#define ARIZONA_MICDET_ADCVAL_DIFF_WIDTH 8 /* MICDET_ADCVAL_DIFF - [15:8] */
> +#define ARIZONA_MICDET_ADCVAL_MASK 0x007F /* MICDET_ADCVAL - [15:8] */
> +#define ARIZONA_MICDET_ADCVAL_SHIFT 0 /* MICDET_ADCVAL - [15:8] */
> +#define ARIZONA_MICDET_ADCVAL_WIDTH 7 /* MICDET_ADCVAL - [15:8] */
> +
> +/*
> * R707 (0x2C3) - Mic noise mix control 1
> */
> #define ARIZONA_MICMUTE_RATE_MASK 0x7800 /* MICMUTE_RATE - [14:11] */
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 11 Aug 2015, Charles Keepax wrote:
> The switch is typically used in conjunction with the MICDET clamp in
> order to suppress pops and clicks associated with jack insertion.
>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> drivers/mfd/wm5110-tables.c | 2 ++
> include/linux/mfd/arizona/pdata.h | 3 +++
> include/linux/mfd/arizona/registers.h | 8 ++++++++
> 3 files changed, 13 insertions(+), 0 deletions(-)
Acked-by: Lee Jones <[email protected]>
> diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
> index dd27872..acb3bb2 100644
> --- a/drivers/mfd/wm5110-tables.c
> +++ b/drivers/mfd/wm5110-tables.c
> @@ -1472,6 +1472,7 @@ static const struct reg_default wm5110_reg_default[] = {
> { 0x00000C04, 0xA101 }, /* R3076 - GPIO5 CTRL */
> { 0x00000C0F, 0x0400 }, /* R3087 - IRQ CTRL 1 */
> { 0x00000C10, 0x1000 }, /* R3088 - GPIO Debounce Config */
> + { 0x00000C18, 0x0000 }, /* R3096 - GP Switch 1 */
> { 0x00000C20, 0x8002 }, /* R3104 - Misc Pad Ctrl 1 */
> { 0x00000C21, 0x8001 }, /* R3105 - Misc Pad Ctrl 2 */
> { 0x00000C22, 0x0000 }, /* R3106 - Misc Pad Ctrl 3 */
> @@ -2524,6 +2525,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
> case ARIZONA_GPIO5_CTRL:
> case ARIZONA_IRQ_CTRL_1:
> case ARIZONA_GPIO_DEBOUNCE_CONFIG:
> + case ARIZONA_GP_SWITCH_1:
> case ARIZONA_MISC_PAD_CTRL_1:
> case ARIZONA_MISC_PAD_CTRL_2:
> case ARIZONA_MISC_PAD_CTRL_3:
> diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
> index f030a32..e76577b 100644
> --- a/include/linux/mfd/arizona/pdata.h
> +++ b/include/linux/mfd/arizona/pdata.h
> @@ -182,6 +182,9 @@ struct arizona_pdata {
>
> /** GPIO for primary IRQ (used for edge triggered emulation) */
> int irq_gpio;
> +
> + /** General purpose switch control */
> + unsigned int gpsw;
> };
>
> #endif
> diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
> index 3f3bb2b..e96644c 100644
> --- a/include/linux/mfd/arizona/registers.h
> +++ b/include/linux/mfd/arizona/registers.h
> @@ -869,6 +869,7 @@
> #define ARIZONA_GPIO5_CTRL 0xC04
> #define ARIZONA_IRQ_CTRL_1 0xC0F
> #define ARIZONA_GPIO_DEBOUNCE_CONFIG 0xC10
> +#define ARIZONA_GP_SWITCH_1 0xC18
> #define ARIZONA_MISC_PAD_CTRL_1 0xC20
> #define ARIZONA_MISC_PAD_CTRL_2 0xC21
> #define ARIZONA_MISC_PAD_CTRL_3 0xC22
> @@ -4573,6 +4574,13 @@
> #define ARIZONA_GP_DBTIME_WIDTH 4 /* GP_DBTIME - [15:12] */
>
> /*
> + * R3096 (0xC18) - GP Switch 1
> + */
> +#define ARIZONA_SW1_MODE_MASK 0x0003 /* SW1_MODE - [1:0] */
> +#define ARIZONA_SW1_MODE_SHIFT 0 /* SW1_MODE - [1:0] */
> +#define ARIZONA_SW1_MODE_WIDTH 2 /* SW1_MODE - [1:0] */
> +
> +/*
> * R3104 (0xC20) - Misc Pad Ctrl 1
> */
> #define ARIZONA_LDO1ENA_PD 0x8000 /* LDO1ENA_PD */
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog