summaryrefslogtreecommitdiff
path: root/drivers/extcon/extcon-arizona.c
AgeCommit message (Collapse)AuthorFilesLines
2021-03-18ASoC/extcon: arizona: Move arizona jack code to sound/soc/codecs/arizona-jack.cHans de Goede1-1819/+0
The jack handling for arizona codecs is being refactored so that it is done directly by the codec drivers, instead of having an extcon-driver bind to a separate "arizona-extcon" child-device for this. drivers/mfd/arizona-core.c has already been updated to no longer instantiate an "arizona-extcon" child-device for the arizona codecs. This means that the "arizona-extcon" driver is no longer useful (there are no longer any devices for it to bind to). This commit drops the extcon Kconfig / Makefile bits and moves drivers/extcon/extcon-arizona.c to sound/soc/codecs/arizona-jack.c . This is a preparation patch for converting the arizona extcon-driver into a helper library for letting the arizona codec-drivers directly report jack state through the standard sound/soc/soc-jack.c functions. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-18extcon: arizona: Always use pm_runtime_get_sync() when we need the device to ↵Hans de Goede1-2/+2
be awake Before this commit the extcon-arizona code was mixing pm_runtime_get() and pm_runtime_get_sync() in different places. In all places where pm_runtime_get[_sync]() is called, the code makes use of the device immediately after the call. This means that we should always use pm_runtime_get_sync(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-18extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol") callHans de Goede1-1/+1
The initial value of the GPIO should match the info->micd_modes[0].gpio value. arizona_extcon_probe() already stores the necessary flag in a mode variable, but instead of passing mode as flags to the gpiod_get() it was using a hardcoded GPIOD_OUT_LOW. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-18extcon: arizona: Fix various races on driver unbindHans de Goede1-19/+21
We must free/disable all interrupts and cancel all pending works before doing further cleanup. Before this commit arizona_extcon_remove() was doing several register writes to shut things down before disabling the IRQs and it was cancelling only 1 of the 3 different works used. Move all the register-writes shutting things down to after the disabling of the IRQs and add the 2 missing cancel_delayed_work_sync() calls. This fixes various possible races on driver unbind. One of which would always trigger on devices using the mic-clamp feature for jack detection. The ARIZONA_MICD_CLAMP_MODE_MASK update was done before disabling the IRQs, causing: 1. arizona_jackdet() to run 2. detect a jack being inserted (clamp disabled means jack inserted) 3. call arizona_start_mic() which: 3.1 Enables the MICVDD regulator 3.2 takes a pm_runtime_reference And this was all happening after the ARIZONA_MICD_ENA bit clearing, which would undo 3.1 and 3.2 because the ARIZONA_MICD_CLAMP_MODE_MASK update was being done after the ARIZONA_MICD_ENA bit clearing. So this means that arizona_extcon_remove() would exit with 1. MICVDD enabled and 2. The pm_runtime_reference being unbalanced. MICVDD still being enabled caused the following oops when the regulator is released by the devm framework: [ 2850.745757] ------------[ cut here ]------------ [ 2850.745827] WARNING: CPU: 2 PID: 2098 at drivers/regulator/core.c:2123 _regulator_put.part.0+0x19f/0x1b0 [ 2850.745835] Modules linked in: extcon_arizona ... ... [ 2850.746909] Call Trace: [ 2850.746932] regulator_put+0x2d/0x40 [ 2850.746946] release_nodes+0x22a/0x260 [ 2850.746984] __device_release_driver+0x190/0x240 [ 2850.747002] driver_detach+0xd4/0x120 ... [ 2850.747337] ---[ end trace f455dfd7abd9781f ]--- Note this oops is just one of various theoretically possible races caused by the wrong ordering inside arizona_extcon_remove(), this fixes the ordering fixing all possible races, including the reported oops. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-18extcon: arizona: Fix some issues when HPDET IRQ fires after the jack has ↵Hans de Goede1-8/+9
been unplugged When the jack is partially inserted and then removed again it may be removed while the hpdet code is running. In this case the following may happen: 1. The "JACKDET rise" or ""JACKDET fall" IRQ triggers 2. arizona_jackdet runs and takes info->lock 3. The "HPDET" IRQ triggers 4. arizona_hpdet_irq runs, blocks on info->lock 5. arizona_jackdet calls arizona_stop_mic() and clears info->hpdet_done 6. arizona_jackdet releases info->lock 7. arizona_hpdet_irq now can continue running and: 7.1 Calls arizona_start_mic() (if a mic was detected) 7.2 sets info->hpdet_done Step 7 is undesirable / a bug: 7.1 causes the device to stay in a high power-state (with MICVDD enabled) 7.2 causes hpdet to not run on the next jack insertion, which in turn causes the EXTCON_JACK_HEADPHONE state to never get set This fixes both issues by skipping these 2 steps when arizona_hpdet_irq runs after the jack has been unplugged. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-05-29extcon: arizona: Fix runtime PM imbalance on errorDinghao Liu1-8/+9
When arizona_request_irq() returns an error code, a pairing runtime PM usage counter decrement is needed to keep the counter balanced. For error paths after this function, things are the same. Also, remove calls to pm_runtime_disable() when pm_runtime_enable() has not been executed. Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Factor out microphone and button detectionCharles Keepax1-44/+71
Continue refactoring the microphone detect handling by factoring out the handling for microphone detection and button detection into separate functions. This both makes the code a little clearer and prepares for some planned future refactoring to make the state handling in the driver more explicit. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Factor out microphone impedance into a functionCharles Keepax1-52/+73
The microphone detection handler is very long, start breaking it up by factoring out the actual reading of the impedance value into a separate functions. Additionally, this also fixes a minor bug and ensures that the microphone timeout will be rescheduled in all error cases. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Invert logic of check in arizona_hpdet_do_idCharles Keepax1-47/+45
Invert the check of hpdet_acc_id at the top of arizona_hpdet_do_id to reduce the identation within the function. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Remove excessive WARN_ONCharles Keepax1-3/+2
A WARN_ON is very strong for simply finding a button that is out of range, downgrade this to a simple error message in the log. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Remove unnecessary sets of ACCDET_MODECharles Keepax1-11/+0
arizona_start_mic sets ACCDET_MODE as required for the microphone detection as such it is redundant to set this outside of this function. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Tidy up transition from mic to headphone detectCharles Keepax1-8/+1
Moving from microphone detection to headphone detection is done fairly haphazardly at the moment, sometimes calling arizona_stop_mic at the call site sometimes relying on a call inside arizona_identify_headphone. Simplify all this and always call arizona_stop_mic at the top of arizona_identify_headphone. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Clear jack status regardless of detection typeCharles Keepax1-4/+4
It makes sense to clear the internal state of the jack detection regardless of if the headphone detect based accessory detection or the normal microphone detect based flow is used. No issues are currently known because of this but the change makes more logical sense and eases future refactoring of the code. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Move pdata extraction to probeCharles Keepax1-9/+5
It makes no sense to be extracting values from pdata for the first time in the jack detection handler function, move this to probe time where it belongs. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Make rev A register sequences atomicCharles Keepax1-6/+14
The special register sequences that are applied for rev A of wm5102 should be applied atomically with respect to any other register writes. Use regmap_multi_reg_write to ensure all writes happen under the regmap lock. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-12-09extcon: arizona: Correct clean up if arizona_identify_headphone failsCharles Keepax1-0/+3
In the error path of arizona_identify_headphone, neither the clamp nor the PM runtime are cleaned up. Add calls to clean up both of these. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-07-24extcon: arizona: Switch to use device_property_count_u32()Andy Shevchenko1-1/+1
Use use device_property_count_u32() directly, that makes code neater. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-07-01Merge tag 'extcon-next-for-5.3' of ↵Greg Kroah-Hartman1-13/+20
git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next Chanwoo writes: Update extcon for 5.3 Detailed description for this pull request: 1. Add new extcon-fsa9480 extcon provider driver - It is extcon provide driver for Fairchild Semiconductor FSA9480 microUSB switch and accessory detector chip which detects the kind of external connector like usb, charger, audio, video and so on. 2. - Add the exception handling code for extcon-arizona.c when using the regmap interface. * tag 'extcon-next-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon: extcon: fsa9480: Fix Kconfig warning and build errors extcon: Add fsa9480 extcon driver dt-bindings: extcon: Add support for fsa9480 switch extcon: arizona: Correct error handling on regmap_update_bits_check
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157Thomas Gleixner1-10/+1
Based on 3 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version 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 this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] 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 this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [graeme] [gregory] [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema] [hk] [hemahk]@[ti] [com] 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 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1105 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30extcon: arizona: Correct error handling on regmap_update_bits_checkCharles Keepax1-13/+20
Ensure the case when regmap_update_bits_check fails and the change variable is not updated is handled correctly. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-04-12extcon: arizona: Disable mic detect if running when driver is removedCharles Keepax1-0/+10
Microphone detection provides the button detection features on the Arizona CODECs as such it will be running if the jack is currently inserted. If the driver is unbound whilst the jack is still inserted this will cause warnings from the regulator framework as the MICVDD regulator is put but was never disabled. Correct this by disabling microphone detection on driver removal and if the microphone detection was running disable the regulator and put the runtime reference that was currently held. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-10-23extcon: Split out extcon header file for consumer and provider deviceChanwoo Choi1-1/+1
The extcon has two type of extcon devices as following. - 'extcon provider deivce' adds new extcon device and detect the state/properties of external connector. Also, it notifies the state/properties to the extcon consumer device. - 'extcon consumer device' gets the change state/properties from extcon provider device. Prior to that, include/linux/extcon.h contains all exported API for both provider and consumer device driver. To clarify the meaning of header file and to remove the wrong use-case on consumer device, this patch separates into extcon.h and extcon-provider.h. [Description for include/linux/{extcon.h|extcon-provider.h}] - extcon.h includes the extcon API and data structure for extcon consumer device driver. This header file contains the following APIs: : Register/unregister the notifier to catch the change of extcon device : Get the extcon device instance : Get the extcon device name : Get the state of each external connector : Get the property value of each external connector : Get the property capability of each external connector - extcon-provider.h includes the extcon API and data structure for extcon provider device driver. This header file contains the following APIs: : Include 'include/linux/extcon.h' : Allocate the memory for extcon device instance : Register/unregister extcon device : Set the state of each external connector : Set the property value of each external connector : Set the property capability of each external connector Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Acked-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
2017-05-23extcon: arizona: Use devm_kcalloc() in arizona_extcon_get_micd_configs()Markus Elfring1-3/+1
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc". * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Reviewed-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06extcon: arizona: Wait for any running HPDETs to complete on jack removalCharles Keepax1-0/+46
As the HPDET can't be aborted mid way through we should not allow any new insertion to be processed until the previous HPDET has finished. It is very unlikely but with low enough debounce settings you could start a new HPDET before the old one has completed, which results in an erroneous reading. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09extcon: arizona: Simplify micd_pol_gpio handlingCharles Keepax1-12/+8
Currently we handle both old style GPIO and new style GPIOD differently simplify this slightly by converting the old style GPIO to a GPIOD and just using that from then on. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-12-01extcon: arizona: Use SoC component pin control functionsRichard Fitzgerald1-3/+5
The name of a codec pin can have an optional prefix string, which is defined by the SoC machine driver. The snd_soc_dapm_x_pin functions take the fully-specified name including the prefix and so the existing code would fail to find the pin if the audio machine driver had added a prefix. Switch to using the snd_soc_component_x_pin equivalent functions that take a specified SoC component and automatically add the name prefix to the provided pin name. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-13extcon: Use the extcon_set_state_sync() instead of deprecated functionsChanwoo Choi1-8/+8
This patch alters the renamed extcon API to set the state of the external connectors instead of deprecated extcon_set_cable_state_(). Because the patch[1] modifies the function name to maintain the function naming pattern. - extcon_set_cable_state_() -> extcon_set_state_sync() - extcon_get_cable_state_() -> extcon_get_state() [1] https://lkml.org/lkml/2016/8/4/729 - extcon: Rename the extcon_set/get_state() to maintain the function naming pattern Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Roger Quadros <rogerq@ti.com>
2016-08-08extcon: arizona: Remove the usage of extcon_update_state()Chanwoo Choi1-4/+7
This patch remvoes the usage of extcon_update_state() because the extcon_update_state() use directly the bit masking calculation to change the state of external connector without the unique id of external connector. It makes the code diffcult to read it. So, this patch uses the extcon_set_cable_state_() instead. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
2016-08-08extcon: arizona: Remove unneeded semi-colonCharles Keepax1-1/+1
There is no need for a semi-colon at the end of a switch statement so remove it. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-01-25extcon: arizona: Use DAPM mutex helper functionsCharles Keepax1-2/+2
We should be using the helper functions to lock the DAPM mutex not accessing it directly. There are no ill effects of this as the moment but it is best practice, and the implementation could be changed in the future. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-12-15extcon: arizona: Add device bindings for the micd configurationsCharles Keepax1-2/+54
Add device bindings to support configuring the jack detection configurations. Each configuration needs to specify the connection of the mic det pins, which micbias should be used and the value of the micd polarity GPIO required to activate that configuration. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-24extcon: arizona: Update naming for micd-timeout DT to include unitsCharles Keepax1-1/+1
Add time units of -ms (milliseconds) to wlf,micd-timeout. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-24extcon: arizona: Update naming for second jack detection DT bindingCharles Keepax1-2/+2
Update the name for the second jack detection pin binding to be a little less confusing. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-20extcon: arizona: Add device binding for second jack detect pin on GPIO5Charles Keepax1-0/+5
Some Arizona devices have the option to use the GPIO5 pin as a second jack detection pin. This patch adds device bindings to specify to the driver that it should use this 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 <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-20extcon: arizona: Add device binding for jack detect polarity inversionCharles Keepax1-0/+3
By default the driver expects the jackdet pin to be pulled low when a jack is inserted. This patch adds a device binding that allows the user to specify that the jackdet pin will be pulled high when a jack is inserted. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-20extcon: arizona: Add device binding for the general purpose switchCharles Keepax1-0/+2
The switch is generally used in conjunction with the MICDET clamp to suppress pops and clicks associated with jack insertion. This patch adds a binding that allows the user to select the mode of operation for this switch. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-20extcon: arizona: Add device binding to enable ADC mode micdetCharles Keepax1-0/+3
Add a simple boolean binding to turn on and off the use of ADC microphone detection mode to determine 3/4 pole jack. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-10-16extcon: Modify the id and name of external connectorChanwoo Choi1-9/+9
This patch modifies the id and name of external connector with the additional prefix to clarify both attribute and meaning of external connector as following: - EXTCON_CHG_* mean the charger connector. - EXTCON_JACK_* mean the jack connector. - EXTCON_DISP_* mean the display port connector. Following table show the new name of external connector with old name: -------------------------------------------------- Old extcon name | New extcon name | -------------------------------------------------- EXTCON_TA | EXTCON_CHG_USB_DCP | EXTCON_CHARGE_DOWNSTREAM| EXTCON_CHG_USB_CDP | EXTCON_FAST_CHARGER | EXTCON_CHG_USB_FAST | EXTCON_SLOW_CHARGER | EXTCON_CHG_USB_SLOW | -------------------------------------------------- EXTCON_MICROPHONE | EXTCON_JACK_MICROPHONE | EXTCON_HEADPHONE | EXTCON_JACK_HEADPHONE | EXTCON_LINE_IN | EXTCON_JACK_LINE_IN | EXTCON_LINE_OUT | EXTCON_JACK_LINE_OUT | EXTCON_VIDEO_IN | EXTCON_JACK_VIDEO_IN | EXTCON_VIDEO_OUT | EXTCON_JACK_VIDEO_OUT | EXTCON_SPDIF_IN | EXTCON_JACK_SPDIF_IN | EXTCON_SPDIF_OUT | EXTCON_JACK_SPDIF_OUT | -------------------------------------------------- EXTCON_HMDI | EXTCON_DISP_HDMI | EXTCON_MHL | EXTCON_DISP_MHL | EXTCON_DVI | EXTCON_DISP_DVI | EXTCON_VGA | EXTCON_DISP_VGA | -------------------------------------------------- And, when altering the name of USB charger connector, EXTCON refers to the "Battery Charging v1.2 Spec and Adopters Agreement"[1] to use the standard name of USB charging port as following. Following name of USB charging port are already used in power_supply subsystem. We chan check it on patch[2]. - EXTCON_CHG_USB_SDP /* Standard Downstream Port */ - EXTCON_CHG_USB_DCP /* Dedicated Charging Port */ - EXTCON_CHG_USB_CDP /* Charging Downstream Port */ - EXTCON_CHG_USB_ACA /* Accessory Charger Adapter */ [1] www.usb.org/developers/docs/devclass_docs/BCv1.2_070312.zip [2] commit 85efc8a18ced ("power_supply: Add types for USB chargers") Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> [ckeepax: For the Arizona changes] Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Reviewed-by: Roger Quadros <rogerq@ti.com>
2015-09-30extcon: arizona: Reorder the default statement to remove unnecessary warningChanwoo Choi1-3/+6
This patch reorders the default statement to remove unnecessary warning message when info->hpdet_ip_version is higher than 2. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
2015-09-29extcon: arizona: Add support for WM8998 and WM1814Richard Fitzgerald1-10/+21
This patch adds support for the WM8998 and WM1814 codecs. These use the same IP version as WM5110 but have different clamp control. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Don't disable debounce for inverted jacksCharles Keepax1-3/+5
Whilst the jack is connected we disable the jack detection debounce to ensure as quick as possible a detection of jack removal. However, it is only safe to disable the jack debounce whilst the jack is connected if using the micd clamp or the jack is not inverted. Otherwise spurious interrupts might be generated when we re-enable the debounce. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Use the micd_clamp for interrupts if it is availableCharles Keepax1-3/+3
Currently we only use the microphone clamp IRQ if GPIO5 is being used as a second jack detection pin. But we should be using it on any system where the clamp is available. This patch updates the driver to do so. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Ignore jd_invert for MICD_CLAMP_STSNariman Poushin1-4/+1
The polarity of MICD_CLAMP_STS does not change when different clamp modes are used, this patch corrects this issue. Signed-off-by: Nariman Poushin <nariman@opensource.wolfsonmicro.com> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Additional settings to improve accuracy of HP detectCharles Keepax1-2/+17
If the TST_CAP_SEL bits aren't set correctly on wm5110/8280 there will be a 100k load along side the headphones, which will affect the accurary towards the very top of the detection range. This patch sets those bits. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Add support for general purpose switchCharles Keepax1-0/+4
The switch is typically used in conjunction with the MICDET clamp in order to suppress pops and clicks associated with jack insertion. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-22extcon: arizona: Add support for new ADC value mic detectCharles Keepax1-6/+58
Newer devices give users the option to make the 3/4 pole jack determination using a software comparison rather than a hardware one. This patch adds support for this functionality. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10extcon: arizona: Simplify pdata symantics for micd_dbtimeCharles Keepax1-3/+14
Currently micd_dbtime can be set to 0 for default, 1 for 4 measurements, or a greater than 16-bit value for 2 measurements. This patch simplifies the symantics to 2 for 2 measurements, 4 for 4 measurements and any other value for the default. I am not super keen on changing the symantics of the pdata at this stage in the drivers life, but acceptance of the DT binding for this field has been made conditional on this happening. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10extcon: arizona: Declare 3-pole jack if we detect open circuit on micCharles Keepax1-0/+3
Detecting an open-circuit on the microphone pin, usually means the headset has a microphone but the cable is faulty. Currently the code will simply stop detecting and declare nothing in this situation. It is better to declare this as headphones such that the user can still use their headset as plain headphones even if the microphone is faulty. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10extcon: arizona: Ensure variables are set for headphone detectionCharles Keepax1-4/+7
The detecting flag really refers to the microphone detection stage and as such should be cleared before arizona_identify_headphones is called. Also the mic flag should be set before identify headphones is called as well. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10extcon: arizona: Use gpiod inteface to handle micd_pol_gpio gpioCharles Keepax1-5/+36
Convert to using the newer gpiod interface for the micd_pol_gpio. Although we still carry support for the old gpio interface from pdata. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> [cw00.choi: Modify the patch titlei to include the detailed content] Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>