Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Vijai Kumar K
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 = < 78 GPIO_ACTIVE_HIGH>;
> > +   vbus-gpio = < 148 GPIO_ACTIVE_HIGH>;
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <_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 = < 78 GPIO_ACTIVE_HIGH>;
>   vbus-gpio = < 148 GPIO_ACTIVE_HIGH>;
>   pinctrl-names = "default";
>   pinctrl-0 = <_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 EXTCON support
> 
noted.

> > +   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.
> 
> cc -> CC (Configuration Channel)
> 
noted.

> > +
> >  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)   += 

Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Vijai Kumar K
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 unsigned int reg_data;
> >> 58 unsigned int port_status;
> >> 59 unsigned int vbus;
> >> 60 unsigned int cable_attach;
> >> 61 unsigned int int_status;
> >> 62 
> >> 63 if (!info->edev)
> >> 64 return;
> >> 65 
> >> 66 mutex_lock(>mutex);
> >> 67 
> >> 68 ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, 
> >> _data);
> >> 69 if (ret) {
> >> 70 dev_err(info->dev,
> >> 71 "failed to read CC STATUS %d\n", ret);
> >> 72 mutex_unlock(>mutex);
> >> 73 return;
> >> 74 }
> >> 75 /* Clear interrupt. Read would clear the register */
> >> 76 ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, 
> >> _status);
> >>   

Re: Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Vijai Kumar K
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

2019-01-21 Thread Chanwoo Choi
Hi Vijai,

This patch looks better. But theare are comments about code clean.
I added the comments.

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.

> 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

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

> +
> +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'?

> +- vbus-gpio: GPIO which controls VBUS on/off
> +
> +Example:
> + ptn5150@1d  {
> + compatible = "nxp,ptn5150";
> + reg = <0x1d>;
> + int-gpio = < 78 GPIO_ACTIVE_HIGH>;
> + vbus-gpio = < 148 GPIO_ACTIVE_HIGH>;
> + pinctrl-names = "default";
> + pinctrl-0 = <_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


> + status = "okay";
> + };

Remove the one tab in front of dt node.

ptn5150@1d  {
compatible = "nxp,ptn5150";
reg = <0x1d>;
int-gpio = < 78 GPIO_ACTIVE_HIGH>;
vbus-gpio = < 148 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <_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 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.

cc -> CC (Configuration Channel)

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

Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Chanwoo Choi
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

> 
> 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   unsigned int reg_data;
>> 58   unsigned int port_status;
>> 59   unsigned int vbus;
>> 60   unsigned int cable_attach;
>> 61   unsigned int int_status;
>> 62   
>> 63   if (!info->edev)
>> 64   return;
>> 65   
>> 66   mutex_lock(>mutex);
>> 67   
>> 68   ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, 
>> _data);
>> 69   if (ret) {
>> 70   dev_err(info->dev,
>> 71   "failed to read CC STATUS %d\n", ret);
>> 72   mutex_unlock(>mutex);
>> 73   return;
>> 74   }
>> 75   /* Clear interrupt. Read would clear the register */
>> 76   ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, 
>> _status);
>> 77   if (ret) {
>> 78   dev_err(info->dev,
>> 79   "failed to read INT STATUS %d\n", ret);
>> 80   mutex_unlock(>mutex);
>> 81   return;
>> 82   }
>> 83   
>> 84 

RE: Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread MyungJoo Ham
>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.

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


Cheers,
MyungJoo

>
>Thanks,
>Vijai Kumar K


Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Vijai Kumar K
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(>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(>mutex);
> 73return;
> 74}
> 75/* Clear interrupt. Read would clear the register */
> 76ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, 
> _status);
> 77if (ret) {
> 78dev_err(info->dev,
> 79"failed to read INT STATUS %d\n", ret);
> 80mutex_unlock(>mutex);
> 81return;
> 82}
> 83
> 84if (int_status) {
> 85cable_attach = int_status & 
> PTN5150_REG_INT_CABLE_ATTACH_MASK;
> 86if (cable_attach) {
> 87port_status = ((reg_data &
> 88
> PTN5150_REG_CC_PORT_ATTACHMENT_MASK) >>
> 89
> PTN5150_REG_CC_PORT_ATTACHMENT_SHIFT);
> 90
> 

Re: [PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread kbuild test robot
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  unsigned int reg_data;
58  unsigned int port_status;
59  unsigned int vbus;
60  unsigned int cable_attach;
61  unsigned int int_status;
62  
63  if (!info->edev)
64  return;
65  
66  mutex_lock(>mutex);
67  
68  ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, 
_data);
69  if (ret) {
70  dev_err(info->dev,
71  "failed to read CC STATUS %d\n", ret);
72  mutex_unlock(>mutex);
73  return;
74  }
75  /* Clear interrupt. Read would clear the register */
76  ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, 
_status);
77  if (ret) {
78  dev_err(info->dev,
79  "failed to read INT STATUS %d\n", ret);
80  mutex_unlock(>mutex);
81  return;
82  }
83  
84  if (int_status) {
85  cable_attach = int_status & 
PTN5150_REG_INT_CABLE_ATTACH_MASK;
86  if (cable_attach) {
87  port_status = ((reg_data &
88  
PTN5150_REG_CC_PORT_ATTACHMENT_MASK) >>
89  
PTN5150_REG_CC_PORT_ATTACHMENT_SHIFT);
90  
91  switch (port_status) {
92  case PTN5150_DFP_ATTACHED:
  > 93  extcon_set_state_sync(info->edev,
94EXTCON_USB_HOST, 
false);
95  gpiod_set_value(info->vbus_gpiod, 0);
96  extcon_set_state_sync(info->edev, 
EXTCON_USB,
97true);
98  break;
99  case PTN5150_UFP_ATTACHED:
   100  extcon_set_state_sync(info->edev, 
EXTCON_USB,
   101false);
   102  vbus = ((reg_data &
   103  
PTN5150_REG_CC_VBUS_DETECTION_MASK) >>
   104  

[PATCH] drivers: extcon: Add support for ptn5150

2019-01-21 Thread Vijai Kumar K
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 = < 78 GPIO_ACTIVE_HIGH>;
+   vbus-gpio = < 148 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_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,
+   struct ptn5150_info, irq_work);
+   int ret = 0;
+   unsigned int reg_data;
+   unsigned int port_status;
+