Skip to content

Commit

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

Chanwoo writes:

Update extcon for v4.2

This patchset include the huge update of extcon core and add the new one extcon
driver and fix minor isseu of extcon drivers.

Detailed description for patchset:
1. Update the extcon core.
- Modify the extcon device name on sysfs from device name name to 'extcon[X]'
as following because if same extcon device are included in H/W development board,
the one of the two device driver might be failed on the probe().
: /sys/class/extcon/[device name] -> /sys/class/extcon/extcon[X]

- Use the unique id for external connectors instead of legacy string name.
Previously, extcon used the string name to identify the type of external
connectors. This way have the many potential issues. So, extcon core define the
unique id for each external connectors as following:

	enum extcon {
		EXTCON_NONE             = 0x0,

		/* USB external connector */
		EXTCON_USB              = 0x1,
		EXTCON_USB_HOST		= 0x2,

		/* Charger external connector */
		EXTCON_TA		= 0x10,
		EXTCON_FAST_CHARGER	= 0x11,
		EXTCON_SLOW_CHARGER	= 0x12,
		EXTCON_CHARGE_DOWNSTREAM = 0x13,

		/* Audio and video external connector */
		EXTCON_LINE_IN		= 0x20,
		EXTCON_LINE_OUT		= 0x21,
		EXTCON_MICROPHONE	= 0x22,
		EXTCON_HEADPHONE	= 0x23,
		...
	};

- Update tye prototype of extcon_register_notifier() by using the unique id
(enum extcon) of external connectors.

- Add extcon_get_edev_name() API to get the name of extcon device on extcon
client driver because the name is included in 'struct extcon_dev' and 'struct
extcon_dev' should be handled in only drivers/extcon directory. So. if extcon
client need the name of extcon device, they could use this function.

- Unify the jig/dock and MHL-TA cable name on extcon driver.
: JIG-{USB-ON|USB-OFF|UART-ON|UART-OFF} -> JIG
: Dock-{Smart|Desk|Audio|Card} -> DOCK
: MHL-TA -> TA

- Use the capital letter for the name of all external connectors.
- Remove the optional print_name() function pointer from struct extcon_dev to
maintain the consistent name of extcon device.

2. Add the new extcon-axp288.c extcon driver.
- The extcon-axp288.c driver support for AXP288 PMIC which has the BC1.2
charger detection capability. So this extcon driver can detect the
EXTCON_SLOW_CHARGER, EXTCON_CHARGE_DOWNSTREAM and EXTCON_FAST_CHARGER.

3. Update the extcon-arizona.c driver.
- Add support for selective detection mode when headphone detection.
- Apply HP clamps for WM8280

4. Clean-up the extcon core and drivers.
- Add manufactor information of each extcon device.
- Fix checkpatch warning and minor coding style on extcon.c.c
- Fix build break if GPIOLIB is not enabled on extcon-usb-gpiio.c.
- Set the direction of gpio when calling devm_gpiod_get() on extcon-usb-gpio.c
  • Loading branch information
Greg Kroah-Hartman committed Jun 3, 2015
2 parents 1f656ff + f8df880 commit 00465f4
Show file tree
Hide file tree
Showing 22 changed files with 885 additions and 613 deletions.
6 changes: 6 additions & 0 deletions Documentation/devicetree/bindings/mfd/arizona.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Optional properties:
present, the number of values should be less than or equal to the
number of inputs, unspecified inputs will use the chip default.

- wlf,hpdet-channel : Headphone detection channel.
ARIZONA_ACCDET_MODE_HPL or 1 - Headphone detect mode is set to HPDETL
ARIZONA_ACCDET_MODE_HPR or 2 - Headphone detect mode is set to HPDETR
If this node is not mentioned or if the value is unknown, then
headphone detection mode is set to HPDETL.

- DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
they are being externally supplied. As covered in
Documentation/devicetree/bindings/regulator/regulator.txt
Expand Down
25 changes: 16 additions & 9 deletions drivers/extcon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@ config EXTCON_ARIZONA
with Wolfson Arizona devices. These are audio CODECs with
advanced audio accessory detection support.

config EXTCON_AXP288
tristate "X-Power AXP288 EXTCON support"
depends on MFD_AXP20X && USB_PHY
help
Say Y here to enable support for USB peripheral detection
and USB MUX switching by X-Power AXP288 PMIC.

config EXTCON_GPIO
tristate "GPIO extcon support"
depends on GPIOLIB
depends on GPIOLIB || COMPILE_TEST
help
Say Y here to enable GPIO based extcon support. Note that GPIO
extcon supports single state per extcon instance.

config EXTCON_MAX14577
tristate "MAX14577/77836 EXTCON Support"
tristate "Maxim MAX14577/77836 EXTCON Support"
depends on MFD_MAX14577
select IRQ_DOMAIN
select REGMAP_I2C
Expand All @@ -46,7 +53,7 @@ config EXTCON_MAX14577
detector and switch.

