[U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support

Ley Foon Tan lftan.linux at gmail.com
Wed Aug 15 10:30:29 UTC 2018


On Wed, Aug 15, 2018 at 6:12 PM, Marek Vasut <marex at denx.de> wrote:
> On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
>> Enabled get_function support for dwapb where the function will
>> return the state of GPIO port.
>>
>> Signed-off-by: Chin Liang See <chin.liang.see at intel.com>
>> Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com>
>> ---
>>  drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
>> index 680b11a..3b5c181 100644
>> --- a/drivers/gpio/dwapb_gpio.c
>> +++ b/drivers/gpio/dwapb_gpio.c
>> @@ -78,11 +78,26 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val)
>>       return 0;
>>  }
>>
>> +static int dwapb_gpio_get_function(struct udevice *dev, unsigned offset)
>> +{
>> +     struct gpio_dwapb_platdata *plat = dev_get_platdata(dev);
>> +     int gpio;
>> +
>> +     gpio = readl(plat->base + GPIO_SWPORT_DDR(plat->bank));
>> +     gpio = (gpio >> offset) & 1;
>> +
>> +     if (gpio)
>
> if (gpio & BIT(offset)) ?
Will change this.
>
>> +             return GPIOF_OUTPUT;
>> +     else
>> +             return GPIOF_INPUT;
>> +}
>> +
>>  static const struct dm_gpio_ops gpio_dwapb_ops = {
>>       .direction_input        = dwapb_gpio_direction_input,
>>       .direction_output       = dwapb_gpio_direction_output,
>>       .get_value              = dwapb_gpio_get_value,
>>       .set_value              = dwapb_gpio_set_value,
>> +     .get_function           = dwapb_gpio_get_function,
>>  };
>>
>>  static int gpio_dwapb_probe(struct udevice *dev)
>>
>
>
Regards
Ley Foon


More information about the U-Boot mailing list