Commit Graph

556 Commits

Author SHA1 Message Date
Hans de Goede
585cb239f4 extcon: intel-cht-wc: Disable external 5v boost converter on probe
Disable the 5v boost converter on probe in case it was left on by
the BIOS, this fixes 2 problems:

1) This gets seen by the external battery charger as a valid Vbus
   supply and it then tries to feed Vsys from this creating a
   feedback loop which causes aprox. 300 mA extra battery drain
   (and unless we drive the external-charger-disable pin high it
   also tries to charge the battery causing even more feedback).
2) This gets seen by the pwrsrc block as a SDP USB Vbus supply

Since the external battery charger has its own 5v boost converter
which does not have these issues, we simply turn the separate
external 5v boost converter off and leave it off entirely.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:25 +09:00
Chanwoo Choi
c9d0f1d121 extcon: Remove porting compatibility of swich class
This patch removes the porting compatibility for switch class
because there is no any usage and requirement of swich class
over a couple of years.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:24 +09:00
Hans de Goede
db0f3baaa3 extcon: intel-cht-wc: Add Intel Cherry Trail Whiskey Cove PMIC extcon driver
Add a driver for charger detection / control on the Intel Cherrytrail
Whiskey Cove PMIC.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:23 +09:00
Roger Quadros
01944321de extcon: palmas: Don't miss GPIO events during suspend/resume
The USB cable state can change during suspend/resume
so be sure to check and update the extcon state.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:22 +09:00
Roger Quadros
8680b4d193 extcon: usb-gpio: Don't miss event during suspend/resume
We must check for ID/VBUS changes during resume irrespective
of whether our device wakeup is enabled or not.

Without this we seem to be missing ID/VBUS events after
system suspend/resume.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:21 +09:00
Peter Chen
98fd079297 extcon: usb-gpio: Do not enable USB as wakeup source by default
Whether the USB port as a wakeup source should be determined by user,
but not enabled by default.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-04-06 10:55:20 +09:00
Charles Keepax
e57bb43c7e extcon: arizona: Wait for any running HPDETs to complete on jack removal
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-04-06 10:55:19 +09:00
Chanwoo Choi
bc9a5c37a5 Merge branch 'ib-extcon-4.12' into HEAD 2017-04-06 10:54:36 +09:00
Chanwoo Choi
815429b39d extcon: Add new extcon_register_notifier_all() to monitor all external connectors
The extcon core already provides the extcon_register_notifier() function
in order to register the notifier block which is used to monitor
the state change for the specific external connector such as EXTCON_USB,
EXTCON_USB_HOST and so on. The extcon consumer uses the this function.

The extcon consumer might need to monitor the all supported external
connectors from the extcon device. In this case, The extcon consumer
should have each notifier_block structure for each external connector.

This patch adds the new extcon_register_notifier_all() function
that extcon consumer is able to monitor the state change of all
supported external connectors by using only one notifier_block structure.

- List of new added functions:
int extcon_register_notifier_all(struct extcon_dev *edev,
			struct notifier_block *nb);
int extcon_unregister_notifier_all(struct extcon_dev *edev,
			struct notifier_block *nb);
int devm_extcon_register_notifier_all(struct device *dev,
			struct extcon_dev *edev, struct notifier_block *nb);
void devm_extcon_unregister_notifier_all(struct device *dev,
			struct extcon_dev *edev, struct notifier_block *nb);

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
2017-04-04 11:22:42 +09:00
Andy Shevchenko
366380cd62 Revert "extcon: usb-gpio: add support for ACPI gpio interface"
The commit 942c7924a5 introduced a check for ACPI handle for the
device that never appears on any ACPI-enabled platform so far. It seems
a confusion with extcon-intel-int3496 which does support ACPI-enabled
platforms.

Revert commit 942c7924a5 to avoid any confusion in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-27 13:17:41 +09:00
Hans de Goede
70216fd937 extcon: int3496: Set the id pin to direction-input if necessary
With the new more strict ACPI gpio code the dsdt's IoRestriction
flags are honored on gpiod_get, but in some dsdt's it is wrong,
so explicitly call gpiod_direction_input on the id gpio if
necessary.

This fixes the following errors when the int3496 code is used
together with the new more strict ACPI gpio code:

[ 2382.484415] gpio gpiochip1: (INT33FF:01): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
[ 2382.484425] gpio gpiochip1: (INT33FF:01): unable to lock HW IRQ 3 for IRQ
[ 2382.484429] genirq: Failed to request resources for INT3496:00 (irq 174) on irqchip chv-gpio
[ 2382.484518] intel-int3496 INT3496:00: can't request IRQ for USB ID GPIO: -22
[ 2382.500359] intel-int3496: probe of INT3496:00 failed with error -22

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-22 18:29:48 +09:00
Hans de Goede
408c5b41d2 extcon: int3496: Use gpiod_get instead of gpiod_get_index
Now that we've an acpi mapping table we should be using gpiod_get
instead of gpiod_get_index.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-22 18:29:47 +09:00
Peter Robinson
059c7874b8 extcon: int3496: Add dependency on X86 as it's Intel specific
Add dependency on X86 so it doesn't show up on other arches and
add a option for compile test so it still gets build coverage.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-22 18:29:46 +09:00
Andy Shevchenko
8cb2cbae45 extcon: int3496: Add GPIO ACPI mapping table
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-22 18:29:46 +09:00
Andy Shevchenko
90400c5884 extcon: int3496: Rename GPIO pins in accordance with binding
Update GPIO pin names in extcon-intel-int3496.c driver to follow
the existing extcon binding.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-22 18:29:45 +09:00
Andy Shevchenko
bafa687dcc extcon: int3496: Propagate error code of gpiod_to_irq()
gpiod_to_irq() doesn't return 0. Thus, we just adjust condition and
replace -EINVAL by actual error code it returns.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-03-13 12:39:30 +09:00
Masahiro Yamada
c6efb58db4 scripts/spelling.txt: add "swithc" pattern and fix typo instances
Fix typos and add the following to the scripts/spelling.txt:

  swithc||switch
  swithced||switched
  swithcing||switching

Link: http://lkml.kernel.org/r/1481573103-11329-3-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-27 18:43:46 -08:00
Roger Quadros
567ab5a81b extcon: palmas: Use dev_dbg macro for the debug messages
User is not interested in USB cable events appearing on the
console. Use dev_dbg() instead of dev_info() for these events.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-25 15:03:54 +09:00
Chanwoo Choi
86d6cda68f extcon: Modify the name of EXTCON_USB_HOST connector
This patch renames the EXTCON_USB_HOST by using '-' char because
the name of all external connector use the '-' char instead of '_' char.
- "USB_HOST" -> "USB-HOST"

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:58 +09:00
Chanwoo Choi
3c5f0e0768 extcon: Add new EXTCON_CHG_USB_PD type for USB Power Delivery
This patch adds the new EXTCON_CHG_USB_PD for USB PD (Power Delivery)[1].
The USB Power Delivery specification specifies that USB cable provides
the increased power more than 7.5W to device with larger power demand.
The EXTCON_CHG_USB_PD has the EXTCON_TYPE_CHG and EXTCON_TYPE_USB type.

