mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Carlo Caione <carlo.caione@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] Add support for GPIO (BCM2835/Raspberry-Pi)
Date: Thu, 11 Oct 2012 09:17:35 +0200	[thread overview]
Message-ID: <20121011071735.GE27665@pengutronix.de> (raw)
In-Reply-To: <19A97966-0AF1-4D37-BC6F-CA6D47F59B50@gmail.com>

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@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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-10-11  7:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 22:07 [PATCH 0/5] BCM2835/Raspberry-Pi: add support Carlo Caione
2012-10-08 22:07 ` [PATCH 1/5] Add support for ARM1176 Carlo Caione
2012-10-08 22:07 ` [PATCH 2/5] Add support for BCM2835 Carlo Caione
2012-10-09 11:26   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-08 22:07 ` [PATCH 3/5] Add support for Raspberry-Pi Carlo Caione
2012-10-09 11:28   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-08 22:07 ` [PATCH 4/5] Add support for BCM2835 clocksource Carlo Caione
2012-10-09 11:20   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-09 11:29   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-08 22:07 ` [PATCH 5/5] Add support for GPIO (BCM2835/Raspberry-Pi) Carlo Caione
2012-10-09 11:31   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-10 20:36     ` Carlo Caione
2012-10-11  7:17       ` Sascha Hauer [this message]
2012-10-11 14:15         ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121011071735.GE27665@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=carlo.caione@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox