aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-26 19:58:05 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-26 19:58:05 -0500
commitd7a26beb6fe65c62d986fdb3d83d5db03185f95d (patch)
treefb793a9a56658f74ed88f48be54b48dc0ced74d6
parentb9884d3b79f60846cdf04be262d13bca8996f99a (diff)
parent08a0a4f987a4b5827e4111eccc97a9271d24633e (diff)
Merge tag 'extcon-next-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next
Chanwoo writes: Update extcon for 4.5 Detailed description for patchset: 1. Add new MAX3355 extcon driver - Maxim Integrated MAX3355E chip integrates a charge pump and comparator to enable a system with an integrated USB OTG dual-role transceiver to function as an USB OTG dual-role device. 2. Update the extcon-arizona driver for jack detection - Add the device binding for the jack detection and add the documentation of extcon-arizona.c. 3. Fix the minor issue of extcon driver - Add IRQF_ONESHOT to interrupt flags of extcon-rt8973. - Fix the return value regmap_irq_get_virq() of extcon-max(14577|77693|77843).c driver by using script[1]. [1] http://permalink.gmane.org/gmane.linux.kernel/2046107
-rw-r--r--Documentation/devicetree/bindings/extcon/extcon-arizona.txt60
-rw-r--r--Documentation/devicetree/bindings/extcon/extcon-max3355.txt21
-rw-r--r--drivers/extcon/Kconfig9
-rw-r--r--drivers/extcon/Makefile1
-rw-r--r--drivers/extcon/extcon-arizona.c71
-rw-r--r--drivers/extcon/extcon-max14577.c2
-rw-r--r--drivers/extcon/extcon-max3355.c146
-rw-r--r--drivers/extcon/extcon-max77693.c4
-rw-r--r--drivers/extcon/extcon-max77843.c2
-rw-r--r--drivers/extcon/extcon-rt8973a.c2
10 files changed, 310 insertions, 8 deletions
diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
index e1705fae63a8..e27341f8a4c7 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
@@ -13,3 +13,63 @@ Optional properties:
13 ARIZONA_ACCDET_MODE_HPR or 2 - Headphone detect mode is set to HPDETR 13 ARIZONA_ACCDET_MODE_HPR or 2 - Headphone detect mode is set to HPDETR
14 If this node is not mentioned or if the value is unknown, then 14 If this node is not mentioned or if the value is unknown, then
15 headphone detection mode is set to HPDETL. 15 headphone detection mode is set to HPDETL.
16
17 - wlf,use-jd2 : Use the additional JD input along with JD1 for dual pin jack
18 detection.
19 - wlf,use-jd2-nopull : Internal pull on JD2 is disabled when used for
20 jack detection.
21 - wlf,jd-invert : Invert the polarity of the jack detection switch
22
23 - wlf,micd-software-compare : Use a software comparison to determine mic
24 presence
25 - wlf,micd-detect-debounce : Additional software microphone detection
26 debounce specified in milliseconds.
27 - wlf,micd-pol-gpio : GPIO specifier for the GPIO controlling the headset
28 polarity if one exists.
29 - wlf,micd-bias-start-time : Time allowed for MICBIAS to startup prior to
30 performing microphone detection, specified as per the ARIZONA_MICD_TIME_XXX
31 defines.
32 - wlf,micd-rate : Delay between successive microphone detection measurements,
33 specified as per the ARIZONA_MICD_TIME_XXX defines.
34 - wlf,micd-dbtime : Microphone detection hardware debounces specified as the
35 number of measurements to take, valid values being 2 and 4.
36 - wlf,micd-timeout-ms : Timeout for microphone detection, specified in
37 milliseconds.
38 - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone
39 detection.
40 - wlf,micd-configs : Headset polarity configurations (generally used for
41 detection of CTIA / OMTP headsets), the field can be of variable length
42 but should always be a multiple of 3 cells long, each three cell group
43 represents one polarity configuration.
44 The first cell defines the accessory detection pin, zero will use MICDET1
45 and all other values will use MICDET2.
46 The second cell represents the MICBIAS to be used.
47 The third cell represents the value of the micd-pol-gpio pin.
48
49 - wlf,gpsw : Settings for the general purpose switch
50
51Example:
52
53codec: wm8280@0 {
54 compatible = "wlf,wm8280";
55 reg = <0>;
56 ...
57
58 wlf,use-jd2;
59 wlf,use-jd2-nopull;
60 wlf,jd-invert;
61
62 wlf,micd-software-compare;
63 wlf,micd-detect-debounce = <0>;
64 wlf,micd-pol-gpio = <&codec 2 0>;
65 wlf,micd-rate = <ARIZONA_MICD_TIME_8MS>;
66 wlf,micd-dbtime = <4>;
67 wlf,micd-timeout-ms = <100>;
68 wlf,micd-force-micbias;
69 wlf,micd-configs = <
70 0 1 0 /* MICDET1 MICBIAS1 GPIO=low */
71 1 2 1 /* MICDET2 MICBIAS2 GPIO=high */
72 >;
73
74 wlf,gpsw = <0>;
75};
diff --git a/Documentation/devicetree/bindings/extcon/extcon-max3355.txt b/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
new file mode 100644
index 000000000000..f2288ea9eb82
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
@@ -0,0 +1,21 @@
1Maxim Integrated MAX3355 USB OTG chip
2-------------------------------------
3
4MAX3355 integrates a charge pump and comparators to enable a system with an
5integrated USB OTG dual-role transceiver to function as a USB OTG dual-role
6device.
7
8Required properties:
9- compatible: should be "maxim,max3355";
10- maxim,shdn-gpios: should contain a phandle and GPIO specifier for the GPIO pin
11 connected to the MAX3355's SHDN# pin;
12- id-gpios: should contain a phandle and GPIO specifier for the GPIO pin
13 connected to the MAX3355's ID_OUT pin.
14
15Example:
16
17 usb-otg {
18 compatible = "maxim,max3355";
19 maxim,shdn-gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
20 id-gpios = <&gpio5 31 GPIO_ACTIVE_HIGH>;
21 };
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 0cebbf668886..3d89e60a3e71 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -52,6 +52,15 @@ config EXTCON_MAX14577
52 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory 52 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory
53 detector and switch. 53 detector and switch.
54 54
55config EXTCON_MAX3355
56 tristate "Maxim MAX3355 USB OTG EXTCON Support"
57 depends on GPIOLIB || COMPILE_TEST
58 help
59 If you say yes here you get support for the USB OTG role detection by
60 MAX3355. The MAX3355 chip integrates a charge pump and comparators to
61 enable a system with an integrated USB OTG dual-role transceiver to
62 function as an USB OTG dual-role device.
63
55config EXTCON_MAX77693 64config EXTCON_MAX77693
56 tristate "Maxim MAX77693 EXTCON Support" 65 tristate "Maxim MAX77693 EXTCON Support"
57 depends on MFD_MAX77693 && INPUT 66 depends on MFD_MAX77693 && INPUT
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index ba787d04295b..2a0e4f45d5b2 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
8obj-$(CONFIG_EXTCON_AXP288) += extcon-axp288.o 8obj-$(CONFIG_EXTCON_AXP288) += extcon-axp288.o
9obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o 9obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
10obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o 10obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o
11obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o
11obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o 12obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o
12obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o 13obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o
13obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o 14obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index e4890dd4fefd..c121d01a5cd6 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1201,10 +1201,58 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
1201 regmap_update_bits(arizona->regmap, reg, mask, level); 1201 regmap_update_bits(arizona->regmap, reg, mask, level);
1202} 1202}
1203 1203
1204static int arizona_extcon_device_get_pdata(struct arizona *arizona) 1204static int arizona_extcon_get_micd_configs(struct device *dev,
1205 struct arizona *arizona)
1206{
1207 const char * const prop = "wlf,micd-configs";
1208 const int entries_per_config = 3;
1209 struct arizona_micd_config *micd_configs;
1210 int nconfs, ret;
1211 int i, j;
1212 u32 *vals;
1213
1214 nconfs = device_property_read_u32_array(arizona->dev, prop, NULL, 0);
1215 if (nconfs <= 0)
1216 return 0;
1217
1218 vals = kcalloc(nconfs, sizeof(u32), GFP_KERNEL);
1219 if (!vals)
1220 return -ENOMEM;
1221
1222 ret = device_property_read_u32_array(arizona->dev, prop, vals, nconfs);
1223 if (ret < 0)
1224 goto out;
1225
1226 nconfs /= entries_per_config;
1227
1228 micd_configs = devm_kzalloc(dev,
1229 nconfs * sizeof(struct arizona_micd_range),
1230 GFP_KERNEL);
1231 if (!micd_configs) {
1232 ret = -ENOMEM;
1233 goto out;
1234 }
1235
1236 for (i = 0, j = 0; i < nconfs; ++i) {
1237 micd_configs[i].src = vals[j++] ? ARIZONA_ACCDET_SRC : 0;
1238 micd_configs[i].bias = vals[j++];
1239 micd_configs[i].gpio = vals[j++];
1240 }
1241
1242 arizona->pdata.micd_configs = micd_configs;
1243 arizona->pdata.num_micd_configs = nconfs;
1244
1245out:
1246 kfree(vals);
1247 return ret;
1248}
1249
1250static int arizona_extcon_device_get_pdata(struct device *dev,
1251 struct arizona *arizona)
1205{ 1252{
1206 struct arizona_pdata *pdata = &arizona->pdata; 1253 struct arizona_pdata *pdata = &arizona->pdata;
1207 unsigned int val = ARIZONA_ACCDET_MODE_HPL; 1254 unsigned int val = ARIZONA_ACCDET_MODE_HPL;
1255 int ret;
1208 1256
1209 device_property_read_u32(arizona->dev, "wlf,hpdet-channel", &val); 1257 device_property_read_u32(arizona->dev, "wlf,hpdet-channel", &val);
1210 switch (val) { 1258 switch (val) {
@@ -1230,12 +1278,29 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
1230 device_property_read_u32(arizona->dev, "wlf,micd-dbtime", 1278 device_property_read_u32(arizona->dev, "wlf,micd-dbtime",
1231 &pdata->micd_dbtime); 1279 &pdata->micd_dbtime);
1232 1280
1233 device_property_read_u32(arizona->dev, "wlf,micd-timeout", 1281 device_property_read_u32(arizona->dev, "wlf,micd-timeout-ms",
1234 &pdata->micd_timeout); 1282 &pdata->micd_timeout);
1235 1283
1236 pdata->micd_force_micbias = device_property_read_bool(arizona->dev, 1284 pdata->micd_force_micbias = device_property_read_bool(arizona->dev,
1237 "wlf,micd-force-micbias"); 1285 "wlf,micd-force-micbias");
1238 1286
1287 pdata->micd_software_compare = device_property_read_bool(arizona->dev,
1288 "wlf,micd-software-compare");
1289
1290 pdata->jd_invert = device_property_read_bool(arizona->dev,
1291 "wlf,jd-invert");
1292
1293 device_property_read_u32(arizona->dev, "wlf,gpsw", &pdata->gpsw);
1294
1295 pdata->jd_gpio5 = device_property_read_bool(arizona->dev,
1296 "wlf,use-jd2");
1297 pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev,
1298 "wlf,use-jd2-nopull");
1299
1300 ret = arizona_extcon_get_micd_configs(dev, arizona);
1301 if (ret < 0)
1302 dev_err(arizona->dev, "Failed to read micd configs: %d\n", ret);
1303
1239 return 0; 1304 return 0;
1240} 1305}
1241 1306
@@ -1257,7 +1322,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1257 return -ENOMEM; 1322 return -ENOMEM;
1258 1323
1259 if (!dev_get_platdata(arizona->dev)) 1324 if (!dev_get_platdata(arizona->dev))
1260 arizona_extcon_device_get_pdata(arizona); 1325 arizona_extcon_device_get_pdata(&pdev->dev, arizona);
1261 1326
1262 info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD"); 1327 info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
1263 if (IS_ERR(info->micvdd)) { 1328 if (IS_ERR(info->micvdd)) {
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 601dbd996487..b30ab97ce75f 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -692,7 +692,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
692 /* Support irq domain for max14577 MUIC device */ 692 /* Support irq domain for max14577 MUIC device */
693 for (i = 0; i < info->muic_irqs_num; i++) { 693 for (i = 0; i < info->muic_irqs_num; i++) {
694 struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; 694 struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
695 unsigned int virq = 0; 695 int virq = 0;
696 696
697 virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq); 697 virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);
698 if (virq <= 0) 698 if (virq <= 0)
diff --git a/drivers/extcon/extcon-max3355.c b/drivers/extcon/extcon-max3355.c
new file mode 100644
index 000000000000..c24abec5d06c
--- /dev/null
+++ b/drivers/extcon/extcon-max3355.c
@@ -0,0 +1,146 @@
1/*
2 * Maxim Integrated MAX3355 USB OTG chip extcon driver
3 *
4 * Copyright (C) 2014-2015 Cogent Embedded, Inc.
5 * Author: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 */
11
12#include <linux/extcon.h>
13#include <linux/gpio.h>
14#include <linux/gpio/consumer.h>
15#include <linux/interrupt.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18
19struct max3355_data {
20 struct extcon_dev *edev;
21 struct gpio_desc *id_gpiod;
22 struct gpio_desc *shdn_gpiod;
23};
24
25static const unsigned int max3355_cable[] = {
26 EXTCON_USB,
27 EXTCON_USB_HOST,
28 EXTCON_NONE,
29};
30
31static irqreturn_t max3355_id_irq(int irq, void *dev_id)
32{
33 struct max3355_data *data = dev_id;
34 int id = gpiod_get_value_cansleep(data->id_gpiod);
35
36 if (id) {
37 /*
38 * ID = 1 means USB HOST cable detached.
39 * As we don't have event for USB peripheral cable attached,
40 * we simulate USB peripheral attach here.
41 */
42 extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, false);
43 extcon_set_cable_state_(data->edev, EXTCON_USB, true);
44 } else {
45 /*
46 * ID = 0 means USB HOST cable attached.
47 * As we don't have event for USB peripheral cable detached,
48 * we simulate USB peripheral detach here.
49 */
50 extcon_set_cable_state_(data->edev, EXTCON_USB, false);
51 extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, true);
52 }
53
54 return IRQ_HANDLED;
55}
56
57static int max3355_probe(struct platform_device *pdev)
58{
59 struct max3355_data *data;
60 struct gpio_desc *gpiod;
61 int irq, err;
62
63 data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data),
64 GFP_KERNEL);
65 if (!data)
66 return -ENOMEM;
67
68 gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
69 if (IS_ERR(gpiod)) {
70 dev_err(&pdev->dev, "failed to get ID_OUT GPIO\n");
71 return PTR_ERR(gpiod);
72 }
73 data->id_gpiod = gpiod;
74
75 gpiod = devm_gpiod_get(&pdev->dev, "maxim,shdn", GPIOD_OUT_HIGH);
76 if (IS_ERR(gpiod)) {
77 dev_err(&pdev->dev, "failed to get SHDN# GPIO\n");
78 return PTR_ERR(gpiod);
79 }
80 data->shdn_gpiod = gpiod;
81
82 data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable);
83 if (IS_ERR(data->edev)) {
84 dev_err(&pdev->dev, "failed to allocate extcon device\n");
85 return PTR_ERR(data->edev);
86 }
87
88 err = devm_extcon_dev_register(&pdev->dev, data->edev);
89 if (err < 0) {
90 dev_err(&pdev->dev, "failed to register extcon device\n");
91 return err;
92 }
93
94 irq = gpiod_to_irq(data->id_gpiod);
95 if (irq < 0) {
96 dev_err(&pdev->dev, "failed to translate ID_OUT GPIO to IRQ\n");
97 return irq;
98 }
99
100 err = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq,
101 IRQF_ONESHOT | IRQF_NO_SUSPEND |
102 IRQF_TRIGGER_RISING |
103 IRQF_TRIGGER_FALLING,
104 pdev->name, data);
105 if (err < 0) {
106 dev_err(&pdev->dev, "failed to request ID_OUT IRQ\n");
107 return err;
108 }
109
110 platform_set_drvdata(pdev, data);
111
112 /* Perform initial detection */
113 max3355_id_irq(irq, data);
114
115 return 0;
116}
117
118static int max3355_remove(struct platform_device *pdev)
119{
120 struct max3355_data *data = platform_get_drvdata(pdev);
121
122 gpiod_set_value_cansleep(data->shdn_gpiod, 0);
123
124 return 0;
125}
126
127static const struct of_device_id max3355_match_table[] = {
128 { .compatible = "maxim,max3355", },
129 { }
130};
131MODULE_DEVICE_TABLE(of, max3355_match_table);
132
133static struct platform_driver max3355_driver = {
134 .probe = max3355_probe,
135 .remove = max3355_remove,
136 .driver = {
137 .name = "extcon-max3355",
138 .of_match_table = max3355_match_table,
139 },
140};
141
142module_platform_driver(max3355_driver);
143
144MODULE_AUTHOR("Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>");
145MODULE_DESCRIPTION("Maxim MAX3355 extcon driver");
146MODULE_LICENSE("GPL v2");
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 44c499e1beee..fdf8f5d4d4e9 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1127,11 +1127,11 @@ static int max77693_muic_probe(struct platform_device *pdev)
1127 /* Support irq domain for MAX77693 MUIC device */ 1127 /* Support irq domain for MAX77693 MUIC device */
1128 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 1128 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
1129 struct max77693_muic_irq *muic_irq = &muic_irqs[i]; 1129 struct max77693_muic_irq *muic_irq = &muic_irqs[i];
1130 unsigned int virq = 0; 1130 int virq;
1131 1131
1132 virq = regmap_irq_get_virq(max77693->irq_data_muic, 1132 virq = regmap_irq_get_virq(max77693->irq_data_muic,
1133 muic_irq->irq); 1133 muic_irq->irq);
1134 if (!virq) 1134 if (virq <= 0)
1135 return -EINVAL; 1135 return -EINVAL;
1136 muic_irq->virq = virq; 1136 muic_irq->virq = virq;
1137 1137
diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index 9f9ea334399c..74dfb7f4f277 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -811,7 +811,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
811 811
812 for (i = 0; i < ARRAY_SIZE(max77843_muic_irqs); i++) { 812 for (i = 0; i < ARRAY_SIZE(max77843_muic_irqs); i++) {
813 struct max77843_muic_irq *muic_irq = &max77843_muic_irqs[i]; 813 struct max77843_muic_irq *muic_irq = &max77843_muic_irqs[i];
814 unsigned int virq = 0; 814 int virq = 0;
815 815
816 virq = regmap_irq_get_virq(max77843->irq_data_muic, 816 virq = regmap_irq_get_virq(max77843->irq_data_muic,
817 muic_irq->irq); 817 muic_irq->irq);
diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c
index 36bf1d63791c..e1bb82809bef 100644
--- a/drivers/extcon/extcon-rt8973a.c
+++ b/drivers/extcon/extcon-rt8973a.c
@@ -603,7 +603,7 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *i2c,
603 603
604 ret = devm_request_threaded_irq(info->dev, virq, NULL, 604 ret = devm_request_threaded_irq(info->dev, virq, NULL,
605 rt8973a_muic_irq_handler, 605 rt8973a_muic_irq_handler,
606 IRQF_NO_SUSPEND, 606 IRQF_NO_SUSPEND | IRQF_ONESHOT,
607 muic_irq->name, info); 607 muic_irq->name, info);
608 if (ret) { 608 if (ret) {
609 dev_err(info->dev, 609 dev_err(info->dev,