From 0a562e73fa7b1eeb26031af067506d3201b2b4cf Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 1 Mar 2018 15:18:55 +0000 Subject: [PATCH] extcon: madera: Support CS47L15 The CS47L15 accessory detect is similar to CS47L90 ACCDET1, but has a 33 ohm offset and detection range 00 is not used Change-Id: I9672c990d7688cecfbc46dcdd3f8b06c93d40eb2 Signed-off-by: Richard Fitzgerald Signed-off-by: Charles Keepax --- .../bindings/extcon/extcon-madera.txt | 6 ++-- drivers/extcon/extcon-madera.c | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/extcon/extcon-madera.txt b/Documentation/devicetree/bindings/extcon/extcon-madera.txt index 16add298be40..781058cbc804 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-madera.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-madera.txt @@ -16,7 +16,7 @@ Optional properties: - cirrus,gpsw : Settings for the general purpose switches, set as per the SWn_MODE bits in the GP Switch 1 register. If given must be 2 cells. First cell is the value for the SW1_MODE - Second cell is the value for the SW2_MODE (cs47l90, cs47l91) + Second cell is the value for the SW2_MODE (cs47l15, cs47l90, cs47l91) - cirrus,micd-pol-gpios : GPIO specifier for the GPIO controlling the headset polarity if one exists. One cell for each child node. @@ -87,7 +87,7 @@ Child node optional properties: must be a multiple of 5 cells, each 5-cell group represents one polarity configuration first cell is the value of - ACCDET_SRC register field (CS47L35, CS47L85, WM1840), + ACCDET_SRC register field (CS47L15, CS47L35, CS47L85, WM1840), MICD_SENSE_SEL register field (all other codecs) second cell is the accessory detection ground as per the MICD_GND_SEL register field @@ -96,7 +96,7 @@ Child node optional properties: fourth cell is the value of the micd-pol-gpio pin, a non-zero value indicates this should be on fifth cell is - set to zero (cs47l35, cs47l85, wm1840) + set to zero (cs47l15, cs47l35, cs47l85, wm1840) value of HPn_GND_SEL register field (all other codecs) Example: diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index 8cf2918274b4..e554f034dc95 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -638,6 +638,7 @@ static void madera_extcon_hp_clamp(struct madera_extcon *info, bool clamp) snd_soc_dapm_mutex_lock(madera->dapm); switch (madera->type) { + case CS47L15: case CS47L35: case CS47L92: case CS47L93: @@ -757,6 +758,16 @@ static const char *madera_extcon_get_micbias_src(struct madera_extcon *info) unsigned int bias = info->micd_modes[info->micd_mode].bias; switch (madera->type) { + case CS47L15: + switch (bias) { + case 0: + case 1: + case 2: + return "MICBIAS1"; + default: + return "MICVDD"; + } + break; case CS47L35: case CS47L85: case WM1840: @@ -804,6 +815,17 @@ static const char *madera_extcon_get_micbias(struct madera_extcon *info) unsigned int bias = info->micd_modes[info->micd_mode].bias; switch (madera->type) { + case CS47L15: + switch (bias) { + case 0: + return "MICBIAS1A"; + case 1: + return "MICBIAS1B"; + case 2: + return "MICBIAS1C"; + default: + return "MICVDD"; + } case CS47L35: switch (bias) { case 1: @@ -2953,6 +2975,9 @@ static int madera_extcon_probe(struct platform_device *pdev) info->micd_modes = madera_micd_default_modes; info->num_micd_modes = ARRAY_SIZE(madera_micd_default_modes); break; + case CS47L15: + info->hpdet_init_range = 1; /* range 0 not used on CS47L15 */ + /* fall through to default case */ default: info->hpdet_ranges = madera_hpdet_ranges; info->num_hpdet_ranges = ARRAY_SIZE(madera_hpdet_ranges); @@ -3137,6 +3162,14 @@ static int madera_extcon_probe(struct platform_device *pdev) default: break; } + } else { + switch (madera->type) { + case CS47L15: + pdata->hpdet_ext_res_x100 += 3300; + break; + default: + break; + } } /* Skip any HPDET ranges less than the external resistance */ -- 2.20.1