mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
bcm2835_gpio: Implement GPIOF_FUNC
So far we could only tell the gpio framework that a GPIO was mapped as input or output, not as alternative function. This patch adds support for determining whether a function is mapped as alternative. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Stephen Warren <swarren@wwwdotorg.org>
This commit is contained in:
parent
c0afcb5889
commit
04a993fe11
2 changed files with 19 additions and 13 deletions
|
@ -66,4 +66,6 @@ struct bcm2835_gpio_platdata {
|
||||||
unsigned long base;
|
unsigned long base;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio);
|
||||||
|
|
||||||
#endif /* _BCM2835_GPIO_H_ */
|
#endif /* _BCM2835_GPIO_H_ */
|
||||||
|
|
|
@ -44,15 +44,6 @@ static int bcm2835_gpio_direction_output(struct udevice *dev, unsigned gpio,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bcm2835_gpio_is_output(const struct bcm2835_gpios *gpios, int gpio)
|
|
||||||
{
|
|
||||||
u32 val;
|
|
||||||
|
|
||||||
val = readl(&gpios->reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
|
|
||||||
val &= BCM2835_GPIO_FSEL_MASK << BCM2835_GPIO_FSEL_SHIFT(gpio);
|
|
||||||
return val ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bcm2835_get_value(const struct bcm2835_gpios *gpios, unsigned gpio)
|
static int bcm2835_get_value(const struct bcm2835_gpios *gpios, unsigned gpio)
|
||||||
{
|
{
|
||||||
unsigned val;
|
unsigned val;
|
||||||
|
@ -81,15 +72,28 @@ static int bcm2835_gpio_set_value(struct udevice *dev, unsigned gpio,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
|
int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio)
|
||||||
{
|
{
|
||||||
struct bcm2835_gpios *gpios = dev_get_priv(dev);
|
struct bcm2835_gpios *gpios = dev_get_priv(dev);
|
||||||
|
u32 val;
|
||||||
|
|
||||||
/* GPIOF_FUNC is not implemented yet */
|
val = readl(&gpios->reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
|
||||||
if (bcm2835_gpio_is_output(gpios, offset))
|
|
||||||
|
return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & BCM2835_GPIO_FSEL_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
|
||||||
|
{
|
||||||
|
int funcid = bcm2835_gpio_get_func_id(dev, offset);
|
||||||
|
|
||||||
|
switch (funcid) {
|
||||||
|
case BCM2835_GPIO_OUTPUT:
|
||||||
return GPIOF_OUTPUT;
|
return GPIOF_OUTPUT;
|
||||||
else
|
case BCM2835_GPIO_INPUT:
|
||||||
return GPIOF_INPUT;
|
return GPIOF_INPUT;
|
||||||
|
default:
|
||||||
|
return GPIOF_FUNC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue