Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/rockchip/rk_pinctrl.c
Show First 20 Lines • Show All 1,111 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
rk_pinctrl_get_flags(device_t pinctrl, device_t gpio, uint32_t pin, | rk_pinctrl_get_flags(device_t pinctrl, device_t gpio, uint32_t pin, | ||||
uint32_t *flags) | uint32_t *flags) | ||||
{ | { | ||||
struct rk_pinctrl_softc *sc; | struct rk_pinctrl_softc *sc; | ||||
struct syscon *syscon; | struct syscon *syscon; | ||||
uint32_t reg, mask, bit; | uint32_t reg, bit; | ||||
uint32_t bias; | uint32_t bias; | ||||
int bank; | int bank; | ||||
int rv = 0; | int rv = 0; | ||||
bool is_gpio; | bool is_gpio; | ||||
sc = device_get_softc(pinctrl); | sc = device_get_softc(pinctrl); | ||||
RK_PINCTRL_LOCK(sc); | RK_PINCTRL_LOCK(sc); | ||||
rv = rk_pinctrl_get_bank(sc, gpio, &bank); | rv = rk_pinctrl_get_bank(sc, gpio, &bank); | ||||
if (rv != 0) | if (rv != 0) | ||||
goto done; | goto done; | ||||
syscon = sc->conf->get_syscon(sc, bank); | syscon = sc->conf->get_syscon(sc, bank); | ||||
rv = rk_pinctrl_is_gpio_locked(sc, syscon, bank, pin, &is_gpio); | rv = rk_pinctrl_is_gpio_locked(sc, syscon, bank, pin, &is_gpio); | ||||
if (rv != 0) | if (rv != 0) | ||||
goto done; | goto done; | ||||
if (!is_gpio) { | if (!is_gpio) { | ||||
rv = EINVAL; | rv = EINVAL; | ||||
goto done; | goto done; | ||||
} | } | ||||
/* Get the pullup/pulldown configuration */ | /* Get the pullup/pulldown configuration */ | ||||
reg = sc->conf->get_pd_offset(sc, bank); | reg = sc->conf->get_pd_offset(sc, bank); | ||||
reg += bank * 0x10 + ((pin / 8) * 0x4); | reg += bank * 0x10 + ((pin / 8) * 0x4); | ||||
bit = (pin % 8) * 2; | bit = (pin % 8) * 2; | ||||
mask = (0x3 << bit) << 16; | |||||
reg = SYSCON_READ_4(syscon, reg); | reg = SYSCON_READ_4(syscon, reg); | ||||
reg = (reg >> bit) & 0x3; | reg = (reg >> bit) & 0x3; | ||||
bias = sc->conf->resolv_bias_value(bank, reg); | bias = sc->conf->resolv_bias_value(bank, reg); | ||||
*flags = bias; | *flags = bias; | ||||
done: | done: | ||||
RK_PINCTRL_UNLOCK(sc); | RK_PINCTRL_UNLOCK(sc); | ||||
return (rv); | return (rv); | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |