Commit graph

18 commits

Author SHA1 Message Date
Li Jun
1bfcaa5700 extcon: ptn5150: Add usb role class support
Some usb controller drivers may not support extcon but use
usb role class as it's the preferred approach, so to support
usb dual role switch with usb role class, add usb role class
consumer support.

Signed-off-by: Li Jun <jun.li@nxp.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2022-05-13 17:03:41 +09:00
Li Jun
782cd939cb extcon: ptn5150: Add queue work sync before driver release
Add device managed action to sync pending queue work, otherwise
the queued work may run after the work is destroyed.

Fixes: 4ed754de2d ("extcon: Add support for ptn5150 extcon driver")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2022-05-13 17:03:41 +09:00
Krzysztof Kozlowski
6be65ed4f8 extcon: ptn5150: Do not print error during probe if nothing is attached
The commit 85256f611f ("extcon: ptn5150: Check current USB mode when
probing") reused code for checking CC status register in the probe path
to determine what is initially connected.  However if nothing is
connected, the CC status register will have 0x0 value and print an error
message:

    ptn5150 1-003d: Unknown Port status : 0

This is not an error.  Also any other unknown port status values are not
really errors but unhandled cases.

Fixes: 85256f611f ("extcon: ptn5150: Check current USB mode when probing")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-30 00:38:54 +09:00
Krzysztof Kozlowski
b9a32f624f extcon: ptn5150: Use defines for registers
The register addresses are not continuous, so use simple defines for
them.  This also makes it easier to find the address for register.

No functional change.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:49 +09:00
Ramuthevar Vadivel Murugan
ea6a95d09c extcon: ptn5150: Set the VBUS and POLARITY property capability
Set the capability value of property for VBUS and POLARITY.

Signed-off-by: Ramuthevar Vadivel Murugan <vadivel.muruganx.ramuthevar@linux.intel.com>
[cw00.choi: Replace the space with tab for the indentation]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:49 +09:00
Ramuthevar Vadivel Murugan
7e3b1caffc extcon: ptn5150: Switch to GENMASK() and BIT() macros
Switch to GENMASK() and BIT() macros.

Signed-off-by: Ramuthevar Vadivel Murugan <vadivel.muruganx.ramuthevar@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Andy Shevchenko
611e92a0a3 extcon: ptn5150: Deduplicate parts of dev_err_probe()
dev_err_probe() is designed to be used like

	return dev_err_probe(dev, ret, "Error message\n");

Hence no need to have a separate return statement. Besides that
dev_err_probe() prints already returned error code, no need to repeat
that either.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
0b0549b6ac extcon: ptn5150: Convert to .probe_new
The 'struct i2c_device_id' argument of probe function is not used, so
convert the driver to simpler 'probe_new' interface.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
35f1f8f2a3 extcon: ptn5150: Convert to module_i2c_driver
Use module_i2c_driver() to simplify driver init boilerplate.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
b8787ff8a4 extcon: ptn5150: Reduce the amount of logs on deferred probe
There is no point to print deferred probe (and its failures to get
resources) as an error.  In case of multiple probe tries this would
pollute the dmesg.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
fbaf3b67d4 extcon: ptn5150: Make 'vbus-gpios' optional
The PTN5150 chip can be used in hardware designs with only reporting of
USB Type-C connection, without the VBUS control.  The driver however
unconditionally expected 'vbus-gpios'.

Since all uses of the VBUS GPIO descriptor are NULL safe, the code can
accept missing GPIO and provide only extcon status reporting.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
85256f611f extcon: ptn5150: Check current USB mode when probing
When machine boots up, the USB could be already in OTG mode.  In such
case there will be no interrupt coming to ptn5150 device and driver will
report default state of nothing connected.  Detection of USB connection
would happen on first unplug of the cable.

Factor out code for checking current connection mode and call it right
after probe so the existing USB mode will be properly reported.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:48 +09:00
Krzysztof Kozlowski
fa31f58717 extcon: ptn5150: Lower the noisiness of probe
The ptn5150 driver always prints device type on probe but as raw hex,
without any translation to meaningful description.  This is useful only
for board bring up time so lower the verbosity to debug.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:47 +09:00
Krzysztof Kozlowski
e095882ee2 extcon: ptn5150: Simplify getting vbus-gpios with flags
Instead of obtaining GPIO as input and configuring it right after to
output-low, just use proper GPIOD_OUT_LOW flag.  Code is smaller and
simpler.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:47 +09:00
Krzysztof Kozlowski
45ce36f5d2 extcon: ptn5150: Use generic "interrupts" property
Interrupts do not have to be always GPIO based so instead of expecting
"int-gpios" property and converting the GPIO to an interrupt, just
accept any interrupt via generic "interrupts" property.

Keep support for old "int-gpios" for backward compatibility.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:47 +09:00
Krzysztof Kozlowski
6aaad58c87 extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chips
The driver uses atomic version of gpiod_set_value() without any real
reason.  It is called in a workqueue under mutex so it could sleep
there.  Changing it to "can_sleep" flavor allows to use the driver with
all GPIO chips.

Fixes: 4ed754de2d ("extcon: Add support for ptn5150 extcon driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2020-09-24 19:20:47 +09:00
Wei Yongjun
3dfed89512 extcon: ptn5150: Fix return value check in ptn5150_i2c_probe()
In case of error, the function devm_gpiod_get() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-02-11 17:21:38 +09:00
Vijai Kumar K
4ed754de2d extcon: Add support for ptn5150 extcon driver
PTN5150 is a small thin low power CC (Configurationn Channel)
Logic chip supporting the USB Type-C connector application with
CC control logic detection and indication functions.

Signed-off-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
[cw00.choi: Fix bulid dependency and clean-up code]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-02-11 17:21:38 +09:00