[1] https://en.wikipedia.org/wiki/USB#PD

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:58 +09:00
Peter Chen
bcb7440e76 extcon: usb-gpio: Add pinctrl operation during system PM
At some systems, the pinctrl setting will be lost or needs to
set as "sleep" state to save power consumption. So, we need to
configure pinctrl as "sleep" state when system enters suspend,
and as "default" state after system resumes. In this way, the
pinctrl value can be recovered as "default" state after resuming.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:12 +09:00
Chanwoo Choi
e6cf046543 extcon: Move defintion of struct extcon_dev to driver/extcon directory
This patch moves the 'struct extcon_dev' of extcon subsystem
to driver/extcon/extcon.h header file because the struct extcon_dev have to
be handled by extcon API to guarantee the consistency of strcut extcon_dev.
If external drivers are able to touch the struct extcon_dev directly, it might
cause the critical and unknown problem.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:11 +09:00
Chanwoo Choi
6e3a7e89ff extcon: adc-jack: Use the internal data instead of using struct extcon_dev
This patch uses the internal dev instance instead of using the field of struct
extcon_dev because the core structure (extcon_dev) of extcon have to be touched
by only extcon core driver.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:11 +09:00
David Cohen
2f556bdb9f extcon: int3496: Add Intel INT3496 ACPI device extcon driver
Add an extcon driver for USB OTG ports controlled by an Intel INT3496
ACPI device (e.g. Baytrail, Cherrytrail devices).

Signed-off-by: David Cohen <david.a.cohen@intel.com>
[hdgoede@redhat.com: Port to current kernel, cleanup, submit upstream]
[hdgoede@redhat.com: Add Documentation/extcon/intel-int3496.txt]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:11 +09:00
Baolin Wang
5298b83658 extcon: axp288: Set EXTCON_USB when EXTCON_CHG_USB_SDP was set
According to the documentation, we should set the EXTCON_USB when
one SDP charger connector was reported.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:11 +09:00
Chanwoo Choi
01b4c9a1ae extcon: Remove potential problem when calling extcon_register_notifier()
This patch removes the potential problem of extcon_register_notifier()
when edev parameter is NULL. When edev is NULL, this function returns
the first extcon device which includes the sepecific external connector
of second paramter. But, it don't guarantee the same operation in all cases.
To remove this confusion and potential problem, this patch fixes it.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:11 +09:00
Hans de Goede
dd3a55fc68 extcon: axp288: Fix the module not auto-loading
Add a MODULE_DEVICE_TABLE to fix the module not auto-loading.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
be1749528e extcon: axp288: Remove unnecessary irq?_en register writes
Setting the irq_enable bits is taken care of by the irq chip when we
request the irqs and the driver should not be meddling with the
irq?_en registers itself.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
5757aca101 extcon: axp288: Use vbus-valid instead of -present to determine cable presence
The vbus-present bit in the power status register also gets set to 1
when a usb-host cable (id-pin shorted to ground) is plugged in and a 5v
boost converter is supplying 5v to the otg usb bus.

This causes a "disconnect or unknown or ID event" warning in dmesg as
well as the extcon device to report the last detected charger cable
type as being connected even though none is connected.

This commit switches to checking the vbus-valid bit instead, which is
only 1 when both vbus is present and the vbus-path is enabled in the
vbus-path control register (the vbus-path gets disabled when a usb-host
cable is detected, to avoid the pmic drawing power from the 5v boost
converter).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
5d2199ea34 extcon: axp288: Fix possibly reporting 2 cables in state true
When the charger type changes from e.g. SDP to CDP, without Vbus being
seen as low in between axp288_handle_chrg_det_event would set the state
for the new cable type to true, without clearing the state of the
previous cable type to false.

This commit fixes this and also gets rid of the function local static
cable variable, properly storing all drv state in the axp288_extcon_info
struct.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
3fe1e0e2ab extcon: axp288: Simplify axp288_handle_chrg_det_event
axp288_handle_chrg_det_event only gets called on change interrupts
(so not that often), extcon_set_state_sync() checks itself if there are
any actual changes before notifying listeners, and gpiod_set_value is
not really expensive either.

So we can simply always do both on each interrupt removing a bunch of
somewhat magic looking code from axp288_handle_chrg_det_event.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
1490d157e0 extcon: axp288: Remove usb_phy notification code
The usb_phy based intel-usb-phy code never got merged into the
mainline kernel, so the devm_usb_get_phy() call will always fail,
blocking the driver from loading.

Since new drivers should use the generic-phy framework, not the
old-style usb_phy stuff, keeping this around is not useful.

Therefor this patch removes the usb_phy notification bits, which together
with the patch to remove the platform_data dependency, makes this driver
actually successfully probe on systems with an axp288 pmic.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:10 +09:00
Hans de Goede
7688424139 extcon: axp288: Remove dependency on non-existing platform_data
When the extcon_axp288 driver was originally merged, it was merged with
a dependency on some other driver providing platform data for it.

However such another driver was never merged, so the extcon_axp288 as
merged upstream has never worked, its probe method simply always returns
-ENODEV.

This commit drops the dependency on the pdata always being there, instead
it treats not having pdata as the pdata having a NULL gpio_mux_control,
something which the code was already prepared to handle.

Note that the code for controlling the mux_control gpio is left in place,
as this may be necessary to allow the axp288 pmic to properly detect the
charger type (instead of assuming 500mA max charge current) on some
tablets. This will make it easier for future patches to add support for
this gpio by getting the gpio info from somewhere.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:09 +09:00
Roger Quadros
9fe172b9be extcon: palmas: Check the parent instance to prevent the NULL
extcon-palmas must be child of palmas and expects parent's
drvdata to be valid. Check for non NULL parent drvdata and
fail if it is NULL. Not doing so will result in a NULL
pointer dereference later in the probe() parent drvdata
is NULL (e.g. misplaced extcon-palmas node in device tree).

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:09 +09:00
Srikant Ritolia
af57fa4de2 extcon: Restructure multi-line comments to follow codingstyle
Aligning all block comments in extcon subsystem as per linux coding style.
Found using checkpatch.pl script.

Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:09 +09:00
Pan Bian
e7d9dd5ab1 extcon: Return error code on failure
Function get_zeroed_page() returns a NULL pointer if there is no enough
memory. In function extcon_sync(), it returns 0 if the call to
get_zeroed_page() fails. The return value 0 indicates success in the
context, which is incosistent with the execution status. This patch
fixes the bug by returning -ENOMEM.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188611

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09 10:04:09 +09:00
Charles Keepax
6c467a106f extcon: arizona: Simplify micd_pol_gpio handling
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>
2017-01-09 10:04:09 +09:00
Linus Torvalds
ce38207f16 sound updates for 4.10-rc1
No dramatic changes are found in this development cycle, but as usual,
 many commits are applied in a wide range of drivers.
 
 Most of big changes are in ASoC, where a few bits of framework work
 and quite a lot of cleanups and improvements to existing code have
 been done.  The rest are usual stuff, a few HD-audio and USB-audio
 quirks and fixes, as well as the drop of kthread usages in the whole
 subsystem.
 
 Below are some highlights:
 
 ASoC:
 - Support for stereo DAPM controls
 - Some initial work on the of-graph sound card
 - regmap conversions of the remaining AC'97 drivers
 - A new version of the topology ABI; this should be backward compatible
 - Updates / cleanups of rsnd, sunxi, sti, nau8825, samsung, arizona,
   Intel skylake, atom-sst
 - New drivers for Cirrus Logic CS42L42, Qualcomm MSM8916-WCD, and
   Realtek RT5665
 
 USB-audio:
 - Yet another race fix at disconnection
 - Tolerated packet size calculation for some Android devices
 - Quirks for Axe-Fx II, QuickCam, TEAC 501/503
 
 HD-audio:
 - Improvement of Dell pin fixup mapping
 - Quirks for HP Z1 Gen3, Alienware 15 R2 2016 and ALC622 headset mic
 
 Misc:
 - Replace all kthread usages with simple works
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJYUGNQAAoJEGwxgFQ9KSmkc3kP/jS5EDPWb6dwqdlZomT0lumR
 flpvLLo6TWTi9CS8MkC1hPHbR+3LGPMUL8Wwf2cVb06dvKpUHa5P3Wq6lMm6T9wO
 1ExhnHeDEDfGXop3/EuADmpRsfsV+z/PpWYmGB0vkoyPTg7e3xQRA6Im6p6IMi45
 pnvEaSe18oEidqzAxaBgBFTdoNyaD9zrPL5J9Jh0/JCZ/kSmY6hhI+hlTjjOKCR6
 fs4ge2WreonAKbhfOE61eE2KDnQA4II/2JUoPA42wZOat9ukb8DiErgHoFgsWTtE
 h+/ZN5Qj3dweP3+NIKsWrmfC6qzTt9OnUNPB2O0A+UYmAMQBjBz9KVxW1FHyTqBp
 ewATtvCNIQs+uPMaO/Q/Qo3ZkKLf/W7o/Dt2u/orSrnQ2plKgIOiHJodhXlTrOWm
 szF+qJq0xRB7+/dZa+gDjGPAjirr6n3Fv7wrJmqfyF0hLaIEy4wa2Rd/IAZ9Ar46
 5S4prL2Ba1CKf1YV27DR1bjUTAonlApfczNp+urCGQJCfZ0kQOAhZJQ/mbMOgSDS
 KEC0vY6NLr88b19OETS4oQZ0ixxIAm8hwAle6z39GGhGZ8JWH5+JRzy8emVh2bss
 lpFLFHLwK+a+JHxmnOniJW9AlC8I7hVqfS63qaTXfvDnMMcRd5fMgniZt8bTWc2/
 F5hsE83JUlcA8Owfyoca
 =WZeb
 -----END PGP SIGNATURE-----

