mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 14:41:31 +00:00
gpio: zynq: Add support for reading gpio pin state
Add zynq_gpio_get_function() which return status on gpio pin. This function enables gpio status command. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
parent
7f307d93ed
commit
a6b9587bad
1 changed files with 22 additions and 0 deletions
|
@ -299,11 +299,33 @@ static int zynq_gpio_direction_output(struct udevice *dev, unsigned gpio,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int zynq_gpio_get_function(struct udevice *dev, unsigned offset)
|
||||||
|
{
|
||||||
|
u32 reg;
|
||||||
|
unsigned int bank_num, bank_pin_num;
|
||||||
|
struct zynq_gpio_privdata *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
|
if (check_gpio(offset, dev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
zynq_gpio_get_bank_pin(offset, &bank_num, &bank_pin_num, dev);
|
||||||
|
|
||||||
|
/* set the GPIO pin as output */
|
||||||
|
reg = readl(priv->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
|
||||||
|
reg &= BIT(bank_pin_num);
|
||||||
|
if (reg)
|
||||||
|
return GPIOF_OUTPUT;
|
||||||
|
else
|
||||||
|
return GPIOF_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct dm_gpio_ops gpio_zynq_ops = {
|
static const struct dm_gpio_ops gpio_zynq_ops = {
|
||||||
.direction_input = zynq_gpio_direction_input,
|
.direction_input = zynq_gpio_direction_input,
|
||||||
.direction_output = zynq_gpio_direction_output,
|
.direction_output = zynq_gpio_direction_output,
|
||||||
.get_value = zynq_gpio_get_value,
|
.get_value = zynq_gpio_get_value,
|
||||||
.set_value = zynq_gpio_set_value,
|
.set_value = zynq_gpio_set_value,
|
||||||
|
.get_function = zynq_gpio_get_function,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct udevice_id zynq_gpio_ids[] = {
|
static const struct udevice_id zynq_gpio_ids[] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue