[PATCH RFC 3/7] [POWERPC] CPM2: implement GPIO API
Anton Vorontsov
avorontsov at ru.mvista.com
Thu Dec 13 03:03:36 EST 2007
On Wed, Dec 12, 2007 at 04:49:46PM +0100, Jochen Friedrich wrote:
> Hi Anton,
>
> > +int gpio_direction_input(unsigned int gpio)
> > +{
> > + unsigned long flags;
> > + int port = gpio / 32;
> > + int pin = gpio % 32;
> > +
> > + spin_lock_irqsave(&cpm2_port_locks[port], flags);
> > +
> > + cpm2_set_pin(port, pin, CPM_PIN_INPUT | CPM_PIN_GPIO);
>
> > +int gpio_direction_output(unsigned int gpio, int value)
> > +{
> > + struct cpm2_ioports __iomem *iop =
> > + (struct cpm2_ioports __iomem *)&cpm2_immr->im_ioport;
> > + int port = gpio / 32;
> > + int pin = gpio % 32;
> > + unsigned long flags;
> > +
> > + pin = 1 << (31 - pin);
> > +
> > + spin_lock_irqsave(&cpm2_port_locks[port], flags);
> > +
> > + cpm2_set_pin(port, pin, CPM_PIN_OUTPUT | CPM_PIN_GPIO);
>
> You seem to do the pin -> bitmask conversation twice in gpio_direction_output().
>
> cpm2_set_pin() must be executed before pin = 1 << (31 - pin);
Yup, found this just after posting. ;-) I've tried to move as much as
possible out of spinlocked section, but done it obviously wrong.
Will fix.
Anyhow, much thanks for looking into this.
--
Anton Vorontsov
email: cbou at mail.ru
backup email: ya-cbou at yandex.ru
irc://irc.freenode.net/bd2
More information about the Linuxppc-dev
mailing list