Merge tag 'sound-4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound updates from Takashi Iwai:
 "No dramatic changes are found in this development cycle, but as usual,
  many commits are applied in a wide range of drivers.

  Most of big changes are in ASoC, where a few bits of framework work
  and quite a lot of cleanups and improvements to existing code have
  been done. The rest are usual stuff, a few HD-audio and USB-audio
  quirks and fixes, as well as the drop of kthread usages in the whole
  subsystem.

  Below are some highlights:

  ASoC:
   - support for stereo DAPM controls
   - some initial work on the of-graph sound card
   - regmap conversions of the remaining AC'97 drivers
   - a new version of the topology ABI; this should be backward
     compatible
   - updates / cleanups of rsnd, sunxi, sti, nau8825, samsung, arizona,
     Intel skylake, atom-sst
   - new drivers for Cirrus Logic CS42L42, Qualcomm MSM8916-WCD, and
     Realtek RT5665

  USB-audio:
   - yet another race fix at disconnection
   - tolerated packet size calculation for some Android devices
   - quirks for Axe-Fx II, QuickCam, TEAC 501/503

  HD-audio:
   - improvement of Dell pin fixup mapping
   - quirks for HP Z1 Gen3, Alienware 15 R2 2016 and ALC622 headset mic

  Misc:
   - replace all kthread usages with simple works"

* tag 'sound-4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (296 commits)
  ALSA: hiface: Fix M2Tech hiFace driver sampling rate change
  ALSA: usb-audio: Eliminate noise at the start of DSD playback.
  ALSA: usb-audio: Add native DSD support for TEAC 501/503 DAC
  ASoC: wm_adsp: wm_adsp_buf_alloc should use kfree in error path
  ASoC: topology: avoid uninitialized kcontrol_type
  ALSA: usb-audio: Add QuickCam Communicate Deluxe/S7500 to volume_control_quirks
  ALSA: usb-audio: add implicit fb quirk for Axe-Fx II
  ASoC: zte: spdif: correct ZX_SPDIF_CLK_RAT define
  ASoC: zte: spdif and i2s drivers are not zx296702 specific
  ASoC: rsnd: setup BRGCKR/BRRA/BRRB when starting
  ASoC: rsnd: enable/disable ADG when suspend/resume timing
  ASoC: rsnd: tidyup ssi->usrcnt counter check in hw_params
  ALSA: cs46xx: add a new line
  ASoC: Intel: update bxt_da7219_max98357a to support quad ch dmic capture
  ASoC: nau8825: disable sinc filter for high THD of ADC
  ALSA: usb-audio: more tolerant packetsize
  ALSA: usb-audio: avoid setting of sample rate multiple times on bus
  ASoC: cs35l34: Simplify the logic to set CS35L34_MCLK_CTL setting
  ALSA: hda - Gate the mic jack on HP Z1 Gen3 AiO
  ALSA: hda: when comparing pin configurations, ignore assoc in addition to seq
  ...
2016-12-14 11:14:28 -08:00
Mark Brown
fba3040105 Merge remote-tracking branches 'asoc/topic/dpcm', 'asoc/topic/es8328', 'asoc/topic/extcon' and 'asoc/topic/fsl' into asoc-next 2016-12-12 15:52:58 +00:00
Richard Fitzgerald
efd95c71f4 extcon: arizona: Use SoC component pin control functions
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-12-01 20:18:44 +00:00
Roger Quadros
541332a13b extcon: usb-gpio: Add VBUS detection support
Driver can now work with both ID and VBUS pins or either one of
them.

There can be the following 3 cases

1) Both ID and VBUS GPIOs are available:

ID = LOW -> USB_HOST active, USB inactive
ID = HIGH -> USB_HOST inactive, USB state is same as VBUS.

2) Only ID GPIO is available:

ID = LOW -> USB_HOST active, USB inactive
ID = HIGH -> USB_HOST inactive, USB active

3) Only VBUS GPIO is available:

VBUS = LOW -> USB_HOST inactive, USB inactive
VBUS = HIGH -> USB_HOST inactive, USB active

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-11-20 21:22:39 +09:00
Stephen Boyd
2925d366f4 extcon: qcom-spmi-misc: Sync the extcon state on interrupt
The driver was changed after submission to use the new style APIs
like extcon_set_state(). Unfortunately, that only sets the state,
and doesn't notify any consumers that the cable state has
changed. Use extcon_set_state_sync() here instead so that we
notify cable consumers of the state change. This fixes USB
host-device role switching on the db8074 platform.

Fixes: 38085c987f ("extcon: Add support for qcom SPMI PMIC USB id detection hardware")
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-10-26 16:04:29 +09:00
Kishon Vijay Abraham I
cb9850d092 Merge branch 'next' into resolution
Conflicts:
	drivers/extcon/extcon-adc-jack.c
	drivers/extcon/extcon-arizona.c
	drivers/extcon/extcon-gpio.c
	include/linux/extcon.h
2016-09-15 16:45:20 +05:30
Stephen Boyd
38085c987f extcon: Add support for qcom SPMI PMIC USB id detection hardware
Some Qualcomm PMICs have a misc device that performs USB id pin
detection via an interrupt. When the interrupt triggers, we
should read the interrupt line to see if it has gone high or low.
If the interrupt is low then the ID pin is grounded, and if the
interrupt is high then the ID pin is being held high.

