From cc5454490b514a87ccf99fce7ee224cc95980d99 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 10 Apr 2015 09:25:36 -0600 Subject: coresight: etb10: Print size of buffer we fail to allocate When we initialise the ETB driver we attempt to allocate a buffer suitable for storing the data buffered in the hardware based on sizing information reported by the hardware. Unfortunately if the hardware is not properly configured (for example if power domains are not set up correctly) then we may read back a nonsensically large value and therefore the allocation will be too big to succeed. Print an error message showing the amount of memory we tried to allocate if the buffer allocation fails to help users diagnose such problems. Normally it is bad practice to print an error message on memory allocation failures since there are verbose core messages reported for this but in this case where the allocation size might be incorrect it is a useful hint. Signed-off-by: Mark Brown Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-etb10.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 40049869aecd..46eb9f88a29f 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -462,8 +462,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) drvdata->buf = devm_kzalloc(dev, drvdata->buffer_depth * 4, GFP_KERNEL); - if (!drvdata->buf) + if (!drvdata->buf) { + dev_err(dev, "Failed to allocate %u bytes for buffer data\n", + drvdata->buffer_depth * 4); return -ENOMEM; + } desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); if (!desc) -- cgit v1.2.3 From f5da7cb24b78f2398c80a3ba25438602a68fc3e4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 10 Apr 2015 09:25:37 -0600 Subject: coresight: etb10: Fix check for bogus buffer depth We attempt to sanity check the buffer depth reported by the hardware by making sure it is not less than zero however this check will never be true since the buffer depth is stored in an unsigned integer. Instead change the check to look for the top bit being set which was the intention. Signed-off-by: Mark Brown Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-etb10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 46eb9f88a29f..2a77d83130e6 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -457,7 +457,7 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) drvdata->buffer_depth = etb_get_buffer_depth(drvdata); clk_disable_unprepare(drvdata->clk); - if (drvdata->buffer_depth < 0) + if (drvdata->buffer_depth & 0x80000000) return -EINVAL; drvdata->buf = devm_kzalloc(dev, -- cgit v1.2.3 From ed2c0604ace93a2c9b8fc055ab61fff68704cd1e Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 3 Apr 2015 09:51:26 +0900 Subject: extcon: Add manufactor name of each extcon device This patch adds the manufactor name of each extcon device and removes un-necessary comment in Kconfig. Signed-off-by: Chanwoo Choi --- drivers/extcon/Kconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index fdc0bf0543ce..bd10b6c6962d 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -36,7 +36,7 @@ config EXTCON_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 @@ -46,7 +46,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 @@ -56,7 +56,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 @@ -66,7 +66,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 @@ -81,7 +81,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 @@ -93,7 +93,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 @@ -110,4 +110,4 @@ config EXTCON_USB_GPIO 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 -- cgit v1.2.3 From d0fd5fbc09b17e26408f7e3db22511b57f6bf22e Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Tue, 28 Apr 2015 13:34:27 +0100 Subject: extcon: arizona: Rename hpdet_ip to make its purpose clearer Renamed to hpdet_ip_version to make it clearer what it does and that the value in it is simply a version number. Signed-off-by: Richard Fitzgerald Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index a0ed35b336e4..830c5f94bc18 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -94,7 +94,7 @@ struct arizona_extcon_info { bool detecting; int jack_flips; - int hpdet_ip; + int hpdet_ip_version; struct extcon_dev *edev; }; @@ -380,7 +380,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", @@ -441,7 +441,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", @@ -1161,7 +1161,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; @@ -1172,7 +1172,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; -- cgit v1.2.3 From f03123783d4e43cd59df58e23e963136e04f8280 Mon Sep 17 00:00:00 2001 From: Ramakrishna Pallala Date: Thu, 30 Apr 2015 20:44:45 +0530 Subject: extcon: axp288: Add axp288 extcon driver support This patch adds the extcon support for AXP288 PMIC which has the BC1.2 charger detection capability. Additionally it also adds the USB mux switching support b/w SOC and PMIC based on GPIO control. Signed-off-by: Ramakrishna Pallala Acked-by: Lee Jones [cw00.choi: Modify the log message to keep the consistent log message pattern] Signed-off-by: Chanwoo Choi --- drivers/extcon/Kconfig | 7 + drivers/extcon/Makefile | 1 + drivers/extcon/extcon-axp288.c | 385 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 393 insertions(+) create mode 100644 drivers/extcon/extcon-axp288.c (limited to 'drivers') diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index bd10b6c6962d..b74e1f27688b 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -28,6 +28,13 @@ 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 diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile index 9204114791a3..ba787d04295b 100644 --- a/drivers/extcon/Makefile +++ b/drivers/extcon/Makefile @@ -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 diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c new file mode 100644 index 000000000000..8299adb9b676 --- /dev/null +++ b/drivers/extcon/extcon-axp288.c @@ -0,0 +1,385 @@ +/* + * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver + * + * Copyright (C) 2015 Intel Corporation + * Author: Ramakrishna Pallala + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Power source status register */ +#define PS_STAT_VBUS_TRIGGER BIT(0) +#define PS_STAT_BAT_CHRG_DIR BIT(2) +#define PS_STAT_VBUS_ABOVE_VHOLD BIT(3) +#define PS_STAT_VBUS_VALID BIT(4) +#define PS_STAT_VBUS_PRESENT BIT(5) + +/* BC module global register */ +#define BC_GLOBAL_RUN BIT(0) +#define BC_GLOBAL_DET_STAT BIT(2) +#define BC_GLOBAL_DBP_TOUT BIT(3) +#define BC_GLOBAL_VLGC_COM_SEL BIT(4) +#define BC_GLOBAL_DCD_TOUT_MASK (BIT(6)|BIT(5)) +#define BC_GLOBAL_DCD_TOUT_300MS 0 +#define BC_GLOBAL_DCD_TOUT_100MS 1 +#define BC_GLOBAL_DCD_TOUT_500MS 2 +#define BC_GLOBAL_DCD_TOUT_900MS 3 +#define BC_GLOBAL_DCD_DET_SEL BIT(7) + +/* BC module vbus control and status register */ +#define VBUS_CNTL_DPDM_PD_EN BIT(4) +#define VBUS_CNTL_DPDM_FD_EN BIT(5) +#define VBUS_CNTL_FIRST_PO_STAT BIT(6) + +/* BC USB status register */ +#define USB_STAT_BUS_STAT_MASK (BIT(3)|BIT(2)|BIT(1)|BIT(0)) +#define USB_STAT_BUS_STAT_SHIFT 0 +#define USB_STAT_BUS_STAT_ATHD 0 +#define USB_STAT_BUS_STAT_CONN 1 +#define USB_STAT_BUS_STAT_SUSP 2 +#define USB_STAT_BUS_STAT_CONF 3 +#define USB_STAT_USB_SS_MODE BIT(4) +#define USB_STAT_DEAD_BAT_DET BIT(6) +#define USB_STAT_DBP_UNCFG BIT(7) + +/* BC detect status register */ +#define DET_STAT_MASK (BIT(7)|BIT(6)|BIT(5)) +#define DET_STAT_SHIFT 5 +#define DET_STAT_SDP 1 +#define DET_STAT_CDP 2 +#define DET_STAT_DCP 3 + +/* IRQ enable-1 register */ +#define PWRSRC_IRQ_CFG_MASK (BIT(4)|BIT(3)|BIT(2)) + +/* IRQ enable-6 register */ +#define BC12_IRQ_CFG_MASK BIT(1) + +#define AXP288_EXTCON_SLOW_CHARGER "SLOW-CHARGER" +#define AXP288_EXTCON_DOWNSTREAM_CHARGER "CHARGE-DOWNSTREAM" +#define AXP288_EXTCON_FAST_CHARGER "FAST-CHARGER" + +enum axp288_extcon_reg { + AXP288_PS_STAT_REG = 0x00, + AXP288_PS_BOOT_REASON_REG = 0x02, + AXP288_BC_GLOBAL_REG = 0x2c, + AXP288_BC_VBUS_CNTL_REG = 0x2d, + AXP288_BC_USB_STAT_REG = 0x2e, + AXP288_BC_DET_STAT_REG = 0x2f, + AXP288_PWRSRC_IRQ_CFG_REG = 0x40, + AXP288_BC12_IRQ_CFG_REG = 0x45, +}; + +enum axp288_mux_select { + EXTCON_GPIO_MUX_SEL_PMIC = 0, + EXTCON_GPIO_MUX_SEL_SOC, +}; + +enum axp288_extcon_irq { + VBUS_FALLING_IRQ = 0, + VBUS_RISING_IRQ, + MV_CHNG_IRQ, + BC_USB_CHNG_IRQ, + EXTCON_IRQ_END, +}; + +static const char *axp288_extcon_cables[] = { + AXP288_EXTCON_SLOW_CHARGER, + AXP288_EXTCON_DOWNSTREAM_CHARGER, + AXP288_EXTCON_FAST_CHARGER, + NULL, +}; + +struct axp288_extcon_info { + struct device *dev; + struct regmap *regmap; + struct regmap_irq_chip_data *regmap_irqc; + struct axp288_extcon_pdata *pdata; + int irq[EXTCON_IRQ_END]; + struct extcon_dev *edev; + struct notifier_block extcon_nb; + struct usb_phy *otg; +}; + +/* Power up/down reason string array */ +static char *axp288_pwr_up_down_info[] = { + "Last wake caused by user pressing the power button", + "Last wake caused by a charger insertion", + "Last wake caused by a battery insertion", + "Last wake caused by SOC initiated global reset", + "Last wake caused by cold reset", + "Last shutdown caused by PMIC UVLO threshold", + "Last shutdown caused by SOC initiated cold off", + "Last shutdown caused by user pressing the power button", + NULL, +}; + +/* + * Decode and log the given "reset source indicator" (rsi) + * register and then clear it. + */ +static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) +{ + char **rsi; + unsigned int val, i, clear_mask = 0; + int ret; + + ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val); + for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) { + if (val & BIT(i)) { + dev_dbg(info->dev, "%s\n", *rsi); + clear_mask |= BIT(i); + } + } + + /* Clear the register value for next reboot (write 1 to clear bit) */ + regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); +} + +static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) +{ + static bool notify_otg, notify_charger; + static char *cable; + int ret, stat, cfg, pwr_stat; + u8 chrg_type; + bool vbus_attach = false; + + ret = regmap_read(info->regmap, AXP288_PS_STAT_REG, &pwr_stat); + if (ret < 0) { + dev_err(info->dev, "failed to read vbus status\n"); + return ret; + } + + vbus_attach = (pwr_stat & PS_STAT_VBUS_PRESENT); + if (!vbus_attach) + goto notify_otg; + + /* Check charger detection completion status */ + ret = regmap_read(info->regmap, AXP288_BC_GLOBAL_REG, &cfg); + if (ret < 0) + goto dev_det_ret; + if (cfg & BC_GLOBAL_DET_STAT) { + dev_dbg(info->dev, "can't complete the charger detection\n"); + goto dev_det_ret; + } + + ret = regmap_read(info->regmap, AXP288_BC_DET_STAT_REG, &stat); + if (ret < 0) + goto dev_det_ret; + + chrg_type = (stat & DET_STAT_MASK) >> DET_STAT_SHIFT; + + switch (chrg_type) { + case DET_STAT_SDP: + dev_dbg(info->dev, "sdp cable is connecetd\n"); + notify_otg = true; + notify_charger = true; + cable = AXP288_EXTCON_SLOW_CHARGER; + break; + case DET_STAT_CDP: + dev_dbg(info->dev, "cdp cable is connecetd\n"); + notify_otg = true; + notify_charger = true; + cable = AXP288_EXTCON_DOWNSTREAM_CHARGER; + break; + case DET_STAT_DCP: + dev_dbg(info->dev, "dcp cable is connecetd\n"); + notify_charger = true; + cable = AXP288_EXTCON_FAST_CHARGER; + break; + default: + dev_warn(info->dev, + "disconnect or unknown or ID event\n"); + } + +notify_otg: + if (notify_otg) { + /* + * If VBUS is absent Connect D+/D- lines to PMIC for BC + * detection. Else connect them to SOC for USB communication. + */ + if (info->pdata->gpio_mux_cntl) + gpiod_set_value(info->pdata->gpio_mux_cntl, + vbus_attach ? EXTCON_GPIO_MUX_SEL_SOC + : EXTCON_GPIO_MUX_SEL_PMIC); + + atomic_notifier_call_chain(&info->otg->notifier, + vbus_attach ? USB_EVENT_VBUS : USB_EVENT_NONE, NULL); + } + + if (notify_charger) + extcon_set_cable_state(info->edev, cable, vbus_attach); + + /* Clear the flags on disconnect event */ + if (!vbus_attach) + notify_otg = notify_charger = false; + + return 0; + +dev_det_ret: + if (ret < 0) + dev_err(info->dev, "failed to detect BC Mod\n"); + + return ret; +} + +static irqreturn_t axp288_extcon_isr(int irq, void *data) +{ + struct axp288_extcon_info *info = data; + int ret; + + ret = axp288_handle_chrg_det_event(info); + if (ret < 0) + dev_err(info->dev, "failed to handle the interrupt\n"); + + return IRQ_HANDLED; +} + +static void axp288_extcon_enable_irq(struct axp288_extcon_info *info) +{ + /* Unmask VBUS interrupt */ + regmap_write(info->regmap, AXP288_PWRSRC_IRQ_CFG_REG, + PWRSRC_IRQ_CFG_MASK); + regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, + BC_GLOBAL_RUN, 0); + /* Unmask the BC1.2 complete interrupts */ + regmap_write(info->regmap, AXP288_BC12_IRQ_CFG_REG, BC12_IRQ_CFG_MASK); + /* Enable the charger detection logic */ + regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, + BC_GLOBAL_RUN, BC_GLOBAL_RUN); +} + +static int axp288_extcon_probe(struct platform_device *pdev) +{ + struct axp288_extcon_info *info; + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); + int ret, i, pirq, gpio; + + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->dev = &pdev->dev; + info->regmap = axp20x->regmap; + info->regmap_irqc = axp20x->regmap_irqc; + info->pdata = pdev->dev.platform_data; + + if (!info->pdata) { + /* Try ACPI provided pdata via device properties */ + if (!device_property_present(&pdev->dev, + "axp288_extcon_data\n")) + dev_err(&pdev->dev, "failed to get platform data\n"); + return -ENODEV; + } + platform_set_drvdata(pdev, info); + + axp288_extcon_log_rsi(info); + + /* Initialize extcon device */ + info->edev = devm_extcon_dev_allocate(&pdev->dev, + axp288_extcon_cables); + if (IS_ERR(info->edev)) { + dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); + return PTR_ERR(info->edev); + } + + /* Register extcon device */ + ret = devm_extcon_dev_register(&pdev->dev, info->edev); + if (ret) { + dev_err(&pdev->dev, "failed to register extcon device\n"); + return ret; + } + + /* Get otg transceiver phy */ + info->otg = usb_get_phy(USB_PHY_TYPE_USB2); + if (IS_ERR(info->otg)) { + dev_err(&pdev->dev, "failed to get otg transceiver\n"); + return PTR_ERR(info->otg); + } + + /* Set up gpio control for USB Mux */ + if (info->pdata->gpio_mux_cntl) { + gpio = desc_to_gpio(info->pdata->gpio_mux_cntl); + ret = gpio_request(gpio, "USB_MUX"); + if (ret < 0) { + dev_err(&pdev->dev, + "failed to request the gpio=%d\n", gpio); + goto gpio_req_failed; + } + gpiod_direction_output(info->pdata->gpio_mux_cntl, + EXTCON_GPIO_MUX_SEL_PMIC); + } + + for (i = 0; i < EXTCON_IRQ_END; i++) { + pirq = platform_get_irq(pdev, i); + info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq); + if (info->irq[i] < 0) { + dev_err(&pdev->dev, + "failed to get virtual interrupt=%d\n", pirq); + ret = info->irq[i]; + goto gpio_req_failed; + } + + ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], + NULL, axp288_extcon_isr, + IRQF_ONESHOT | IRQF_NO_SUSPEND, + pdev->name, info); + if (ret) { + dev_err(&pdev->dev, "failed to request interrupt=%d\n", + info->irq[i]); + goto gpio_req_failed; + } + } + + /* Enable interrupts */ + axp288_extcon_enable_irq(info); + + return 0; + +gpio_req_failed: + usb_put_phy(info->otg); + return ret; +} + +static int axp288_extcon_remove(struct platform_device *pdev) +{ + struct axp288_extcon_info *info = platform_get_drvdata(pdev); + + usb_put_phy(info->otg); + return 0; +} + +static struct platform_driver axp288_extcon_driver = { + .probe = axp288_extcon_probe, + .remove = axp288_extcon_remove, + .driver = { + .name = "axp288_extcon", + }, +}; +module_platform_driver(axp288_extcon_driver); + +MODULE_AUTHOR("Ramakrishna Pallala "); +MODULE_DESCRIPTION("X-Powers AXP288 extcon driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 71c3ffa5d23af0554c27010cf12710da9bf85950 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 15 Apr 2015 15:02:01 +0900 Subject: extcon: Modify the device name as extcon[X] for sysfs This patch modify the device name as extcon[X] for sysfs by using the 'extcon' prefix word instead of separate device name. On user-space aspect, user would find the some extcon drvier with extcon[X] pattern. So, this patch modify the device name as following: - /sys/class/extcon/[device name] -> /sys/class/extcon/extcon[X] Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 4c9f165e4a04..1a932292d6c8 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -163,7 +163,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, return ret; } - return sprintf(buf, "%s\n", dev_name(&edev->dev)); + return sprintf(buf, "%s\n", edev->name); } static DEVICE_ATTR_RO(name); @@ -701,6 +701,7 @@ EXPORT_SYMBOL_GPL(devm_extcon_dev_free); int extcon_dev_register(struct extcon_dev *edev) { int ret, index = 0; + static atomic_t edev_no = ATOMIC_INIT(-1); if (!extcon_class) { ret = create_extcon_class(); @@ -725,13 +726,14 @@ int extcon_dev_register(struct extcon_dev *edev) edev->dev.class = extcon_class; edev->dev.release = extcon_dev_release; - edev->name = edev->name ? edev->name : dev_name(edev->dev.parent); + edev->name = dev_name(edev->dev.parent); if (IS_ERR_OR_NULL(edev->name)) { dev_err(&edev->dev, "extcon device name is null\n"); return -EINVAL; } - dev_set_name(&edev->dev, "%s", edev->name); + dev_set_name(&edev->dev, "extcon%lu", + (unsigned long)atomic_inc_return(&edev_no)); if (edev->max_supported) { char buf[10]; -- cgit v1.2.3 From 707d7550875a9bd245ce5f1077d2d2cb44eab218 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 15 Apr 2015 13:57:51 +0900 Subject: extcon: Add extcon_get_edev_name() API to get the extcon device name This patch adds the extcon_get_edev_name() API to get the name of extcon device because all information inclued in the structure extcon_dev should be accessed by extcon core API instead of directly accessing the data. Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 1a932292d6c8..c5e9ebf0a914 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1046,6 +1046,15 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) #endif /* CONFIG_OF */ EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); +/** + * extcon_get_edev_name() - Get the name of the extcon device. + * @edev: the extcon device + */ +const char *extcon_get_edev_name(struct extcon_dev *edev) +{ + return !edev ? NULL : edev->name; +} + static int __init extcon_class_init(void) { return create_extcon_class(); -- cgit v1.2.3 From b9ec23c08a0274d31ee626f14b359563ea0cae46 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 24 Apr 2015 14:48:52 +0900 Subject: extcon: Fix the checkpatch warning and minor coding style issue This patch clean up the extcon core driver by fixing the checkpatch warning and minor coding style issue. Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index c5e9ebf0a914..2fb5f757e811 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1,5 +1,5 @@ /* - * drivers/extcon/extcon_class.c + * drivers/extcon/extcon.c - External Connector (extcon) framework. * * External connector (extcon) class driver * @@ -19,8 +19,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * -*/ + */ #include #include @@ -469,7 +468,6 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, ret = raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb); spin_unlock_irqrestore(&obj->edev->lock, flags); - return ret; } else { struct class_dev_iter iter; struct extcon_dev *extd; @@ -489,8 +487,10 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, cable_name, nb); } - return -ENODEV; + ret = -ENODEV; } + + return ret; } EXPORT_SYMBOL_GPL(extcon_register_interest); -- cgit v1.2.3 From a71fbc1525c4fbe894c52256404575c5f697c571 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 15 Apr 2015 15:33:44 +0900 Subject: extcon: arizona: Remove the setting of device name This patch removes the setting of device name. Instead, extcon_dev_register() set the device name such as 'extcon[number]' naming method. - /sys/class/extcon/Headset Jack -> /sys/class/extcon/extcon[number] Cc: Charles Keepax Signed-off-by: Chanwoo Choi Acked-by: Charles Keepax --- drivers/extcon/extcon-arizona.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 830c5f94bc18..50975b3123d6 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1185,7 +1185,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) { -- cgit v1.2.3 From 2b51f9c2f1bd43907e1dc75912de6f06c6f59860 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 30 Apr 2015 23:43:37 +0900 Subject: extcon: arizona: Apply HP clamps correctly for WM8280 The headphone clamping is not set correctly currently, this was missed because the wm8280 patches and the patch fixing the clamping for wm5110 went upstream at very similar times. This patch sets the headphone clamping correctly for wm8280. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 50975b3123d6..5e08c358649b 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -145,6 +145,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) -- cgit v1.2.3 From 9e86b2ad4c11fd52ee8133abce7a29e0b32d29a7 Mon Sep 17 00:00:00 2001 From: Inha Song Date: Mon, 4 May 2015 13:42:13 +0900 Subject: extcon: arizona: Add support for select accessory detect mode when headphone detection This patch add support for select accessory detect mode to HPDETL or HPDETR. Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins to measure the impedance of an external load connected to the headphone. Depending on board design, headphone detect pins can change to HPDETR or HPDETL. Signed-off-by: Inha Song Acked-by: Lee Jones Acked-by: Charles Keepax Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 5e08c358649b..1ec06b4b4875 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -32,13 +32,10 @@ #include #include #include +#include #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 @@ -671,9 +668,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; } @@ -723,9 +720,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; } @@ -1121,6 +1118,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); @@ -1138,6 +1155,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); -- cgit v1.2.3 From 41b3c0154c48940c39401f3ba74ade74badb17c5 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 24 Apr 2015 19:50:48 +0900 Subject: extcon: Unify the jig cable names on rt8973 and max14577/77693/77843 This patch change the name of various jig cables as 'JIG' because the name of various jig cables are strange and ambiguous on user-space aspect. They include the different information of either USB and UART state. It is never important for user-space process. This patch unifies the name of jig cables as following: - JIG-USB-ON -->|--> JIG - JIG-USB-OFF -->| - JIG-UART-ON -->| - JIG-UART-OFF -->| Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-max14577.c | 19 +++---------------- drivers/extcon/extcon-max77693.c | 23 +++-------------------- drivers/extcon/extcon-max77843.c | 37 ++++++++++++------------------------- drivers/extcon/extcon-rt8973a.c | 22 +++++----------------- 4 files changed, 23 insertions(+), 78 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 3823aa4a3a80..6d5febe91a39 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -155,10 +155,7 @@ enum { EXTCON_CABLE_FAST_CHARGER, EXTCON_CABLE_SLOW_CHARGER, EXTCON_CABLE_CHARGE_DOWNSTREAM, - EXTCON_CABLE_JIG_USB_ON, - EXTCON_CABLE_JIG_USB_OFF, - EXTCON_CABLE_JIG_UART_OFF, - EXTCON_CABLE_JIG_UART_ON, + EXTCON_CABLE_JIG, _EXTCON_CABLE_NUM, }; @@ -169,10 +166,7 @@ static const char *max14577_extcon_cable[] = { [EXTCON_CABLE_FAST_CHARGER] = "Fast-charger", [EXTCON_CABLE_SLOW_CHARGER] = "Slow-charger", [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", - [EXTCON_CABLE_JIG_USB_ON] = "JIG-USB-ON", - [EXTCON_CABLE_JIG_USB_OFF] = "JIG-USB-OFF", - [EXTCON_CABLE_JIG_UART_OFF] = "JIG-UART-OFF", - [EXTCON_CABLE_JIG_UART_ON] = "JIG-UART-ON", + [EXTCON_CABLE_JIG] = "JIG", NULL, }; @@ -348,7 +342,6 @@ static int max14577_muic_get_cable_type(struct max14577_muic_info *info, static int max14577_muic_jig_handler(struct max14577_muic_info *info, int cable_type, bool attached) { - char cable_name[32]; int ret = 0; u8 path = CTRL1_SW_OPEN; @@ -358,18 +351,12 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info, switch (cable_type) { case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */ - /* PATH:AP_USB */ - strcpy(cable_name, "JIG-USB-OFF"); - path = CTRL1_SW_USB; - break; case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */ /* PATH:AP_USB */ - strcpy(cable_name, "JIG-USB-ON"); path = CTRL1_SW_USB; break; case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */ /* PATH:AP_UART */ - strcpy(cable_name, "JIG-UART-OFF"); path = CTRL1_SW_UART; break; default: @@ -382,7 +369,7 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info, if (ret < 0) return ret; - extcon_set_cable_state(info->edev, cable_name, attached); + extcon_set_cable_state(info->edev, "JIG", attached); return 0; } diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index a66bec8f6252..107932105798 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -209,10 +209,7 @@ enum { EXTCON_CABLE_CHARGE_DOWNSTREAM, EXTCON_CABLE_MHL, EXTCON_CABLE_MHL_TA, - EXTCON_CABLE_JIG_USB_ON, - EXTCON_CABLE_JIG_USB_OFF, - EXTCON_CABLE_JIG_UART_OFF, - EXTCON_CABLE_JIG_UART_ON, + EXTCON_CABLE_JIG, EXTCON_CABLE_DOCK_SMART, EXTCON_CABLE_DOCK_DESK, EXTCON_CABLE_DOCK_AUDIO, @@ -229,10 +226,7 @@ static const char *max77693_extcon_cable[] = { [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", [EXTCON_CABLE_MHL] = "MHL", [EXTCON_CABLE_MHL_TA] = "MHL-TA", - [EXTCON_CABLE_JIG_USB_ON] = "JIG-USB-ON", - [EXTCON_CABLE_JIG_USB_OFF] = "JIG-USB-OFF", - [EXTCON_CABLE_JIG_UART_OFF] = "JIG-UART-OFF", - [EXTCON_CABLE_JIG_UART_ON] = "JIG-UART-ON", + [EXTCON_CABLE_JIG] = "JIG", [EXTCON_CABLE_DOCK_SMART] = "Dock-Smart", [EXTCON_CABLE_DOCK_DESK] = "Dock-Desk", [EXTCON_CABLE_DOCK_AUDIO] = "Dock-Audio", @@ -642,7 +636,6 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) static int max77693_muic_jig_handler(struct max77693_muic_info *info, int cable_type, bool attached) { - char cable_name[32]; int ret = 0; u8 path = CONTROL1_SW_OPEN; @@ -652,23 +645,13 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info, switch (cable_type) { case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */ - /* PATH:AP_USB */ - strcpy(cable_name, "JIG-USB-OFF"); - path = CONTROL1_SW_USB; - break; case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */ /* PATH:AP_USB */ - strcpy(cable_name, "JIG-USB-ON"); path = CONTROL1_SW_USB; break; case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */ - /* PATH:AP_UART */ - strcpy(cable_name, "JIG-UART-OFF"); - path = CONTROL1_SW_UART; - break; case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */ /* PATH:AP_UART */ - strcpy(cable_name, "JIG-UART-ON"); path = CONTROL1_SW_UART; break; default: @@ -681,7 +664,7 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info, if (ret < 0) return ret; - extcon_set_cable_state(info->edev, cable_name, attached); + extcon_set_cable_state(info->edev, "JIG", attached); return 0; } diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index 8db6a926ea07..d64aed485fdc 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -127,10 +127,7 @@ enum { MAX77843_CABLE_SLOW_CHARGER, MAX77843_CABLE_MHL, MAX77843_CABLE_MHL_TA, - MAX77843_CABLE_JIG_USB_ON, - MAX77843_CABLE_JIG_USB_OFF, - MAX77843_CABLE_JIG_UART_ON, - MAX77843_CABLE_JIG_UART_OFF, + MAX77843_CABLE_JIG, MAX77843_CABLE_NUM, }; @@ -144,10 +141,7 @@ static const char *max77843_extcon_cable[] = { [MAX77843_CABLE_SLOW_CHARGER] = "SLOW-CHARGER", [MAX77843_CABLE_MHL] = "MHL", [MAX77843_CABLE_MHL_TA] = "MHL-TA", - [MAX77843_CABLE_JIG_USB_ON] = "JIG-USB-ON", - [MAX77843_CABLE_JIG_USB_OFF] = "JIG-USB-OFF", - [MAX77843_CABLE_JIG_UART_ON] = "JIG-UART-ON", - [MAX77843_CABLE_JIG_UART_OFF] = "JIG-UART-OFF", + [MAX77843_CABLE_JIG] = "JIG", }; struct max77843_muic_irq { @@ -385,36 +379,29 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, int cable_type, bool attached) { int ret; + u8 path = CONTROL1_SW_OPEN; dev_dbg(info->dev, "external connector is %s (adc:0x%02x)\n", attached ? "attached" : "detached", cable_type); switch (cable_type) { case MAX77843_MUIC_ADC_FACTORY_MODE_USB_OFF: - ret = max77843_muic_set_path(info, CONTROL1_SW_USB, attached); - if (ret < 0) - return ret; - extcon_set_cable_state(info->edev, "JIG-USB-OFF", attached); - break; case MAX77843_MUIC_ADC_FACTORY_MODE_USB_ON: - ret = max77843_muic_set_path(info, CONTROL1_SW_USB, attached); - if (ret < 0) - return ret; - extcon_set_cable_state(info->edev, "JIG-USB-ON", attached); + path = CONTROL1_SW_USB; break; case MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF: - ret = max77843_muic_set_path(info, CONTROL1_SW_UART, attached); - if (ret < 0) - return ret; - extcon_set_cable_state(info->edev, "JIG-UART-OFF", attached); + path = CONTROL1_SW_UART; break; default: - ret = max77843_muic_set_path(info, CONTROL1_SW_OPEN, attached); - if (ret < 0) - return ret; - break; + return -EINVAL; } + ret = max77843_muic_set_path(info, path, attached); + if (ret < 0) + return ret; + + extcon_set_cable_state(info->edev, "JIG", attached); + return 0; } diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c index 9ccd5af89d1c..8c2194fde387 100644 --- a/drivers/extcon/extcon-rt8973a.c +++ b/drivers/extcon/extcon-rt8973a.c @@ -94,10 +94,7 @@ enum { EXTCON_CABLE_USB = 0, EXTCON_CABLE_USB_HOST, EXTCON_CABLE_TA, - EXTCON_CABLE_JIG_OFF_USB, - EXTCON_CABLE_JIG_ON_USB, - EXTCON_CABLE_JIG_OFF_UART, - EXTCON_CABLE_JIG_ON_UART, + EXTCON_CABLE_JIG, EXTCON_CABLE_END, }; @@ -106,10 +103,7 @@ static const char *rt8973a_extcon_cable[] = { [EXTCON_CABLE_USB] = "USB", [EXTCON_CABLE_USB_HOST] = "USB-Host", [EXTCON_CABLE_TA] = "TA", - [EXTCON_CABLE_JIG_OFF_USB] = "JIG-USB-OFF", - [EXTCON_CABLE_JIG_ON_USB] = "JIG-USB-ON", - [EXTCON_CABLE_JIG_OFF_UART] = "JIG-UART-OFF", - [EXTCON_CABLE_JIG_ON_UART] = "JIG-UART-ON", + [EXTCON_CABLE_JIG] = "JIG", NULL, }; @@ -355,19 +349,13 @@ static int rt8973a_muic_cable_handler(struct rt8973a_muic_info *info, con_sw = DM_DP_SWITCH_OPEN; break; case RT8973A_MUIC_ADC_FACTORY_MODE_BOOT_OFF_USB: - idx = EXTCON_CABLE_JIG_OFF_USB; - con_sw = DM_DP_SWITCH_UART; - break; case RT8973A_MUIC_ADC_FACTORY_MODE_BOOT_ON_USB: - idx = EXTCON_CABLE_JIG_ON_USB; - con_sw = DM_DP_SWITCH_UART; + idx = EXTCON_CABLE_JIG; + con_sw = DM_DP_SWITCH_USB; break; case RT8973A_MUIC_ADC_FACTORY_MODE_BOOT_OFF_UART: - idx = EXTCON_CABLE_JIG_OFF_UART; - con_sw = DM_DP_SWITCH_UART; - break; case RT8973A_MUIC_ADC_FACTORY_MODE_BOOT_ON_UART: - idx = EXTCON_CABLE_JIG_ON_UART; + idx = EXTCON_CABLE_JIG; con_sw = DM_DP_SWITCH_UART; break; case RT8973A_MUIC_ADC_USB: -- cgit v1.2.3 From d519c423ff4f1de2fd48778eacef1696a03ed934 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Sat, 25 Apr 2015 19:05:10 +0900 Subject: extcon: Unify the dock device names on max8997/77693 This patch change the name of various dock devices as 'DOCK' because the name of various dock devices have not the standard naming rules. The name of dock devices include the differenct word but it is ambiguous and never important information on user-space aspect. This patch unifies the name of dock devices as following: - Dock-Smart -->|--> DOCK - Dock-Desk -->| - Dock-Audio -->| - Dock-Card -->| Signed-off-by: Chanwoo Choi Reviewed-by: Krzysztof Kozlowski --- drivers/extcon/extcon-max77693.c | 31 +++++++++++++------------------ drivers/extcon/extcon-max8997.c | 10 +++------- 2 files changed, 16 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 107932105798..652bb13739f1 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -210,9 +210,7 @@ enum { EXTCON_CABLE_MHL, EXTCON_CABLE_MHL_TA, EXTCON_CABLE_JIG, - EXTCON_CABLE_DOCK_SMART, - EXTCON_CABLE_DOCK_DESK, - EXTCON_CABLE_DOCK_AUDIO, + EXTCON_CABLE_DOCK, _EXTCON_CABLE_NUM, }; @@ -227,9 +225,7 @@ static const char *max77693_extcon_cable[] = { [EXTCON_CABLE_MHL] = "MHL", [EXTCON_CABLE_MHL_TA] = "MHL-TA", [EXTCON_CABLE_JIG] = "JIG", - [EXTCON_CABLE_DOCK_SMART] = "Dock-Smart", - [EXTCON_CABLE_DOCK_DESK] = "Dock-Desk", - [EXTCON_CABLE_DOCK_AUDIO] = "Dock-Audio", + [EXTCON_CABLE_DOCK] = "DOCK", NULL, }; @@ -501,15 +497,15 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info, } /* - * Notify Dock-Smart/MHL state. - * - Dock-Smart device include three type of cable which + * Notify Dock/MHL state. + * - Dock device include three type of cable which * are HDMI, USB for mouse/keyboard and micro-usb port - * for USB/TA cable. Dock-Smart device need always exteranl - * power supply(USB/TA cable through micro-usb cable). Dock- - * Smart device support screen output of target to separate + * for USB/TA cable. Dock device need always exteranl + * power supply(USB/TA cable through micro-usb cable). Dock + * device support screen output of target to separate * monitor and mouse/keyboard for desktop mode. * - * Features of 'USB/TA cable with Dock-Smart device' + * Features of 'USB/TA cable with Dock device' * - Support MHL * - Support external output feature of audio * - Support charging through micro-usb port without data @@ -523,14 +519,14 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info, if (ret < 0) return ret; - extcon_set_cable_state(info->edev, "Dock-Smart", attached); + extcon_set_cable_state(info->edev, "DOCK", attached); extcon_set_cable_state(info->edev, "MHL", attached); goto out; case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE: /* Dock-Desk */ - strcpy(dock_name, "Dock-Desk"); + strcpy(dock_name, "DOCK"); break; case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */ - strcpy(dock_name, "Dock-Audio"); + strcpy(dock_name, "DOCK"); if (!attached) extcon_set_cable_state(info->edev, "USB", false); break; @@ -847,7 +843,7 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) extcon_set_cable_state(info->edev, "USB", attached); if (!cable_attached) - extcon_set_cable_state(info->edev, "Dock-Audio", + extcon_set_cable_state(info->edev, "DOCK", cable_attached); break; case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ @@ -876,8 +872,7 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) if (ret < 0) return ret; - extcon_set_cable_state(info->edev, "Dock-Smart", - attached); + extcon_set_cable_state(info->edev, "DOCK", attached); extcon_set_cable_state(info->edev, "MHL", attached); break; diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 5774e56c6422..da269a170fd8 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -153,8 +153,7 @@ enum { EXTCON_CABLE_SLOW_CHARGER, EXTCON_CABLE_CHARGE_DOWNSTREAM, EXTCON_CABLE_MHL, - EXTCON_CABLE_DOCK_DESK, - EXTCON_CABLE_DOCK_CARD, + EXTCON_CABLE_DOCK, EXTCON_CABLE_JIG, _EXTCON_CABLE_NUM, @@ -168,8 +167,7 @@ static const char *max8997_extcon_cable[] = { [EXTCON_CABLE_SLOW_CHARGER] = "Slow-charger", [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", [EXTCON_CABLE_MHL] = "MHL", - [EXTCON_CABLE_DOCK_DESK] = "Dock-Desk", - [EXTCON_CABLE_DOCK_CARD] = "Dock-Card", + [EXTCON_CABLE_DOCK] = "DOCK", [EXTCON_CABLE_JIG] = "JIG", NULL, @@ -374,10 +372,8 @@ static int max8997_muic_handle_dock(struct max8997_muic_info *info, switch (cable_type) { case MAX8997_MUIC_ADC_AV_CABLE_NOLOAD: - extcon_set_cable_state(info->edev, "Dock-desk", attached); - break; case MAX8997_MUIC_ADC_FACTORY_MODE_UART_ON: - extcon_set_cable_state(info->edev, "Dock-card", attached); + extcon_set_cable_state(info->edev, "DOCK", attached); break; default: dev_err(info->dev, "failed to detect %s dock device\n", -- cgit v1.2.3 From 942e0239d51185d6532f3ac846e5ab06db0a86cf Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Sat, 25 Apr 2015 19:06:18 +0900 Subject: extcon: Alter MHL-TA cable name to TA cable name This patch alters the MHL-TA cable name to TA cable name because MHL-TA is not standard name. The MHL-TA is MHL cable with charger cable (TA or USB). So, this patch use the TA cable instead of MHL-TA to inform the charger cable state. - MHL-TA -> TA Signed-off-by: Chanwoo Choi Reviewed-by: Krzysztof Kozlowski --- drivers/extcon/extcon-max77693.c | 12 +++++------- drivers/extcon/extcon-max77843.c | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 652bb13739f1..a4fe7fd3f74d 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -208,7 +208,6 @@ enum { EXTCON_CABLE_SLOW_CHARGER, EXTCON_CABLE_CHARGE_DOWNSTREAM, EXTCON_CABLE_MHL, - EXTCON_CABLE_MHL_TA, EXTCON_CABLE_JIG, EXTCON_CABLE_DOCK, @@ -223,7 +222,6 @@ static const char *max77693_extcon_cable[] = { [EXTCON_CABLE_SLOW_CHARGER] = "Slow-charger", [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", [EXTCON_CABLE_MHL] = "MHL", - [EXTCON_CABLE_MHL_TA] = "MHL-TA", [EXTCON_CABLE_JIG] = "JIG", [EXTCON_CABLE_DOCK] = "DOCK", @@ -802,19 +800,19 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) case MAX77693_MUIC_GND_MHL: case MAX77693_MUIC_GND_MHL_VB: /* - * MHL cable with MHL-TA(USB/TA) cable + * MHL cable with USB/TA cable * - MHL cable include two port(HDMI line and separate * micro-usb port. When the target connect MHL cable, - * extcon driver check whether MHL-TA(USB/TA) cable is - * connected. If MHL-TA cable is connected, extcon + * extcon driver check whether USB/TA cable is + * connected. If USB/TA cable is connected, extcon * driver notify state to notifiee for charging battery. * - * Features of 'MHL-TA(USB/TA) with MHL cable' + * Features of 'USB/TA with MHL cable' * - Support MHL * - Support charging through micro-usb port without * data connection */ - extcon_set_cable_state(info->edev, "MHL-TA", attached); + extcon_set_cable_state(info->edev, "TA", attached); if (!cable_attached) extcon_set_cable_state(info->edev, "MHL", cable_attached); diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index d64aed485fdc..5746d7bc165f 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -126,7 +126,6 @@ enum { MAX77843_CABLE_FAST_CHARGER, MAX77843_CABLE_SLOW_CHARGER, MAX77843_CABLE_MHL, - MAX77843_CABLE_MHL_TA, MAX77843_CABLE_JIG, MAX77843_CABLE_NUM, @@ -140,7 +139,6 @@ static const char *max77843_extcon_cable[] = { [MAX77843_CABLE_FAST_CHARGER] = "FAST-CHARGER", [MAX77843_CABLE_SLOW_CHARGER] = "SLOW-CHARGER", [MAX77843_CABLE_MHL] = "MHL", - [MAX77843_CABLE_MHL_TA] = "MHL-TA", [MAX77843_CABLE_JIG] = "JIG", }; @@ -529,9 +527,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) /* Charger cable on MHL accessory is attach or detach */ if (gnd_type == MAX77843_MUIC_GND_MHL_VB) - extcon_set_cable_state(info->edev, "MHL-TA", true); + extcon_set_cable_state(info->edev, "TA", true); else if (gnd_type == MAX77843_MUIC_GND_MHL) - extcon_set_cable_state(info->edev, "MHL-TA", false); + extcon_set_cable_state(info->edev, "TA", false); break; case MAX77843_MUIC_CHG_NONE: break; -- cgit v1.2.3 From c571bbb4b699cfd3af5b4c1027b04eb4290e6726 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Sat, 25 Apr 2015 18:44:47 +0900 Subject: extcon: adc-jack: Remove the unneeded num_cables field This patch removes the 'num_cables' filed from 'struct adc_jack_pdata' because 'struct extcon_dev' contains the 'max_supported' field which means the number of supported cable of extcon device. Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-adc-jack.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 2bb82e55065a..768eaed66380 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -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). @@ -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; @@ -114,16 +112,6 @@ static int adc_jack_probe(struct platform_device *pdev) } 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) { dev_err(&pdev->dev, "error: adc_conditions not defined.\n"); -- cgit v1.2.3 From 638f958baeaf9d50f42cd09993f518b3a7a0f52e Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 5 May 2015 18:32:20 +0200 Subject: extcon: Allow compile test of GPIO consumers if !GPIOLIB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where appropriate. If GPIOLIB=n and asm-generic/gpio.h is not used: drivers/extcon/extcon-usb-gpio.c: In function ‘usb_extcon_detect_cable’: drivers/extcon/extcon-usb-gpio.c:63: error: implicit declaration of function ‘gpiod_get_value_cansleep’ drivers/extcon/extcon-usb-gpio.c: In function ‘usb_extcon_probe’: drivers/extcon/extcon-usb-gpio.c:116: error: implicit declaration of function ‘devm_gpiod_get’ drivers/extcon/extcon-usb-gpio.c:116: warning: assignment makes pointer from integer without a cast drivers/extcon/extcon-usb-gpio.c:122: error: implicit declaration of function ‘gpiod_set_debounce’ drivers/extcon/extcon-usb-gpio.c:129: error: implicit declaration of function ‘gpiod_to_irq’ Add the missing #include to fix this. Signed-off-by: Geert Uytterhoeven Signed-off-by: Chanwoo Choi --- drivers/extcon/Kconfig | 4 ++-- drivers/extcon/extcon-usb-gpio.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index b74e1f27688b..0cebbf668886 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -37,7 +37,7 @@ config EXTCON_AXP288 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. @@ -112,7 +112,7 @@ 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. diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index e45d1f13f445..160ec12c2653 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include -- cgit v1.2.3 From d71aadda19f83521eca301cb154b81a7bcca78a2 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 4 May 2015 20:20:27 +0900 Subject: extcon: Remove the optional name of extcon device This patch removes the optional name of extcon device. Instead, extcon_dev_register() set the device name as 'extcon[number]' naming pattern. - /sys/class/extcon/[hardcoded device name] -> /sys/class/extcon/extcon[number] Signed-off-by: Chanwoo Choi Acked-by: Krzysztof Kozlowski Cc: MyungJoo Ham Cc: Charles Keepax Cc: Graeme Gregory Cc: Kishon Vijay Abraham I Cc: Krzysztof Kozlowski Cc: Jaewon Kim --- drivers/extcon/extcon-adc-jack.c | 1 - drivers/extcon/extcon-gpio.c | 1 - drivers/extcon/extcon-max14577.c | 2 -- drivers/extcon/extcon-max77693.c | 1 - drivers/extcon/extcon-max8997.c | 1 - drivers/extcon/extcon-palmas.c | 1 - drivers/extcon/extcon-rt8973a.c | 1 - drivers/extcon/extcon-sm5502.c | 1 - 8 files changed, 9 deletions(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 768eaed66380..5bf08ec1cacf 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -110,7 +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; if (!pdata->adc_conditions || !pdata->adc_conditions[0].state) { diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 7af33fc433cd..355459a54e8b 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -104,7 +104,6 @@ static int gpio_extcon_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to allocate extcon device\n"); return -ENOMEM; } - extcon_data->edev->name = pdata->name; extcon_data->gpio = pdata->gpio; extcon_data->gpio_active_low = pdata->gpio_active_low; diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 6d5febe91a39..ad8f8ddc8e51 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -729,8 +729,6 @@ static int max14577_muic_probe(struct platform_device *pdev) return -ENOMEM; } - info->edev->name = dev_name(&pdev->dev); - ret = devm_extcon_dev_register(&pdev->dev, info->edev); if (ret) { dev_err(&pdev->dev, "failed to register extcon device\n"); diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index a4fe7fd3f74d..c274249245ff 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1158,7 +1158,6 @@ static int max77693_muic_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); return -ENOMEM; } - info->edev->name = DEV_NAME; ret = devm_extcon_dev_register(&pdev->dev, info->edev); if (ret) { diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index da269a170fd8..33613c490d34 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -696,7 +696,6 @@ static int max8997_muic_probe(struct platform_device *pdev) ret = -ENOMEM; goto err_irq; } - info->edev->name = DEV_NAME; ret = devm_extcon_dev_register(&pdev->dev, info->edev); if (ret) { diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 11c6757b6c40..9c8943d691b1 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -193,7 +193,6 @@ static int palmas_usb_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to allocate extcon device\n"); return -ENOMEM; } - palmas_usb->edev->name = kstrdup(node->name, GFP_KERNEL); palmas_usb->edev->mutually_exclusive = mutually_exclusive; status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev); diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c index 8c2194fde387..04447f36c994 100644 --- a/drivers/extcon/extcon-rt8973a.c +++ b/drivers/extcon/extcon-rt8973a.c @@ -631,7 +631,6 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *i2c, dev_err(info->dev, "failed to allocate memory for extcon\n"); return -ENOMEM; } - info->edev->name = np->name; /* Register extcon device */ ret = devm_extcon_dev_register(info->dev, info->edev); diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index 2f93cf307852..6f1d11f8723b 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c @@ -623,7 +623,6 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2c, dev_err(info->dev, "failed to allocate memory for extcon\n"); return -ENOMEM; } - info->edev->name = np->name; /* Register extcon device */ ret = devm_extcon_dev_register(info->dev, info->edev); -- cgit v1.2.3 From 35eed7a0768886e2f66db3cdbf3faf6435275e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 19 May 2015 14:18:30 +0200 Subject: extcon: usb-gpio: use flags argument of devm_gpiod_get to set direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Without this patch there is no call to gpiod_direction_input but the gpio is used for irq reporting and for that the line should be in input mode. Signed-off-by: Uwe Kleine-König Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-usb-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index 160ec12c2653..900744b978fc 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -114,7 +114,7 @@ static int usb_extcon_probe(struct platform_device *pdev) return -ENOMEM; info->dev = dev; - info->id_gpiod = devm_gpiod_get(&pdev->dev, "id"); + info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); if (IS_ERR(info->id_gpiod)) { dev_err(dev, "failed to get ID GPIO\n"); return PTR_ERR(info->id_gpiod); -- cgit v1.2.3 From 2a9de9c0f08d61fbe3764a21d22d0b72df97d6ae Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 24 Apr 2015 19:16:05 +0900 Subject: extcon: Use the unique id for external connector instead of string This patch uses the unique id to identify the type of external connector instead of string name. The string name have the many potential issues. So, this patch defines the 'extcon' enumeration which includes all supported external connector on EXTCON subsystem. If new external connector is necessary, the unique id of new connector have to be added in 'extcon' enumeration. There are current supported external connector in 'enum extcon' 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, EXTCON_HDMI = 0x30, EXTCON_MHL = 0x31, EXTCON_DVI = 0x32, EXTCON_VGA = 0x33, EXTCON_SPDIF_IN = 0x34, EXTCON_SPDIF_OUT = 0x35, EXTCON_VIDEO_IN = 0x36, EXTCON_VIDEO_OUT = 0x37, /* Miscellaneous external connector */ EXTCON_DOCK = 0x50, EXTCON_JIG = 0x51, EXTCON_MECHANICAL = 0x52, EXTCON_END, }; For example in extcon-arizona.c: To use unique id removes the potential issue about handling the inconsistent name of external connector with string. - Previously, use the string to register the type of arizona jack connector static const char *arizona_cable[] = { "Mechanical", "Microphone", "Headphone", "Line-out", }; - Newly, use the unique id to register the type of arizona jack connector static const enum extcon arizona_cable[] = { EXTCON_MECHANICAL, EXTCON_MICROPHONE, EXTCON_HEADPHONE, EXTCON_LINE_OUT, EXTCON_NONE, }; And this patch modify the prototype of extcon_{get|set}_cable_state_() which uses the 'enum extcon id' instead of 'cable_index'. Because although one more extcon drivers support USB cable, each extcon driver might has the differnt 'cable_index' for USB cable. All extcon drivers can use the unique id number for same external connector with modified extcon_{get|set}_cable_state_(). - Previously, use 'cable_index' on these functions: extcon_get_cable_state_(struct extcon_dev*, int cable_index) extcon_set_cable_state_(struct extcon_dev*, int cable_index, bool state) -Newly, use 'enum extcon id' on these functions: extcon_get_cable_state_(struct extcon_dev*, enum extcon id) extcon_set_cable_state_(struct extcon_dev*, enum extcon id, bool state) Cc: Arnd Bergmann Cc: Felipe Balbi Signed-off-by: Chanwoo Choi Acked-by: Roger Quadros Acked-by: Charles Keepax Acked-by: Ramakrishna Pallala Reviewed-by: Krzysztof Kozlowski [arnd: Report the build break about drivers/usb/phy/phy-tahvo.c after using the unique id for external connector insteadf of string] Reported-by: Arnd Bergmann [dan.carpenter: Report the build warning of extcon_{set|get}_cable_state_()] Reported-by: Dan Carpenter --- drivers/extcon/extcon-arizona.c | 38 ++++----- drivers/extcon/extcon-axp288.c | 24 +++--- drivers/extcon/extcon-max14577.c | 45 ++++------- drivers/extcon/extcon-max77693.c | 95 ++++++++++------------- drivers/extcon/extcon-max77843.c | 56 ++++++-------- drivers/extcon/extcon-max8997.c | 59 ++++++-------- drivers/extcon/extcon-palmas.c | 22 +++--- drivers/extcon/extcon-rt8973a.c | 40 ++++------ drivers/extcon/extcon-sm5502.c