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

Commit 86d39839 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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

Merge tag 'extcon-next-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon for v4.1

This patchset include two new extcon driver and fix minor issue of extcon
driver.

Detailed description for patchset:
1. new extcon-max77843.c and extcon-usb-gpio.c extcon driver
- extcon-max77843.c driver support the MAXIM MAX77843 MUIC (Micor-USB Interface
Controller) device which handles the various external connectors such as TA/USB
/USB-HOST/JIG and so on.
- extcon-usb-gpio.c driver support the USB and USB-HOST cable detection by
using the GPIO pin which is connected to USB ID pin. This GPIO pin updates the
USB cable states.

2. Rename the filename of extcon core driver and add missing locking mechanism
- Rename the previous extcon-class driver.c as extcon.c because '-class'
postfix is not necessary word.
- extcon core driver (extcon.c) used the raw_notifier_chain. It must be
protected by locking mechanism to avoid the list changing while
extcon_update_state() is executed.

3. Fix minor issue of extcon drviers
- Fix cable name by using the capital letter instead of small letter on
extcon-max77693.c driver.
- Clean-up code of extcon-arizona.c to detect headphone cable.
- Fix the wrong return type and variable type on extcon-max77843.c.
- Fix the checkpatch warning of all extcon drivers.
parents 911a8882 66bee35f
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
USB GPIO Extcon device

This is a virtual device used to generate USB cable states from the USB ID pin
connected to a GPIO pin.

Required properties:
- compatible: Should be "linux,extcon-usb-gpio"
- id-gpio: gpio for USB ID pin. See gpio binding.

Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
	extcon_usb1 {
		compatible = "linux,extcon-usb-gpio";
		id-gpio = <&gpio6 1 GPIO_ACTIVE_HIGH>;
	}

	&omap_dwc3_1 {
		extcon = <&extcon_usb1>;
	};
+17 −0
Original line number Diff line number Diff line
@@ -55,6 +55,16 @@ config EXTCON_MAX77693
	  Maxim MAX77693 PMIC. The MAX77693 MUIC is a USB port accessory
	  detector and switch.

config EXTCON_MAX77843
	tristate "MAX77843 EXTCON Support"
	depends on MFD_MAX77843
	select IRQ_DOMAIN
	select REGMAP_I2C
	help
	  If you say yes here you get support for the MUIC device of
	  Maxim MAX77843. The MAX77843 MUIC is a USB port accessory
	  detector add switch.

config EXTCON_MAX8997
	tristate "MAX8997 EXTCON Support"
	depends on MFD_MAX8997 && IRQ_DOMAIN
@@ -93,4 +103,11 @@ config EXTCON_SM5502
	  Silicon Mitus SM5502. The SM5502 is a USB port accessory
	  detector and switch.

config EXTCON_USB_GPIO
	tristate "USB GPIO extcon support"
	depends on GPIOLIB
	help
	  Say Y here to enable GPIO based USB cable detection extcon support.
	  Used typically if GPIO is used for USB ID pin detection.

endif # MULTISTATE_SWITCH
+3 −1
Original line number Diff line number Diff line
@@ -2,13 +2,15 @@
# Makefile for external connector class (extcon) devices
#

obj-$(CONFIG_EXTCON)		+= extcon-class.o
obj-$(CONFIG_EXTCON)		+= extcon.o
obj-$(CONFIG_EXTCON_ADC_JACK)	+= extcon-adc-jack.o
obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
obj-$(CONFIG_EXTCON_GPIO)	+= extcon-gpio.o
obj-$(CONFIG_EXTCON_MAX14577)	+= extcon-max14577.o
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_RT8973A)	+= extcon-rt8973a.o
obj-$(CONFIG_EXTCON_SM5502)	+= extcon-sm5502.o
obj-$(CONFIG_EXTCON_USB_GPIO)	+= extcon-usb-gpio.o
+33 −16
Original line number Diff line number Diff line
@@ -136,18 +136,35 @@ static const char *arizona_cable[] = {

static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);

static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
				    unsigned int magic)
static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
				    bool clamp)
{
	struct arizona *arizona = info->arizona;
	unsigned int mask = 0, val = 0;
	int ret;

	switch (arizona->type) {
	case WM5110:
		mask = ARIZONA_HP1L_SHRTO | ARIZONA_HP1L_FLWR |
		       ARIZONA_HP1L_SHRTI;
		if (clamp)
			val = ARIZONA_HP1L_SHRTO;
		else
			val = ARIZONA_HP1L_FLWR | ARIZONA_HP1L_SHRTI;
		break;
	default:
		mask = ARIZONA_RMV_SHRT_HP1L;
		if (clamp)
			val = ARIZONA_RMV_SHRT_HP1L;
		break;
	};

	mutex_lock(&arizona->dapm->card->dapm_mutex);

	arizona->hpdet_magic = magic;
	arizona->hpdet_clamp = clamp;

	/* Keep the HP output stages disabled while doing the magic */
	if (magic) {
	/* Keep the HP output stages disabled while doing the clamp */
	if (clamp) {
		ret = regmap_update_bits(arizona->regmap,
					 ARIZONA_OUTPUT_ENABLES_1,
					 ARIZONA_OUT1L_ENA |
@@ -158,20 +175,20 @@ static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
				 ret);
	}

	ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000,
				 magic);
	ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
				 mask, val);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n",
		dev_warn(arizona->dev, "Failed to do clamp: %d\n",
				 ret);

	ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000,
				 magic);
	ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
				 mask, val);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n",
		dev_warn(arizona->dev, "Failed to do clamp: %d\n",
			 ret);

	/* Restore the desired state while not doing the magic */
	if (!magic) {
	/* Restore the desired state while not doing the clamp */
	if (!clamp) {
		ret = regmap_update_bits(arizona->regmap,
					 ARIZONA_OUTPUT_ENABLES_1,
					 ARIZONA_OUT1L_ENA |
@@ -603,7 +620,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
			   ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
			   0);

	arizona_extcon_do_magic(info, 0);
	arizona_extcon_hp_clamp(info, false);

	if (id_gpio)
		gpio_set_value_cansleep(id_gpio, 0);
@@ -648,7 +665,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
	if (info->mic)
		arizona_stop_mic(info);

	arizona_extcon_do_magic(info, 0x4000);
	arizona_extcon_hp_clamp(info, true);

	ret = regmap_update_bits(arizona->regmap,
				 ARIZONA_ACCESSORY_DETECT_MODE_1,
@@ -699,7 +716,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)

	info->hpdet_active = true;

	arizona_extcon_do_magic(info, 0x4000);
	arizona_extcon_hp_clamp(info, true);

	ret = regmap_update_bits(arizona->regmap,
				 ARIZONA_ACCESSORY_DETECT_MODE_1,
+1 −4
Original line number Diff line number Diff line
@@ -539,8 +539,6 @@ static void max14577_muic_irq_work(struct work_struct *work)
		dev_err(info->dev, "failed to handle MUIC interrupt\n");

	mutex_unlock(&info->mutex);

	return;
}

/*
@@ -730,8 +728,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
				muic_irq->name, info);
		if (ret) {
			dev_err(&pdev->dev,
				"failed: irq request (IRQ: %d,"
				" error :%d)\n",
				"failed: irq request (IRQ: %d, error :%d)\n",
				muic_irq->irq, ret);
			return ret;
		}
Loading