Skip to content

Commit

Permalink
Merge tag 'extcon-next-for-4.9' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/chanwoo/extcon into usb-testing

Chanwoo writes:

Update extcon for 4.9

Detailed description for this pull request:
1. Support the extcon property and add the synchronization APIs.
- This feature supports the extcon property for external connector
  because each external connector might have the property according to
  the H/W design.

- The property name should keep the following style.
  : EXTCON_PROP_USB_[property_name]
  : EXTCON_PROP_CHG_[property_name]
  : EXTCON_PROP_JACK_[property_name]
  : EXTCON_PROP_DISP_[property_name]

- Add the new extcon APIs to support the extcon property.
  : extcon_set_property()
  : extcon_get_property()
  : extcon_set_property_capability()
  : extcon_get_property_capability()

- Add the new synchronization extcon APIs.
  : This feature adds the synchronization extcon APIs to support the noti
  for both state and property. When extcon_*_sync() functions is called,
  the extcon informs the information from extcon provider to extcon client.

  The extcon driver may need to change the both state and multiple properties
  at the same time. After setting the data of a external connector,
  the extcon send the notification to client driver with the extcon_*_sync().

  : extcon_sync()
  : extcon_set_state_sync()
  : extcon_set_property_sync()

- Change the name of existing APIs.
  : extcon_set_cable_state_() -> extcon_set_cable()
  : extcon_get_cable_state_() -> extcon_get_cable()

2. Add the extcon type to group the connector into five category.
- EXTCON_TYPE_USB  : USB connector
- EXTCON_TYPE_CHG  : Charger connector
- EXTCON_TYPE_JACK : Jack connector
- EXTCON_TYPE_DISP : Display connector
- EXTCON_TYPE_MISC : Miscellaneous connector

3. Add the new property for external connector.
- EXTCON_PROP_USB_VBUS
- EXTCON_PROP_USB_TYPEC_POLARITY
- EXTCON_PROP_USB_SS   (SuperSpeed)
- EXTCON_PROP_DISP_HPD (Hot Plug Detect)

4. Add the new type of external connector.
- EXTCON_DISP_DP  : Display Port
- EXTCON_DISP_HMD : Head Mounted Device
- EXTCON_CHG_WPT  : Wireless Power Transfer device

5. Add the new extcon driver.
- Qualcomm SPMI PMIC USB id detection driver detects whether
  EXTCON_USB_HOST is attached or detached. (extcon-qcom-spmi-mis.c)

6. Remove the usage of extcon_update_state() and old extcon_set_state()
- Both extcon_update_state() and extcon_set_state() should change the state
  of all external connectors with bit masking handling. It may occur the
  problem. Instead, extcon provides the extcon_set/get_state() functions.

7. Fix the minor issues on extcon drivers.
  • Loading branch information
Greg Kroah-Hartman committed Sep 13, 2016
2 parents 050bc4e + 38085c9 commit 4d71920
Show file tree
Hide file tree
Showing 20 changed files with 1,122 additions and 276 deletions.
41 changes: 41 additions & 0 deletions Documentation/devicetree/bindings/extcon/qcom,pm8941-misc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Qualcomm's PM8941 USB ID Extcon device

Some Qualcomm PMICs have a "misc" module that can be used to detect when
the USB ID pin has been pulled low or high.

PROPERTIES

- compatible:
Usage: required
Value type: <string>
Definition: Should contain "qcom,pm8941-misc";

- reg:
Usage: required
Value type: <u32>
Definition: Should contain the offset to the misc address space

- interrupts:
Usage: required
Value type: <prop-encoded-array>
Definition: Should contain the usb id interrupt

- interrupt-names:
Usage: required
Value type: <stringlist>
Definition: Should contain the string "usb_id" for the usb id interrupt

Example:

pmic {
usb_id: misc@900 {
compatible = "qcom,pm8941-misc";
reg = <0x900>;
interrupts = <0x0 0x9 0 IRQ_TYPE_EDGE_BOTH>;
interrupt-names = "usb_id";
};
}

usb-controller {
extcon = <&usb_id>;
};
6 changes: 6 additions & 0 deletions drivers/extcon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ config EXTCON_PALMAS
Say Y here to enable support for USB peripheral and USB host
detection by palmas usb.

config EXTCON_QCOM_SPMI_MISC
tristate "Qualcomm USB extcon support"
help
Say Y here to enable SPMI PMIC based USB cable detection
support on Qualcomm PMICs such as PM8941.

config EXTCON_RT8973A
tristate "Richtek RT8973A EXTCON support"
depends on I2C
Expand Down
1 change: 1 addition & 0 deletions drivers/extcon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o
obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o
obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o
obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.o
obj-$(CONFIG_EXTCON_RT8973A) += extcon-rt8973a.o
obj-$(CONFIG_EXTCON_SM5502) += extcon-sm5502.o
obj-$(CONFIG_EXTCON_USB_GPIO) += extcon-usb-gpio.o
27 changes: 15 additions & 12 deletions drivers/extcon/extcon-adc-jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*
* Analog Jack extcon driver with ADC-based detection capability.
*
* Copyright (C) 2016 Samsung Electronics
* Chanwoo Choi <cw00.choi@samsung.com>
*
* Copyright (C) 2012 Samsung Electronics
* MyungJoo Ham <myungjoo.ham@samsung.com>
*
Expand Down Expand Up @@ -58,7 +61,7 @@ static void adc_jack_handler(struct work_struct *work)
struct adc_jack_data *data = container_of(to_delayed_work(work),
struct adc_jack_data,
handler);
u32 state = 0;
struct adc_jack_cond *def;
int ret, adc_val;
int i;

Expand All @@ -70,17 +73,18 @@ static void adc_jack_handler(struct work_struct *work)

/* Get state from adc value with adc_conditions */
for (i = 0; i < data->num_conditions; i++) {
struct adc_jack_cond *def = &data->adc_conditions[i];
if (!def->state)
break;
def = &data->adc_conditions[i];
if (def->min_adc <= adc_val && def->max_adc >= adc_val) {
state = def->state;
break;
extcon_set_state_sync(data->edev, def->id, true);
return;
}
}
/* if no def has met, it means state = 0 (no cables attached) */

extcon_set_state(data->edev, state);
/* Set the detached state if adc value is not included in the range */
for (i = 0; i < data->num_conditions; i++) {
def = &data->adc_conditions[i];
extcon_set_state_sync(data->edev, def->id, false);
}
}

static irqreturn_t adc_jack_irq_thread(int irq, void *_data)
Expand Down Expand Up @@ -114,16 +118,14 @@ static int adc_jack_probe(struct platform_device *pdev)
return -ENOMEM;
}

if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
if (!pdata->adc_conditions) {
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;

/* Check the length of array and set num_conditions */
for (i = 0; data->adc_conditions[i].state; i++)
;
for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++);
data->num_conditions = i;

data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
Expand Down Expand Up @@ -158,6 +160,7 @@ static int adc_jack_probe(struct platform_device *pdev)
if (data->wakeup_source)
device_init_wakeup(&pdev->dev, 1);

adc_jack_handler(&data->handler.work);
return 0;
}

Expand Down
27 changes: 15 additions & 12 deletions drivers/extcon/extcon-arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
if (clamp)
val = ARIZONA_RMV_SHRT_HP1L;
break;
};
}

snd_soc_dapm_mutex_lock(arizona->dapm);

Expand Down Expand Up @@ -614,7 +614,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
}

/* If the cable was removed while measuring ignore the result */
ret = extcon_get_cable_state_(info->edev, EXTCON_MECHANICAL);
ret = extcon_get_state(info->edev, EXTCON_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -649,7 +649,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
else
report = EXTCON_JACK_HEADPHONE;

ret = extcon_set_cable_state_(info->edev, report, true);
ret = extcon_set_state_sync(info->edev, report, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report HP/line: %d\n",
ret);
Expand Down Expand Up @@ -732,7 +732,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);

/* Just report headphone */
ret = extcon_set_cable_state_(info->edev, EXTCON_JACK_HEADPHONE, true);
ret = extcon_set_state_sync(info->edev, EXTCON_JACK_HEADPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);

Expand Down Expand Up @@ -789,7 +789,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);

/* Just report headphone */
ret = extcon_set_cable_state_(info->edev, EXTCON_JACK_HEADPHONE, true);
ret = extcon_set_state_sync(info->edev, EXTCON_JACK_HEADPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);

Expand Down Expand Up @@ -829,7 +829,7 @@ static void arizona_micd_detect(struct work_struct *work)
mutex_lock(&info->lock);

