summaryrefslogtreecommitdiff
path: root/drivers/extcon/extcon-ptn5150.c
AgeCommit message (Collapse)Author
2020-09-30extcon: ptn5150: Do not print error during probe if nothing is attachedKrzysztof Kozlowski
The commit 85256f611f66 ("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: 85256f611f66 ("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-24extcon: ptn5150: Use defines for registersKrzysztof Kozlowski
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-24extcon: ptn5150: Set the VBUS and POLARITY property capabilityRamuthevar Vadivel Murugan
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-24extcon: ptn5150: Switch to GENMASK() and BIT() macrosRamuthevar Vadivel Murugan
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-24extcon: ptn5150: Deduplicate parts of dev_err_probe()Andy Shevchenko
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-24extcon: ptn5150: Convert to .probe_newKrzysztof Kozlowski
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-24extcon: ptn5150: Convert to module_i2c_driverKrzysztof Kozlowski
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-24extcon: ptn5150: Reduce the amount of logs on deferred probeKrzysztof Kozlowski
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-24extcon: ptn5150: Make 'vbus-gpios' optionalKrzysztof Kozlowski
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-24extcon: ptn5150: Check current USB mode when probingKrzysztof Kozlowski
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-24extcon: ptn5150: Lower the noisiness of probeKrzysztof Kozlowski
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-24extcon: ptn5150: Simplify getting vbus-gpios with flagsKrzysztof Kozlowski
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-24extcon: ptn5150: Use generic "interrupts" propertyKrzysztof Kozlowski
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-24extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chipsKrzysztof Kozlowski
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: 4ed754de2d66 ("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>
2019-02-11extcon: ptn5150: Fix return value check in ptn5150_i2c_probe()Wei Yongjun
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-11extcon: Add support for ptn5150 extcon driverVijai Kumar K
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>