rockchip: Add gpio_set() function

The <gpio.h> API is supposed to include a gpio_set() function that just
toggles the state of a GPIO already configured as an output, even though
we rarely need it since gpio_output() can already be used to initialze a
GPIO to a default value while configuring it as an output. This function
was forgotten on Rockchip, so this patch adds it now.

Change-Id: I201288139a2870e71f55a7af0d79d4a460b30a0c
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/25393
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Julius Werner 2018-03-27 16:22:00 -07:00
parent e7e35674d6
commit ffeee42091
1 changed files with 6 additions and 1 deletions

View File

@ -109,10 +109,15 @@ int gpio_get(gpio_t gpio)
return (read32(&gpio_port[gpio.port]->ext_porta) >> gpio.num) & 0x1;
}
void gpio_output(gpio_t gpio, int value)
void gpio_set(gpio_t gpio, int value)
{
clrsetbits_le32(&gpio_port[gpio.port]->swporta_dr, 1 << gpio.num,
!!value << gpio.num);
}
void gpio_output(gpio_t gpio, int value)
{
gpio_set(gpio, value);
gpio_set_dir(gpio, GPIO_OUTPUT);
gpio_set_pull(gpio, GPIO_PULLNONE);
}