[U-Boot] [PATCH 1/4] dm: rpi: Convert GPIO driver to driver model

Simon Glass sjg at chromium.org
Wed Oct 1 04:15:24 CEST 2014


Hi Stephen,

On 30 September 2014 19:40, Stephen Warren <swarren at wwwdotorg.org> wrote:
> On 09/22/2014 05:30 PM, Simon Glass wrote:
>> Convert the BCM2835 GPIO driver to use driver model, and switch over
>> Raspberry Pi to use this, since it is the only board.
>
>> diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c
>
>> +static inline bool gpio_is_requested(struct bcm2835_gpios *gpios, int offset)
>>  {
>> +     return *gpios->label[offset] != '\0';
>>  }
>>
>> +static int check_requested(struct udevice *dev, unsigned offset,
>> +                        const char *func)
>>  {
>> +     struct bcm2835_gpios *gpios = dev_get_priv(dev);
>> +     struct gpio_dev_priv *uc_priv = dev->uclass_priv;
>> +
>> +     if (!gpio_is_requested(gpios, offset)) {
>> +             printf("omap_gpio: %s: error: gpio %s%d not requested\n",
>> +                    func, uc_priv->bank_name, offset);
>> +             return -EPERM;
>> +     }
>> +
>> +     return 0;
>>  }
>
> It seems like the core GPIO layer should be doing the high-level
> management of GPIO requesting, so each driver doesn't have to duplicate
> the code?

Yes, agreed. I figured this was coming but took a conservative
approach with the uclass to start with. I will be taking a look at
moving this logic into the uclass soon. I've done enough GPIO drivers
to prove this out.

Regards,
Simon


More information about the U-Boot mailing list