Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d719209 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'extcon-next-for-4.9' of...

Merge tag 'extcon-next-for-4.9' of git://git.kernel.org/pub/scm/linux/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.
parents 050bc4e8 38085c98
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+15 −12
Original line number Diff line number Diff line
@@ -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>
 *
@@ -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;

@@ -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)
@@ -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);
@@ -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;
}

+15 −12
Original line number Diff line number Diff line
@@ -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);

@@ -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);
@@ -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);
@@ -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);

@@ -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);

@@ -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);
@@ -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",
@@ -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)
@@ -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);
		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);
				dev_err(arizona->dev,
					"Removal report failed: %d\n", ret);
		}

		regmap_update_bits(arizona->regmap,
				   ARIZONA_JACK_DETECT_DEBOUNCE,
Loading