aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-arizona.c
diff options
context:
space:
mode:
authorInha Song <ideal.song@samsung.com>2015-05-04 00:42:13 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2015-05-19 03:39:05 -0400
commit9e86b2ad4c11fd52ee8133abce7a29e0b32d29a7 (patch)
tree9b51091594489f7c44d686932111c121a7ffd3f8 /drivers/extcon/extcon-arizona.c
parent2b51f9c2f1bd43907e1dc75912de6f06c6f59860 (diff)
extcon: arizona: Add support for select accessory detect mode when headphone detection
This patch add support for select accessory detect mode to HPDETL or HPDETR. Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins to measure the impedance of an external load connected to the headphone. Depending on board design, headphone detect pins can change to HPDETR or HPDETL. Signed-off-by: Inha Song <ideal.song@samsung.com> Acked-by: Lee Jones <lee@kernel.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r--drivers/extcon/extcon-arizona.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 5e08c358649b..1ec06b4b4875 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -32,13 +32,10 @@
32#include <linux/mfd/arizona/core.h> 32#include <linux/mfd/arizona/core.h>
33#include <linux/mfd/arizona/pdata.h> 33#include <linux/mfd/arizona/pdata.h>
34#include <linux/mfd/arizona/registers.h> 34#include <linux/mfd/arizona/registers.h>
35#include <dt-bindings/mfd/arizona.h>
35 36
36#define ARIZONA_MAX_MICD_RANGE 8 37#define ARIZONA_MAX_MICD_RANGE 8
37 38
38#define ARIZONA_ACCDET_MODE_MIC 0
39#define ARIZONA_ACCDET_MODE_HPL 1
40#define ARIZONA_ACCDET_MODE_HPR 2
41
42#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4 39#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4
43#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5 40#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5
44#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9 41#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
@@ -671,9 +668,9 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
671 ret = regmap_update_bits(arizona->regmap, 668 ret = regmap_update_bits(arizona->regmap,
672 ARIZONA_ACCESSORY_DETECT_MODE_1, 669 ARIZONA_ACCESSORY_DETECT_MODE_1,
673 ARIZONA_ACCDET_MODE_MASK, 670 ARIZONA_ACCDET_MODE_MASK,
674 ARIZONA_ACCDET_MODE_HPL); 671 arizona->pdata.hpdet_channel);
675 if (ret != 0) { 672 if (ret != 0) {
676 dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret); 673 dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
677 goto err; 674 goto err;
678 } 675 }
679 676
@@ -723,9 +720,9 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
723 ARIZONA_ACCESSORY_DETECT_MODE_1, 720 ARIZONA_ACCESSORY_DETECT_MODE_1,
724 ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK, 721 ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK,
725 info->micd_modes[0].src | 722 info->micd_modes[0].src |
726 ARIZONA_ACCDET_MODE_HPL); 723 arizona->pdata.hpdet_channel);
727 if (ret != 0) { 724 if (ret != 0) {
728 dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret); 725 dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
729 goto err; 726 goto err;
730 } 727 }
731 728
@@ -1121,6 +1118,26 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
1121 regmap_update_bits(arizona->regmap, reg, mask, level); 1118 regmap_update_bits(arizona->regmap, reg, mask, level);
1122} 1119}
1123 1120
1121static int arizona_extcon_of_get_pdata(struct arizona *arizona)
1122{
1123 struct arizona_pdata *pdata = &arizona->pdata;
1124 unsigned int val = ARIZONA_ACCDET_MODE_HPL;
1125
1126 of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", &val);
1127 switch (val) {
1128 case ARIZONA_ACCDET_MODE_HPL:
1129 case ARIZONA_ACCDET_MODE_HPR:
1130 pdata->hpdet_channel = val;
1131 break;
1132 default:
1133 dev_err(arizona->dev,
1134 "Wrong wlf,hpdet-channel DT value %d\n", val);
1135 pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL;
1136 }
1137
1138 return 0;
1139}
1140
1124static int arizona_extcon_probe(struct platform_device *pdev) 1141static int arizona_extcon_probe(struct platform_device *pdev)
1125{ 1142{
1126 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1143 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -1138,6 +1155,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1138 if (!info) 1155 if (!info)
1139 return -ENOMEM; 1156 return -ENOMEM;
1140 1157
1158 if (IS_ENABLED(CONFIG_OF)) {
1159 if (!dev_get_platdata(arizona->dev))
1160 arizona_extcon_of_get_pdata(arizona);
1161 }
1162
1141 info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); 1163 info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
1142 if (IS_ERR(info->micvdd)) { 1164 if (IS_ERR(info->micvdd)) {
1143 ret = PTR_ERR(info->micvdd); 1165 ret = PTR_ERR(info->micvdd);