
Hi Albert,
On 12 February 2015 at 23:30, Albert ARIBAUD albert.aribaud@3adev.fr wrote:
Hi Simon,
Le Thu, 12 Feb 2015 22:06:51 -0700, Simon Glass sjg@chromium.org a écrit :
Hi Albert,
On 12 February 2015 at 10:37, Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr wrote:
This driver only supports Driver Model, not legacy model.
Signed-off-by: Albert ARIBAUD (3ADEV) albert.aribaud@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, ®s->p0_dir_clr);
break;
case 1:
writel(mask, ®s->p1_dir_clr);
break;
case 2:
/* ports 2 and 3 share a common direction */
case 3:
writel(mask, ®s->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