| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <soc/addressmap.h> |
| 5 |
#include <soc/gpio.h> |
| 6 |
#include <soc/gpio_eint_v2.h> |
| 7 |
|
| 8 |
void gpio_calc_eint_pos_bit(gpio_t gpio, u32 *pos, u32 *bit) |
| 9 |
{ |
| 10 |
uint32_t idx = gpio.id; |
| 11 |
|
| 12 |
*pos = 0; |
| 13 |
*bit = 0; |
| 14 |
|
| 15 |
if (idx >= eint_data_len) |
| 16 |
return; |
| 17 |
|
| 18 |
uint8_t index = eint_data[idx].index; |
| 19 |
|
| 20 |
*pos = index / MAX_EINT_REG_BITS; |
| 21 |
*bit = index % MAX_EINT_REG_BITS; |
| 22 |
} |
| 23 |
|
| 24 |
struct eint_regs *gpio_get_eint_reg(gpio_t gpio) |
| 25 |
{ |
| 26 |
uint32_t idx = gpio.id; |
| 27 |
uintptr_t addr; |
| 28 |
|
| 29 |
if (idx >= eint_data_len) |
| 30 |
return NULL; |
| 31 |
|
| 32 |
switch (eint_data[idx].instance) { |
| 33 |
case EINT_E: |
| 34 |
addr = EINT_E_BASE; |
| 35 |
break; |
| 36 |
case EINT_S: |
| 37 |
addr = EINT_S_BASE; |
| 38 |
break; |
| 39 |
case EINT_W: |
| 40 |
addr = EINT_W_BASE; |
| 41 |
break; |
| 42 |
case EINT_N: |
| 43 |
addr = EINT_N_BASE; |
| 44 |
break; |
| 45 |
case EINT_C: |
| 46 |
addr = EINT_C_BASE; |
| 47 |
break; |
| 48 |
default: |
| 49 |
printk(BIOS_ERR, "%s: Failed to look up a valid EINT base for %d\n", |
| 50 |
__func__, idx); |
| 51 |
return NULL; |
| 52 |
} |
| 53 |
|
| 54 |
return (void *)addr; |
| 55 |
} |