From afe330098d255e698088e010be3cb4fa57e9ff86 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 19 Nov 2015 15:45:39 +0000 Subject: extcon: arizona: Update DT binding documentation for mic detection Add additional bindings to allow configuration of the system specific microphone detection settings. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- .../devicetree/bindings/extcon/extcon-arizona.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index e1705fae63a8..d6618119a9a8 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -13,3 +13,23 @@ Optional properties: 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. + + - wlf,micd-software-compare : Use a software comparison to determine mic + presence + - wlf,micd-detect-debounce : Additional software microphone detection + debounce specified in milliseconds. + - wlf,micd-pol-gpio : GPIO specifier for the GPIO controlling the headset + polarity if one exists. + - wlf,micd-bias-start-time : Time allowed for MICBIAS to startup prior to + performing microphone detection, specified as per the ARIZONA_MICD_TIME_XXX + defines. + - wlf,micd-rate : Delay between successive microphone detection measurements, + specified as per the ARIZONA_MICD_TIME_XXX defines. + - wlf,micd-dbtime : Microphone detection hardware debounces specified as the + number of measurements to take, valid values being 2 and 4. + - wlf,micd-timeout : Timeout for microphone detection, specified in + milliseconds. + - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone + detection. + + - wlf,gpsw : Settings for the general purpose switch -- cgit v1.2.3 From 36a86872964609f2596d22f323070b60b17e08ef Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 19 Nov 2015 15:45:40 +0000 Subject: extcon: arizona: Update DT binding documentation for jack detection Add additional bindings for both inverting the polarity of the jack detection pins and allowing the use of a second jack detection pin. Note that the second jack detection pin is hard wired in the chip so can only be enabled through the binding, rather than a pin being specified. Signed-off-by: Charles Keepax Reviewed-by: Chanwoo Choi Signed-off-by: Chanwoo Choi --- Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index d6618119a9a8..7640a3502c67 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -14,6 +14,12 @@ Optional properties: If this node is not mentioned or if the value is unknown, then headphone detection mode is set to HPDETL. + - wlf,use-jd-gpio : Use GPIO input along with JD1 for dual pin jack + detection. + - wlf,use-jd-gpio-nopull : Internal pull on GPIO is disabled when used for + jack detection. + - wlf,jd-invert : Invert the polarity of the jack detection switch + - wlf,micd-software-compare : Use a software comparison to determine mic presence - wlf,micd-detect-debounce : Additional software microphone detection -- cgit v1.2.3 From 832df9e8ecabec271a0c418bdbb94da826dc5b6d Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Fri, 20 Nov 2015 17:53:59 +0900 Subject: extcon: arizona: Update naming for second jack detection DT binding Update the name for the second jack detection pin binding to be a little less confusing. Signed-off-by: Charles Keepax Acked-by: Rob Herring Signed-off-by: Chanwoo Choi --- Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 4 ++-- drivers/extcon/extcon-arizona.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index 7640a3502c67..8aa0bd430f7b 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -14,9 +14,9 @@ Optional properties: If this node is not mentioned or if the value is unknown, then headphone detection mode is set to HPDETL. - - wlf,use-jd-gpio : Use GPIO input along with JD1 for dual pin jack + - wlf,use-jd2 : Use the additional JD input along with JD1 for dual pin jack detection. - - wlf,use-jd-gpio-nopull : Internal pull on GPIO is disabled when used for + - wlf,use-jd2-nopull : Internal pull on JD2 is disabled when used for jack detection. - wlf,jd-invert : Invert the polarity of the jack detection switch diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 7c9598db318d..c377030807c4 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1245,9 +1245,9 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona) device_property_read_u32(arizona->dev, "wlf,gpsw", &pdata->gpsw); pdata->jd_gpio5 = device_property_read_bool(arizona->dev, - "wlf,use-jd-gpio"); + "wlf,use-jd2"); pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev, - "wlf,use-jd-gpio-nopull"); + "wlf,use-jd2-nopull"); return 0; } -- cgit v1.2.3 From 7a7ef0f2a4b359d0206772bf291781157d07f7dc Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 23 Nov 2015 14:51:30 +0000 Subject: extcon: arizona: Update naming for micd-timeout DT to include units Add time units of -ms (milliseconds) to wlf,micd-timeout. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 2 +- drivers/extcon/extcon-arizona.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index 8aa0bd430f7b..238e10e86a20 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -33,7 +33,7 @@ Optional properties: specified as per the ARIZONA_MICD_TIME_XXX defines. - wlf,micd-dbtime : Microphone detection hardware debounces specified as the number of measurements to take, valid values being 2 and 4. - - wlf,micd-timeout : Timeout for microphone detection, specified in + - wlf,micd-timeout-ms : Timeout for microphone detection, specified in milliseconds. - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone detection. diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index c377030807c4..86475338e51e 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1230,7 +1230,7 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona) device_property_read_u32(arizona->dev, "wlf,micd-dbtime", &pdata->micd_dbtime); - device_property_read_u32(arizona->dev, "wlf,micd-timeout", + device_property_read_u32(arizona->dev, "wlf,micd-timeout-ms", &pdata->micd_timeout); pdata->micd_force_micbias = device_property_read_bool(arizona->dev, -- cgit v1.2.3 From cb0eac8fd1a3180ce260a8dca01584bc5495a8e8 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 14 Dec 2015 10:37:12 +0000 Subject: extcon: arizona: Update device tree binding for mic detect configurations Update the device tree binding documentation to include documentation for the wlf,micd-configs property that is used to specify the configurations for headset polarity detection (CTIA / OTMP). Signed-off-by: Charles Keepax Acked-by: Rob Herring Signed-off-by: Chanwoo Choi --- Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index 238e10e86a20..fd9b898d2d7d 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -37,5 +37,13 @@ Optional properties: milliseconds. - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone detection. + - wlf,micd-configs : Headset polarity configurations (generally used for + detection of CTIA / OMTP headsets), the field can be of variable length + but should always be a multiple of 3 cells long, each three cell group + represents one polarity configuration. + The first cell defines the accessory detection pin, zero will use MICDET1 + and all other values will use MICDET2. + The second cell represents the MICBIAS to be used. + The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch -- cgit v1.2.3 From 36e2693b68562d4b984b841c041ffa76370e9b7f Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 14 Dec 2015 10:37:13 +0000 Subject: extcon: arizona: Add DT binding examples Add an example for all elements of the Arizona extcon device tree binding. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- .../devicetree/bindings/extcon/extcon-arizona.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt index fd9b898d2d7d..e27341f8a4c7 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -47,3 +47,29 @@ Optional properties: The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch + +Example: + +codec: wm8280@0 { + compatible = "wlf,wm8280"; + reg = <0>; + ... + + wlf,use-jd2; + wlf,use-jd2-nopull; + wlf,jd-invert; + + wlf,micd-software-compare; + wlf,micd-detect-debounce = <0>; + wlf,micd-pol-gpio = <&codec 2 0>; + wlf,micd-rate = ; + wlf,micd-dbtime = <4>; + wlf,micd-timeout-ms = <100>; + wlf,micd-force-micbias; + wlf,micd-configs = < + 0 1 0 /* MICDET1 MICBIAS1 GPIO=low */ + 1 2 1 /* MICDET2 MICBIAS2 GPIO=high */ + >; + + wlf,gpsw = <0>; +}; -- cgit v1.2.3 From 08a0a4f987a4b5827e4111eccc97a9271d24633e Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Sat, 19 Dec 2015 08:17:41 +0900 Subject: extcon: add Maxim MAX3355 driver Maxim Integrated MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as an USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we aren't currently interested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to a GPIO, it should be driven high for the normal operation. Signed-off-by: Sergei Shtylyov Acked-by: Chanwoo Choi Acked-by: Rob Herring [cw00.choi: Add the GPIOLIB dependency] Signed-off-by: Chanwoo Choi --- .../devicetree/bindings/extcon/extcon-max3355.txt | 21 +++ drivers/extcon/Kconfig | 9 ++ drivers/extcon/Makefile | 1 + drivers/extcon/extcon-max3355.c | 146 +++++++++++++++++++++ 4 files changed, 177 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max3355.txt create mode 100644 drivers/extcon/extcon-max3355.c (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/extcon/extcon-max3355.txt b/Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file mode 100644 index 000000000000..f2288ea9eb82 --- /dev/null +++ b/Documentation/devicetree/bindings/extcon/extcon-max3355.txt @@ -0,0 +1,21 @@ +Maxim Integrated MAX3355 USB OTG chip +------------------------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpios: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's SHDN# pin; +- id-gpios: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example: + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpios = <&gpio2 4 GPIO_ACTIVE_LOW>; + id-gpios = <&gpio5 31 GPIO_ACTIVE_HIGH>; + }; diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index 0cebbf668886..3d89e60a3e71 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -52,6 +52,15 @@ config EXTCON_MAX14577 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX3355 + tristate "Maxim MAX3355 USB OTG EXTCON Support" + depends on GPIOLIB || COMPILE_TEST + help + If you say yes here you get support for the USB OTG role detection by + MAX3355. The MAX3355 chip integrates a charge pump and comparators to + enable a system with an integrated USB OTG dual-role transceiver to + function as an USB OTG dual-role device. + config EXTCON_MAX77693 tristate "Maxim MAX77693 EXTCON Support" depends on MFD_MAX77693 && INPUT diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile index ba787d04295b..2a0e4f45d5b2 100644 --- a/drivers/extcon/Makefile +++ b/drivers/extcon/Makefile @@ -8,6 +8,7 @@ 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_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o diff --git a/drivers/extcon/extcon-max3355.c b/drivers/extcon/extcon-max3355.c new file mode 100644 index 000000000000..c24abec5d06c --- /dev/null +++ b/drivers/extcon/extcon-max3355.c @@ -0,0 +1,146 @@ +/* + * Maxim Integrated MAX3355 USB OTG chip extcon driver + * + * Copyright (C) 2014-2015 Cogent Embedded, Inc. + * Author: Sergei Shtylyov + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + */ + +#include +#include +#include +#include +#include +#include + +struct max3355_data { + struct extcon_dev *edev; + struct gpio_desc *id_gpiod; + struct gpio_desc *shdn_gpiod; +}; + +static const unsigned int max3355_cable[] = { + EXTCON_USB, + EXTCON_USB_HOST, + EXTCON_NONE, +}; + +static irqreturn_t max3355_id_irq(int irq, void *dev_id) +{ + struct max3355_data *data = dev_id; + int id = gpiod_get_value_cansleep(data->id_gpiod); + + if (id) { + /* + * ID = 1 means USB HOST cable detached. + * As we don't have event for USB peripheral cable attached, + * we simulate USB peripheral attach here. + */ + extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, false); + extcon_set_cable_state_(data->edev, EXTCON_USB, true); + } else { + /* + * ID = 0 means USB HOST cable attached. + * As we don't have event for USB peripheral cable detached, + * we simulate USB peripheral detach here. + */ + extcon_set_cable_state_(data->edev, EXTCON_USB, false); + extcon_set_cable_state_(data->edev, EXTCON_USB_HOST, true); + } + + return IRQ_HANDLED; +} + +static int max3355_probe(struct platform_device *pdev) +{ + struct max3355_data *data; + struct gpio_desc *gpiod; + int irq, err; + + data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN); + if (IS_ERR(gpiod)) { + dev_err(&pdev->dev, "failed to get ID_OUT GPIO\n"); + return PTR_ERR(gpiod); + } + data->id_gpiod = gpiod; + + gpiod = devm_gpiod_get(&pdev->dev, "maxim,shdn", GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) { + dev_err(&pdev->dev, "failed to get SHDN# GPIO\n"); + return PTR_ERR(gpiod); + } + data->shdn_gpiod = gpiod; + + data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable); + if (IS_ERR(data->edev)) { + dev_err(&pdev->dev, "failed to allocate extcon device\n"); + return PTR_ERR(data->edev); + } + + err = devm_extcon_dev_register(&pdev->dev, data->edev); + if (err < 0) { + dev_err(&pdev->dev, "failed to register extcon device\n"); + return err; + } + + irq = gpiod_to_irq(data->id_gpiod); + if (irq < 0) { + dev_err(&pdev->dev, "failed to translate ID_OUT GPIO to IRQ\n"); + return irq; + } + + err = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_ONESHOT | IRQF_NO_SUSPEND | + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING, + pdev->name, data); + if (err < 0) { + dev_err(&pdev->dev, "failed to request ID_OUT IRQ\n"); + return err; + } + + platform_set_drvdata(pdev, data); + + /* Perform initial detection */ + max3355_id_irq(irq, data); + + return 0; +} + +static int max3355_remove(struct platform_device *pdev) +{ + struct max3355_data *data = platform_get_drvdata(pdev); + + gpiod_set_value_cansleep(data->shdn_gpiod, 0); + + return 0; +} + +static const struct of_device_id max3355_match_table[] = { + { .compatible = "maxim,max3355", }, + { } +}; +MODULE_DEVICE_TABLE(of, max3355_match_table); + +static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .remove = max3355_remove, + .driver = { + .name = "extcon-max3355", + .of_match_table = max3355_match_table, + }, +}; + +module_platform_driver(max3355_driver); + +MODULE_AUTHOR("Sergei Shtylyov "); +MODULE_DESCRIPTION("Maxim MAX3355 extcon driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3