diff options
author | Quentin Schulz <quentin.schulz@free-electrons.com> | 2017-12-05 09:46:46 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-12-07 04:08:12 -0500 |
commit | e1190083b89bd0d53c83b647ff313d9f004c6772 (patch) | |
tree | 7526e7e9f2ddfdc5e79b3a7cd0ec952db8f44d12 | |
parent | a0a4b4c2420e0af6171a2be1965bdd983d35953c (diff) |
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: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio-axp209.txt | 13 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-axp209.c | 35 |
2 files changed, 39 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt index 0d77597c3f92..fc42b2caa06d 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt | |||
@@ -9,7 +9,9 @@ Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt | |||
9 | This driver employs the per-pin muxing pattern. | 9 | This driver employs the per-pin muxing pattern. |
10 | 10 | ||
11 | Required properties: | 11 | Required properties: |
12 | - compatible: Should be "x-powers,axp209-gpio" | 12 | - compatible: Should be one of: |
13 | - "x-powers,axp209-gpio" | ||
14 | - "x-powers,axp813-gpio" | ||
13 | - #gpio-cells: Should be two. The first cell is the pin number and the | 15 | - #gpio-cells: Should be two. The first cell is the pin number and the |
14 | second is the GPIO flags. | 16 | second is the GPIO flags. |
15 | - gpio-controller: Marks the device node as a GPIO controller. | 17 | - gpio-controller: Marks the device node as a GPIO controller. |
@@ -57,8 +59,17 @@ GPIOs and their functions | |||
57 | Each GPIO is independent from the other (i.e. GPIO0 in gpio_in function does | 59 | Each GPIO is independent from the other (i.e. GPIO0 in gpio_in function does |
58 | not force GPIO1 and GPIO2 to be in gpio_in function as well). | 60 | not force GPIO1 and GPIO2 to be in gpio_in function as well). |
59 | 61 | ||
62 | axp209 | ||
63 | ------ | ||
60 | GPIO | Functions | 64 | GPIO | Functions |
61 | ------------------------ | 65 | ------------------------ |
62 | GPIO0 | gpio_in, gpio_out, ldo, adc | 66 | GPIO0 | gpio_in, gpio_out, ldo, adc |
63 | GPIO1 | gpio_in, gpio_out, ldo, adc | 67 | GPIO1 | gpio_in, gpio_out, ldo, adc |
64 | GPIO2 | gpio_in, gpio_out | 68 | GPIO2 | gpio_in, gpio_out |
69 | |||
70 | axp813 | ||
71 | ------ | ||
72 | GPIO | Functions | ||
73 | ------------------------ | ||
74 | GPIO0 | gpio_in, gpio_out, ldo, adc | ||
75 | GPIO1 | gpio_in, gpio_out, ldo | ||
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c index 9bb8722ba90f..22d3bb0bf927 100644 --- a/drivers/pinctrl/pinctrl-axp209.c +++ b/drivers/pinctrl/pinctrl-axp209.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mfd/axp20x.h> | 19 | #include <linux/mfd/axp20x.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_device.h> | ||
22 | #include <linux/pinctrl/pinconf-generic.h> | 23 | #include <linux/pinctrl/pinconf-generic.h> |
23 | #include <linux/pinctrl/pinctrl.h> | 24 | #include <linux/pinctrl/pinctrl.h> |
24 | #include <linux/pinctrl/pinmux.h> | 25 | #include <linux/pinctrl/pinmux.h> |
@@ -41,6 +42,8 @@ | |||
41 | #define AXP20X_MUX_GPIO_IN BIT(1) | 42 | #define AXP20X_MUX_GPIO_IN BIT(1) |
42 | #define AXP20X_MUX_ADC BIT(2) | 43 | #define AXP20X_MUX_ADC BIT(2) |
43 | 44 | ||
45 | #define AXP813_MUX_ADC (BIT(2) | BIT(0)) | ||
46 | |||
44 | struct axp20x_pctrl_desc { | 47 | struct axp20x_pctrl_desc { |
45 | const struct pinctrl_pin_desc *pins; | 48 | const struct pinctrl_pin_desc *pins; |
46 | unsigned int npins; | 49 | unsigned int npins; |
@@ -74,6 +77,11 @@ static const struct pinctrl_pin_desc axp209_pins[] = { | |||
74 | PINCTRL_PIN(2, "GPIO2"), | 77 | PINCTRL_PIN(2, "GPIO2"), |
75 | }; | 78 | }; |
76 | 79 | ||
80 | static const struct pinctrl_pin_desc axp813_pins[] = { | ||
81 | PINCTRL_PIN(0, "GPIO0"), | ||
82 | PINCTRL_PIN(1, "GPIO1"), | ||
83 | }; | ||
84 | |||
77 | static const struct axp20x_pctrl_desc axp20x_data = { | 85 | static const struct axp20x_pctrl_desc axp20x_data = { |
78 | .pins = axp209_pins, | 86 | .pins = axp209_pins, |
79 | .npins = ARRAY_SIZE(axp209_pins), | 87 | .npins = ARRAY_SIZE(axp209_pins), |
@@ -83,6 +91,15 @@ static const struct axp20x_pctrl_desc axp20x_data = { | |||
83 | .adc_mux = AXP20X_MUX_ADC, | 91 | .adc_mux = AXP20X_MUX_ADC, |
84 | }; | 92 | }; |
85 | 93 | ||
94 | static const struct axp20x_pctrl_desc axp813_data = { | ||
95 | .pins = axp813_pins, | ||
96 | .npins = ARRAY_SIZE(axp813_pins), | ||
97 | .ldo_mask = BIT(0) | BIT(1), | ||
98 | .adc_mask = BIT(0), | ||
99 | .gpio_status_offset = 0, | ||
100 | .adc_mux = AXP813_MUX_ADC, | ||
101 | }; | ||
102 | |||
86 | static int axp20x_gpio_get_reg(unsigned int offset) | 103 | static int axp20x_gpio_get_reg(unsigned int offset) |
87 | { | 104 | { |
88 | switch (offset) { | 105 | switch (offset) { |
@@ -357,10 +374,18 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev) | |||
357 | pctl->desc->pins); | 374 | pctl->desc->pins); |
358 | } | 375 | } |
359 | 376 | ||
377 | static const struct of_device_id axp20x_pctl_match[] = { | ||
378 | { .compatible = "x-powers,axp209-gpio", .data = &axp20x_data, }, | ||
379 | { .compatible = "x-powers,axp813-gpio", .data = &axp813_data, }, | ||
380 | { } | ||
381 | }; | ||
382 | MODULE_DEVICE_TABLE(of, axp20x_pctl_match); | ||
383 | |||
360 | static int axp20x_pctl_probe(struct platform_device *pdev) | 384 | static int axp20x_pctl_probe(struct platform_device *pdev) |
361 | { | 385 | { |
362 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); | 386 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); |
363 | struct axp20x_pctl *pctl; | 387 | struct axp20x_pctl *pctl; |
388 | struct device *dev = &pdev->dev; | ||
364 | struct pinctrl_desc *pctrl_desc; | 389 | struct pinctrl_desc *pctrl_desc; |
365 | int ret; | 390 | int ret; |
366 | 391 | ||
@@ -388,9 +413,9 @@ static int axp20x_pctl_probe(struct platform_device *pdev) | |||
388 | pctl->chip.set = axp20x_gpio_set; | 413 | pctl->chip.set = axp20x_gpio_set; |
389 | pctl->chip.direction_input = axp20x_gpio_input; | 414 | pctl->chip.direction_input = axp20x_gpio_input; |
390 | pctl->chip.direction_output = axp20x_gpio_output; | 415 | pctl->chip.direction_output = axp20x_gpio_output; |
391 | pctl->chip.ngpio = 3; | 416 | pctl->chip.ngpio = pctl->desc->npins; |
392 | 417 | ||
393 | pctl->desc = &axp20x_data; | 418 | pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev); |
394 | pctl->regmap = axp20x->regmap; | 419 | pctl->regmap = axp20x->regmap; |
395 | pctl->dev = &pdev->dev; | 420 | pctl->dev = &pdev->dev; |
396 | 421 | ||
@@ -435,12 +460,6 @@ static int axp20x_pctl_probe(struct platform_device *pdev) | |||
435 | return 0; | 460 | return 0; |
436 | } | 461 | } |
437 | 462 | ||
438 | static const struct of_device_id axp20x_pctl_match[] = { | ||
439 | { .compatible = "x-powers,axp209-gpio" }, | ||
440 | { } | ||
441 | }; | ||
442 | MODULE_DEVICE_TABLE(of, axp20x_pctl_match); | ||
443 | |||
444 | static struct platform_driver axp20x_pctl_driver = { | 463 | static struct platform_driver axp20x_pctl_driver = { |
445 | .probe = axp20x_pctl_probe, | 464 | .probe = axp20x_pctl_probe, |
446 | .driver = { | 465 | .driver = { |