Skip to content

Commit 16eb2bf

Browse files
committed
Merge tag 'extcon-next-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next
Chanwoo writes: Update extcon for v3.17 This patchset add new extcon provider driver and fix minor issue of extcon driver. Detailed description for patchset: 1. Add new Silicon-Mitus SM5502 MUIC (Micro-USB Interface Controller) device - extcon-sm5502 driver is capable of identifying the type of the external power source and attached accessory. And external power sources, such as Dedicated charger or a standard USB port, are able to charge the battery in the smart phone via the connector. 2. Fix minor issue of extcon driver - extcon-arizona driver - extcon-palmas driver - Remove unnecessary OOM messages for all extcon device drivers 3. Fix minor issue of extcon core - Re-order the sequence of extcon device driver in Kconfig/Makefile alphabitically - Set parent device of extcon device automatically using devm_extcon_dev_allocate() 4. Fix MAX77693 driver - This patchset has dependency on MFD/Regulator/Extcon. So, Lee Jones (MFD Maintainer) created Immutable branch between MFD and Extcon due for v3.17 merge-window and then I merged this patchset from MFD git repo[1] to Extcon git repo. [1] git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd (branch: ib-mfd-extcon-regulator)
2 parents 7b9d1f0 + d3b5031 commit 16eb2bf

20 files changed

Lines changed: 1335 additions & 494 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
* SM5502 MUIC (Micro-USB Interface Controller) device
3+
4+
The Silicon Mitus SM5502 is a MUIC (Micro-USB Interface Controller) device
5+
which can detect the state of external accessory when external accessory is
6+
attached or detached and button is pressed or released. It is interfaced to
7+
the host controller using an I2C interface.
8+
9+
Required properties:
10+
- compatible: Should be "siliconmitus,sm5502-muic"
11+
- reg: Specifies the I2C slave address of the MUIC block. It should be 0x25
12+
- interrupt-parent: Specifies the phandle of the interrupt controller to which
13+
the interrupts from sm5502 are delivered to.
14+
- interrupts: Interrupt specifiers for detection interrupt sources.
15+
16+
Example:
17+
18+
sm5502@25 {
19+
compatible = "siliconmitus,sm5502-muic";
20+
interrupt-parent = <&gpx1>;
21+
interrupts = <5 0>;
22+
reg = <0x25>;
23+
};

‎drivers/extcon/Kconfig‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,27 @@ if EXTCON
1414

1515
comment "Extcon Device Drivers"
1616

17+
config EXTCON_ADC_JACK
18+
tristate "ADC Jack extcon support"
19+
depends on IIO
20+
help
21+
Say Y here to enable extcon device driver based on ADC values.
22+
23+
config EXTCON_ARIZONA
24+
tristate "Wolfson Arizona EXTCON support"
25+
depends on MFD_ARIZONA && INPUT && SND_SOC
26+
help
27+
Say Y here to enable support for external accessory detection
28+
with Wolfson Arizona devices. These are audio CODECs with
29+
advanced audio accessory detection support.
30+
1731
config EXTCON_GPIO
1832
tristate "GPIO extcon support"
1933
depends on GPIOLIB
2034
help
2135
Say Y here to enable GPIO based extcon support. Note that GPIO
2236
extcon supports single state per extcon instance.
2337

24-
config EXTCON_ADC_JACK
25-
tristate "ADC Jack extcon support"
26-
depends on IIO
27-
help
28-
Say Y here to enable extcon device driver based on ADC values.
29-
3038
config EXTCON_MAX14577
3139
tristate "MAX14577/77836 EXTCON Support"
3240
depends on MFD_MAX14577
@@ -55,19 +63,21 @@ config EXTCON_MAX8997
5563
Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
5664
detector and switch.
5765

58-
config EXTCON_ARIZONA
59-
tristate "Wolfson Arizona EXTCON support"
60-
depends on MFD_ARIZONA && INPUT && SND_SOC
61-
help
62-
Say Y here to enable support for external accessory detection
63-
with Wolfson Arizona devices. These are audio CODECs with
64-
advanced audio accessory detection support.
65-
6666
config EXTCON_PALMAS
6767
tristate "Palmas USB EXTCON support"
6868
depends on MFD_PALMAS
6969
help
7070
Say Y here to enable support for USB peripheral and USB host
7171
detection by palmas usb.
7272

73+
config EXTCON_SM5502
74+
tristate "SM5502 EXTCON support"
75+
select IRQ_DOMAIN
76+
select REGMAP_I2C
77+
select REGMAP_IRQ
78+
help
79+
If you say yes here you get support for the MUIC device of
80+
Silicon Mitus SM5502. The SM5502 is a USB port accessory
81+
detector and switch.
82+
7383
endif # MULTISTATE_SWITCH

