tegra: Add gpio_output_open_drain() function
This patch adds a function to configure an output GPIO with the PINMUX_OPEN_DRAIN flag set, such as is necessary for some of the DD class GPIOs. It requires some shifting around of the GPIO code plumbing but doesn't change the existing external interfaces. BUG=None TEST=None Change-Id: Iac294aeb8705834104c8351849b37d07759c3dae Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174650 Reviewed-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
3f31a634f6
commit
bc1c289268
2 changed files with 14 additions and 6 deletions
|
|
@ -36,15 +36,13 @@ void __gpio_input(gpio_t gpio, u32 pull)
|
|||
pinmux_set_config(gpio >> GPIO_PINMUX_SHIFT, pinmux_config);
|
||||
}
|
||||
|
||||
void gpio_output(gpio_t gpio, int value)
|
||||
void __gpio_output(gpio_t gpio, int value, u32 od)
|
||||
{
|
||||
/* TODO: Set OPEN_DRAIN based on what pin it is? */
|
||||
|
||||
gpio_set_int_enable(gpio, 0);
|
||||
gpio_set_out_value(gpio, value);
|
||||
gpio_set_out_enable(gpio, 1);
|
||||
gpio_set_mode(gpio, GPIO_MODE_GPIO);
|
||||
pinmux_set_config(gpio >> GPIO_PINMUX_SHIFT, PINMUX_PULL_NONE);
|
||||
pinmux_set_config(gpio >> GPIO_PINMUX_SHIFT, PINMUX_PULL_NONE | od);
|
||||
}
|
||||
|
||||
enum {
|
||||
|
|
|
|||
|
|
@ -31,10 +31,20 @@ typedef u32 gpio_t;
|
|||
#define GPIO(name) ((gpio_t)(GPIO_##name##_INDEX | \
|
||||
(PINMUX_GPIO_##name << GPIO_PINMUX_SHIFT)))
|
||||
|
||||
void __gpio_output(gpio_t gpio, int value, u32 open_drain);
|
||||
void __gpio_input(gpio_t gpio, u32 pull);
|
||||
|
||||
/* Higher level function wrappers for common GPIO configurations. */
|
||||
|
||||
void gpio_output(gpio_t gpio, int value);
|
||||
void __gpio_input(gpio_t gpio, u32 pull);
|
||||
static inline void gpio_output(gpio_t gpio, int value)
|
||||
{
|
||||
__gpio_output(gpio, value, 0);
|
||||
}
|
||||
|
||||
static inline void gpio_output_open_drain(gpio_t gpio, int value)
|
||||
{
|
||||
__gpio_output(gpio, value, PINMUX_OPEN_DRAIN);
|
||||
}
|
||||
|
||||
static inline void gpio_input(gpio_t gpio)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue