Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi,

On Sat, Nov 21, 2015 at 12:05 AM, Chanwoo Choi  wrote:
> Hi Felipe,
>
> On Fri, Nov 20, 2015 at 11:37 PM, Felipe Balbi  wrote:
>>
>> Hi Chanwoo,
>>
>> Chanwoo Choi  writes:
>>> Hi Felipe,
>>>
>>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
 Hi Felipe,

 Looks good to me. But I have one comment.

 On 2015년 11월 13일 02:57, Felipe Balbi wrote:
> TPS659038 can remux its GPIO_1 as VBUSDET output,
> which can be tied to a SoC GPIO and used as a VBUS
> interrupt.
>
> Beagle X15 uses that, in fact, and without it, I
> could not get USB peripheral working with that
> board.
>
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/extcon/extcon-palmas.c | 22 --
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-palmas.c 
> b/drivers/extcon/extcon-palmas.c
> index 93c30a885740..7985d092c069 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
> *pdev)
> }
>
> if (palmas_usb->enable_vbus_detection) {
> +   int irq = platform_get_irq(pdev, 0);
> +
> +   if (irq > 0) {
> +   /* remux GPIO_1 as VBUSDET */
> +   status = palmas_update_bits(palmas, 
> PALMAS_PU_PD_OD_BASE,
> +   PALMAS_PRIMARY_SECONDARY_PAD1,
> +   
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
> +   (1 << 3));

 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
 using '3'.
>>
>> good point :-)
>>
> +   if (status < 0) {
> +   dev_err(>dev, "can't remux GPIO1\n");
> +   return status;
> +   }
> +
> +   palmas_usb->vbus_irq = irq;
> +   } else {
> +   irq = regmap_irq_get_virq(palmas->irq_data,
> +   PALMAS_VBUS_IRQ);
> +   palmas_usb->vbus_irq = irq;
> +   }
> +
> palmas_usb->vbus_otg_irq = 
> regmap_irq_get_virq(palmas->irq_data,
>PALMAS_VBUS_OTG_IRQ);
> -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
> -  PALMAS_VBUS_IRQ);
> status = devm_request_threaded_irq(palmas_usb->dev,
> palmas_usb->vbus_irq, NULL,
> palmas_vbus_irq_handler,
>

 Thanks,
 Chanwoo Choi
 --
 To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/

>>>
>>> If you are OK about following patch, I'll apply it on extcon branch.
>>
>> that's perfect, thanks for fixing it :-)
>
> Applied it.

Please ignore this reply about applies because I need to discuss about it.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi Felipe,

On 2015. 11. 20. 오후 11:37, Felipe Balbi wrote:
> 
> Hi Chanwoo,
> 
> Chanwoo Choi  writes:
>> Hi Felipe,
>>
>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>>> Hi Felipe,
>>>
>>> Looks good to me. But I have one comment.
>>>
>>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
 TPS659038 can remux its GPIO_1 as VBUSDET output,
 which can be tied to a SoC GPIO and used as a VBUS
 interrupt.

 Beagle X15 uses that, in fact, and without it, I
 could not get USB peripheral working with that
 board.

 Signed-off-by: Felipe Balbi 
 ---
  drivers/extcon/extcon-palmas.c | 22 --
  1 file changed, 20 insertions(+), 2 deletions(-)

 diff --git a/drivers/extcon/extcon-palmas.c 
 b/drivers/extcon/extcon-palmas.c
 index 93c30a885740..7985d092c069 100644
 --- a/drivers/extcon/extcon-palmas.c
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
}
  
if (palmas_usb->enable_vbus_detection) {
 +  int irq = platform_get_irq(pdev, 0);
 +
 +  if (irq > 0) {
 +  /* remux GPIO_1 as VBUSDET */
 +  status = palmas_update_bits(palmas, 
 PALMAS_PU_PD_OD_BASE,
 +  PALMAS_PRIMARY_SECONDARY_PAD1,
 +  
 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
 +  (1 << 3));
>>>
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>>> using '3'.
> 
> good point :-)
> 
 +  if (status < 0) {
 +  dev_err(>dev, "can't remux GPIO1\n");
 +  return status;
 +  }
 +
 +  palmas_usb->vbus_irq = irq;
 +  } else {
 +  irq = regmap_irq_get_virq(palmas->irq_data,
 +  PALMAS_VBUS_IRQ);
 +  palmas_usb->vbus_irq = irq;
 +  }
 +
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
 -  palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
 - PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,