‎drivers/extcon/Makefile‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#
1+
22
# Makefile for external connector class (extcon) devices
33
#
44

55
obj-$(CONFIG_EXTCON) += extcon-class.o
6-
obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
76
obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o
7+
obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
8+
obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
89
obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o
910
obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o
1011
obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
11-
obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
1212
obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o
13+
obj-$(CONFIG_EXTCON_SM5502) += extcon-sm5502.o

‎drivers/extcon/extcon-adc-jack.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ static int adc_jack_probe(struct platform_device *pdev)
112112
dev_err(&pdev->dev, "failed to allocate extcon device\n");
113113
return -ENOMEM;
114114
}
115-
data->edev->dev.parent = &pdev->dev;
116115
data->edev->name = pdata->name;
117116

118117
/* Check the length of array and set num_cables */

‎drivers/extcon/extcon-arizona.c‎

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
#define ARIZONA_ACCDET_MODE_HPL 1
4040
#define ARIZONA_ACCDET_MODE_HPR 2
4141

42+
#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4
43+
#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5
44+
#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
45+
#define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb
46+
4247
#define ARIZONA_HPDET_MAX 10000
4348

4449
#define HPDET_DEBOUNCE 500
@@ -324,14 +329,17 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
324329
}
325330

326331
static struct {
332+
unsigned int threshold;
327333
unsigned int factor_a;
328334
unsigned int factor_b;
329335
} arizona_hpdet_b_ranges[] = {
330-
{ 5528, 362464 },
331-
{ 11084, 6186851 },
332-
{ 11065, 65460395 },
336+
{ 100, 5528, 362464 },
337+
{ 169, 11084, 6186851 },
338+
{ 169, 11065, 65460395 },
333339
};
334340

341+
#define ARIZONA_HPDET_B_RANGE_MAX 0x3fb
342+
335343
static struct {
336344
int min;
337345
int max;
@@ -386,7 +394,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
386394
>> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
387395

388396
if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 &&
389-
(val < 100 || val >= 0x3fb)) {
397+
(val < arizona_hpdet_b_ranges[range].threshold ||
398+
val >= ARIZONA_HPDET_B_RANGE_MAX)) {
390399
range++;
391400
dev_dbg(arizona->dev, "Moving to HPDET range %d\n",
392401
range);
@@ -399,7 +408,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
399408
}
400409

