[U-Boot] [PATCH v2 4/8] lpc32xx: add GPIO support

Simon Glass sjg at chromium.org
Fri Feb 13 15:33:05 CET 2015


Hi Albert,

On 12 February 2015 at 23:30, Albert ARIBAUD <albert.aribaud at 3adev.fr> wrote:
> Hi Simon,
>
> Le Thu, 12 Feb 2015 22:06:51 -0700, Simon Glass <sjg at chromium.org> a
> écrit :
>
>> Hi Albert,
>>
>> On 12 February 2015 at 10:37, Albert ARIBAUD (3ADEV)
>> <albert.aribaud at 3adev.fr> wrote:
>> > This driver only supports Driver Model, not legacy model.
>> >
>> > Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud at 3adev.fr>
>> > ---
>> >
>> > Changes in v2:
>> > - move from legacy to Driver Model support
[snip]
>> > +static int lpc32xx_gpio_direction_input(struct udevice *dev, unsigned offset)
>> > +{
>> > +       int port, mask;
>> > +
>> > +       port = GPIO_TO_PORT(offset);
>> > +       mask = GPIO_TO_MASK(offset);
>> > +
>> > +       switch (port) {
>> > +       case 0:
>> > +               writel(mask, &regs->p0_dir_clr);
>> > +               break;
>> > +       case 1:
>> > +               writel(mask, &regs->p1_dir_clr);
>> > +               break;
>> > +       case 2:
>> > +               /* ports 2 and 3 share a common direction */
>> > +       case 3:
>> > +               writel(mask, &regs->p2_p3_dir_clr);
>> > +               break;
>> > +       default:
>> > +               return -1;
>> > +       }
>> > +
>> > +       lpc32xx_function[offset] = GPIOF_INPUT;
>>
>> Another way of doing this is to read the status from the hardware.
>> This might allow you to support GPIOF_FUNCTION - i.e. the GPIO is
>> currently used by a function.
>
> Even under the simplified model I used for LPC32XX GPIOs, finding out
> the state of an individual gpio would be quite complicated and would
> incur much work for a feature which is actually only useful for the
> 'gpio' command -- a commodity but not a necessity as far a the actual
> board user is concerned.

Yes it's only a nicety and can easily be added later if someone wants
it. But it might be worth adding a comment to that effect - someone
using this driver for inspiration might get the wrong idea.

Regards,
Simon


More information about the U-Boot mailing list