>>>
>>> Thanks,
>>> Chanwoo Choi
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>
>>
>> If you are OK about following patch, I'll apply it on extcon branch.
> 
> that's perfect, thanks for fixing it :-)
> 

Before applying this patch, I think that there are more generic method?
So, I check the extcon-palmas.c driver again. There is similiar case for id 
detection.

In some case, id detection use whether 'enable_id_detection' with own interrupt
or 'enable_gpio_id_dectection' with specific h/w gpio like this case of vbus.

In result, I implement the following patch for vbus gpio detection.
But, I'm not sure because I have not any H/W board for test.

If you possible, could you test it with following patch?

Thanks,
Chanwoo Choi

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a8..885ee95 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -216,11 +216,23 @@ static int palmas_usb_probe(struct platform_device *pdev)
return PTR_ERR(palmas_usb->id_gpiod);
}
 
+   palmas_usb->vbus_gpiod = devm_gpiod_get_optional(>dev, "vbus",
+   GPIOD_IN);
+   if (IS_ERR(palmas_usb->vbus_gpiod)) {
+   dev_err(>dev, "failed to get vbus gpio\n");
+   return PTR_ERR(palmas_usb->vbus_gpiod);
+   }
+
if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) {
palmas_usb->enable_id_detection = false;
palmas_usb->enable_gpio_id_detection = true;
}
 
