arm64: rockchip: rk_pinctrl: Add bias parsing based on the SoC type
Not all rockchip have the same value for pullup/pulldown so add a function per SoC and call the right one to have the proper value. MFC after: 3 days
This commit is contained in:
parent
a88611b67b
commit
064486c05f
@ -100,6 +100,7 @@ struct rk_pinctrl_conf {
|
||||
uint32_t ngpio_bank;
|
||||
uint32_t (*get_pd_offset)(struct rk_pinctrl_softc *, uint32_t);
|
||||
struct syscon *(*get_syscon)(struct rk_pinctrl_softc *, uint32_t);
|
||||
int (*parse_bias)(phandle_t node);
|
||||
};
|
||||
|
||||
struct rk_pinctrl_softc {
|
||||
@ -370,6 +371,19 @@ rk3288_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank)
|
||||
return (sc->grf);
|
||||
}
|
||||
|
||||
static int
|
||||
rk3288_parse_bias(phandle_t node)
|
||||
{
|
||||
if (OF_hasprop(node, "bias-disable"))
|
||||
return (0);
|
||||
if (OF_hasprop(node, "bias-pull-up"))
|
||||
return (1);
|
||||
if (OF_hasprop(node, "bias-pull-down"))
|
||||
return (2);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct rk_pinctrl_conf rk3288_conf = {
|
||||
.iomux_conf = rk3288_iomux_bank,
|
||||
.iomux_nbanks = nitems(rk3288_iomux_bank),
|
||||
@ -381,6 +395,7 @@ struct rk_pinctrl_conf rk3288_conf = {
|
||||
.ngpio_bank = nitems(rk3288_gpio_bank),
|
||||
.get_pd_offset = rk3288_get_pd_offset,
|
||||
.get_syscon = rk3288_get_syscon,
|
||||
.parse_bias = rk3288_parse_bias,
|
||||
};
|
||||
|
||||
static struct rk_pinctrl_gpio rk3328_gpio_bank[] = {
|
||||
@ -524,6 +539,7 @@ struct rk_pinctrl_conf rk3328_conf = {
|
||||
.ngpio_bank = nitems(rk3328_gpio_bank),
|
||||
.get_pd_offset = rk3328_get_pd_offset,
|
||||
.get_syscon = rk3328_get_syscon,
|
||||
.parse_bias = rk3288_parse_bias,
|
||||
};
|
||||
|
||||
static struct rk_pinctrl_gpio rk3399_gpio_bank[] = {
|
||||
@ -611,12 +627,28 @@ rk3399_get_pd_offset(struct rk_pinctrl_softc *sc, uint32_t bank)
|
||||
static struct syscon *
|
||||
rk3399_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank)
|
||||
{
|
||||
if (bank < 2)
|
||||
if (bank < 2) {
|
||||
device_printf(sc->dev, "%s: Using PMU GRF\n", __func__);
|
||||
return (sc->pmu);
|
||||
}
|
||||
|
||||
device_printf(sc->dev, "%s: Using GRF\n", __func__);
|
||||
return (sc->grf);
|
||||
}
|
||||
|
||||
static int
|
||||
rk3399_parse_bias(phandle_t node)
|
||||
{
|
||||
if (OF_hasprop(node, "bias-disable"))
|
||||
return (0);
|
||||
if (OF_hasprop(node, "bias-pull-up"))
|
||||
return (3);
|
||||
if (OF_hasprop(node, "bias-pull-down"))
|
||||
return (1);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct rk_pinctrl_conf rk3399_conf = {
|
||||
.iomux_conf = rk3399_iomux_bank,
|
||||
.iomux_nbanks = nitems(rk3399_iomux_bank),
|
||||
@ -628,6 +660,7 @@ struct rk_pinctrl_conf rk3399_conf = {
|
||||
.ngpio_bank = nitems(rk3399_gpio_bank),
|
||||
.get_pd_offset = rk3399_get_pd_offset,
|
||||
.get_syscon = rk3399_get_syscon,
|
||||
.parse_bias = rk3399_parse_bias,
|
||||
};
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
@ -637,19 +670,6 @@ static struct ofw_compat_data compat_data[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static int
|
||||
rk_pinctrl_parse_bias(phandle_t node)
|
||||
{
|
||||
if (OF_hasprop(node, "bias-disable"))
|
||||
return (0);
|
||||
if (OF_hasprop(node, "bias-pull-up"))
|
||||
return (1);
|
||||
if (OF_hasprop(node, "bias-pull-down"))
|
||||
return (2);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
rk_pinctrl_parse_drive(struct rk_pinctrl_softc *sc, phandle_t node,
|
||||
uint32_t bank, uint32_t subbank, uint32_t *drive, uint32_t *offset)
|
||||
@ -842,7 +862,7 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, uint32_t *pindata)
|
||||
SYSCON_MODIFY_4(syscon, reg, mask, function << bit | (mask << 16));
|
||||
|
||||
/* Pull-Up/Down */
|
||||
bias = rk_pinctrl_parse_bias(pin_conf);
|
||||
bias = sc->conf->parse_bias(pin_conf);
|
||||
if (bias >= 0) {
|
||||
reg = sc->conf->get_pd_offset(sc, bank);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user