config EXTCON_MAX77693
tristate "MAX77693 EXTCON Support"
tristate "Maxim MAX77693 EXTCON Support"
depends on MFD_MAX77693 && INPUT
select IRQ_DOMAIN
select REGMAP_I2C
Expand All @@ -56,7 +63,7 @@ config EXTCON_MAX77693
detector and switch.

config EXTCON_MAX77843
tristate "MAX77843 EXTCON Support"
tristate "Maxim MAX77843 EXTCON Support"
depends on MFD_MAX77843
select IRQ_DOMAIN
select REGMAP_I2C
Expand All @@ -66,7 +73,7 @@ config EXTCON_MAX77843
detector add switch.

config EXTCON_MAX8997
tristate "MAX8997 EXTCON Support"
tristate "Maxim MAX8997 EXTCON Support"
depends on MFD_MAX8997 && IRQ_DOMAIN
help
If you say yes here you get support for the MUIC device of
Expand All @@ -81,7 +88,7 @@ config EXTCON_PALMAS
detection by palmas usb.

config EXTCON_RT8973A
tristate "RT8973A EXTCON support"
tristate "Richtek RT8973A EXTCON support"
depends on I2C
select IRQ_DOMAIN
select REGMAP_I2C
Expand All @@ -93,7 +100,7 @@ config EXTCON_RT8973A
from abnormal high input voltage (up to 28V).

config EXTCON_SM5502
tristate "SM5502 EXTCON support"
tristate "Silicon Mitus SM5502 EXTCON support"
depends on I2C
select IRQ_DOMAIN
select REGMAP_I2C
Expand All @@ -105,9 +112,9 @@ config EXTCON_SM5502

config EXTCON_USB_GPIO
tristate "USB GPIO extcon support"
depends on GPIOLIB
depends on GPIOLIB || COMPILE_TEST
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
endif
1 change: 1 addition & 0 deletions drivers/extcon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
obj-$(CONFIG_EXTCON) += extcon.o
obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o
obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
obj-$(CONFIG_EXTCON_AXP288) += extcon-axp288.o
obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o
obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o
Expand Down
13 changes: 0 additions & 13 deletions drivers/extcon/extcon-adc-jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* struct adc_jack_data - internal data for adc_jack device driver
* @edev: extcon device.
* @cable_names: list of supported cables.
* @num_cables: size of cable_names.
* @adc_conditions: list of adc value conditions.
* @num_conditions: size of adc_conditions.
* @irq: irq number of attach/detach event (0 if not exist).
Expand All @@ -42,7 +41,6 @@ struct adc_jack_data {
struct extcon_dev *edev;

const char **cable_names;
int num_cables;
struct adc_jack_cond *adc_conditions;
int num_conditions;

Expand Down Expand Up @@ -112,17 +110,6 @@ static int adc_jack_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to allocate extcon device\n");
return -ENOMEM;
}
data->edev->name = pdata->name;

/* Check the length of array and set num_cables */
for (i = 0; data->edev->supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
return -EINVAL;
}
data->num_cables = i;

if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
Expand Down
88 changes: 51 additions & 37 deletions drivers/extcon/extcon-arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
#include <dt-bindings/mfd/arizona.h>

#define ARIZONA_MAX_MICD_RANGE 8

#define ARIZONA_ACCDET_MODE_MIC 0
#define ARIZONA_ACCDET_MODE_HPL 1
#define ARIZONA_ACCDET_MODE_HPR 2

#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4
#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5
#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
Expand Down Expand Up @@ -94,7 +91,7 @@ struct arizona_extcon_info {
bool detecting;
int jack_flips;

int hpdet_ip;
int hpdet_ip_version;

struct extcon_dev *edev;
};
Expand All @@ -121,17 +118,12 @@ static const int arizona_micd_levels[] = {
1257,
};

#define ARIZONA_CABLE_MECHANICAL 0
#define ARIZONA_CABLE_MICROPHONE 1
#define ARIZONA_CABLE_HEADPHONE 2
#define ARIZONA_CABLE_LINEOUT 3