+   if (palmas_usb->enable_vbus_detection && palmas_usb->vbus_gpiod) {
+   palmas_usb->enable_vbus_detection = false;
+   palmas_usb->enable_gpio_vbus_detection = true;
+   }
+
if (palmas_usb->enable_gpio_id_detection) {
u32 debounce;
 
@@ -311,6 +323,40 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->vbus_irq, status);
return status;
}
+   } else if (palmas_usb->enable_gpio_vbus_detection) {
+   /* remux 

Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi Felipe,

On Fri, Nov 20, 2015 at 11:37 PM, Felipe Balbi  wrote:
>
> Hi Chanwoo,
>
> Chanwoo Choi  writes:
>> Hi Felipe,
>>
>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>>> Hi Felipe,
>>>
>>> Looks good to me. But I have one comment.
>>>
>>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
 TPS659038 can remux its GPIO_1 as VBUSDET output,
 which can be tied to a SoC GPIO and used as a VBUS
 interrupt.

 Beagle X15 uses that, in fact, and without it, I
 could not get USB peripheral working with that
 board.

 Signed-off-by: Felipe Balbi 
 ---
  drivers/extcon/extcon-palmas.c | 22 --
  1 file changed, 20 insertions(+), 2 deletions(-)

 diff --git a/drivers/extcon/extcon-palmas.c 
 b/drivers/extcon/extcon-palmas.c
 index 93c30a885740..7985d092c069 100644
 --- a/drivers/extcon/extcon-palmas.c
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
 }

 if (palmas_usb->enable_vbus_detection) {
 +   int irq = platform_get_irq(pdev, 0);
 +
 +   if (irq > 0) {
 +   /* remux GPIO_1 as VBUSDET */
 +   status = palmas_update_bits(palmas, 
 PALMAS_PU_PD_OD_BASE,
 +   PALMAS_PRIMARY_SECONDARY_PAD1,
 +   
 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
 +   (1 << 3));
>>>
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>>> using '3'.
>
> good point :-)
>
 +   if (status < 0) {
 +   dev_err(>dev, "can't remux GPIO1\n");
 +   return status;
 +   }
 +
 +   palmas_usb->vbus_irq = irq;
 +   } else {
 +   irq = regmap_irq_get_virq(palmas->irq_data,
 +   PALMAS_VBUS_IRQ);
 +   palmas_usb->vbus_irq = irq;
 +   }
 +
 palmas_usb->vbus_otg_irq = 
 regmap_irq_get_virq(palmas->irq_data,
PALMAS_VBUS_OTG_IRQ);
 -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
 -  PALMAS_VBUS_IRQ);
 status = devm_request_threaded_irq(palmas_usb->dev,
 palmas_usb->vbus_irq, NULL,
 palmas_vbus_irq_handler,

>>>
>>> Thanks,
>>> Chanwoo Choi
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>
>>
>> If you are OK about following patch, I'll apply it on extcon branch.
>
> that's perfect, thanks for fixing it :-)

Applied it.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Felipe Balbi

Hi Chanwoo,

Chanwoo Choi  writes:
> Hi Felipe,
>
> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>> Hi Felipe,
>> 
>> Looks good to me. But I have one comment.
>> 
>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
>>> TPS659038 can remux its GPIO_1 as VBUSDET output,
>>> which can be tied to a SoC GPIO and used as a VBUS
>>> interrupt.
>>>
>>> Beagle X15 uses that, in fact, and without it, I
>>> could not get USB peripheral working with that
>>> board.
>>>
>>> Signed-off-by: Felipe Balbi 
>>> ---
>>>  drivers/extcon/extcon-palmas.c | 22 --
>>>  1 file changed, 20 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>>> index 93c30a885740..7985d092c069 100644
>>> --- a/drivers/extcon/extcon-palmas.c
>>> +++ b/drivers/extcon/extcon-palmas.c
>>> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
>>> *pdev)
>>> }
>>>  
>>> if (palmas_usb->enable_vbus_detection) {
>>> +   int irq = platform_get_irq(pdev, 0);
>>> +
>>> +   if (irq > 0) {
>>> +   /* remux GPIO_1 as VBUSDET */
>>> +   status = palmas_update_bits(palmas, 
>>> PALMAS_PU_PD_OD_BASE,
>>> +   PALMAS_PRIMARY_SECONDARY_PAD1,
>>> +   
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
>>> +   (1 << 3));
>> 
>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>> using '3'.

good point :-)

>>> +   if (status < 0) {
>>> +   dev_err(>dev, "can't remux GPIO1\n");
>>> +   return status;
>>> +   }
>>> +
>>> +   palmas_usb->vbus_irq = irq;
>>> +   } else {
>>> +   irq = regmap_irq_get_virq(palmas->irq_data,
>>> +   PALMAS_VBUS_IRQ);
>>> +   palmas_usb->vbus_irq = irq;
>>> +   }
>>> +
>>> palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>>>PALMAS_VBUS_OTG_IRQ);
>>> -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
>>> -  PALMAS_VBUS_IRQ);
>>> status = devm_request_threaded_irq(palmas_usb->dev,
>>> palmas_usb->vbus_irq, NULL,
>>> palmas_vbus_irq_handler,
>>>
>> 
>> Thanks,
>> Chanwoo Choi
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>> 
>
> If you are OK about following patch, I'll apply it on extcon branch.

that's perfect, thanks for fixing it :-)

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi Felipe,

On Fri, Nov 20, 2015 at 11:37 PM, Felipe Balbi  wrote:
>
> Hi Chanwoo,
>
> Chanwoo Choi  writes:
>> Hi Felipe,
>>
>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>>> Hi Felipe,
>>>
>>> Looks good to me. But I have one comment.
>>>
>>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
 TPS659038 can remux its GPIO_1 as VBUSDET output,
 which can be tied to a SoC GPIO and used as a VBUS
 interrupt.

 Beagle X15 uses that, in fact, and without it, I
 could not get USB peripheral working with that
 board.

 Signed-off-by: Felipe Balbi 
 ---
  drivers/extcon/extcon-palmas.c | 22 --
  1 file changed, 20 insertions(+), 2 deletions(-)

 diff --git a/drivers/extcon/extcon-palmas.c 
 b/drivers/extcon/extcon-palmas.c
 index 93c30a885740..7985d092c069 100644
 --- a/drivers/extcon/extcon-palmas.c
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
 }

 if (palmas_usb->enable_vbus_detection) {
 +   int irq = platform_get_irq(pdev, 0);
 +
 +   if (irq > 0) {
 +   /* remux GPIO_1 as VBUSDET */
 +   status = palmas_update_bits(palmas, 
 PALMAS_PU_PD_OD_BASE,
 +   PALMAS_PRIMARY_SECONDARY_PAD1,
 +   
 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
 +   (1 << 3));
>>>
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>>> using '3'.
>
> good point :-)
>
 +   if (status < 0) {
 +   dev_err(>dev, "can't remux GPIO1\n");
 +   return status;
 +   }
 +
 +   palmas_usb->vbus_irq = irq;
 +   } else {
 +   irq = regmap_irq_get_virq(palmas->irq_data,
 +   PALMAS_VBUS_IRQ);
 +   palmas_usb->vbus_irq = irq;
 +   }
 +
 palmas_usb->vbus_otg_irq = 
 regmap_irq_get_virq(palmas->irq_data,
PALMAS_VBUS_OTG_IRQ);
 -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
 -  PALMAS_VBUS_IRQ);
 status = devm_request_threaded_irq(palmas_usb->dev,
 palmas_usb->vbus_irq, NULL,
 palmas_vbus_irq_handler,

>>>
>>> Thanks,
>>> Chanwoo Choi
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>
>>
>> If you are OK about following patch, I'll apply it on extcon branch.
>
> that's perfect, thanks for fixing it :-)

Applied it.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Felipe Balbi

Hi Chanwoo,

Chanwoo Choi  writes:
> Hi Felipe,
>
> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>> Hi Felipe,
>> 
>> Looks good to me. But I have one comment.
>> 
>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
>>> TPS659038 can remux its GPIO_1 as VBUSDET output,
>>> which can be tied to a SoC GPIO and used as a VBUS
>>> interrupt.
>>>
>>> Beagle X15 uses that, in fact, and without it, I
>>> could not get USB peripheral working with that
>>> board.
>>>
>>> Signed-off-by: Felipe Balbi 
>>> ---
>>>  drivers/extcon/extcon-palmas.c | 22 --
>>>  1 file changed, 20 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>>> index 93c30a885740..7985d092c069 100644
>>> --- a/drivers/extcon/extcon-palmas.c
>>> +++ b/drivers/extcon/extcon-palmas.c
>>> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
>>> *pdev)
>>> }
>>>  
>>> if (palmas_usb->enable_vbus_detection) {
>>> +   int irq = platform_get_irq(pdev, 0);
>>> +
>>> +   if (irq > 0) {
>>> +   /* remux GPIO_1 as VBUSDET */
>>> +   status = palmas_update_bits(palmas, 
>>> PALMAS_PU_PD_OD_BASE,
>>> +   PALMAS_PRIMARY_SECONDARY_PAD1,
>>> +   
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
>>> +   (1 << 3));
>> 
>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>> using '3'.

good point :-)

>>> +   if (status < 0) {
>>> +   dev_err(>dev, "can't remux GPIO1\n");
>>> +   return status;
>>> +   }
>>> +
>>> +   palmas_usb->vbus_irq = irq;
>>> +   } else {
>>> +   irq = regmap_irq_get_virq(palmas->irq_data,
>>> +   PALMAS_VBUS_IRQ);
>>> +   palmas_usb->vbus_irq = irq;
>>> +   }
>>> +
>>> palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>>>PALMAS_VBUS_OTG_IRQ);
>>> -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
>>> -  PALMAS_VBUS_IRQ);
>>> status = devm_request_threaded_irq(palmas_usb->dev,
>>> palmas_usb->vbus_irq, NULL,
>>> palmas_vbus_irq_handler,
>>>
>> 
>> Thanks,
>> Chanwoo Choi
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>> 
>
> If you are OK about following patch, I'll apply it on extcon branch.

that's perfect, thanks for fixing it :-)

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi Felipe,

On 2015. 11. 20. 오후 11:37, Felipe Balbi wrote:
> 
> Hi Chanwoo,
> 
> Chanwoo Choi  writes:
>> Hi Felipe,
>>
>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
>>> Hi Felipe,
>>>
>>> Looks good to me. But I have one comment.
>>>
>>> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
 TPS659038 can remux its GPIO_1 as VBUSDET output,
 which can be tied to a SoC GPIO and used as a VBUS
 interrupt.

 Beagle X15 uses that, in fact, and without it, I
 could not get USB peripheral working with that
 board.

 Signed-off-by: Felipe Balbi 
 ---
  drivers/extcon/extcon-palmas.c | 22 --
  1 file changed, 20 insertions(+), 2 deletions(-)

 diff --git a/drivers/extcon/extcon-palmas.c 
 b/drivers/extcon/extcon-palmas.c
 index 93c30a885740..7985d092c069 100644
 --- a/drivers/extcon/extcon-palmas.c
 +++ b/drivers/extcon/extcon-palmas.c
 @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
 *pdev)
}
  
