pinctrl: rk805: Add rk816 pinctrl support

This adds support for RK816 to the exising rk805 pinctrl driver

It has a single pin which can be configured as input from a thermistor (for
instance in an attached battery) or as a gpio.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240416161237.2500037-4-knaerzche@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Alex Bee 2024-04-16 18:12:35 +02:00 committed by Lee Jones
parent e9006f81fa
commit 1bd97d64b5

View File

@ -93,6 +93,11 @@ enum rk806_pinmux_option {
RK806_PINMUX_FUN5,
};
enum rk816_pinmux_option {
RK816_PINMUX_THERMISTOR,
RK816_PINMUX_GPIO,
};
enum {
RK805_GPIO0,
RK805_GPIO1,
@ -104,6 +109,10 @@ enum {
RK806_GPIO_DVS3
};
enum {
RK816_GPIO0,
};
static const char *const rk805_gpio_groups[] = {
"gpio0",
"gpio1",
@ -115,6 +124,10 @@ static const char *const rk806_gpio_groups[] = {
"gpio_pwrctrl3",
};
static const char *const rk816_gpio_groups[] = {
"gpio0",
};
/* RK805: 2 output only GPIOs */
static const struct pinctrl_pin_desc rk805_pins_desc[] = {
PINCTRL_PIN(RK805_GPIO0, "gpio0"),
@ -128,6 +141,11 @@ static const struct pinctrl_pin_desc rk806_pins_desc[] = {
PINCTRL_PIN(RK806_GPIO_DVS3, "gpio_pwrctrl3"),
};
/* RK816 */
static const struct pinctrl_pin_desc rk816_pins_desc[] = {
PINCTRL_PIN(RK816_GPIO0, "gpio0"),
};
static const struct rk805_pin_function rk805_pin_functions[] = {
{
.name = "gpio",
@ -176,6 +194,21 @@ static const struct rk805_pin_function rk806_pin_functions[] = {
},
};
static const struct rk805_pin_function rk816_pin_functions[] = {
{
.name = "gpio",
.groups = rk816_gpio_groups,
.ngroups = ARRAY_SIZE(rk816_gpio_groups),
.mux_option = RK816_PINMUX_GPIO,
},
{
.name = "thermistor",
.groups = rk816_gpio_groups,
.ngroups = ARRAY_SIZE(rk816_gpio_groups),
.mux_option = RK816_PINMUX_THERMISTOR,
},
};
static const struct rk805_pin_group rk805_pin_groups[] = {
{
.name = "gpio0",
@ -207,6 +240,14 @@ static const struct rk805_pin_group rk806_pin_groups[] = {
}
};
static const struct rk805_pin_group rk816_pin_groups[] = {
{
.name = "gpio0",
.pins = { RK816_GPIO0 },
.npins = 1,
},
};
#define RK805_GPIO0_VAL_MSK BIT(0)
#define RK805_GPIO1_VAL_MSK BIT(1)
@ -255,6 +296,20 @@ static struct rk805_pin_config rk806_gpio_cfgs[] = {
}
};
#define RK816_FUN_MASK BIT(2)
#define RK816_VAL_MASK BIT(3)
#define RK816_DIR_MASK BIT(4)
static struct rk805_pin_config rk816_gpio_cfgs[] = {
{
.fun_reg = RK818_IO_POL_REG,
.fun_msk = RK816_FUN_MASK,
.reg = RK818_IO_POL_REG,
.val_msk = RK816_VAL_MASK,
.dir_msk = RK816_DIR_MASK,
},
};
/* generic gpio chip */
static int rk805_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
@ -439,6 +494,8 @@ static int rk805_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev,
return _rk805_pinctrl_set_mux(pctldev, offset, RK805_PINMUX_GPIO);
case RK806_ID:
return _rk805_pinctrl_set_mux(pctldev, offset, RK806_PINMUX_FUN5);
case RK816_ID:
return _rk805_pinctrl_set_mux(pctldev, offset, RK816_PINMUX_GPIO);
}
return -ENOTSUPP;
@ -588,6 +645,18 @@ static int rk805_pinctrl_probe(struct platform_device *pdev)
pci->pin_cfg = rk806_gpio_cfgs;
pci->gpio_chip.ngpio = ARRAY_SIZE(rk806_gpio_cfgs);
break;
case RK816_ID:
pci->pins = rk816_pins_desc;
pci->num_pins = ARRAY_SIZE(rk816_pins_desc);
pci->functions = rk816_pin_functions;
pci->num_functions = ARRAY_SIZE(rk816_pin_functions);
pci->groups = rk816_pin_groups;
pci->num_pin_groups = ARRAY_SIZE(rk816_pin_groups);
pci->pinctrl_desc.pins = rk816_pins_desc;
pci->pinctrl_desc.npins = ARRAY_SIZE(rk816_pins_desc);
pci->pin_cfg = rk816_gpio_cfgs;
pci->gpio_chip.ngpio = ARRAY_SIZE(rk816_gpio_cfgs);
break;
default:
dev_err(&pdev->dev, "unsupported RK805 ID %lu\n",
pci->rk808->variant);