/* If the cable was removed while measuring ignore the result */
ret = extcon_get_cable_state_(info->edev, EXTCON_MECHANICAL);
ret = extcon_get_state(info->edev, EXTCON_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -914,7 +914,7 @@ static void arizona_micd_detect(struct work_struct *work)

arizona_identify_headphone(info);

ret = extcon_set_cable_state_(info->edev,
ret = extcon_set_state_sync(info->edev,
EXTCON_JACK_MICROPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Headset report failed: %d\n",
Expand Down Expand Up @@ -1108,7 +1108,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)

if (info->last_jackdet == present) {
dev_dbg(arizona->dev, "Detected jack\n");
ret = extcon_set_cable_state_(info->edev,
ret = extcon_set_state_sync(info->edev,
EXTCON_MECHANICAL, true);

if (ret != 0)
Expand Down Expand Up @@ -1149,10 +1149,13 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
info->micd_ranges[i].key, 0);
input_sync(info->input);

ret = extcon_update_state(info->edev, 0xffffffff, 0);
if (ret != 0)
dev_err(arizona->dev, "Removal report failed: %d\n",
ret);
for (i = 0; i < ARRAY_SIZE(arizona_cable) - 1; i++) {
ret = extcon_set_state_sync(info->edev,
arizona_cable[i], false);
if (ret != 0)
dev_err(arizona->dev,
"Removal report failed: %d\n", ret);
}

regmap_update_bits(arizona->regmap,
ARIZONA_JACK_DETECT_DEBOUNCE,
Expand Down
8 changes: 4 additions & 4 deletions drivers/extcon/extcon-axp288.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)

switch (chrg_type) {
case DET_STAT_SDP:
dev_dbg(info->dev, "sdp cable is connecetd\n");
dev_dbg(info->dev, "sdp cable is connected\n");
notify_otg = true;
notify_charger = true;
cable = EXTCON_CHG_USB_SDP;
break;
case DET_STAT_CDP:
dev_dbg(info->dev, "cdp cable is connecetd\n");
dev_dbg(info->dev, "cdp cable is connected\n");
notify_otg = true;
notify_charger = true;
cable = EXTCON_CHG_USB_CDP;
break;
case DET_STAT_DCP:
dev_dbg(info->dev, "dcp cable is connecetd\n");
dev_dbg(info->dev, "dcp cable is connected\n");
notify_charger = true;
cable = EXTCON_CHG_USB_DCP;
break;
Expand All @@ -226,7 +226,7 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
}

if (notify_charger)
extcon_set_cable_state_(info->edev, cable, vbus_attach);
extcon_set_state_sync(info->edev, cable, vbus_attach);

/* Clear the flags on disconnect event */
if (!vbus_attach)
Expand Down
2 changes: 1 addition & 1 deletion drivers/extcon/extcon-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void gpio_extcon_work(struct work_struct *work)
state = gpiod_get_value_cansleep(data->id_gpiod);
if (data->pdata->gpio_active_low)
state = !state;
extcon_set_state(data->edev, state);
extcon_set_state_sync(data->edev, data->pdata->extcon_id, state);
}

static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
Expand Down
18 changes: 9 additions & 9 deletions drivers/extcon/extcon-max14577.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (C) 2013,2014 Samsung Electronics
* Chanwoo Choi <cw00.choi@samsung.com>
* Krzysztof Kozlowski <k.kozlowski@samsung.com>
* Krzysztof Kozlowski <krzk@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -357,7 +357,7 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info,
if (ret < 0)
return ret;

extcon_set_cable_state_(info->edev, EXTCON_JIG, attached);
extcon_set_state_sync(info->edev, EXTCON_JIG, attached);

return 0;
}
Expand Down Expand Up @@ -454,24 +454,24 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
if (ret < 0)
return ret;

extcon_set_cable_state_(info->edev, EXTCON_USB, attached);
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SDP,
extcon_set_state_sync(info->edev, EXTCON_USB, attached);
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
attached);
break;
case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
attached);
break;
case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_CDP,
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
attached);
break;
case MAX14577_CHARGER_TYPE_SPECIAL_500MA:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SLOW,
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
attached);
break;
case MAX14577_CHARGER_TYPE_SPECIAL_1A:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_FAST,
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
attached);
break;
case MAX14577_CHARGER_TYPE_NONE:
Expand Down Expand Up @@ -791,6 +791,6 @@ static struct platform_driver max14577_muic_driver = {
module_platform_driver(max14577_muic_driver);

MODULE_DESCRIPTION("Maxim 14577/77836 Extcon driver");
MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>");
MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <krzk@kernel.org>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:extcon-max14577");
8 changes: 4 additions & 4 deletions drivers/extcon/extcon-max3355.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ static irqreturn_t max3355_id_irq(int irq, void *dev_id)
* As we don't have event for USB peripheral cable attached,
* we simulate USB peripheral attach here.
*/
extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, false);
extcon_set_cable_state_(data->edev, EXTCON_USB, true);
extcon_set_state_sync(data->edev, EXTCON_USB_HOST, false);
extcon_set_state_sync(data->edev, EXTCON_USB, true);
} else {
/*
* ID = 0 means USB HOST cable attached.
* As we don't have event for USB peripheral cable detached,
* we simulate USB peripheral detach here.
*/
extcon_set_cable_state_(data->edev, EXTCON_USB, false);
extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, true);
extcon_set_state_sync(data->edev, EXTCON_USB, false);
extcon_set_state_sync(data->edev, EXTCON_USB_HOST, true);
}

return IRQ_HANDLED;
Expand Down
Loading

0 comments on commit 4d71920

Please sign in to comment.