if (palmas_usb->enable_vbus_detection) {
 +  int irq = platform_get_irq(pdev, 0);
 +
 +  if (irq > 0) {
 +  /* remux GPIO_1 as VBUSDET */
 +  status = palmas_update_bits(palmas, 
 PALMAS_PU_PD_OD_BASE,
 +  PALMAS_PRIMARY_SECONDARY_PAD1,
 +  
 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
 +  (1 << 3));
>>>
>>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
>>> using '3'.
> 
> good point :-)
> 
 +  if (status < 0) {
 +  dev_err(>dev, "can't remux GPIO1\n");
 +  return status;
 +  }
 +
 +  palmas_usb->vbus_irq = irq;
 +  } else {
 +  irq = regmap_irq_get_virq(palmas->irq_data,
 +  PALMAS_VBUS_IRQ);
 +  palmas_usb->vbus_irq = irq;
 +  }
 +
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
 -  palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
 - PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,

>>>
>>> Thanks,
>>> Chanwoo Choi
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>>
>>
>> If you are OK about following patch, I'll apply it on extcon branch.
> 
> that's perfect, thanks for fixing it :-)
> 

Before applying this patch, I think that there are more generic method?
So, I check the extcon-palmas.c driver again. There is similiar case for id 
detection.

In some case, id detection use whether 'enable_id_detection' with own interrupt
or 'enable_gpio_id_dectection' with specific h/w gpio like this case of vbus.

In result, I implement the following patch for vbus gpio detection.
But, I'm not sure because I have not any H/W board for test.

If you possible, could you test it with following patch?

Thanks,
Chanwoo Choi

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a8..885ee95 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -216,11 +216,23 @@ static int palmas_usb_probe(struct platform_device *pdev)
return PTR_ERR(palmas_usb->id_gpiod);
}
 
+   palmas_usb->vbus_gpiod = devm_gpiod_get_optional(>dev, "vbus",
+   GPIOD_IN);
+   if (IS_ERR(palmas_usb->vbus_gpiod)) {
+   dev_err(>dev, "failed to get vbus gpio\n");
+   return PTR_ERR(palmas_usb->vbus_gpiod);
+   }
+
if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) {
palmas_usb->enable_id_detection = false;
palmas_usb->enable_gpio_id_detection = true;
}
 
+   if (palmas_usb->enable_vbus_detection && palmas_usb->vbus_gpiod) {
+   palmas_usb->enable_vbus_detection = false;
+   palmas_usb->enable_gpio_vbus_detection = true;
+   }
+
if (palmas_usb->enable_gpio_id_detection) {
u32 debounce;
 
@@ -311,6 +323,40 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->vbus_irq, status);
return status;
}
+   } else if 

Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-20 Thread Chanwoo Choi
Hi,

On Sat, Nov 21, 2015 at 12:05 AM, Chanwoo Choi  wrote:
> Hi Felipe,
>
> On Fri, Nov 20, 2015 at 11:37 PM, Felipe Balbi  wrote:
>>
>> Hi Chanwoo,
>>
>> Chanwoo Choi  writes:
>>> Hi Felipe,
>>>
>>> On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
 Hi Felipe,

 Looks good to me. But I have one comment.

 On 2015년 11월 13일 02:57, Felipe Balbi wrote:
