Re: [PATCH] extcon: Fix build issues in ptn5150
On Mon, Jan 28, 2019 at 10:08:12AM +0530, Vijai Kumar K wrote: I was wondering, what is the normal procedure in the below case when the build fails because of the driver. Should I send a new patch as a whole [PATCH v3] for the driver or should I send a new patch to fix the issue like below. Thanks, Vijai Kumar K > - extcon-ptn5150 driver uses gpio libraries > - Add GPIOLIB in depends section of Kconfig > > Error: > - > > CC drivers/extcon/extcon-ptn5150.o > > ../drivers/extcon/extcon-ptn5150.c: In function ‘ptn5150_irq_work’: > > ../drivers/extcon/extcon-ptn5150.c:130:5: error: implicit declaration of > > function ‘gpiod_set_value’ [-Werror=implicit-function-declaration] > > gpiod_set_value(info->vbus_gpiod, 0); > > ^ > > ../drivers/extcon/extcon-ptn5150.c: In function ‘ptn5150_i2c_probe’: > > ../drivers/extcon/extcon-ptn5150.c:242:2: error: implicit declaration of > > function ‘devm_gpiod_get’ [-Werror=implicit-function-declaration] > > info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); > > ^ > > ../drivers/extcon/extcon-ptn5150.c:242:53: error: ‘GPIOD_IN’ undeclared > > (first use in this function) > > info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); > > ^ > > ../drivers/extcon/extcon-ptn5150.c:242:53: note: each undeclared identifier > > is reported only once for each function it appears in > > ../drivers/extcon/extcon-ptn5150.c:252:2: error: implicit declaration of > > function ‘gpiod_direction_output’ [-Werror=implicit-function-declaration] > > ret = gpiod_direction_output(info->vbus_gpiod, 0); > > ^ > > ../drivers/extcon/extcon-ptn5150.c:271:3: error: implicit declaration of > > function ‘gpiod_to_irq’ [-Werror=implicit-function-declaration] > >info->irq = gpiod_to_irq(info->int_gpiod); > - > > Signed-off-by: Vijai Kumar K > --- > drivers/extcon/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig > index b9cc027..330dd8b 100644 > --- a/drivers/extcon/Kconfig > +++ b/drivers/extcon/Kconfig > @@ -116,7 +116,7 @@ config EXTCON_PALMAS > > config EXTCON_PTN5150 > tristate "NXP PTN5150 CC LOGIC USB EXTCON support" > - depends on I2C > + depends on I2C && GPIOLIB > select REGMAP_I2C > help > Say Y here to enable support for USB peripheral and USB host > -- > 2.7.4 >
[PATCH] extcon: Fix build issues in ptn5150
- extcon-ptn5150 driver uses gpio libraries - Add GPIOLIB in depends section of Kconfig Error: - > CC drivers/extcon/extcon-ptn5150.o > ../drivers/extcon/extcon-ptn5150.c: In function ‘ptn5150_irq_work’: > ../drivers/extcon/extcon-ptn5150.c:130:5: error: implicit declaration of > function ‘gpiod_set_value’ [-Werror=implicit-function-declaration] > gpiod_set_value(info->vbus_gpiod, 0); > ^ > ../drivers/extcon/extcon-ptn5150.c: In function ‘ptn5150_i2c_probe’: > ../drivers/extcon/extcon-ptn5150.c:242:2: error: implicit declaration of > function ‘devm_gpiod_get’ [-Werror=implicit-function-declaration] > info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); > ^ > ../drivers/extcon/extcon-ptn5150.c:242:53: error: ‘GPIOD_IN’ undeclared > (first use in this function) > info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); > ^ > ../drivers/extcon/extcon-ptn5150.c:242:53: note: each undeclared identifier > is reported only once for each function it appears in > ../drivers/extcon/extcon-ptn5150.c:252:2: error: implicit declaration of > function ‘gpiod_direction_output’ [-Werror=implicit-function-declaration] > ret = gpiod_direction_output(info->vbus_gpiod, 0); > ^ > ../drivers/extcon/extcon-ptn5150.c:271:3: error: implicit declaration of > function ‘gpiod_to_irq’ [-Werror=implicit-function-declaration] >info->irq = gpiod_to_irq(info->int_gpiod); - Signed-off-by: Vijai Kumar K --- drivers/extcon/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index b9cc027..330dd8b 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -116,7 +116,7 @@ config EXTCON_PALMAS config EXTCON_PTN5150 tristate "NXP PTN5150 CC LOGIC USB EXTCON support" - depends on I2C + depends on I2C && GPIOLIB select REGMAP_I2C help Say Y here to enable support for USB peripheral and USB host -- 2.7.4
[PATCH V2] drivers: extcon: Add support for ptn5150
PTN5150A is a small thin low power CC Logic chip supporting the USB Type-C connector application with Configurationn Channel(CC) control logic detection and indication functions. Add driver, Kconfig and Makefile entries. Signed-off-by: Vijai Kumar K --- Hi Chanwoo, I have implemented the review comments and below is the updated patchset. Can you please review it? Highlights: - extcon.h -> extcon-provider.h - Remove dummy implementations for .remove, _suspend/_resume - Change license format to SPDX - remove extcon-ptn5150.h and collapse definitions to extcon-ptn5150.c - Replace tabs with spaces - Update Documentation - Fix coding style issues Thanks Vijai Kumar K .../devicetree/bindings/extcon/extcon-ptn5150.txt | 27 ++ drivers/extcon/Kconfig | 8 + drivers/extcon/Makefile| 1 + drivers/extcon/extcon-ptn5150.c| 335 + 4 files changed, 371 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt create mode 100644 drivers/extcon/extcon-ptn5150.c diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt new file mode 100644 index 000..e772d42 --- /dev/null +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt @@ -0,0 +1,27 @@ + +* PTN5150 CC (Configuration Channel) Logic device +PTN5150A is a small thin low power CC logic chip supporting the USB Type-C +connector application with Configuration Channel (CC) control logic detection and +indication functions. It is interfaced to the host controller using an I2C interface. + +Required properties: +- compatible: Should be "nxp,ptn5150" +- reg: Specifies the I2C slave address of the device +- int-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the PTN5150's INTB pin. +- vbus-gpio: should contain a phandle and GPIO specifier for the GPIO pin which +is used to control VBUS. +- pinctrl-names : a pinctrl state named "default" must be defined. +- pinctrl-0 : phandle referencing pin configuration of interrupt and vbus control. + +Example: + + ptn5150@1d { + compatible = "nxp,ptn5150"; + reg = <0x1d>; + int-gpio = <&msmgpio 78 GPIO_ACTIVE_HIGH>; + vbus-gpio = <&msmgpio 148 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&ptn5150_default>; + status = "okay"; + }; diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index de15bf5..405cd76 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -114,6 +114,14 @@ config EXTCON_PALMAS Say Y here to enable support for USB peripheral and USB host detection by palmas usb. +config EXTCON_PTN5150 + tristate "PTN5150 CC (Configuration Channel) LOGIC USB EXTCON support" + depends on I2C + select REGMAP_I2C + help + Say Y here to enable support for USB peripheral and USB host + detection by ptn5150 CC (Configuration Channel) logic chip. + config EXTCON_QCOM_SPMI_MISC tristate "Qualcomm USB extcon support" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile index 0888fde..261ce4c 100644 --- a/drivers/extcon/Makefile +++ b/drivers/extcon/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o obj-$(CONFIG_EXTCON_PALMAS)+= extcon-palmas.o +obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.o obj-$(CONFIG_EXTCON_RT8973A) += extcon-rt8973a.o obj-$(CONFIG_EXTCON_SM5502)+= extcon-sm5502.o diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c new file mode 100644 index 000..155620b --- /dev/null +++ b/drivers/extcon/extcon-ptn5150.c @@ -0,0 +1,335 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// extcon-ptn5150.c - PTN5150 CC logic extcon driver to support USB detection +// +// Based on extcon-sm5502.c driver +// Copyright (c) 2018-2019 by Vijai Kumar K +// Author: Vijai Kumar K + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PTN5150 registers */ +enum ptn5150_reg { + PTN5150_REG_DEVICE_ID = 0x01, + PTN5150_REG_CONTROL, + PTN5150_REG_INT_STATUS, + PTN5150_REG_CC_STATUS, + PTN5150_REG_CON_DET = 0x09, + PTN5150_REG_VCONN_STATUS, + PTN5150_REG_RESET, + PTN5150_REG_INT_MASK = 0x18, + PTN5150_REG_INT_REG_STATUS, + PTN5150_REG_END, +}; + +#define PTN5150_DFP_ATTACHED 0x1 +#define PTN5150_UFP_ATTACHED
Re: [PATCH] drivers: extcon: Add support for ptn5150
On Tue, Jan 22, 2019 at 03:20:09PM +0900, Chanwoo Choi wrote: > Hi Vijai, > > This patch looks better. But theare are comments about code clean. > I added the comments. > Thanks. And Thank you for reviewing it Chanwoo. Please find my inline comments. I will rebase, implement the review comments and will push an updated patch. > On 19. 1. 21. 오후 6:09, Vijai Kumar K wrote: > > PTN5150A is a small thin low power CC Logic chip supporting > > the USB Type-C connector application with Configurationn Channel(CC) > > control logic detection and indication functions. > > > > Add driver, Kconfig and Makefile entries. > > > > Change-Id: I3b2da147a33b913b9ec60cd914b20acd955950c7 > > Remove it of gerrit system. > Sure. > > Signed-off-by: Vijai Kumar K > > --- > > .../devicetree/bindings/extcon/extcon-ptn5150.txt | 22 ++ > > drivers/extcon/Kconfig | 8 + > > drivers/extcon/Makefile| 1 + > > drivers/extcon/extcon-ptn5150.c| 327 > > + > > drivers/extcon/extcon-ptn5150.h| 51 > > 5 files changed, 409 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt > > create mode 100644 drivers/extcon/extcon-ptn5150.c > > create mode 100644 drivers/extcon/extcon-ptn5150.h > > > > diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt > > b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt > > new file mode 100644 > > index 000..8ea33bb > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt > > @@ -0,0 +1,22 @@ > > + > > +* PTN5150 CC logic device > > You better to specify the full name as following: > : PTN5150 CC (Configuration Channel) Logic device > > > +PTN5150A is a small thin low power CC Logic chip supporting the USB Type-C > > s/Logic/logic > noted. > > +connector application with Configuration Channel (CC) control logic > > detection and > > +indication functions. It is Interfaced to the host controller using an I2C > > interface. > > s/Interfaced/interfaced > noted. > > + > > +Required properties: > > +- compatible: Should be "nxp,ptn5150" > > +- reg: Specifies the I2C slave address of the device > > +- int-gpio: GPIO to which INTB is connected > > What is meaning of 'INTB'? > INTB is the interrupt out pin of PTN5150. > > +- vbus-gpio: GPIO which controls VBUS on/off > > + > > +Example: > > + ptn5150@1d { > > + compatible = "nxp,ptn5150"; > > + reg = <0x1d>; > > + int-gpio = <&msmgpio 78 GPIO_ACTIVE_HIGH>; > > + vbus-gpio = <&msmgpio 148 GPIO_ACTIVE_HIGH>; > > + pinctrl-names = "default"; > > + pinctrl-0 = <&ptn5150_default>; > > You need to add some description why pinctrl properties are needed. > For example, some hwmon device driver[1] explained the properties > related to pinctrl. Please add the description as following. > > - pinctrl-names : a pinctrl state named "default" must be defined. > > - pinctrl-0 : phandle referencing pin configuration of the PWM ports. > > > [1] Documentation/devicetree/hwmon/aspeed-pwm-tacho.txt > Thanks for the pointer. Will look into it and add appropiate description. > > > + status = "okay"; > > + }; > > Remove the one tab in front of dt node. noted. > > ptn5150@1d { > compatible = "nxp,ptn5150"; > reg = <0x1d>; > int-gpio = <&msmgpio 78 GPIO_ACTIVE_HIGH>; > vbus-gpio = <&msmgpio 148 GPIO_ACTIVE_HIGH>; > pinctrl-names = "default"; > pinctrl-0 = <&ptn5150_default>; > status = "okay"; > }; > > > > > diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig > > index a7bca42..6adc797 100644 > > --- a/drivers/extcon/Kconfig > > +++ b/drivers/extcon/Kconfig > > @@ -113,6 +113,14 @@ config EXTCON_PALMAS > > Say Y here to enable support for USB peripheral and USB host > > detection by palmas usb. > > > > +config EXTCON_PTN5150 > > + tristate "PTN5150 CC LOGIC USB EXTCON support" > > PTN5150 CC (Configuration Channel) LOGIC USB E
Re: [PATCH] drivers: extcon: Add support for ptn5150
On Tue, Jan 22, 2019 at 02:27:51PM +0900, Chanwoo Choi wrote: > Hi Vijai, > > On 19. 1. 22. 오후 1:42, Vijai Kumar K wrote: > > Hi Chanwoo Choi, > > > > This is the first time I am sending a driver to LKML. I have a few doubts. > > Can > > you please clarify them when you are free? > > > > 1. I have developed and tested this patch on 4.14.89 kernel. When trying to > > mainline the driver should I rebase and send the patch on top of current > > tree(v5.0-rc2)? > > You better to rebase your patch on extcon-next branch (v5.0-rc1). > because the extcon.git[1] keep the v5.0-rc1 version. But, if you use over > v5.0-rc1 version, > it doesn't matter. Maybe, this patch doesn't get the any impact from the > modification > of v5.0-rcX. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git Thanks, I will rebase and share an updated patchset. > > > > > 2. Is there any specific git on which I should test this driver on? Like > > below? > > https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git > > Yes. > > > > > Thanks, > > Vijai Kumar K > > > > On Tue, Jan 22, 2019 at 08:05:33AM +0800, kbuild test robot wrote: > >> Hi Vijai, > >> > >> Thank you for the patch! Yet something to improve: > >> > >> [auto build test ERROR on chanwoo-extcon/extcon-next] > >> [also build test ERROR on v5.0-rc2] > >> [if your patch is applied to the wrong git tree, please drop us a note to > >> help improve the system] > >> > >> url: > >> https://github.com/0day-ci/linux/commits/Vijai-Kumar-K/drivers-extcon-Add-support-for-ptn5150/20190122-041153 > >> base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git > >> extcon-next > >> config: sh-allyesconfig (attached as .config) > >> compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0 > >> reproduce: > >> wget > >> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross > >> -O ~/bin/make.cross > >> chmod +x ~/bin/make.cross > >> # save the attached .config to linux build tree > >> GCC_VERSION=8.2.0 make.cross ARCH=sh > >> > >> All error/warnings (new ones prefixed by >>): > >> > >>drivers//extcon/extcon-ptn5150.c: In function 'ptn5150_irq_work': > >>>> drivers//extcon/extcon-ptn5150.c:93:5: error: implicit declaration of > >>>> function 'extcon_set_state_sync'; did you mean 'extcon_get_state'? > >>>> [-Werror=implicit-function-declaration] > >> extcon_set_state_sync(info->edev, > >> ^ > >> extcon_get_state > >>drivers//extcon/extcon-ptn5150.c: In function 'ptn5150_i2c_probe': > >>>> drivers//extcon/extcon-ptn5150.c:255:15: error: implicit declaration of > >>>> function 'devm_extcon_dev_allocate'; did you mean 'extcon_get_state'? > >>>> [-Werror=implicit-function-declaration] > >> info->edev = devm_extcon_dev_allocate(info->dev, > >> ptn5150_extcon_cable); > >> ^~~~ > >> extcon_get_state > >>>> drivers//extcon/extcon-ptn5150.c:255:13: warning: assignment to 'struct > >>>> extcon_dev *' from 'int' makes pointer from integer without a cast > >>>> [-Wint-conversion] > >> info->edev = devm_extcon_dev_allocate(info->dev, > >> ptn5150_extcon_cable); > >> ^ > >>>> drivers//extcon/extcon-ptn5150.c:262:8: error: implicit declaration of > >>>> function 'devm_extcon_dev_register'; did you mean > >>>> 'devm_pinctrl_register'? [-Werror=implicit-function-declaration] > >> ret = devm_extcon_dev_register(info->dev, info->edev); > >>^~~~ > >>devm_pinctrl_register > >>cc1: some warnings being treated as errors > >> > >> vim +93 drivers//extcon/extcon-ptn5150.c > >> > >> 51 > >> 52 static void ptn5150_irq_work(struct work_struct *work) > >> 53 { > >> 54 struct ptn5150_info *info = container_of(work, > >> 55 struct ptn5150_info, irq_work); > >> 56 int ret = 0; > >> 57 unsign
Re: Re: [PATCH] drivers: extcon: Add support for ptn5150
On Tue, Jan 22, 2019 at 01:57:46PM +0900, MyungJoo Ham wrote: > >Hi Chanwoo Choi, > > > >This is the first time I am sending a driver to LKML. I have a few doubts. > >Can > >you please clarify them when you are free? > > Although I'm not Chanwoo, but a guy who's about 50ft away from his cubicle, > as he appears to be busy today... :) :) > > > > >1. I have developed and tested this patch on 4.14.89 kernel. When trying to > >mainline the driver should I rebase and send the patch on top of current > >tree(v5.0-rc2)? > > Yes, you are supposed to be based on the most recent RC. Sure. Will do that and push an updated patch > > > > >2. Is there any specific git on which I should test this driver on? Like > >below? > >https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git > > I'd recommend to pull torvald's master with RC tag. Thanks. Will took into that. > > > Cheers, > MyungJoo > > > > >Thanks, > >Vijai Kumar K
Re: [PATCH] drivers: extcon: Add support for ptn5150
Hi Chanwoo Choi, This is the first time I am sending a driver to LKML. I have a few doubts. Can you please clarify them when you are free? 1. I have developed and tested this patch on 4.14.89 kernel. When trying to mainline the driver should I rebase and send the patch on top of current tree(v5.0-rc2)? 2. Is there any specific git on which I should test this driver on? Like below? https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git Thanks, Vijai Kumar K On Tue, Jan 22, 2019 at 08:05:33AM +0800, kbuild test robot wrote: > Hi Vijai, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on chanwoo-extcon/extcon-next] > [also build test ERROR on v5.0-rc2] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Vijai-Kumar-K/drivers-extcon-Add-support-for-ptn5150/20190122-041153 > base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon.git > extcon-next > config: sh-allyesconfig (attached as .config) > compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0 > reproduce: > wget > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O > ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > GCC_VERSION=8.2.0 make.cross ARCH=sh > > All error/warnings (new ones prefixed by >>): > >drivers//extcon/extcon-ptn5150.c: In function 'ptn5150_irq_work': > >> drivers//extcon/extcon-ptn5150.c:93:5: error: implicit declaration of > >> function 'extcon_set_state_sync'; did you mean 'extcon_get_state'? > >> [-Werror=implicit-function-declaration] > extcon_set_state_sync(info->edev, > ^ > extcon_get_state >drivers//extcon/extcon-ptn5150.c: In function 'ptn5150_i2c_probe': > >> drivers//extcon/extcon-ptn5150.c:255:15: error: implicit declaration of > >> function 'devm_extcon_dev_allocate'; did you mean 'extcon_get_state'? > >> [-Werror=implicit-function-declaration] > info->edev = devm_extcon_dev_allocate(info->dev, ptn5150_extcon_cable); > ^~~~ > extcon_get_state > >> drivers//extcon/extcon-ptn5150.c:255:13: warning: assignment to 'struct > >> extcon_dev *' from 'int' makes pointer from integer without a cast > >> [-Wint-conversion] > info->edev = devm_extcon_dev_allocate(info->dev, ptn5150_extcon_cable); > ^ > >> drivers//extcon/extcon-ptn5150.c:262:8: error: implicit declaration of > >> function 'devm_extcon_dev_register'; did you mean 'devm_pinctrl_register'? > >> [-Werror=implicit-function-declaration] > ret = devm_extcon_dev_register(info->dev, info->edev); >^~~~ >devm_pinctrl_register >cc1: some warnings being treated as errors > > vim +93 drivers//extcon/extcon-ptn5150.c > > 51 > 52static void ptn5150_irq_work(struct work_struct *work) > 53{ > 54struct ptn5150_info *info = container_of(work, > 55struct ptn5150_info, irq_work); > 56int ret = 0; > 57unsigned int reg_data; > 58unsigned int port_status; > 59unsigned int vbus; > 60unsigned int cable_attach; > 61unsigned int int_status; > 62 > 63if (!info->edev) > 64return; > 65 > 66mutex_lock(&info->mutex); > 67 > 68ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, > ®_data); > 69if (ret) { > 70dev_err(info->dev, > 71"failed to read CC STATUS %d\n", ret); > 72mutex_unlock(&info->mutex); > 73return; > 74} > 75/* Clear interrupt. Read would clear the register */ > 76ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, > &int_status); > 77if (ret) { > 78dev_err(info->dev, > 79"failed to read INT STATUS %d\n", ret); > 80mutex_unlock(&info->mutex); > 81
[PATCH] drivers: extcon: Add support for ptn5150
PTN5150A is a small thin low power CC Logic chip supporting the USB Type-C connector application with Configurationn Channel(CC) control logic detection and indication functions. Add driver, Kconfig and Makefile entries. Change-Id: I3b2da147a33b913b9ec60cd914b20acd955950c7 Signed-off-by: Vijai Kumar K --- .../devicetree/bindings/extcon/extcon-ptn5150.txt | 22 ++ drivers/extcon/Kconfig | 8 + drivers/extcon/Makefile| 1 + drivers/extcon/extcon-ptn5150.c| 327 + drivers/extcon/extcon-ptn5150.h| 51 5 files changed, 409 insertions(+) create mode 100644 Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt create mode 100644 drivers/extcon/extcon-ptn5150.c create mode 100644 drivers/extcon/extcon-ptn5150.h diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt new file mode 100644 index 000..8ea33bb --- /dev/null +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt @@ -0,0 +1,22 @@ + +* PTN5150 CC logic device +PTN5150A is a small thin low power CC Logic chip supporting the USB Type-C +connector application with Configuration Channel (CC) control logic detection and +indication functions. It is Interfaced to the host controller using an I2C interface. + +Required properties: +- compatible: Should be "nxp,ptn5150" +- reg: Specifies the I2C slave address of the device +- int-gpio: GPIO to which INTB is connected +- vbus-gpio: GPIO which controls VBUS on/off + +Example: + ptn5150@1d { + compatible = "nxp,ptn5150"; + reg = <0x1d>; + int-gpio = <&msmgpio 78 GPIO_ACTIVE_HIGH>; + vbus-gpio = <&msmgpio 148 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&ptn5150_default>; + status = "okay"; + }; diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index a7bca42..6adc797 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -113,6 +113,14 @@ config EXTCON_PALMAS Say Y here to enable support for USB peripheral and USB host detection by palmas usb. +config EXTCON_PTN5150 + tristate "PTN5150 CC LOGIC USB EXTCON support" + depends on I2C + select REGMAP_I2C + help + Say Y here to enable support for USB peripheral and USB host + detection by ptn5150 cc logic chip. + config EXTCON_QCOM_SPMI_MISC tristate "Qualcomm USB extcon support" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile index 0888fde..261ce4c 100644 --- a/drivers/extcon/Makefile +++ b/drivers/extcon/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX77843) += extcon-max77843.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o obj-$(CONFIG_EXTCON_PALMAS)+= extcon-palmas.o +obj-$(CONFIG_EXTCON_PTN5150) += extcon-ptn5150.o obj-$(CONFIG_EXTCON_QCOM_SPMI_MISC) += extcon-qcom-spmi-misc.o obj-$(CONFIG_EXTCON_RT8973A) += extcon-rt8973a.o obj-$(CONFIG_EXTCON_SM5502)+= extcon-sm5502.o diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c new file mode 100644 index 000..bc00874 --- /dev/null +++ b/drivers/extcon/extcon-ptn5150.c @@ -0,0 +1,327 @@ +/* + * extcon-ptn5150.c - PTN5150 CC logic extcon driver to support USB detection + * + * Copyright (c) 2018-2019 by Vijai Kumar K + * Author: Vijai Kumar K + * + * Based on extcon-sm5502.c driver + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "extcon-ptn5150.h" + +struct ptn5150_info { + struct device *dev; + struct extcon_dev *edev; + struct i2c_client *i2c; + struct regmap *regmap; + struct gpio_desc *int_gpiod; + struct gpio_desc *vbus_gpiod; + int irq; + struct work_struct irq_work; + struct mutex mutex; +}; + +/* List of detectable cables */ +static const unsigned int ptn5150_extcon_cable[] = { + EXTCON_USB, + EXTCON_USB_HOST, + EXTCON_NONE, +}; + +static const struct regmap_config ptn5150_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = PTN5150_REG_END, +}; + +static void ptn5150_irq_work(struct work_struct *work) +{ + struct ptn5150_info *info = container_of(work,