Commit e1190083 authored by Quentin Schulz's avatar Quentin Schulz Committed by Linus Walleij

pinctrl: axp209: add support for AXP813 GPIOs

The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO
regulator.

Moreover, the status bit of the GPIOs when in input mode is not offset
by 4 unlike the AXP209.
Signed-off-by: default avatarQuentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent a0a4b4c2
...@@ -9,7 +9,9 @@ Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt ...@@ -9,7 +9,9 @@ Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
This driver employs the per-pin muxing pattern. This driver employs the per-pin muxing pattern.
Required properties: Required properties:
- compatible: Should be "x-powers,axp209-gpio" - compatible: Should be one of:
- "x-powers,axp209-gpio"
- "x-powers,axp813-gpio"
- #gpio-cells: Should be two. The first cell is the pin number and the - #gpio-cells: Should be two. The first cell is the pin number and the
second is the GPIO flags. second is the GPIO flags.
- gpio-controller: Marks the device node as a GPIO controller. - gpio-controller: Marks the device node as a GPIO controller.
...@@ -57,8 +59,17 @@ GPIOs and their functions ...@@ -57,8 +59,17 @@ GPIOs and their functions
Each GPIO is independent from the other (i.e. GPIO0 in gpio_in function does Each GPIO is independent from the other (i.e. GPIO0 in gpio_in function does
not force GPIO1 and GPIO2 to be in gpio_in function as well). not force GPIO1 and GPIO2 to be in gpio_in function as well).
axp209
------
GPIO | Functions GPIO | Functions
------------------------ ------------------------
GPIO0 | gpio_in, gpio_out, ldo, adc GPIO0 | gpio_in, gpio_out, ldo, adc
GPIO1 | gpio_in, gpio_out, ldo, adc GPIO1 | gpio_in, gpio_out, ldo, adc
GPIO2 | gpio_in, gpio_out GPIO2 | gpio_in, gpio_out
axp813
------
GPIO | Functions
------------------------
GPIO0 | gpio_in, gpio_out, ldo, adc
GPIO1 | gpio_in, gpio_out, ldo
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/mfd/axp20x.h> #include <linux/mfd/axp20x.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinconf-generic.h> #include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h> #include <linux/pinctrl/pinmux.h>
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
#define AXP20X_MUX_GPIO_IN BIT(1) #define AXP20X_MUX_GPIO_IN BIT(1)
#define AXP20X_MUX_ADC BIT(2) #define AXP20X_MUX_ADC BIT(2)
#define AXP813_MUX_ADC (BIT(2) | BIT(0))
struct axp20x_pctrl_desc { struct axp20x_pctrl_desc {
const struct pinctrl_pin_desc *pins; const struct pinctrl_pin_desc *pins;
unsigned int npins; unsigned int npins;
...@@ -74,6 +77,11 @@ static const struct pinctrl_pin_desc axp209_pins[] = { ...@@ -74,6 +77,11 @@ static const struct pinctrl_pin_desc axp209_pins[] = {
PINCTRL_PIN(2, "GPIO2"), PINCTRL_PIN(2, "GPIO2"),
}; };
static const struct pinctrl_pin_desc axp813_pins[] = {
PINCTRL_PIN(0, "GPIO0"),
PINCTRL_PIN(1, "GPIO1"),
};
static const struct axp20x_pctrl_desc axp20x_data = { static const struct axp20x_pctrl_desc axp20x_data = {
.pins = axp209_pins, .pins = axp209_pins,
.npins = ARRAY_SIZE(axp209_pins), .npins = ARRAY_SIZE(axp209_pins),
...@@ -83,6 +91,15 @@ static const struct axp20x_pctrl_desc axp20x_data = { ...@@ -83,6 +91,15 @@ static const struct axp20x_pctrl_desc axp20x_data = {
.adc_mux = AXP20X_MUX_ADC, .adc_mux = AXP20X_MUX_ADC,
}; };
static const struct axp20x_pctrl_desc axp813_data = {
.pins = axp813_pins,
.npins = ARRAY_SIZE(axp813_pins),
.ldo_mask = BIT(0) | BIT(1),
.adc_mask = BIT(0),
.gpio_status_offset = 0,
.adc_mux = AXP813_MUX_ADC,
};
static int axp20x_gpio_get_reg(unsigned int offset) static int axp20x_gpio_get_reg(unsigned int offset)
{ {
switch (offset) { switch (offset) {
...@@ -357,10 +374,18 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev) ...@@ -357,10 +374,18 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev)
pctl->desc->pins); pctl->desc->pins);
} }
static const struct of_device_id axp20x_pctl_match[] = {
{ .compatible = "x-powers,axp209-gpio", .data = &axp20x_data, },
{ .compatible = "x-powers,axp813-gpio", .data = &axp813_data, },
{ }
};
MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
static int axp20x_pctl_probe(struct platform_device *pdev) static int axp20x_pctl_probe(struct platform_device *pdev)
{ {
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct axp20x_pctl *pctl; struct axp20x_pctl *pctl;
struct device *dev = &pdev->dev;
struct pinctrl_desc *pctrl_desc; struct pinctrl_desc *pctrl_desc;
int ret; int ret;
...@@ -388,9 +413,9 @@ static int axp20x_pctl_probe(struct platform_device *pdev) ...@@ -388,9 +413,9 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
pctl->chip.set = axp20x_gpio_set; pctl->chip.set = axp20x_gpio_set;
pctl->chip.direction_input = axp20x_gpio_input; pctl->chip.direction_input = axp20x_gpio_input;
pctl->chip.direction_output = axp20x_gpio_output; pctl->chip.direction_output = axp20x_gpio_output;
pctl->chip.ngpio = 3; pctl->chip.ngpio = pctl->desc->npins;
pctl->desc = &axp20x_data; pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
pctl->regmap = axp20x->regmap; pctl->regmap = axp20x->regmap;
pctl->dev = &pdev->dev; pctl->dev = &pdev->dev;
...@@ -435,12 +460,6 @@ static int axp20x_pctl_probe(struct platform_device *pdev) ...@@ -435,12 +460,6 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id axp20x_pctl_match[] = {
{ .compatible = "x-powers,axp209-gpio" },
{ }
};
MODULE_DEVICE_TABLE(of, axp20x_pctl_match);
static struct platform_driver axp20x_pctl_driver = { static struct platform_driver axp20x_pctl_driver = {
.probe = axp20x_pctl_probe, .probe = axp20x_pctl_probe,
.driver = { .driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment