[PATCH 5/5] Add support for GPIO (BCM2835/Raspberry-Pi)

Sascha Hauer s.hauer at pengutronix.de
Thu Oct 11 03:17:35 EDT 2012


On Wed, Oct 10, 2012 at 10:36:59PM +0200, Carlo Caione wrote:
> 
> On Oct 9, 2012, at 1:31 PM, Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> wrote:
> [cut]
> 
> > you should add one bank pre gpio_chip 
> >> +	struct bcm2835_gpio_chip *bcmgpio = container_of(chip, struct bcm2835_gpio_chip, chip);
> >> +	void __iomem *base = bcmgpio->base;
> >> +	unsigned gpiodir;
> >> +	unsigned gpio_bank = gpio / 10;
> >> +	unsigned gpio_field_offset = (gpio - 10 * gpio_bank) * 3;
> > so this will be dropped
> >> +
> >> +	gpiodir = readl(base + GPIOFSEL(gpio_bank));
> >> +	gpiodir &= ~(7 << gpio_field_offset);
> >> +	gpiodir |= function << gpio_field_offset;
> >> +	writel(gpiodir, base + GPIOFSEL(gpio_bank));
> >> +	gpiodir = readl(base + GPIOFSEL(gpio_bank));
> >> +
> >> +	return 0;
> >> +}
> >> +
> 
> Uhm, this could be not convenient since the two banks in BCM2835 are
> not really separated, there are not exclusive registers for one bank
> or for the other. The registers used for GPIOs configuration manage
> both the two banks (see for example GPFSELx).  If I add one bank I can
> avoid calculating the bank offset for GPCLRx and GPSETx but not for
> GPFSELx and viceversa (in fact in the code I select the bank for
> GPCLRx and GPSETx with gpio_bank = gpio / 32 whereas for GPIOFSEL with
> gpio_bank = gpio / 10).  Yay, confusing …

I sometimes wonder if hardware designers know what pains they cause...

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list