Cc: Roger Quadros <rogerq@ti.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
[cw00.choi: Edited the driver description and added the author information]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-13 11:26:26 +09:00
Chanwoo Choi
8670b45980 extcon: Use the extcon_set_state_sync() instead of deprecated functions
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-09-13 11:26:26 +09:00
Colin Ian King
525867dbd1 extcon: axp288: Fix spelling mistake
This patch fixes the spelling mistake in dev_dbg messages.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
[cw00.choi: Modify the patch title/description]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-13 11:26:26 +09:00
Krzysztof Kozlowski
e5b07e555b extcon: max14577: Change Krzysztof Kozlowski's email to kernel.org
Change my email address to kernel.org instead of Samsung one for the
purpose of any future contact.  The copyrights remain untouched and are
attributed to Samsung.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-13 11:26:26 +09:00
Chanwoo Choi
af9b9285f2 extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device
This patchs add the new EXTCON_CHG_WPT for Wireless Power Transfer[1].
The Wireless Power Transfer is the transmission of electronical energy
from a power source. The EXTCON_CHG_WPT has the EXTCON_TYPE_CHG.

[1] https://en.wikipedia.org/wiki/Wireless_power_transfer

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:57 +05:30
Chanwoo Choi
736d25b115 extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device
This patch adds the new EXTCON_DISP_HMD id for Head-mounted Display[1] device.
The HMD device is usually for USB connector type So, the HMD connector
has the two extcon types of both EXTCON_TYPE_DISP and EXTCON_TYPE_USB.

[1] https://en.wikipedia.org/wiki/Head-mounted_display

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:56 +05:30
Chris Zhong
2f25140601 extcon: Add EXTCON_DISP_DP and the property for USB Type-C
Add EXTCON_DISP_DP for the Display external connector. For Type-C
connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
Alt Mode on USB Type-C Standard). The Type-C support both normal
and flipped orientation, so add a property to extcon.

Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:55 +05:30
Chanwoo Choi
a580982f08 extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.

The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().

The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
		synchronize the information between extcon provider driver
		and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.

For example,
case 1, change the state of external connector and synchronized the data.
	extcon_set_state_sync(edev, EXTCON_USB, 1);

case 2, change both the state and property of external connector
	and synchronized the data.
	extcon_set_state(edev, EXTCON_USB, 1);
	extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
	extcon_sync(edev, EXTCON_USB);

case 3, change the property of external connector and synchronized the data.
	extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
	extcon_sync(edev, EXTCON_USB);

case 4, change the property of external connector and synchronized the data.
	extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:54 +05:30
Chanwoo Choi
35872fdcbf extcon: Rename the extcon_set/get_state() to maintain the function naming pattern
This patch just renames the existing extcon_get/set_cable_state_()
as following because of maintaining the function naming pattern
like as extcon APIs for property.
- extcon_set_cable_state_() -> extcon_set_state()
- extcon_get_cable_state_() -> extcon_get_state()

But, this patch remains the old extcon_set/get_cable_state_() functions
to prevent the build break. After altering new APIs, remove the old APIs.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:53 +05:30
Chanwoo Choi
ceaa98f442 extcon: Add the support for the capability of each property
This patch adds the support of the property capability setting. This function
decides the supported properties of each external connector on extcon provider
driver.

Ths list of new extcon APIs to get/set the capability of property as following:
- int extcon_get_property_capability(struct extcon_dev *edev,
					unsigned int id, unsigned int prop);
- int extcon_set_property_capability(struct extcon_dev *edev,
					unsigned int id, unsigned int prop);

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:52 +05:30
Chanwoo Choi
067c1652e7 extcon: Add the support for extcon property according to extcon type
This patch support the extcon property for the external connector
because each external connector might have the property according to
the H/W design and the specific characteristics.

- EXTCON_PROP_USB_[property name]
- EXTCON_PROP_CHG_[property name]
- EXTCON_PROP_JACK_[property name]
- EXTCON_PROP_DISP_[property name]

Add the new extcon APIs to get/set the property value as following:
- int extcon_get_property(struct extcon_dev *edev, unsigned int id,
			unsigned int prop,
			union extcon_property_value *prop_val)
- int extcon_set_property(struct extcon_dev *edev, unsigned int id,
			unsigned int prop,
			union extcon_property_value prop_val)

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:51 +05:30
Chanwoo Choi
505cf01f98 extcon: Add the extcon_type to gather each connector into five category
This patch adds the new extcon type to group the each connecotr
into following five category. This type would be used to handle
the connectors as a group unit instead of a connector unit.
- EXTCON_TYPE_USB  : USB connector
- EXTCON_TYPE_CHG  : Charger connector
- EXTCON_TYPE_JACK : Jack connector
- EXTCON_TYPE_DISP : Display connector
- EXTCON_TYPE_MISC : Miscellaneous connector

Also, each external connector is possible to belong to one more extcon type.
In caes of EXTCON_CHG_USB_SDP, it have the EXTCON_TYPE_CHG and EXTCON_TYPE_USB.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-09-10 16:48:51 +05:30
Maninder Singh
6e25baab5a extcon: Fix compile time warning
This patch fixes below compilation warning:-
drivers/extcon/extcon.c: In function extcon_register_notifier:
drivers/extcon/extcon.c:455:6: warning: idx may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (idx >= 0) {

Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
[cw00.choi : Modify the patch title using the a captical letter for first char]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:50 +05:30
Chanwoo Choi
84c48dc559 extcon: Block the bit masking operation for cable state except for extcon core
This patch restrict the usage of extcon_update_state() in the extcon
core because the extcon_update_state() use the bit masking to change
the state of external connector. When this function is used in device drivers,
it may occur the probelm with the handling mistake of bit masking.

Also, this patch removes the extcon_get/set_state() functions because these
functions use the bit masking which is reluctant way. Instead, extcon
provides the extcon_set/get_cable_state_() functions.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:49 +05:30
Chanwoo Choi
0143f59de5 extcon: Remove the state_store() to prevent the wrong access
This patch removes the state_store() which change the state of external
connectors with bit masking on user-space. It is wrong access to modify
the change the state of external connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:48 +05:30
Chanwoo Choi
1662622fe5 extcon: gpio: Remove the usage of extcon_set_state()
This patch removes the usage of extcon_set_state() because it uses
the bit masking to change the state of external connectors. The extcon framework
should handle the state by extcon_set_cable_state_() with extcon id.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:47 +05:30
Chanwoo Choi
cc60211237 extcon: adc-jack: Remove the usage of extcon_set_state()
This patch removes the usage of extcon_set_state() because it uses the bit
masking to change the state of external connectors. The extcon framework
should handle the state by extcon_set/get_cable_state_() with extcon id.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:46 +05:30
Chanwoo Choi
cdc0583202 extcon: arizona: Remove the usage of extcon_update_state()
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-09-10 16:48:45 +05:30
Charles Keepax
32daff5d77 extcon: arizona: Remove unneeded semi-colon
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-09-10 16:48:44 +05:30
Stephen Boyd
97536d1d27 extcon: Move extcon_get_edev_by_phandle() errors to dbg level
Sometimes drivers may call this API and expect it to fail because
the extcon they're looking for is optional. Let's move these
prints to debug level so it doesn't look like there's a problem
when there isn't one.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:43 +05:30
Venkat Reddy Talla
44d6106808 extcon: adc-jack: update cable state during boot
Update cable state during boot to avoid any missing
external cable events occurred before driver initialisation.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-10 16:48:42 +05:30
Chanwoo Choi
7fe95fb889 extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device
This patchs add the new EXTCON_CHG_WPT for Wireless Power Transfer[1].
The Wireless Power Transfer is the transmission of electronical energy
from a power source. The EXTCON_CHG_WPT has the EXTCON_TYPE_CHG.

[1] https://en.wikipedia.org/wiki/Wireless_power_transfer

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 11:17:23 +09:00
Chanwoo Choi
9c0595d688 extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device
This patch adds the new EXTCON_DISP_HMD id for Head-mounted Display[1] device.
The HMD device is usually for USB connector type So, the HMD connector
has the two extcon types of both EXTCON_TYPE_DISP and EXTCON_TYPE_USB.

[1] https://en.wikipedia.org/wiki/Head-mounted_display

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 11:17:23 +09:00
Chris Zhong
2164188d57 extcon: Add EXTCON_DISP_DP and the property for USB Type-C
Add EXTCON_DISP_DP for the Display external connector. For Type-C
connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort
Alt Mode on USB Type-C Standard). The Type-C support both normal
and flipped orientation, so add a property to extcon.

Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:23 +09:00
Chanwoo Choi
ab11af049f extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.

The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().

The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
		synchronize the information between extcon provider driver
		and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.

For example,
case 1, change the state of external connector and synchronized the data.
	extcon_set_state_sync(edev, EXTCON_USB, 1);

case 2, change both the state and property of external connector
	and synchronized the data.
	extcon_set_state(edev, EXTCON_USB, 1);
	extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
	extcon_sync(edev, EXTCON_USB);

case 3, change the property of external connector and synchronized the data.
	extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
	extcon_sync(edev, EXTCON_USB);

case 4, change the property of external connector and synchronized the data.
	extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:22 +09:00
Chanwoo Choi
575c2b867e extcon: Rename the extcon_set/get_state() to maintain the function naming pattern
This patch just renames the existing extcon_get/set_cable_state_()
as following because of maintaining the function naming pattern
like as extcon APIs for property.
- extcon_set_cable_state_() -> extcon_set_state()
- extcon_get_cable_state_() -> extcon_get_state()

But, this patch remains the old extcon_set/get_cable_state_() functions
to prevent the build break. After altering new APIs, remove the old APIs.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:22 +09:00
Chanwoo Choi
7f2a0a1699 extcon: Add the support for the capability of each property
This patch adds the support of the property capability setting. This function
decides the supported properties of each external connector on extcon provider
driver.

Ths list of new extcon APIs to get/set the capability of property as following:
- int extcon_get_property_capability(struct extcon_dev *edev,
					unsigned int id, unsigned int prop);
- int extcon_set_property_capability(struct extcon_dev *edev,
					unsigned int id, unsigned int prop);

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:22 +09:00
Chanwoo Choi
792e7e9e5d extcon: Add the support for extcon property according to extcon type
This patch support the extcon property for the external connector
because each external connector might have the property according to
the H/W design and the specific characteristics.

- EXTCON_PROP_USB_[property name]
- EXTCON_PROP_CHG_[property name]
- EXTCON_PROP_JACK_[property name]
- EXTCON_PROP_DISP_[property name]

Add the new extcon APIs to get/set the property value as following:
- int extcon_get_property(struct extcon_dev *edev, unsigned int id,
			unsigned int prop,
			union extcon_property_value *prop_val)
- int extcon_set_property(struct extcon_dev *edev, unsigned int id,
			unsigned int prop,
			union extcon_property_value prop_val)

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:22 +09:00
Chanwoo Choi
55e4e2f129 extcon: Add the extcon_type to gather each connector into five category
This patch adds the new extcon type to group the each connecotr
into following five category. This type would be used to handle
the connectors as a group unit instead of a connector unit.
- EXTCON_TYPE_USB  : USB connector
- EXTCON_TYPE_CHG  : Charger connector
- EXTCON_TYPE_JACK : Jack connector
- EXTCON_TYPE_DISP : Display connector
- EXTCON_TYPE_MISC : Miscellaneous connector

