[PATCH] Add MPC52xx simple interrupt GPIO support

Grant Likely grant.likely at secretlab.ca
Tue Mar 3 04:45:09 EST 2009


On Mon, Mar 2, 2009 at 10:16 AM, Anton Vorontsov
<avorontsov at ru.mvista.com> wrote:
> On Thu, Feb 26, 2009 at 10:06:59PM -0700, Grant Likely wrote:
>>  Maybe something like:
>>
>> struct of_gpio_chip {
>>         int gpio_cells;
>>         int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
>>                      const void *gpio_spec, enum of_gpio_flags *flags);
>>         struct gpio_chip gc[1];
>> };
>
> I'd suggest to not touch of_gpio_chip structure, I'd like to keep
> of_gpio_chip struct 1:1 bound to a pure gpio_chip structure. This keeps
> things simple and understandable on the low level.
>
> And when you need several gpio controllers bound to some Linux struct,
> I would rather suggest this:
>
> struct mpc5200_gpio_controller {
>        void __iomem *regs;
>        void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
>        struct of_gpio_chip of_gc[1];
> };
>
> In the of_gc->xlate callback you'll always get &of_gc[0], but since you
> know that this is mpc5200 controller, you can add needed offset depending
> on gpio_spec.

Fair enough.  That works too.

> OTOH, there is even more straightforward solution, all you actually need
> is to define "HW GPIO" bindings (which are wkup, which are interrupt, etc.),
> and then:
>
> void mpc5200_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
> {
>        if (mpc5200_is_wkup(gpio))
>                write to the wkup registers block;
>        else if (mpc5200_is_int(gpio))
>                write to the int registers block;
>        else
>                ...
> }
>
> That is, the same thing we do for the interrupt controllers.

Ugh, I'd really do not want to use this approach.  The GPIOs path is
too long as is.  When GPIOs are used for things like JTAG or other bus
emulation, every cycle counts.  As much as possible the long path,
such as figuring out which chip, should be preprocessed so that it is
already known by the time the set/get/direction hooks are called.

IRQ controllers typically need to deal with far lower frequencies on
the IRQ line.

>
> (Note that these "if"s can be replaced by a table, as in
> arch/powerpc/sysdev/qe_lib/qe_ic.c).

Even with the table it is a cost I don't want in the GPIO handler.  If
it were possible to do so, I'd even like to remove the spinlocks from
the hooks, but that isn't an option at the moment.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.



More information about the Linuxppc-dev mailing list