summaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-axp288.c
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2018-01-02 20:12:07 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2018-01-02 20:12:07 -0500
commitd61b814ab958cdd119eac76e9aa3455b908c51cd (patch)
treefdd1896d45492abb8120528fa19c2c6859061deb /drivers/extcon/extcon-axp288.c
parent447641eb88287fa29971b076166397e3f4cce3dd (diff)
parent9bf317e900a19a857eb9921c9441a92e89f40415 (diff)
Merge branch 'ib-extcon-mfd-4.16' into extcon-next
Diffstat (limited to 'drivers/extcon/extcon-axp288.c')
-rw-r--r--drivers/extcon/extcon-axp288.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 981fba56bc18..1621f2f7f129 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -24,8 +24,6 @@
24#include <linux/notifier.h> 24#include <linux/notifier.h>
25#include <linux/extcon-provider.h> 25#include <linux/extcon-provider.h>
26#include <linux/regmap.h> 26#include <linux/regmap.h>
27#include <linux/gpio.h>
28#include <linux/gpio/consumer.h>
29#include <linux/mfd/axp20x.h> 27#include <linux/mfd/axp20x.h>
30 28
31/* Power source status register */ 29/* Power source status register */
@@ -79,11 +77,6 @@ enum axp288_extcon_reg {
79 AXP288_BC_DET_STAT_REG = 0x2f, 77 AXP288_BC_DET_STAT_REG = 0x2f,
80}; 78};
81 79
82enum axp288_mux_select {
83 EXTCON_GPIO_MUX_SEL_PMIC = 0,
84 EXTCON_GPIO_MUX_SEL_SOC,
85};
86
87enum axp288_extcon_irq { 80enum axp288_extcon_irq {
88 VBUS_FALLING_IRQ = 0, 81 VBUS_FALLING_IRQ = 0,
89 VBUS_RISING_IRQ, 82 VBUS_RISING_IRQ,
@@ -104,10 +97,8 @@ struct axp288_extcon_info {
104 struct device *dev; 97 struct device *dev;
105 struct regmap *regmap; 98 struct regmap *regmap;
106 struct regmap_irq_chip_data *regmap_irqc; 99 struct regmap_irq_chip_data *regmap_irqc;
107 struct gpio_desc *gpio_mux_cntl;
108 int irq[EXTCON_IRQ_END]; 100 int irq[EXTCON_IRQ_END];
109 struct extcon_dev *edev; 101 struct extcon_dev *edev;
110 struct notifier_block extcon_nb;
111 unsigned int previous_cable; 102 unsigned int previous_cable;
112}; 103};
113 104
@@ -197,15 +188,6 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
197 } 188 }
198 189
199no_vbus: 190no_vbus:
200 /*
201 * If VBUS is absent Connect D+/D- lines to PMIC for BC
202 * detection. Else connect them to SOC for USB communication.
203 */
204 if (info->gpio_mux_cntl)
205 gpiod_set_value(info->gpio_mux_cntl,
206 vbus_attach ? EXTCON_GPIO_MUX_SEL_SOC
207 : EXTCON_GPIO_MUX_SEL_PMIC);
208
209 extcon_set_state_sync(info->edev, info->previous_cable, false); 191 extcon_set_state_sync(info->edev, info->previous_cable, false);
210 if (info->previous_cable == EXTCON_CHG_USB_SDP) 192 if (info->previous_cable == EXTCON_CHG_USB_SDP)
211 extcon_set_state_sync(info->edev, EXTCON_USB, false); 193 extcon_set_state_sync(info->edev, EXTCON_USB, false);
@@ -253,8 +235,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
253{ 235{
254 struct axp288_extcon_info *info; 236 struct axp288_extcon_info *info;
255 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 237 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
256 struct axp288_extcon_pdata *pdata = pdev->dev.platform_data; 238 int ret, i, pirq;
257 int ret, i, pirq, gpio;
258 239
259 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 240 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
260 if (!info) 241 if (!info)
@@ -264,8 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
264 info->regmap = axp20x->regmap; 245 info->regmap = axp20x->regmap;
265 info->regmap_irqc = axp20x->regmap_irqc; 246 info->regmap_irqc = axp20x->regmap_irqc;
266 info->previous_cable = EXTCON_NONE; 247 info->previous_cable = EXTCON_NONE;
267 if (pdata)
268 info->gpio_mux_cntl = pdata->gpio_mux_cntl;
269 248
270 platform_set_drvdata(pdev, info); 249 platform_set_drvdata(pdev, info);
271 250
@@ -286,21 +265,11 @@ static int axp288_extcon_probe(struct platform_device *pdev)
286 return ret; 265 return ret;
287 } 266 }
288 267
289 /* Set up gpio control for USB Mux */
290 if (info->gpio_mux_cntl) {
291 gpio = desc_to_gpio(info->gpio_mux_cntl);
292 ret = devm_gpio_request(&pdev->dev, gpio, "USB_MUX");
293 if (ret < 0) {
294 dev_err(&pdev->dev,
295 "failed to request the gpio=%d\n", gpio);
296 return ret;
297 }
298 gpiod_direction_output(info->gpio_mux_cntl,
299 EXTCON_GPIO_MUX_SEL_PMIC);
300 }
301
302 for (i = 0; i < EXTCON_IRQ_END; i++) { 268 for (i = 0; i < EXTCON_IRQ_END; i++) {
303 pirq = platform_get_irq(pdev, i); 269 pirq = platform_get_irq(pdev, i);
270 if (pirq < 0)
271 return pirq;
272
304 info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq); 273 info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq);
305 if (info->irq[i] < 0) { 274 if (info->irq[i] < 0) {
306 dev_err(&pdev->dev, 275 dev_err(&pdev->dev,