History log of /linux-master/drivers/extcon/extcon-axp288.c
Revision Date Author Comments
# 07c8eb32 02-Jan-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: axp288: Replace open coded acpi_dev_put()

Instead of calling put_device(&adev->dev) where adev is a pointer
to an ACPI device, use specific call, i.e. acpi_dev_put().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 58e4a2d2 16-Dec-2021 Dan Carpenter <dan.carpenter@oracle.com>

extcon: Fix extcon_get_extcon_dev() error handling

The extcon_get_extcon_dev() function returns error pointers on error,
NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV)
when the CONFIG_EXTCON option is disabled. This is very complicated for
the callers to handle and a number of them had bugs that would lead to
an Oops.

In real life, there are two things which prevented crashes. First,
error pointers would only be returned if there was bug in the caller
where they passed a NULL "extcon_name" and none of them do that.
Second, only two out of the eight drivers will build when CONFIG_EXTCON
is disabled.

The normal way to write this would be to return -EPROBE_DEFER directly
when appropriate and return NULL when CONFIG_EXTCON is disabled. Then
the error handling is simple and just looks like:

dev->edev = extcon_get_extcon_dev(acpi_dev_name(adev));
if (IS_ERR(dev->edev))
return PTR_ERR(dev->edev);

For the two drivers which can build with CONFIG_EXTCON disabled, then
extcon_get_extcon_dev() will now return NULL which is not treated as an
error and the probe will continue successfully. Those two drivers are
"typec_fusb302" and "max8997-battery". In the original code, the
typec_fusb302 driver had an 800ms hang in tcpm_get_current_limit() but
now that function is a no-op. For the max8997-battery driver everything
should continue working as is.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 968bd3f0 16-Sep-2021 Fabio Aiuto <fabioaiuto83@gmail.com>

extcon: extcon-axp288: Use P-Unit semaphore lock for register accesses

use low level P-Unit semaphore lock for axp288 register
accesses directly and for more than one access a time,
to reduce the number of times this semaphore is locked
and released which is an expensive operation.

i2c-bus to the XPower is shared between the kernel and the
SoCs P-Unit. The P-Unit has a semaphore wich the kernel must
lock for axp288 register accesses. When the P-Unit semaphore
is locked CPU and GPU power states cannot change or the system
will freeze.

The P-Unit semaphore lock is already managed inside the regmap
access logic, but for each access the semaphore is locked and
released. So use directly iosf_mbi_(un)block_punit_i2c_access(),
we are safe in doing so because nested calls to the same
semaphore are turned to nops.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# dbc88807 14-Sep-2020 Liu Shixin <liushixin2@huawei.com>

extcon: axp288: Use module_platform_driver to simplify the code

module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 9c945530 23-Mar-2020 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Add wakeup support

On devices with an AXP288, we need to wakeup from suspend when a charger
is plugged in, so that we can do charger-type detection and so that the
axp288-charger driver, which listens for our extcon events, can configure
the input-current-limit accordingly.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 20d320c6 20-Mar-2020 Thomas Gleixner <tglx@linutronix.de>

extcon: axp288: Convert to new X86 CPU match macros

The new macro set has a consistent namespace and uses C99 initializers
instead of the grufty C89 ones.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lkml.kernel.org/r/20200320131510.075227793@linutronix.de


# a69dff99 08-Oct-2019 Heikki Krogerus <heikki.krogerus@linux.intel.com>

extcon: axp288: Remove the build-in connection description

Getting handle to the USB role switch by first finding its
software fwnode.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20191008122600.22340-3-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 21be848e 26-Jul-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()

This simplifies and standardizes axp288_extcon_log_rsi()
by using for_each_set_bit() library function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# d72e3dc7 26-Jul-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: axp288: Add missed error check

It seems from the very beginning the error check has been missed
in axp288_extcon_log_rsi(). Add it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 1802d0be 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174

Based on 1 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 version 2 as
published by the free software foundation this program is
distributed in the hope that it will be useful but without any
warranty without even the implied warranty of merchantability or
fitness for a particular purpose see the gnu general public license
for more details

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 655 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0cf064db 28-Mar-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

extcon: axp288: Convert to use acpi_dev_get_first_match_dev()

acpi_dev_get_first_match_name() is deprecated and going to be removed
because it leaks a reference.

Convert the driver to use acpi_dev_get_first_match_dev() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# d54f063c 20-Mar-2018 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Set USB role where necessary

The AXP288 BC1.2 charger detection / extcon code may seem like a strange
place to add code to control the USB role-switch on devices with an AXP288,
but there are 2 reasons to do this inside the axp288 extcon code:

1) On many devices the USB role is controlled by ACPI AML code, but the AML
code only switches between the host and none roles, because of Windows
not really using device mode. To make device mode work we need to toggle
between the none/device roles based on Vbus presence, and the axp288
extcon gets interrupts on Vbus insertion / removal.

2) In order for our BC1.2 charger detection to work properly the role
mux must be properly set to device mode before we do the detection.

Also note the Kconfig help-text / obsolete depends on USB_PHY which are
remnants from older never upstreamed code also controlling the mux from
the axp288 extcon code.

This commit also adds code to get notifications from the INT3496 extcon
device, which is used on some devices to notify the kernel about id-pin
changes instead of them being handled through AML code.

This fixes:
-Device mode not working on most CHT devices with an AXP288
-Host mode not working on devices with an INT3496 ACPI device
-Charger-type misdetection (always SDP) on devices with an INT3496 when the
USB role (always) gets initialized as host

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d82e233c 12-Feb-2018 Hans de Goede <hdegoede@redhat.com>

Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()"

Redoing the charger type detection to give the usb-role-switch code time
to properly set the role-switch is no good for mainline, since the
usb-role-switch code is not yet in mainline (my bad, sorry).

Also once we've that code there are better ways to fix this which are
not prone to racing as doing a retry after 2 seconds is.

This reverts commit 50082c17bb1455acacd376ae30dff92f2e1addbd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 5b4e64be 12-Feb-2018 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Constify the axp288_pwr_up_down_info array

Make the axp288_pwr_up_down_info array const char * const, this leads
to the following section size changes:

.text 0x674 -> 0x664
.data 0x148 -> 0x0f0
.rodata 0x0b4 -> 0x114

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# ca90a64d 22-Dec-2017 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Handle reserved charger-type values better

According to the data sheets all the values not handled in the
switch-case are "reserved". Update the dev_warn message to reflect
this and set the cable-type to EXTCON_CHG_USB_SDP (so max 500mA
current draw) as safe default.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 60ed9996 22-Dec-2017 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Redo charger type detection a couple of seconds after probe()

The axp288 extcon code depends on other drivers to do things like mux the
data lines, enable/disable vbus based on the id-pin, etc.

Sometimes the BIOS has not set these things up correctly resulting in the
initial charger cable type detection giving a wrong result and we end up
not charging or charging at only 0.5A.

This commit starts a second charger-detection cycle a couple of seconds
after the first one finishes, giving the other drivers time to load and
do their thing.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 9bf317e9 30-Dec-2017 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Remove unused platform data

This is not used / set anywhere in the tree.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 10887fb0 22-Dec-2017 Hans de Goede <hdegoede@redhat.com>

extcon: axp288: Remove unused extcon_nb struct member

Remove the unused extcon_nb struct member.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 01e1429b 23-Nov-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

extcon: axp288:: Handle return value of platform_get_irq

platform_get_irq() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>


# 176aa360 20-Sep-2017 Chanwoo Choi <cw00.choi@samsung.com>

extcon: Split out extcon header file for consumer and provider device

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>


# 5298b836 20-Dec-2016 Baolin Wang <baolin.wang@linaro.org>

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>


# dd3a55fc 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# be174952 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 5757aca1 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 5d2199ea 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 3fe1e0e2 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 1490d157 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 76884241 18-Dec-2016 Hans de Goede <hdegoede@redhat.com>

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>


# 8670b459 16-Aug-2016 Chanwoo Choi <cw00.choi@samsung.com>

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>


