* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
@ 2013-10-23 6:36 Haojian Zhuang
2013-10-28 22:55 ` Linus Walleij
0 siblings, 1 reply; 7+ messages in thread
From: Haojian Zhuang @ 2013-10-23 6:36 UTC (permalink / raw)
To: linux-arm-kernel
gpio-ranges property could binds gpio to pinctrl. But there may be some
gpios without pinctrl operation. So check whether gpio-ranges property
exists in device node first.
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
---
drivers/gpio/gpio-pl061.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index cb5510b..44a0ba1 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -306,8 +306,11 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
spin_lock_init(&chip->lock);
- chip->gc.request = pl061_gpio_request;
- chip->gc.free = pl061_gpio_free;
+ /* Hook the request()/free() for pinctrl operation */
+ if (of_get_property(dev->of_node, "gpio-ranges", NULL)) {
+ chip->gc.request = pl061_gpio_request;
+ chip->gc.free = pl061_gpio_free;
+ }
chip->gc.direction_input = pl061_direction_input;
chip->gc.direction_output = pl061_direction_output;
chip->gc.get = pl061_get_value;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
2013-10-23 6:36 Haojian Zhuang
@ 2013-10-28 22:55 ` Linus Walleij
0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2013-10-28 22:55 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Oct 23, 2013 at 8:36 AM, Haojian Zhuang
<haojian.zhuang@linaro•org> wrote:
> gpio-ranges property could binds gpio to pinctrl. But there may be some
> gpios without pinctrl operation. So check whether gpio-ranges property
> exists in device node first.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
OK...
> + /* Hook the request()/free() for pinctrl operation */
> + if (of_get_property(dev->of_node, "gpio-ranges", NULL)) {
> + chip->gc.request = pl061_gpio_request;
> + chip->gc.free = pl061_gpio_free;
> + }
This is quite hard for those not using pinctrl to understand, maybe someone
wants to use the request/free callbacks for something else in the
future.
Can't you:
- Add a variable bool uses_pinctrl to struct pl061_gpio
- Use the bool check:
if (of_property_read_bool(np, "gpio-ranges"))
chip->uses_pinctrl = true;
- Alter the code in pl061_gpio_request() to do like this:
if (chip->uses_pinctrl)
pinctrl_request_gpio()
And the same for pl061_gpio_free().
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
@ 2014-10-09 9:42 Haojian Zhuang
[not found] ` <543665A4.6000404@hisilicon.com>
2014-10-17 9:26 ` Alexandre Courbot
0 siblings, 2 replies; 7+ messages in thread
From: Haojian Zhuang @ 2014-10-09 9:42 UTC (permalink / raw)
To: linux-arm-kernel
gpio-ranges property could binds gpio to pinctrl. But there may be some
gpios without pinctrl operation. So check whether gpio-ranges property
exists in device node first.
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
---
drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 84b49cf..d1813f0 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -52,28 +52,34 @@ struct pl061_gpio {
void __iomem *base;
struct gpio_chip gc;
+ int uses_pinctrl;
#ifdef CONFIG_PM
struct pl061_context_save_regs csave_regs;
#endif
};
-static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
+static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
{
/*
* Map back to global GPIO space and request muxing, the direction
* parameter does not matter for this controller.
*/
- int gpio = chip->base + offset;
+ struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
+ int gpio = gc->base + offset;
- return pinctrl_request_gpio(gpio);
+ if (chip->uses_pinctrl)
+ return pinctrl_request_gpio(gpio);
+ return 0;
}
-static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
+static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
{
- int gpio = chip->base + offset;
+ struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
+ int gpio = gc->base + offset;
- pinctrl_free_gpio(gpio);
+ if (chip->uses_pinctrl)
+ pinctrl_free_gpio(gpio);
}
static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
@@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
spin_lock_init(&chip->lock);
+ /* Hook the request()/free() for pinctrl operation */
+ if (of_property_read_bool(dev->of_node, "gpio-ranges"))
+ chip->uses_pinctrl = true;
chip->gc.request = pl061_gpio_request;
chip->gc.free = pl061_gpio_free;
chip->gc.direction_input = pl061_direction_input;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
[not found] ` <543665A4.6000404@hisilicon.com>
@ 2014-10-09 10:56 ` Haojian Zhuang
2014-10-09 11:15 ` k00278426
0 siblings, 1 reply; 7+ messages in thread
From: Haojian Zhuang @ 2014-10-09 10:56 UTC (permalink / raw)
To: linux-arm-kernel
Hi Xinwei,
Do I miss anything? At here, .request pointer isn't null. It always
points to pl061_gpio_request().
Best Regards
Haojian
On 9 October 2014 18:38, k00278426 <kong.kongxinwei@hisilicon•com> wrote:
> On 2014/10/9 17:42, Haojian Zhuang wrote:
>
> gpio-ranges property could binds gpio to pinctrl. But there may be some
> gpios without pinctrl operation. So check whether gpio-ranges property
> exists in device node first.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
> ---
> drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 84b49cf..d1813f0 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -52,28 +52,34 @@ struct pl061_gpio {
>
> void __iomem *base;
> struct gpio_chip gc;
> + int uses_pinctrl;
>
> #ifdef CONFIG_PM
> struct pl061_context_save_regs csave_regs;
> #endif
> };
>
> -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
> +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
> {
> /*
> * Map back to global GPIO space and request muxing, the direction
> * parameter does not matter for this controller.
> */
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - return pinctrl_request_gpio(gpio);
> + if (chip->uses_pinctrl)
> + return pinctrl_request_gpio(gpio);
> + return 0;
> }
>
> In the request_gpio process,if the .request point is null,the return
> of request_gpio process will value 0. the request_gpio process will not
> enter the pintrcl system.
> so the request_gpio have deal with the "if" branch.
>
>
> -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
> +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
> {
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - pinctrl_free_gpio(gpio);
> + if (chip->uses_pinctrl)
> + pinctrl_free_gpio(gpio);
> }
>
> static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const
> struct amba_id *id)
>
> spin_lock_init(&chip->lock);
>
> + /* Hook the request()/free() for pinctrl operation */
> + if (of_property_read_bool(dev->of_node, "gpio-ranges"))
> + chip->uses_pinctrl = true;
> chip->gc.request = pl061_gpio_request;
> chip->gc.free = pl061_gpio_free;
> chip->gc.direction_input = pl061_direction_input;
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
2014-10-09 10:56 ` Haojian Zhuang
@ 2014-10-09 11:15 ` k00278426
2014-10-09 11:23 ` Haojian Zhuang
0 siblings, 1 reply; 7+ messages in thread
From: k00278426 @ 2014-10-09 11:15 UTC (permalink / raw)
To: linux-arm-kernel
hi jian
In the afternoon,we submit a patch about gpio-ranges item,we slove this issue by setting the .request pointer which is null. before coming true the
pl061_gpio_request function, we slove the issue.you can study it.
Best Regards
xinwei
On 2014/10/9 18:56, Haojian Zhuang wrote:
> Hi Xinwei,
>
> Do I miss anything? At here, .request pointer isn't null. It always
> points to pl061_gpio_request().
>
> Best Regards
> Haojian
>
> On 9 October 2014 18:38, k00278426 <kong.kongxinwei@hisilicon•com> wrote:
>> On 2014/10/9 17:42, Haojian Zhuang wrote:
>>
>> gpio-ranges property could binds gpio to pinctrl. But there may be some
>> gpios without pinctrl operation. So check whether gpio-ranges property
>> exists in device node first.
>>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
>> ---
>> drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
>> 1 file changed, 15 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
>> index 84b49cf..d1813f0 100644
>> --- a/drivers/gpio/gpio-pl061.c
>> +++ b/drivers/gpio/gpio-pl061.c
>> @@ -52,28 +52,34 @@ struct pl061_gpio {
>>
>> void __iomem *base;
>> struct gpio_chip gc;
>> + int uses_pinctrl;
>>
>> #ifdef CONFIG_PM
>> struct pl061_context_save_regs csave_regs;
>> #endif
>> };
>>
>> -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
>> +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
>> {
>> /*
>> * Map back to global GPIO space and request muxing, the direction
>> * parameter does not matter for this controller.
>> */
>> - int gpio = chip->base + offset;
>> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
>> + int gpio = gc->base + offset;
>>
>> - return pinctrl_request_gpio(gpio);
>> + if (chip->uses_pinctrl)
>> + return pinctrl_request_gpio(gpio);
>> + return 0;
>> }
>>
>> In the request_gpio process,if the .request point is null,the return
>> of request_gpio process will value 0. the request_gpio process will not
>> enter the pintrcl system.
>> so the request_gpio have deal with the "if" branch.
>>
>>
>> -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
>> +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
>> {
>> - int gpio = chip->base + offset;
>> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
>> + int gpio = gc->base + offset;
>>
>> - pinctrl_free_gpio(gpio);
>> + if (chip->uses_pinctrl)
>> + pinctrl_free_gpio(gpio);
>> }
>>
>> static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
>> @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const
>> struct amba_id *id)
>>
>> spin_lock_init(&chip->lock);
>>
>> + /* Hook the request()/free() for pinctrl operation */
>> + if (of_property_read_bool(dev->of_node, "gpio-ranges"))
>> + chip->uses_pinctrl = true;
>> chip->gc.request = pl061_gpio_request;
>> chip->gc.free = pl061_gpio_free;
>> chip->gc.direction_input = pl061_direction_input;
>>
>>
> .
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
2014-10-09 11:15 ` k00278426
@ 2014-10-09 11:23 ` Haojian Zhuang
0 siblings, 0 replies; 7+ messages in thread
From: Haojian Zhuang @ 2014-10-09 11:23 UTC (permalink / raw)
To: linux-arm-kernel
It's good. But it's similar the one that I sent in last year. You can
check this link in below.
http://marc.info/?l=linux-gpio&m=138300092720593&w=2
My patch is used to fix this issue according to the comments.
Best Regards
Haojian
On 9 October 2014 19:15, k00278426 <kong.kongxinwei@hisilicon•com> wrote:
> hi jian
>
> In the afternoon,we submit a patch about gpio-ranges item,we slove this issue by setting the .request pointer which is null. before coming true the
>
> pl061_gpio_request function, we slove the issue.you can study it.
>
> Best Regards
> xinwei
>
>
> On 2014/10/9 18:56, Haojian Zhuang wrote:
>> Hi Xinwei,
>>
>> Do I miss anything? At here, .request pointer isn't null. It always
>> points to pl061_gpio_request().
>>
>> Best Regards
>> Haojian
>>
>> On 9 October 2014 18:38, k00278426 <kong.kongxinwei@hisilicon•com> wrote:
>>> On 2014/10/9 17:42, Haojian Zhuang wrote:
>>>
>>> gpio-ranges property could binds gpio to pinctrl. But there may be some
>>> gpios without pinctrl operation. So check whether gpio-ranges property
>>> exists in device node first.
>>>
>>> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
>>> ---
>>> drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
>>> 1 file changed, 15 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
>>> index 84b49cf..d1813f0 100644
>>> --- a/drivers/gpio/gpio-pl061.c
>>> +++ b/drivers/gpio/gpio-pl061.c
>>> @@ -52,28 +52,34 @@ struct pl061_gpio {
>>>
>>> void __iomem *base;
>>> struct gpio_chip gc;
>>> + int uses_pinctrl;
>>>
>>> #ifdef CONFIG_PM
>>> struct pl061_context_save_regs csave_regs;
>>> #endif
>>> };
>>>
>>> -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
>>> +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
>>> {
>>> /*
>>> * Map back to global GPIO space and request muxing, the direction
>>> * parameter does not matter for this controller.
>>> */
>>> - int gpio = chip->base + offset;
>>> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
>>> + int gpio = gc->base + offset;
>>>
>>> - return pinctrl_request_gpio(gpio);
>>> + if (chip->uses_pinctrl)
>>> + return pinctrl_request_gpio(gpio);
>>> + return 0;
>>> }
>>>
>>> In the request_gpio process,if the .request point is null,the return
>>> of request_gpio process will value 0. the request_gpio process will not
>>> enter the pintrcl system.
>>> so the request_gpio have deal with the "if" branch.
>>>
>>>
>>> -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
>>> +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
>>> {
>>> - int gpio = chip->base + offset;
>>> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
>>> + int gpio = gc->base + offset;
>>>
>>> - pinctrl_free_gpio(gpio);
>>> + if (chip->uses_pinctrl)
>>> + pinctrl_free_gpio(gpio);
>>> }
>>>
>>> static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
>>> @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const
>>> struct amba_id *id)
>>>
>>> spin_lock_init(&chip->lock);
>>>
>>> + /* Hook the request()/free() for pinctrl operation */
>>> + if (of_property_read_bool(dev->of_node, "gpio-ranges"))
>>> + chip->uses_pinctrl = true;
>>> chip->gc.request = pl061_gpio_request;
>>> chip->gc.free = pl061_gpio_free;
>>> chip->gc.direction_input = pl061_direction_input;
>>>
>>>
>> .
>>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gpio: pl061: hook request if gpio-ranges avaiable
2014-10-09 9:42 [PATCH] gpio: pl061: hook request if gpio-ranges avaiable Haojian Zhuang
[not found] ` <543665A4.6000404@hisilicon.com>
@ 2014-10-17 9:26 ` Alexandre Courbot
1 sibling, 0 replies; 7+ messages in thread
From: Alexandre Courbot @ 2014-10-17 9:26 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Oct 9, 2014 at 6:42 PM, Haojian Zhuang
<haojian.zhuang@linaro•org> wrote:
> gpio-ranges property could binds gpio to pinctrl. But there may be some
> gpios without pinctrl operation. So check whether gpio-ranges property
> exists in device node first.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
> ---
> drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 84b49cf..d1813f0 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -52,28 +52,34 @@ struct pl061_gpio {
>
> void __iomem *base;
> struct gpio_chip gc;
> + int uses_pinctrl;
>
> #ifdef CONFIG_PM
> struct pl061_context_save_regs csave_regs;
> #endif
> };
>
> -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
> +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
> {
> /*
> * Map back to global GPIO space and request muxing, the direction
> * parameter does not matter for this controller.
> */
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - return pinctrl_request_gpio(gpio);
> + if (chip->uses_pinctrl)
> + return pinctrl_request_gpio(gpio);
> + return 0;
> }
>
> -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
> +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
> {
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - pinctrl_free_gpio(gpio);
> + if (chip->uses_pinctrl)
> + pinctrl_free_gpio(gpio);
> }
>
> static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
>
> spin_lock_init(&chip->lock);
>
> + /* Hook the request()/free() for pinctrl operation */
> + if (of_property_read_bool(dev->of_node, "gpio-ranges"))
> + chip->uses_pinctrl = true;
You probably want to document this property in
Documentation/devicetree/bindings/gpio/pl061-gpio.txt.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-17 9:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-09 9:42 [PATCH] gpio: pl061: hook request if gpio-ranges avaiable Haojian Zhuang
[not found] ` <543665A4.6000404@hisilicon.com>
2014-10-09 10:56 ` Haojian Zhuang
2014-10-09 11:15 ` k00278426
2014-10-09 11:23 ` Haojian Zhuang
2014-10-17 9:26 ` Alexandre Courbot
-- strict thread matches above, loose matches on Subject: below --
2013-10-23 6:36 Haojian Zhuang
2013-10-28 22:55 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox