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

Stephen Warren swarren at wwwdotorg.org
Wed Oct 1 03:40:12 CEST 2014


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?


More information about the U-Boot mailing list