> TPS659038 can remux its GPIO_1 as VBUSDET output,
> which can be tied to a SoC GPIO and used as a VBUS
> interrupt.
>
> Beagle X15 uses that, in fact, and without it, I
> could not get USB peripheral working with that
> board.
>
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/extcon/extcon-palmas.c | 22 --
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-palmas.c 
> b/drivers/extcon/extcon-palmas.c
> index 93c30a885740..7985d092c069 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
> *pdev)
> }
>
> if (palmas_usb->enable_vbus_detection) {
> +   int irq = platform_get_irq(pdev, 0);
> +
> +   if (irq > 0) {
> +   /* remux GPIO_1 as VBUSDET */
> +   status = palmas_update_bits(palmas, 
> PALMAS_PU_PD_OD_BASE,
> +   PALMAS_PRIMARY_SECONDARY_PAD1,
> +   
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
> +   (1 << 3));

 PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of
 using '3'.
>>
>> good point :-)
>>
> +   if (status < 0) {
> +   dev_err(>dev, "can't remux GPIO1\n");
> +   return status;
> +   }
> +
> +   palmas_usb->vbus_irq = irq;
> +   } else {
> +   irq = regmap_irq_get_virq(palmas->irq_data,
> +   PALMAS_VBUS_IRQ);
> +   palmas_usb->vbus_irq = irq;
> +   }
> +
> palmas_usb->vbus_otg_irq = 
> regmap_irq_get_virq(palmas->irq_data,
>PALMAS_VBUS_OTG_IRQ);
> -   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
> -  PALMAS_VBUS_IRQ);
> status = devm_request_threaded_irq(palmas_usb->dev,
> palmas_usb->vbus_irq, NULL,
> palmas_vbus_irq_handler,
>

 Thanks,
 Chanwoo Choi
 --
 To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/

>>>
>>> If you are OK about following patch, I'll apply it on extcon branch.
>>
>> that's perfect, thanks for fixing it :-)
>
> Applied it.

Please ignore this reply about applies because I need to discuss about it.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-19 Thread Chanwoo Choi
Hi Felipe,

On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
> Hi Felipe,
> 
> Looks good to me. But I have one comment.
> 
> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
>> TPS659038 can remux its GPIO_1 as VBUSDET output,
>> which can be tied to a SoC GPIO and used as a VBUS
>> interrupt.
>>
>> Beagle X15 uses that, in fact, and without it, I
>> could not get USB peripheral working with that
>> board.
>>
>> Signed-off-by: Felipe Balbi 
>> ---
>>  drivers/extcon/extcon-palmas.c | 22 --
>>  1 file changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 93c30a885740..7985d092c069 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
>> *pdev)
>>  }
>>  
>>  if (palmas_usb->enable_vbus_detection) {
>> +int irq = platform_get_irq(pdev, 0);
>> +
>> +if (irq > 0) {
>> +/* remux GPIO_1 as VBUSDET */
>> +status = palmas_update_bits(palmas, 
>> PALMAS_PU_PD_OD_BASE,
>> +PALMAS_PRIMARY_SECONDARY_PAD1,
>> +
>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
>> +(1 << 3));
> 
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of using 
> '3'.
> Also, I don't recommend the over line 80. The everything else is good
> 
> 
>> +if (status < 0) {
>> +dev_err(>dev, "can't remux GPIO1\n");
>> +return status;
>> +}
>> +
>> +palmas_usb->vbus_irq = irq;
>> +} else {
>> +irq = regmap_irq_get_virq(palmas->irq_data,
>> +PALMAS_VBUS_IRQ);
>> +palmas_usb->vbus_irq = irq;
>> +}
>> +
>>  palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>> PALMAS_VBUS_OTG_IRQ);
>> -palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
>> -   PALMAS_VBUS_IRQ);
>>  status = devm_request_threaded_irq(palmas_usb->dev,
>>  palmas_usb->vbus_irq, NULL,
>>  palmas_vbus_irq_handler,
>>
> 
> Thanks,
> Chanwoo Choi
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

If you are OK about following patch, I'll apply it on extcon branch.

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a885740..f601370c9466 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -296,10 +296,29 @@ static int palmas_usb_probe(struct platform_device *pdev)
}
 
if (palmas_usb->enable_vbus_detection) {
+   int irq = platform_get_irq(pdev, 0);
+
+   if (irq > 0) {
+   /* remux GPIO_1 as VBUSDET */
+   status = palmas_update_bits(palmas,
+   PALMAS_PU_PD_OD_BASE,
+   PALMAS_PRIMARY_SECONDARY_PAD1,
+   PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
+   (1 << 
PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT));
+   if (status < 0) {
+   dev_err(>dev, "can't remux GPIO1\n");
+   return status;
+   }
+
+   palmas_usb->vbus_irq = irq;
+   } else {
+   irq = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);
+   palmas_usb->vbus_irq = irq;
+   }
+
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
-   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
-  PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,
-- 
1.9.1


Thanks,
Chanwoo Choi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-19 Thread Chanwoo Choi
Hi Felipe,

Looks good to me. But I have one comment.

On 2015년 11월 13일 02:57, Felipe Balbi wrote:
> TPS659038 can remux its GPIO_1 as VBUSDET output,
> which can be tied to a SoC GPIO and used as a VBUS
> interrupt.
> 
> Beagle X15 uses that, in fact, and without it, I
> could not get USB peripheral working with that
> board.
> 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/extcon/extcon-palmas.c | 22 --
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index 93c30a885740..7985d092c069 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
> *pdev)
>   }
>  
>   if (palmas_usb->enable_vbus_detection) {
> + int irq = platform_get_irq(pdev, 0);
> +
> + if (irq > 0) {
> + /* remux GPIO_1 as VBUSDET */
> + status = palmas_update_bits(palmas, 
> PALMAS_PU_PD_OD_BASE,
> + PALMAS_PRIMARY_SECONDARY_PAD1,
> + 
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
> + (1 << 3));

PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of using '3'.
Also, I don't recommend the over line 80. The everything else is good


> + if (status < 0) {
> + dev_err(>dev, "can't remux GPIO1\n");
> + return status;
> + }
> +
> + palmas_usb->vbus_irq = irq;
> + } else {
> + irq = regmap_irq_get_virq(palmas->irq_data,
> + PALMAS_VBUS_IRQ);
> + palmas_usb->vbus_irq = irq;
> + }
> +
>   palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>  PALMAS_VBUS_OTG_IRQ);
> - palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
> -PALMAS_VBUS_IRQ);
>   status = devm_request_threaded_irq(palmas_usb->dev,
>   palmas_usb->vbus_irq, NULL,
>   palmas_vbus_irq_handler,
> 

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-19 Thread Chanwoo Choi
Hi Felipe,

Looks good to me. But I have one comment.

On 2015년 11월 13일 02:57, Felipe Balbi wrote:
> TPS659038 can remux its GPIO_1 as VBUSDET output,
> which can be tied to a SoC GPIO and used as a VBUS
> interrupt.
> 
> Beagle X15 uses that, in fact, and without it, I
> could not get USB peripheral working with that
> board.
> 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/extcon/extcon-palmas.c | 22 --
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index 93c30a885740..7985d092c069 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
> *pdev)
>   }
>  
>   if (palmas_usb->enable_vbus_detection) {
> + int irq = platform_get_irq(pdev, 0);
> +
> + if (irq > 0) {
> + /* remux GPIO_1 as VBUSDET */
> + status = palmas_update_bits(palmas, 
> PALMAS_PU_PD_OD_BASE,
> + PALMAS_PRIMARY_SECONDARY_PAD1,
> + 
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
> + (1 << 3));

PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of using '3'.
Also, I don't recommend the over line 80. The everything else is good


> + if (status < 0) {
> + dev_err(>dev, "can't remux GPIO1\n");
> + return status;
> + }
> +
> + palmas_usb->vbus_irq = irq;
> + } else {
> + irq = regmap_irq_get_virq(palmas->irq_data,
> + PALMAS_VBUS_IRQ);
> + palmas_usb->vbus_irq = irq;
> + }
> +
>   palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>  PALMAS_VBUS_OTG_IRQ);
> - palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
> -PALMAS_VBUS_IRQ);
>   status = devm_request_threaded_irq(palmas_usb->dev,
>   palmas_usb->vbus_irq, NULL,
>   palmas_vbus_irq_handler,
> 

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-19 Thread Chanwoo Choi
Hi Felipe,

On 2015년 11월 20일 14:33, Chanwoo Choi wrote:
> Hi Felipe,
> 
> Looks good to me. But I have one comment.
> 
> On 2015년 11월 13일 02:57, Felipe Balbi wrote:
>> TPS659038 can remux its GPIO_1 as VBUSDET output,
>> which can be tied to a SoC GPIO and used as a VBUS
>> interrupt.
>>
>> Beagle X15 uses that, in fact, and without it, I
>> could not get USB peripheral working with that
>> board.
>>
>> Signed-off-by: Felipe Balbi 
>> ---
>>  drivers/extcon/extcon-palmas.c | 22 --
>>  1 file changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 93c30a885740..7985d092c069 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device 
>> *pdev)
>>  }
>>  
>>  if (palmas_usb->enable_vbus_detection) {
>> +int irq = platform_get_irq(pdev, 0);
>> +
>> +if (irq > 0) {
>> +/* remux GPIO_1 as VBUSDET */
>> +status = palmas_update_bits(palmas, 
>> PALMAS_PU_PD_OD_BASE,
>> +PALMAS_PRIMARY_SECONDARY_PAD1,
>> +
>> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
>> +(1 << 3));
> 
> PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT is appropriate instead of using 
> '3'.
> Also, I don't recommend the over line 80. The everything else is good
> 
> 
>> +if (status < 0) {
>> +dev_err(>dev, "can't remux GPIO1\n");
>> +return status;
>> +}
>> +
>> +palmas_usb->vbus_irq = irq;
>> +} else {
>> +irq = regmap_irq_get_virq(palmas->irq_data,
>> +PALMAS_VBUS_IRQ);
>> +palmas_usb->vbus_irq = irq;
>> +}
>> +
>>  palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
>> PALMAS_VBUS_OTG_IRQ);
>> -palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
>> -   PALMAS_VBUS_IRQ);
>>  status = devm_request_threaded_irq(palmas_usb->dev,
>>  palmas_usb->vbus_irq, NULL,
>>  palmas_vbus_irq_handler,
>>
> 
> Thanks,
> Chanwoo Choi
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

If you are OK about following patch, I'll apply it on extcon branch.

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a885740..f601370c9466 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -296,10 +296,29 @@ static int palmas_usb_probe(struct platform_device *pdev)
}
 
