| 1 |
|
| 2 |
|
| 3 |
#ifndef AMD_BLOCK_GPIO_BANKS_H |
| 4 |
#define AMD_BLOCK_GPIO_BANKS_H |
| 5 |
|
| 6 |
#include <types.h> |
| 7 |
#include <amdblocks/gpio_defs.h> |
| 8 |
|
| 9 |
typedef uint32_t gpio_t; |
| 10 |
|
| 11 |
struct soc_amd_gpio { |
| 12 |
gpio_t gpio; |
| 13 |
uint8_t function; |
| 14 |
uint32_t control; |
| 15 |
uint32_t flags; |
| 16 |
}; |
| 17 |
|
| 18 |
struct soc_amd_gpio_register_save { |
| 19 |
uint32_t control_value; |
| 20 |
uint8_t mux_value; |
| 21 |
}; |
| 22 |
|
| 23 |
struct soc_amd_event { |
| 24 |
gpio_t gpio; |
| 25 |
uint8_t event; |
| 26 |
}; |
| 27 |
|
| 28 |
struct gpio_wake_state { |
| 29 |
uint32_t control_switch; |
| 30 |
uint32_t wake_stat[2]; |
| 31 |
|
| 32 |
uint32_t num_valid_wake_gpios; |
| 33 |
|
| 34 |
gpio_t wake_gpios[16]; |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
void gpio_fill_wake_state(struct gpio_wake_state *state); |
| 39 |
|
| 40 |
void gpio_add_events(void); |
| 41 |
|
| 42 |
static inline bool is_gpio_event_level_triggered(uint32_t flags) |
| 43 |
{ |
| 44 |
return (flags & GPIO_FLAG_EVENT_TRIGGER_MASK) == GPIO_FLAG_EVENT_TRIGGER_LEVEL; |
| 45 |
} |
| 46 |
|
| 47 |
static inline bool is_gpio_event_edge_triggered(uint32_t flags) |
| 48 |
{ |
| 49 |
return (flags & GPIO_FLAG_EVENT_TRIGGER_MASK) == GPIO_FLAG_EVENT_TRIGGER_EDGE; |
| 50 |
} |
| 51 |
|
| 52 |
static inline bool is_gpio_event_active_high(uint32_t flags) |
| 53 |
{ |
| 54 |
return (flags & GPIO_FLAG_EVENT_ACTIVE_MASK) == GPIO_FLAG_EVENT_ACTIVE_HIGH; |
| 55 |
} |
| 56 |
|
| 57 |
static inline bool is_gpio_event_active_low(uint32_t flags) |
| 58 |
{ |
| 59 |
return (flags & GPIO_FLAG_EVENT_ACTIVE_MASK) == GPIO_FLAG_EVENT_ACTIVE_LOW; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
void gpio_configure_pads_with_override(const struct soc_amd_gpio *base_cfg, |
| 74 |
size_t base_num_pads, |
| 75 |
const struct soc_amd_gpio *override_cfg, |
| 76 |
size_t override_num_pads); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size); |
| 87 |
|
| 88 |
int gpio_interrupt_status(gpio_t gpio); |
| 89 |
|
| 90 |
void soc_get_gpio_event_table(const struct soc_amd_event **table, size_t *items); |
| 91 |
|
| 92 |
void gpio_save_pin_registers(gpio_t gpio, struct soc_amd_gpio_register_save *save); |
| 93 |
void gpio_restore_pin_registers(gpio_t gpio, struct soc_amd_gpio_register_save *save); |
| 94 |
|
| 95 |
|
| 96 |
gpio_t cr50_override_gpio(gpio_t irq); |
| 97 |
|
| 98 |
#endif |