# 525867db 17-Aug-2016 Colin Ian King <colin.king@canonical.com>

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>


# 11eecf91 02-Oct-2015 Chanwoo Choi <cw00.choi@samsung.com>

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 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>


# 4bf27b70 14-Sep-2015 Vaishali Thakkar <vthakkar1994@gmail.com>

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>


# 73b6ecdb 11-Jun-2015 Chanwoo Choi <cw00.choi@samsung.com>

extcon: Redefine the unique id of supported external connectors without 'enum extcon' type

This patch just redefine the unique id of supported external connectors without
'enum extcon' type. Because unique id would be used on devictree file(*.dts) to
indicate the specific external connectors like key number of input framework.
So, I have the plan to move this definitions to following header file which
includes the unique id of supported external connectors.
- include/dt-bindings/extcon/extcon.h

Fixes: 2a9de9c0f08d ("extcon: Use the unique id for external connector instead of string")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2a9de9c0 24-Apr-2015 Chanwoo Choi <cw00.choi@samsung.com>

extcon: Use the unique id for external connector instead of string

This patch uses the unique id to identify the type of external connector instead
of string name. The string name have the many potential issues. So, this patch
defines the 'extcon' enumeration which includes all supported external connector
on EXTCON subsystem. If new external connector is necessary, the unique id of
new connector have to be added in 'extcon' enumeration. There are current
supported external connector in 'enum extcon' as following:

enum extcon {
EXTCON_NONE = 0x0,

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

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

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

EXTCON_HDMI = 0x30,
EXTCON_MHL = 0x31,
EXTCON_DVI = 0x32,
EXTCON_VGA = 0x33,
EXTCON_SPDIF_IN = 0x34,
EXTCON_SPDIF_OUT = 0x35,
EXTCON_VIDEO_IN = 0x36,
EXTCON_VIDEO_OUT = 0x37,

/* Miscellaneous external connector */
EXTCON_DOCK = 0x50,
EXTCON_JIG = 0x51,
EXTCON_MECHANICAL = 0x52,

EXTCON_END,
};

For example in extcon-arizona.c:
To use unique id removes the potential issue about handling
the inconsistent name of external connector with string.
- Previously, use the string to register the type of arizona jack connector
static const char *arizona_cable[] = {
"Mechanical",
"Microphone",
"Headphone",
"Line-out",
};
- Newly, use the unique id to register the type of arizona jack connector
static const enum extcon arizona_cable[] = {
EXTCON_MECHANICAL,
EXTCON_MICROPHONE,
EXTCON_HEADPHONE,
EXTCON_LINE_OUT,

EXTCON_NONE,
};

And this patch modify the prototype of extcon_{get|set}_cable_state_() which
uses the 'enum extcon id' instead of 'cable_index'. Because although one more
extcon drivers support USB cable, each extcon driver might has the differnt
'cable_index' for USB cable. All extcon drivers can use the unique id number
for same external connector with modified extcon_{get|set}_cable_state_().

- Previously, use 'cable_index' on these functions:
extcon_get_cable_state_(struct extcon_dev*, int cable_index)
extcon_set_cable_state_(struct extcon_dev*, int cable_index, bool state)

-Newly, use 'enum extcon id' on these functions:
extcon_get_cable_state_(struct extcon_dev*, enum extcon id)
extcon_set_cable_state_(struct extcon_dev*, enum extcon id, bool state)

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[arnd: Report the build break about drivers/usb/phy/phy-tahvo.c after using the
unique id for external connector insteadf of string]
Reported-by: Arnd Bergmann <arnd@arndb.de>
[dan.carpenter: Report the build warning of extcon_{set|get}_cable_state_()]
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>


# f0312378 30-Apr-2015 Ramakrishna Pallala <ramakrishna.pallala@intel.com>

extcon: axp288: Add axp288 extcon driver support

This patch adds the extcon support for AXP288 PMIC which
has the BC1.2 charger detection capability. Additionally
it also adds the USB mux switching support b/w SOC and PMIC
based on GPIO control.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
[cw00.choi: Modify the log message to keep the consistent log message pattern]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>