if (palmas_usb->enable_vbus_detection) {
+   int irq = platform_get_irq(pdev, 0);
+
+   if (irq > 0) {
+   /* remux GPIO_1 as VBUSDET */
+   status = palmas_update_bits(palmas,
+   PALMAS_PU_PD_OD_BASE,
+   PALMAS_PRIMARY_SECONDARY_PAD1,
+   PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
+   (1 << 
PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT));
+   if (status < 0) {
+   dev_err(>dev, "can't remux GPIO1\n");
+   return status;
+   }
+
+   palmas_usb->vbus_irq = irq;
+   } else {
+   irq = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);
+   palmas_usb->vbus_irq = irq;
+   }
+
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
-   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
-  PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,
-- 
1.9.1


Thanks,
Chanwoo Choi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-12 Thread Felipe Balbi
TPS659038 can remux its GPIO_1 as VBUSDET output,
which can be tied to a SoC GPIO and used as a VBUS
interrupt.

Beagle X15 uses that, in fact, and without it, I
could not get USB peripheral working with that
board.

Signed-off-by: Felipe Balbi 
---
 drivers/extcon/extcon-palmas.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a885740..7985d092c069 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device *pdev)
}
 
if (palmas_usb->enable_vbus_detection) {
+   int irq = platform_get_irq(pdev, 0);
+
+   if (irq > 0) {
+   /* remux GPIO_1 as VBUSDET */
+   status = palmas_update_bits(palmas, 
PALMAS_PU_PD_OD_BASE,
+   PALMAS_PRIMARY_SECONDARY_PAD1,
+   
PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
+   (1 << 3));
+   if (status < 0) {
+   dev_err(>dev, "can't remux GPIO1\n");
+   return status;
+   }
+
+   palmas_usb->vbus_irq = irq;
+   } else {
+   irq = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);
+   palmas_usb->vbus_irq = irq;
+   }
+
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
-   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
-  PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] extcon: palmas: add support for using VBUSDET output

2015-11-12 Thread Felipe Balbi
TPS659038 can remux its GPIO_1 as VBUSDET output,
which can be tied to a SoC GPIO and used as a VBUS
interrupt.

Beagle X15 uses that, in fact, and without it, I
could not get USB peripheral working with that
board.

Signed-off-by: Felipe Balbi 
---
 drivers/extcon/extcon-palmas.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 93c30a885740..7985d092c069 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -296,10 +296,28 @@ static int palmas_usb_probe(struct platform_device *pdev)
}
 
if (palmas_usb->enable_vbus_detection) {
+   int irq = platform_get_irq(pdev, 0);
+
+   if (irq > 0) {
+   /* remux GPIO_1 as VBUSDET */
+   status = palmas_update_bits(palmas, 
PALMAS_PU_PD_OD_BASE,
+   PALMAS_PRIMARY_SECONDARY_PAD1,
+   
PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK,
+   (1 << 3));
+   if (status < 0) {
+   dev_err(>dev, "can't remux GPIO1\n");
+   return status;
+   }
+
+   palmas_usb->vbus_irq = irq;
+   } else {
+   irq = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);
+   palmas_usb->vbus_irq = irq;
+   }
+
palmas_usb->vbus_otg_irq = regmap_irq_get_virq(palmas->irq_data,
   PALMAS_VBUS_OTG_IRQ);
-   palmas_usb->vbus_irq = regmap_irq_get_virq(palmas->irq_data,
-  PALMAS_VBUS_IRQ);
status = devm_request_threaded_irq(palmas_usb->dev,
palmas_usb->vbus_irq, NULL,
palmas_vbus_irq_handler,
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/