Also, each external connector is possible to belong to one more extcon type.
In caes of EXTCON_CHG_USB_SDP, it have the EXTCON_TYPE_CHG and EXTCON_TYPE_USB.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-08 11:17:20 +09:00
Maninder Singh
2c8116a111 extcon: Fix compile time warning
This patch fixes below compilation warning:-
drivers/extcon/extcon.c: In function extcon_register_notifier:
drivers/extcon/extcon.c:455:6: warning: idx may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (idx >= 0) {

Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
[cw00.choi : Modify the patch title using the a captical letter for first char]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:37 +09:00
Chanwoo Choi
912465bcf8 extcon: Block the bit masking operation for cable state except for extcon core
This patch restrict the usage of extcon_update_state() in the extcon
core because the extcon_update_state() use the bit masking to change
the state of external connector. When this function is used in device drivers,
it may occur the probelm with the handling mistake of bit masking.

Also, this patch removes the extcon_get/set_state() functions because these
functions use the bit masking which is reluctant way. Instead, extcon
provides the extcon_set/get_cable_state_() functions.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:36 +09:00
Chanwoo Choi
5d5321e90a extcon: Remove the state_store() to prevent the wrong access
This patch removes the state_store() which change the state of external
connectors with bit masking on user-space. It is wrong access to modify
the change the state of external connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:36 +09:00
Chanwoo Choi
7575591c2d extcon: gpio: Remove the usage of extcon_set_state()
This patch removes the usage of extcon_set_state() because it uses
the bit masking to change the state of external connectors. The extcon framework
should handle the state by extcon_set_cable_state_() with extcon id.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:36 +09:00
Chanwoo Choi
a7da72eeec extcon: adc-jack: Remove the usage of extcon_set_state()
This patch removes the usage of extcon_set_state() because it uses the bit
masking to change the state of external connectors. The extcon framework
should handle the state by extcon_set/get_cable_state_() with extcon id.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:35 +09:00
Chanwoo Choi
5475e63175 extcon: arizona: Remove the usage of extcon_update_state()
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-08 10:58:35 +09:00
Charles Keepax
c19dc203e6 extcon: arizona: Remove unneeded semi-colon
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-08-08 10:58:35 +09:00
Stephen Boyd
e8752b7a72 extcon: Move extcon_get_edev_by_phandle() errors to dbg level
Sometimes drivers may call this API and expect it to fail because
the extcon they're looking for is optional. Let's move these
prints to debug level so it doesn't look like there's a problem
when there isn't one.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:35 +09:00
Venkat Reddy Talla
ba4b27151a extcon: adc-jack: update cable state during boot
Update cable state during boot to avoid any missing
external cable events occurred before driver initialisation.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-08-08 10:58:35 +09:00
Venkat Reddy Talla
1b6cf31010 extcon: adc-jack: add suspend/resume support
adding suspend and resume funtionality for extcon-adc-jack
driver to configure system wake up for extcon events,
also adding support to enable/disable system wakeup
through flag wakeup_source based on platform requirement.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-07-02 14:31:34 +09:00
Peter Chen
5d5c4c139d extcon: add missing of_node_put after calling of_parse_phandle
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-07-02 13:24:25 +09:00
Arnd Bergmann
af61f96109 extcon: link devres into core module
Splitting the resource-managed functions into a separate module
means that the extcon core now fails to build because the internal
"extcon_dev_allocate" symbol is not exported:

ERROR: extcon_dev_allocate [drivers/extcon/devres.ko] undefined!

My guess is that the intention was not to have two separate
modules (which could be fixed by adding an export, plus the
normal MODULE_AUTHOR/MODULE_LICENSE/... fields), but have two
source files in the same module.

This fixes the Makefile accordingly, making the name of the
module extcon_core.ko, which is created from building both
extcon.c and devres.c.

Fixes: b225d00f3a ("extcon: Split out the resource-managed functions from extcon core")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-30 22:18:40 +09:00
Chanwoo Choi
58f386560a extcon: Add resource-managed functions to register extcon notifier
This patch adds the resource-managed functions for register/unregister
the extcon notifier with the id of each external connector. This function
will make it easy to handle the extcon notifier.

- int devm_extcon_register_notifier(struct device *dev,
				struct extcon_dev *edev, unsigned int id,
				struct notifier_block *nb);
- void devm_extcon_unregister_notifier(struct device *dev,
				struct extcon_dev *edev, unsigned int id,
				struct notifier_block *nb);

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-27 21:03:23 +09:00
Chanwoo Choi
b225d00f3a extcon: Split out the resource-managed functions from extcon core
This patch split out the resource-managed related functions
from extcon core driver.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-27 20:31:23 +09:00
Chanwoo Choi
20f7b53dfc extcon: Move struct extcon_cable from header file to core
This patch moves the struct extcon_cable because that should
be only handled by extcon core. There are no reason to publish
the internal structure.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-27 20:31:21 +09:00
Stephen Boyd
a05f44c89e extcon: Check for incorrect connection type in notifier register
If we call extcon_register_notifier() with the wrong cable type,
it blows up with an oops instead of returning an error code.
Let's be nice and fail gracefully given that the consumer might
not know if the cable is supported by the extcon provider.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-23 19:35:10 +09:00
Chanwoo Choi
70a7da4587 Merge branch 'ib-extcon-powersupply-4.8' into extcon-next 2016-06-21 14:10:00 +09:00
Lu Baolu
942c7924a5 extcon: usb-gpio: add support for ACPI gpio interface
GPIO resource could be retrieved through APCI as well.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-21 14:09:53 +09:00
Lu Baolu
058b6659e9 extcon: usb-gpio: add device binding for platform device
This is needed to handle the GPIO connected USB ID pin found on
Intel Baytrail devices.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-21 14:09:53 +09:00
Roger Quadros
04c0800808 extcon: usb-gpio: Don't miss event during suspend/resume
Pin state might have changed during suspend/resume while
our interrupts were disabled and if device doesn't support wakeup.

Scan for change during resume for such case.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-21 14:09:53 +09:00
Grygorii Strashko
12bd0f323b extcon: usb-gpio: switch to use pm wakeirq apis
Switch to use PM wakeirq APIs which automates wakeup IRQs
enabling/disabling and so allows to make code simpler.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-21 14:09:53 +09:00
Roger Quadros
62e6d1e59c extcon: palmas: Fix boot up state of VBUS when using GPIO detection
If USB cable is connected prior to boot, we don't get any interrupts
so we must manually check the VBUS state and report it during probe.
If we don't do it then USB controller will never know that peripheral
cable was connected till the user unplugs and replugs the cable.

Fixes: b7aad8e268 ("extcon: palmas: Add the support for VBUS detection by using GPIO")
Cc: stable@vger.kernel.org
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-15 17:17:22 +09:00
Chanwoo Choi
830ae44220 extcon: Remove the deprecated extcon functions
This patch removes the deprecated extcon functions using string type
to identify the type of external connector. The Commit 2a9de9c0f0
("extcon: Use the unique id for external connector instead of string)
uses the unique id to separate the type of external connector instead of
string name.
- extcon_register_interest()
- extcon_unregister_interest()
- extcon_set_cable_state()
- extcon_get_cable_state()

And, extcon_register_interest() finds the first extcon device to include the
requested external connector from extcon client device and then register the
notifier if extcon device argument is NULL. Instead, extcon_register_notifier()
supports this feature.

But, this patch remains the deprecatd function definition to prevent
the build break.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-06-10 11:12:50 +09:00
Nishanth Menon
f75587b8ca extcon: palmas: Drop stray IRQF_EARLY_RESUME flag
Palmas extcon IRQs are nested threaded and wired to the Palmas
interrupt controller. So, this flag is not required for nested
IRQs anymore, since commit 3c646f2c6a ("genirq: Don't suspend
nested_thread irqs over system suspend") was merged. However, the
fix in commit ae64e42cc2 ("extcon: palmas: Drop IRQF_EARLY_RESUME
flag") missed a stray flag causing the following crash on resume on
BeagleBoard-X15 platform:

[   53.670141] Unhandled fault: imprecise external abort (0x1406) at 0x00000000
[..]
[   53.670141] [<c04ae734>] (omap_set_gpio_triggering) from [<c04aeb94>] (omap_gpio_unmask_irq+0xc0/0xc4)
[   53.670141] [<c04aeb94>] (omap_gpio_unmask_irq) from [<c01a0b88>] (irq_enable+0x30/0x44)
[   53.670141] [<c01a0b88>] (irq_enable) from [<c019ebd8>] (__enable_irq+0x54/0x78)
[   53.670141] [<c019ebd8>] (__enable_irq) from [<c01a4e60>] (resume_irqs+0xe8/0x100)
[   53.670141] [<c01a4e60>] (resume_irqs) from [<c0514840>] (syscore_resume+0x94/0x298)
[   53.670141] [<c0514840>] (syscore_resume) from [<c01981cc>] (suspend_devices_and_enter+0x790/0x9e4)
[   53.670141] [<c01981cc>] (suspend_devices_and_enter) from [<c0198a60>] (pm_suspend+0x640/0x75c)
[   53.670141] [<c0198a60>] (pm_suspend) from [<c0196bec>] (state_store+0x64/0xb8)
[   53.670141] [<c0196bec>] (state_store) from [<c0307944>] (kernfs_fop_write+0xc0/0x1bc)
[   53.670141] [<c0307944>] (kernfs_fop_write) from [<c028acb0>] (__vfs_write+0x1c/0xd8)
[   53.670141] [<c028acb0>] (__vfs_write) from [<c028bba0>] (vfs_write+0x90/0x16c)
[   53.670141] [<c028bba0>] (vfs_write) from [<c028c8c0>] (SyS_write+0x44/0x9c)
[   53.670141] [<c028c8c0>] (SyS_write) from [<c0107840>] (ret_fast_syscall+0x0/0x1c)
[..]

Fixes: ae64e42cc2 ("extcon: palmas: Drop IRQF_EARLY_RESUME flag")
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Roger Quadros <rogerq@ti.com>

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-04-04 08:32:45 +09:00
Grygorii Strashko
ae64e42cc2 extcon: palmas: Drop IRQF_EARLY_RESUME flag
Palams extcon IRQs are nested threaded and wired to the Palmas
inerrupt controller. So, this flag is not required for nested irqs
anymore, since commit 3c646f2c6a ("genirq: Don't suspend
nested_thread irqs over system suspend") was merged.

Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Roger Quadros <rogerq@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-02-29 11:07:34 +09:00
Felipe Balbi
b7aad8e268 extcon: palmas: Add the support for VBUS detection by using GPIO
This patch support for VBUS detection by using GPIO pin.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
2016-02-05 14:15:31 +09:00
Dan Carpenter
c4924e9244 extcon: max77843: Use correct size for reading the interrupt register
The info->status[] array has 3 elements.  We are using size
MAX77843_MUIC_IRQ_NUM (16) instead of MAX77843_MUIC_STATUS_NUM (3) as
intended.

Fixes: 135d9f7d13 ('extcon: max77843: Clear IRQ bits state before request IRQ')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jaewon Kim <jaewon02.kim@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[cw00.choi: Modify the patch title]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-02-05 11:37:26 +09:00
Charles Keepax
03bf1adbd6 extcon: arizona: Use DAPM mutex helper functions
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>
2016-01-25 13:16:53 +09:00
Chanwoo Choi
8b45b6a074 extcon: Add the EXTCON_CHG_USB_SDP to support SDP charing port
This patch adds the new EXTCON_CHG_USB_SDP connector to support SDP (Standard
Downstream Port) USB charging port. The commit 11eecf910b ("extcon: Modify
the id and name of external connector") add the new EXTCON_CHG_USB_SDP
connector which support the both data transfer and usb charging at the same
time.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2016-01-25 13:16:53 +09:00
Moritz Fischer
b51b387020 extcon: gpio: Fix typo in comment
This patch fixes the typo in comment of extcon-gpio.c driver.
- 'interrput' -> 'interrupt'

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-01-25 13:16:53 +09:00
Geliang Tang
d58593426e extcon: Use to_i2c_client for both rt8973a and sm5502
Use to_i2c_client() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-01-25 13:16:53 +09:00
Sergei Shtylyov
08a0a4f987 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 <sergei.shtylyov@cogentembedded.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Rob Herring <robh@kernel.org>
[cw00.choi: Add the GPIOLIB dependency]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-12-21 11:44:00 +09:00
Andrzej Hajda
c05c0d544e extcon: max77843: fix handling return value of regmap_irq_get_virq
The function can return negative values, so its result should
be assigned to signed variable.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-12-15 10:02:34 +09:00
Andrzej Hajda
cbc46603df extcon: max77693: fix handling return value of regmap_irq_get_virq
The function can return negative values, so its result should
be assigned to signed variable.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Suggested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-12-15 10:02:23 +09:00
Andrzej Hajda
c2957563ad extcon: max14577: fix handling return value of regmap_irq_get_virq
The function can return negative values, so its result should
be assigned to signed variable.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-12-15 10:02:03 +09:00
Charles Keepax
bb6da5d954 extcon: arizona: Add device bindings for the micd configurations
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-12-15 09:57:36 +09:00
Saurabh Sengar
5f01e6bc33 extcon: rt8973: Add IRQF_ONESHOT to interrupt flags
This patch adds IRQF_ONESHOT if no primary handler is provided for request
threaded irq.

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-27 10:42:00 +09:00
Charles Keepax
7a7ef0f2a4 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 <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-24 09:00:27 +09:00
Charles Keepax
832df9e8ec 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 <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-11-24 08:59:11 +09:00
Charles Keepax
35247c136a extcon: arizona: Add device binding for second jack detect pin on GPIO5
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-20 10:14:23 +09:00
Charles Keepax
3d7a872fa3 extcon: arizona: Add device binding for jack detect polarity inversion
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-20 10:14:23 +09:00
Charles Keepax
99374227cf extcon: arizona: Add device binding for the general purpose switch
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-20 10:14:23 +09:00
Charles Keepax
2e87b7a8be extcon: arizona: Add device binding to enable ADC mode micdet
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-11-20 10:14:23 +09:00
Chanwoo Choi
11eecf910b extcon: Modify the id and name of external connector
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 85efc8a18c ("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-10-16 08:30:09 +09:00
Chanwoo Choi
de992acb93 extcon: gpio: Use descriptor-based GPIO interface instead of legacy gpio_* API
This patch uses the descriptor-based GPIO interface (gpiod_* API) instead of
legacy gpio_* API and add the internal gpio_extcon_init() to handle
all gpio-related tasks.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-30 19:22:50 +09:00
Chanwoo Choi
6ba129974a extcon: gpio: Fix minor coding style and remove the unused fields.
This patch fixes the minor coding style about indentation and removes the
unused fields from struct gpio_extcon_platform_data.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-30 19:22:50 +09:00
Chanwoo Choi
ce6f749605 extcon: gpio: Add the missing supported_cable parameter to devm_extcon_dev_allocate()
The commit 2a9de9c0 ("extcon: Use the unique id for external connector instead
of string") defines the unique id of each external connector to identify the
type of external connector instead of string name. So, devm_extcon_dev_allocate()
should include the second parameter (unsigned int *supported_cable). This patch
adds the supported_cable parameter which is passed by platform data.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-30 19:22:49 +09:00
Chanwoo Choi
60f9b9e65c extcon: gpio: Remove duplicate data from struct gpio_extcon_data
There are duplicate data between struct gpio_extcon_data and struct
gpio_extcon_platform_data. This patch removes them from struct gpio_extcon_data.
Instead, this patch add pdata field to struct gpio_extcon_data.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-30 19:22:49 +09:00
Chanwoo Choi
ae59f3a21f extcon: gpio: Use resource managed function for request_irq
This patch uses the resource managed function for registering
interrupt.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-30 19:22:49 +09:00
Chanwoo Choi
e9844b2caf extcon: arizona: Reorder the default statement to remove unnecessary warning
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-30 19:11:47 +09:00
Richard Fitzgerald
d8d09564b8 extcon: arizona: Add support for WM8998 and WM1814
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-29 18:11:10 +09:00
Chanwoo Choi
37e57066d5 Merge branch 'ib-extcon-mfd-4.4' into extcon-next 2015-09-29 18:10:04 +09:00
Andrzej Hajda
363b389106 extcon: sm5502: fix handling regmap_irq_get_virq result
The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-29 17:58:43 +09:00
Andrzej Hajda
238ffc2e64 extcon: rt8973a: fix handling regmap_irq_get_virq result
The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-29 17:58:43 +09:00
Vaishali Thakkar
4bf27b7038 extcon: axp288: Convert to using managed resources
Use resource managed functions devm_usb_get_phy and
devm_gpio_request to make error path simpler. To be
compatible the change, various gotos are replaced
with direct returns and unnecessary label
gpio_req_failed is dropped.

Also, remove function axp288_extcon_remove as it is
now redundant.

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-29 17:58:42 +09:00
Javier Martinez Canillas
ff612f9170 extcon: Export OF module alias information in missing drivers
The I2C core always reports the MODALIAS uevent as "i2c:<modalias>"
regardless of the mechanism that was used to register the device
(i.e: OF or board code) and the table that is used later to match
the driver with the device (i.e: I2C id table or OF match table).

So drivers needs to export the I2C id table and this be built into
the module or udev won't have the necessary information to autoload
the needed driver module when the device is added.

But this means that OF-only drivers needs to have both OF and I2C id
tables that have to be kept in sync and also the dev node compatible
manufacturer prefix is stripped when reporting the MODALIAS. Which can
lead to issues if two vendors use the same I2C device name for example.

To avoid the above, the I2C core behavior may be changed in the future
to not require an SPI device table for OF-only drivers and report the
OF module alias. So, it's better to also export the OF table even when
is unused now to prevent breaking module loading when the core changes.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-29 17:58:42 +09:00
Charles Keepax
6c20b93424 extcon: arizona: Don't disable debounce for inverted jacks
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-22 15:28:00 +09:00
Charles Keepax
ff1cb0ed71 extcon: arizona: Use the micd_clamp for interrupts if it is available
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-22 15:28:00 +09:00
Nariman Poushin
a0ef642849 extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS
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-22 15:27:59 +09:00
Charles Keepax
f719ae3311 extcon: arizona: Additional settings to improve accuracy of HP detect
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-22 15:27:59 +09:00
Charles Keepax
6772a5ab4f extcon: arizona: Add support for general purpose switch
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-22 15:27:58 +09:00
Charles Keepax
df8b6771bd extcon: arizona: Add support for new ADC value mic detect
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-09-22 15:27:57 +09:00
Hans de Goede
f4513b065f extcon: Fix attached value returned by is_extcon_changed
is_extcon_changed should only check the idx-th bit of new, not
the entirety of new when setting attached.

This fixes extcon sending notifications that a cable was inserted when
it gets removed while another cable is still connected.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-09-21 15:07:19 +09:00
Linus Torvalds
cf9d615f7f regulator: Updates for v4.3
The biggest changes in the core this time around have been some
 refactorings that move us towards being able to drop the list of
 regulators maintained by the core and instead just use the driver model
 list maintained for the class devices for regulators which will make the
 code smaller and avoid some potential bugs.  Otherwise another fairly
 quiet release for the regulator API, highlights include:
 
  - A new API for setting voltages based on a minimum, target, maximum
    triplet.
  - Support for continuous voltage ranges rather than tables of explicit
    steps in the PWM regulator, requiring less explicit configuration.
  - New driver support for Dialog DA9215, Maxim 77843, Mediatek MT6311
    and Qualcomm RPM.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJV5DCWAAoJECTWi3JdVIfQDgYH/3mNwtRcwslt8M1L8lzRVyf1
 gRrJY5r4EUOcqqsLnQvDHdjgO2yowEolEd3Hd/GElZqzeFgwXaQ62kHwgqnvOt9k
 O0l99FbU6ECpB56tSENrV1lfvBTlld9bEhq9NhxvNiWAdpGPqIcjvXfSH28GssJ0
 NGr4Yt/A1DG6GsOWxKSODX56WJXJn4emKx3vHH+leUClNWwQVK6JunTmj5IPKLxW
 K94Ke41L3JgAy18TLqvFNlTAC22QaHFaM8ul9v7gnPW+S8Bx15MCQz16rMkGViZV
 c/DyCu69qCVFLI1svRrvB5oq700QT0GT6jANCVmw+CrkIkESwjS39kX861H6hk8=
 =vrVx
 -----END PGP SIGNATURE-----

Merge tag 'regulator-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "The biggest changes in the core this time around have been some
  refactorings that move us towards being able to drop the list of
  regulators maintained by the core and instead just use the driver
  model list maintained for the class devices for regulators which will
  make the code smaller and avoid some potential bugs.

  Otherwise another fairly quiet release for the regulator API,
  highlights include:

   - a new API for setting voltages based on a minimum, target, maximum
     triplet

   - support for continuous voltage ranges rather than tables of
     explicit steps in the PWM regulator, requiring less explicit
     configuration

   - new driver support for Dialog DA9215, Maxim 77843, Mediatek MT6311
     and Qualcomm RPM"

* tag 'regulator-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (70 commits)
  regulator: mt6311: fix platform_no_drv_owner.cocci warnings
  regulator: ltc3589: Remove unnecessary MODULE_ALIAS()
  regulator: ad5398: Remove unnecessary MODULE_ALIAS()
  regulator: pfuze100: Remove unnecessary MODULE_ALIAS()
  regulator: core: use debug level print in regulator_check_drms
  regulator: lp872x: handle error case
  regulator: lp872x: use the private data instead of updating I2C device platform data
  regulator: isl9305: Export OF module alias information
  regulators: max77693: register driver earlier to avoid deferred probe
  regulator: qcom_smd: Set n_voltages for pm8941_lnldo
  regulator: core: Use IS_ERR_OR_NULL()
  regulator: core: Define regulator_set_voltage_triplet()
  regulator: Regulator driver for the Qualcomm RPM
  regulator: pbias: Fix broken pbias disable functionality
  regulator: core: Spelling fix
  regulator: core: Use class device list for regulator_list in late init
  regulator: core: Move more deallocation into class unregister
  regulator: core: Reduce rdev locking region when releasing regulator
  Input: Remove the max77843 haptic driver
  Input: max77693: Add support for Maxim 77843
  ...
2015-08-31 15:49:19 -07:00
Mark Brown
176175b613 Merge remote-tracking branches 'regulator/topic/lp872x', 'regulator/topic/ltc3589', 'regulator/topic/max77693' and 'regulator/topic/max8973' into regulator-next 2015-08-30 14:39:34 +01:00
Chanwoo Choi
ac22a1d338 extcon: palmas: Fix build break due to devm_gpiod_get_optional API change
With commit b17d1bf16c ("gpio: make flags mandatory for gpiod_get functions")
it becomes necessary to pass the flags argument. And this patch adds the gpio
header file to fix the build breakage when build testing with random
configuration files.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2015-08-13 20:56:18 +09:00
Roger Quadros
92b7cb5dc8 extcon: palmas: Support GPIO based USB ID detection
Some palmas based chip variants do not have OTG based ID logic.
For these variants we rely on GPIO based USB ID detection.

These chips do have VBUS comparator for VBUS detection so we
continue to use the old way of detecting VBUS.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 21:26:25 +09:00
Dan Carpenter
a598af7f02 extcon: Fix signedness bugs about break error handling
Unsigned is never less than zero so this error handling won't work.

Fixes: be052cc877 ('extcon: Fix hang and extcon_get/set_cable_state().')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
[cw00.choi: Change the patch title and fix signedness bug of find_cable_index_by_id() ]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:57 +09:00
Krzysztof Kozlowski
bef025a1f8 extcon: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:56 +09:00
Charles Keepax
bb327e92a9 extcon: arizona: Simplify pdata symantics for micd_dbtime
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-10 11:48:56 +09:00
Charles Keepax
57f70ef9bd extcon: arizona: Declare 3-pole jack if we detect open circuit on mic
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-10 11:48:56 +09:00
Chanwoo Choi
7eae43aeab extcon: Add exception handling to prevent the NULL pointer access
This patch check whether argument is NULL to prevent NULL pointer access.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:56 +09:00
Charles Keepax
0ffe8cbd51 extcon: arizona: Ensure variables are set for headphone detection
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-10 11:48:56 +09:00
Charles Keepax
8e5838dd7b extcon: arizona: Use gpiod inteface to handle micd_pol_gpio gpio
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>
2015-08-10 11:48:55 +09:00
Charles Keepax
4778d44ff3 extcon: arizona: Add basic microphone detection DT/ACPI bindings
This patch adds bindings for the basic microphone detection platform
data.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:55 +09:00
Charles Keepax
feffb0cc63 extcon: arizona: Update to use the new device properties API
The device properties API will load data from both device tree and ACPI,
update the binding to use this API instead of the OF API.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:55 +09:00
Chanwoo Choi
1fe189bfb0 extcon: palmas: Remove the mutually_exclusive array
This patch removes the mutually_exclusive array of extcon-palmas.c.
After used the unique id of each external connector on 2a9de9c0f0
("extcon: Use the unique id for external connector instead of string"),
extcon driver can't directly handle the bit value indicating the external
connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:55 +09:00
Chanwoo Choi
2519b7650e extcon: Remove optional print_state() function pointer of struct extcon_dev
This patch removes the optional print_state() function pointer which included
in 'struct extcon_dev' because the extcon must maintain the consistent name
of extcon device on sysfs instead of inconsistent state of external connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10 11:48:55 +09:00