static const char *arizona_cable[] = {
"Mechanical",
"Microphone",
"Headphone",
"Line-out",
NULL,
static const enum extcon arizona_cable[] = {
EXTCON_MECHANICAL,
EXTCON_MICROPHONE,
EXTCON_HEADPHONE,
EXTCON_LINE_OUT,
EXTCON_NONE,
};

static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
Expand All @@ -145,6 +137,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,

switch (arizona->type) {
case WM5110:
case WM8280:
mask = ARIZONA_HP1L_SHRTO | ARIZONA_HP1L_FLWR |
ARIZONA_HP1L_SHRTI;
if (clamp)
Expand Down Expand Up @@ -380,7 +373,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
return ret;
}

switch (info->hpdet_ip) {
switch (info->hpdet_ip_version) {
case 0:
if (!(val & ARIZONA_HP_DONE)) {
dev_err(arizona->dev, "HPDET did not complete: %x\n",
Expand Down Expand Up @@ -441,7 +434,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)

default:
dev_warn(arizona->dev, "Unknown HPDET IP revision %d\n",
info->hpdet_ip);
info->hpdet_ip_version);
case 2:
if (!(val & ARIZONA_HP_DONE_B)) {
dev_err(arizona->dev, "HPDET did not complete: %x\n",
Expand Down Expand Up @@ -559,7 +552,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
struct arizona_extcon_info *info = data;
struct arizona *arizona = info->arizona;
int id_gpio = arizona->pdata.hpdet_id_gpio;
int report = ARIZONA_CABLE_HEADPHONE;
enum extcon report = EXTCON_HEADPHONE;
int ret, reading;
bool mic = false;

Expand All @@ -573,7 +566,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, ARIZONA_CABLE_MECHANICAL);
ret = extcon_get_cable_state_(info->edev, EXTCON_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -604,9 +597,9 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)

/* Report high impedence cables as line outputs */
if (reading >= 5000)
report = ARIZONA_CABLE_LINEOUT;
report = EXTCON_LINE_OUT;
else
report = ARIZONA_CABLE_HEADPHONE;
report = EXTCON_HEADPHONE;

ret = extcon_set_cable_state_(info->edev, report, true);
if (ret != 0)
Expand Down Expand Up @@ -670,9 +663,9 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
ret = regmap_update_bits(arizona->regmap,
ARIZONA_ACCESSORY_DETECT_MODE_1,
ARIZONA_ACCDET_MODE_MASK,
ARIZONA_ACCDET_MODE_HPL);
arizona->pdata.hpdet_channel);
if (ret != 0) {
dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
goto err;
}

Expand All @@ -691,8 +684,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,
ARIZONA_CABLE_HEADPHONE, true);
ret = extcon_set_cable_state_(info->edev, EXTCON_HEADPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);

Expand Down Expand Up @@ -722,9 +714,9 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
ARIZONA_ACCESSORY_DETECT_MODE_1,
ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK,
info->micd_modes[0].src |
ARIZONA_ACCDET_MODE_HPL);
arizona->pdata.hpdet_channel);
if (ret != 0) {
dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
goto err;
}

Expand All @@ -749,8 +741,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,
ARIZONA_CABLE_HEADPHONE, true);
ret = extcon_set_cable_state_(info->edev, EXTCON_HEADPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);

Expand Down Expand Up @@ -789,7 +780,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, ARIZONA_CABLE_MECHANICAL);
ret = extcon_get_cable_state_(info->edev, EXTCON_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -838,8 +829,7 @@ static void arizona_micd_detect(struct work_struct *work)
arizona_identify_headphone(info);

ret = extcon_set_cable_state_(info->edev,
ARIZONA_CABLE_MICROPHONE, true);

EXTCON_MICROPHONE, true);
if (ret != 0)
dev_err(arizona->dev, "Headset report failed: %d\n",
ret);
Expand Down Expand Up @@ -1030,7 +1020,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,
ARIZONA_CABLE_MECHANICAL, true);
EXTCON_MECHANICAL, true);

if (ret != 0)
dev_err(arizona->dev, "Mechanical report failed: %d\n",
Expand Down Expand Up @@ -1120,6 +1110,26 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
regmap_update_bits(arizona->regmap, reg, mask, level);
}

static int arizona_extcon_of_get_pdata(struct arizona *arizona)
{
struct arizona_pdata *pdata = &arizona->pdata;
unsigned int val = ARIZONA_ACCDET_MODE_HPL;

of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", &val);
switch (val) {
case ARIZONA_ACCDET_MODE_HPL:
case ARIZONA_ACCDET_MODE_HPR:
pdata->hpdet_channel = val;
break;
default:
dev_err(arizona->dev,
"Wrong wlf,hpdet-channel DT value %d\n", val);
pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL;
}

return 0;
}

static int arizona_extcon_probe(struct platform_device *pdev)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
Expand All @@ -1137,6 +1147,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
if (!info)
return -ENOMEM;

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev))
arizona_extcon_of_get_pdata(arizona);
}

info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
ret = PTR_ERR(info->micvdd);
Expand All @@ -1161,7 +1176,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
break;
default:
info->micd_clamp = true;
info->hpdet_ip = 1;
info->hpdet_ip_version = 1;
break;
}
break;
Expand All @@ -1172,7 +1187,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
break;
default:
info->micd_clamp = true;
info->hpdet_ip = 2;
info->hpdet_ip_version = 2;
break;
}
break;
Expand All @@ -1185,7 +1200,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to allocate extcon device\n");
return -ENOMEM;
}
info->edev->name = "Headset Jack";

ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret < 0) {
Expand Down
Loading

0 comments on commit 00465f4

Please sign in to comment.