401410
/* If we go out of range report top of range */
402-
if (val < 100 || val >= 0x3fb) {
411+
if (val < arizona_hpdet_b_ranges[range].threshold ||
412+
val >= ARIZONA_HPDET_B_RANGE_MAX) {
403413
dev_dbg(arizona->dev, "Measurement out of range\n");
404414
return ARIZONA_HPDET_MAX;
405415
}
@@ -664,9 +674,8 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
664674
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
665675

666676
/* Just report headphone */
667-
ret = extcon_update_state(info->edev,
668-
1 << ARIZONA_CABLE_HEADPHONE,
669-
1 << ARIZONA_CABLE_HEADPHONE);
677+
ret = extcon_set_cable_state_(info->edev,
678+
ARIZONA_CABLE_HEADPHONE, true);
670679
if (ret != 0)
671680
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
672681

@@ -723,9 +732,8 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
723732
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
724733

725734
/* Just report headphone */
726-
ret = extcon_update_state(info->edev,
727-
1 << ARIZONA_CABLE_HEADPHONE,
728-
1 << ARIZONA_CABLE_HEADPHONE);
735+
ret = extcon_set_cable_state_(info->edev,
736+
ARIZONA_CABLE_HEADPHONE, true);
729737
if (ret != 0)
730738
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
731739

@@ -812,16 +820,15 @@ static void arizona_micd_detect(struct work_struct *work)
812820
if (info->detecting && (val & ARIZONA_MICD_LVL_8)) {
813821
arizona_identify_headphone(info);
814822

815-
ret = extcon_update_state(info->edev,
816-
1 << ARIZONA_CABLE_MICROPHONE,
817-
1 << ARIZONA_CABLE_MICROPHONE);
823+
ret = extcon_set_cable_state_(info->edev,
824+
ARIZONA_CABLE_MICROPHONE, true);
818825

819826
if (ret != 0)
820827
dev_err(arizona->dev, "Headset report failed: %d\n",
821828
ret);
822829

823830
/* Don't need to regulate for button detection */
824-
ret = regulator_allow_bypass(info->micvdd, false);
831+
ret = regulator_allow_bypass(info->micvdd, true);
825832
if (ret != 0) {
826833
dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
827834
ret);
@@ -962,10 +969,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
962969

963970
if (arizona->pdata.jd_gpio5) {
964971
mask = ARIZONA_MICD_CLAMP_STS;
965-
present = 0;
972+
if (arizona->pdata.jd_invert)
973+
present = ARIZONA_MICD_CLAMP_STS;
974+
else
975+
present = 0;
966976
} else {
967977
mask = ARIZONA_JD1_STS;
968-
present = ARIZONA_JD1_STS;
978+
if (arizona->pdata.jd_invert)
979+
present = 0;
980+
else
981+
present = ARIZONA_JD1_STS;
969982
}
970983

971984
ret = regmap_read(arizona->regmap, ARIZONA_AOD_IRQ_RAW_STATUS, &val);
@@ -1096,19 +1109,18 @@ static int arizona_extcon_probe(struct platform_device *pdev)
10961109
struct arizona_pdata *pdata = &arizona->pdata;
10971110
struct arizona_extcon_info *info;
10981111
unsigned int val;
1112+
unsigned int clamp_mode;
10991113
int jack_irq_fall, jack_irq_rise;
11001114
int ret, mode, i, j;
11011115

11021116
if (!arizona->dapm || !arizona->dapm->card)
11031117
return -EPROBE_DEFER;
11041118

11051119
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
1106-
if (!info) {
1107-
dev_err(&pdev->dev, "Failed to allocate memory\n");
1120+
if (!info)
11081121
return -ENOMEM;
1109-
}
11101122

1111-
info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
1123+
info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
11121124
if (IS_ERR(info->micvdd)) {
11131125
ret = PTR_ERR(info->micvdd);
11141126
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
@@ -1156,7 +1168,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
11561168
return -ENOMEM;
11571169
}
11581170
info->edev->name = "Headset Jack";
1159-
info->edev->dev.parent = arizona->dev;
11601171

11611172
ret = devm_extcon_dev_register(&pdev->dev, info->edev);
11621173
if (ret < 0) {
@@ -1174,7 +1185,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
11741185

11751186
info->input->name = "Headset";
11761187
info->input->phys = "arizona/extcon";
1177-
info->input->dev.parent = &pdev->dev;
11781188

11791189
if (pdata->num_micd_configs) {
11801190
info->micd_modes = pdata->micd_configs;
@@ -1305,15 +1315,21 @@ static int arizona_extcon_probe(struct platform_device *pdev)
13051315
regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL,
13061316
val);
13071317

1308-
regmap_update_bits(arizona->regmap,
1309-
ARIZONA_MICD_CLAMP_CONTROL,
1310-
ARIZONA_MICD_CLAMP_MODE_MASK, 0x9);
1318+
if (arizona->pdata.jd_invert)
1319+
clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH_GP5H;
1320+
else
1321+
clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL_GP5H;
13111322
} else {
1312-
regmap_update_bits(arizona->regmap,
1313-
ARIZONA_MICD_CLAMP_CONTROL,
1314-
ARIZONA_MICD_CLAMP_MODE_MASK, 0x4);
1323+
if (arizona->pdata.jd_invert)
1324+
clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH;
1325+
else
1326+
clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL;
13151327
}
13161328

1329+
regmap_update_bits(arizona->regmap,
1330+
ARIZONA_MICD_CLAMP_CONTROL,
1331+
ARIZONA_MICD_CLAMP_MODE_MASK, clamp_mode);
1332+
13171333
regmap_update_bits(arizona->regmap,
13181334
ARIZONA_JACK_DETECT_DEBOUNCE,
13191335
ARIZONA_MICD_CLAMP_DB,

‎drivers/extcon/extcon-class.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
645645
return edev;
646646
}
647647

648+
edev->dev.parent = dev;
649+
648650
*ptr = edev;
649651
devres_add(dev, ptr);
650652

‎drivers/extcon/extcon-gpio.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
105105
return -ENOMEM;
106106
}
107107
extcon_data->edev->name = pdata->name;
108-
extcon_data->edev->dev.parent = &pdev->dev;
109108

110109
extcon_data->gpio = pdata->gpio;
111110
extcon_data->gpio_active_low = pdata->gpio_active_low;

‎drivers/extcon/extcon-max14577.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,9 @@ static int max14577_muic_probe(struct platform_device *pdev)
692692
u8 id;
693693

694694
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
695-
if (!info) {
696-
dev_err(&pdev->dev, "failed to allocate memory\n");
695+
if (!info)
697696
return -ENOMEM;
698-
}
697+
699698
info->dev = &pdev->dev;
700699
info->max14577 = max14577;
701700

0 commit comments

Comments
 (0)