diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-19 15:50:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-19 15:50:56 -0400 |
commit | a37571a29eca963562ff5a9233db4a5c73c72cf9 (patch) | |
tree | ec78d4b5b905f32bc541b2faa5b89f88967cf990 | |
parent | a0d3c7c5c07cfbe00ab89438ddf82482f5a99422 (diff) | |
parent | 0d5358330c20d50e52e3e65ff07a5db8007041fc (diff) |
Merge tag 'pinctrl-v4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pin control updates from Linus Walleij:
"This kernel cycle was quite calm when it comes to pin control and
there is really just one major change, and that is the introduction of
devm_pinctrl_register() managed resources.
Apart from that linear development, details below.
Core changes:
- Add the devm_pinctrl_register() API and switch all applicable
drivers to use it, saving lots of lines of code all over the place.
New drivers:
- driver for the Broadcom NS2 SoC
- subdriver for the PXA25x SoCs
- subdriver for the AMLogic Meson GXBB SoC
Driver improvements:
- the Intel Baytrail driver now properly supports pin control
- Nomadik, Rockchip, Broadcom BCM2835 support the .get_direction()
callback in the GPIO portions
- continued development and stabilization of several SH-PFC SoC
subdrivers: r8a7795, r8a7790, r8a7794 etc"
* tag 'pinctrl-v4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: (85 commits)
Revert "pinctrl: tegra: avoid parked_reg and parked_bank"
pinctrl: meson: Fix eth_tx_en bit index
pinctrl: tegra: avoid parked_reg and parked_bank
pinctrl: tegra: Correctly check the supported configuration
pinctrl: amlogic: Add support for Amlogic Meson GXBB SoC
pinctrl: rockchip: fix pull setting error for rk3399
pinctrl: stm32: Implement .pin_config_dbg_show()
pinctrl: nomadik: hide nmk_gpio_get_mode when unused
pinctrl: ns2: rename pinctrl_utils_dt_free_map
pinctrl: at91: Merge clk_prepare and clk_enable into clk_prepare_enable
pinctrl: at91: Make at91_gpio_template const
pinctrl: baytrail: fix some error handling in debugfs
pinctrl: ns2: add pinmux driver support for Broadcom NS2 SoC
pinctrl: sirf/atlas7: trivial fix of spelling mistake on flagged
pinctrl: sh-pfc: Kill unused variable in sh_pfc_remove()
pinctrl: nomadik: implement .get_direction()
pinctrl: nomadik: use BIT() with offsets consequently
pinctrl: exynos5440: Use off-stack memory for pinctrl_gpio_range
pinctrl: zynq: Use devm_pinctrl_register() for pinctrl registration
pinctrl: u300: Use devm_pinctrl_register() for pinctrl registration
...
120 files changed, 4756 insertions, 869 deletions
diff --git a/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt index ffadb7a371f6..74e6ec0339d6 100644 --- a/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt +++ b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt | |||
@@ -72,8 +72,8 @@ Pin Configuration Node Properties: | |||
72 | 72 | ||
73 | The pin configuration parameters use the generic pinconf bindings defined in | 73 | The pin configuration parameters use the generic pinconf bindings defined in |
74 | pinctrl-bindings.txt in this directory. The supported parameters are | 74 | pinctrl-bindings.txt in this directory. The supported parameters are |
75 | bias-disable, bias-pull-up, bias-pull-down and power-source. For pins that | 75 | bias-disable, bias-pull-up, bias-pull-down, drive strength and power-source. For |
76 | have a configurable I/O voltage, the power-source value should be the | 76 | pins that have a configurable I/O voltage, the power-source value should be the |
77 | nominal I/O voltage in millivolts. | 77 | nominal I/O voltage in millivolts. |
78 | 78 | ||
79 | 79 | ||
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 73b98dfbcea4..e89f7b51f243 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -328,6 +328,8 @@ PHY | |||
328 | PINCTRL | 328 | PINCTRL |
329 | devm_pinctrl_get() | 329 | devm_pinctrl_get() |
330 | devm_pinctrl_put() | 330 | devm_pinctrl_put() |
331 | devm_pinctrl_register() | ||
332 | devm_pinctrl_unregister() | ||
331 | 333 | ||
332 | PWM | 334 | PWM |
333 | devm_pwm_get() | 335 | devm_pwm_get() |
diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 2cc74384cafa..c356223e1c9c 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig | |||
@@ -86,3 +86,16 @@ config PINCTRL_NSP_GPIO | |||
86 | The ChipcommonA GPIO controller support basic PINCONF functions such | 86 | The ChipcommonA GPIO controller support basic PINCONF functions such |
87 | as bias pull up, pull down, and drive strength configurations, when | 87 | as bias pull up, pull down, and drive strength configurations, when |
88 | these pins are muxed to GPIO. | 88 | these pins are muxed to GPIO. |
89 | |||
90 | config PINCTRL_NS2_MUX | ||
91 | bool "Broadcom Northstar2 pinmux driver" | ||
92 | depends on OF | ||
93 | depends on ARCH_BCM_IPROC || COMPILE_TEST | ||
94 | select PINMUX | ||
95 | select GENERIC_PINCONF | ||
96 | default ARM64 && ARCH_BCM_IPROC | ||
97 | help | ||
98 | Say yes here to enable the Broadcom NS2 MUX driver. | ||
99 | |||
100 | The Broadcom Northstar2 IOMUX driver supports group based IOMUX | ||
101 | configuration. | ||
diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 6148367d5e8c..3861a1c1f8ff 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile | |||
@@ -5,3 +5,4 @@ obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o | |||
5 | obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o | 5 | obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o |
6 | obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o | 6 | obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o |
7 | obj-$(CONFIG_PINCTRL_NSP_GPIO) += pinctrl-nsp-gpio.o | 7 | obj-$(CONFIG_PINCTRL_NSP_GPIO) += pinctrl-nsp-gpio.o |
8 | obj-$(CONFIG_PINCTRL_NS2_MUX) += pinctrl-ns2-mux.o | ||
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm281xx.c b/drivers/pinctrl/bcm/pinctrl-bcm281xx.c index c3c692e508e8..582f6df446e8 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm281xx.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm281xx.c | |||
@@ -1024,7 +1024,7 @@ static struct pinctrl_ops bcm281xx_pinctrl_ops = { | |||
1024 | .get_group_pins = bcm281xx_pinctrl_get_group_pins, | 1024 | .get_group_pins = bcm281xx_pinctrl_get_group_pins, |
1025 | .pin_dbg_show = bcm281xx_pinctrl_pin_dbg_show, | 1025 | .pin_dbg_show = bcm281xx_pinctrl_pin_dbg_show, |
1026 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 1026 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
1027 | .dt_free_map = pinctrl_utils_dt_free_map, | 1027 | .dt_free_map = pinctrl_utils_free_map, |
1028 | }; | 1028 | }; |
1029 | 1029 | ||
1030 | static int bcm281xx_pinctrl_get_fcns_count(struct pinctrl_dev *pctldev) | 1030 | static int bcm281xx_pinctrl_get_fcns_count(struct pinctrl_dev *pctldev) |
@@ -1422,9 +1422,7 @@ static int __init bcm281xx_pinctrl_probe(struct platform_device *pdev) | |||
1422 | bcm281xx_pinctrl_desc.pins = bcm281xx_pinctrl.pins; | 1422 | bcm281xx_pinctrl_desc.pins = bcm281xx_pinctrl.pins; |
1423 | bcm281xx_pinctrl_desc.npins = bcm281xx_pinctrl.npins; | 1423 | bcm281xx_pinctrl_desc.npins = bcm281xx_pinctrl.npins; |
1424 | 1424 | ||
1425 | pctl = pinctrl_register(&bcm281xx_pinctrl_desc, | 1425 | pctl = devm_pinctrl_register(&pdev->dev, &bcm281xx_pinctrl_desc, pdata); |
1426 | &pdev->dev, | ||
1427 | pdata); | ||
1428 | if (IS_ERR(pctl)) { | 1426 | if (IS_ERR(pctl)) { |
1429 | dev_err(&pdev->dev, "Failed to register pinctrl\n"); | 1427 | dev_err(&pdev->dev, "Failed to register pinctrl\n"); |
1430 | return PTR_ERR(pctl); | 1428 | return PTR_ERR(pctl); |
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 08b1d93da9fe..fa77165fab2c 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c | |||
@@ -342,6 +342,18 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
342 | return bcm2835_gpio_get_bit(pc, GPLEV0, offset); | 342 | return bcm2835_gpio_get_bit(pc, GPLEV0, offset); |
343 | } | 343 | } |
344 | 344 | ||
345 | static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) | ||
346 | { | ||
347 | struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); | ||
348 | enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset); | ||
349 | |||
350 | /* Alternative function doesn't clearly provide a direction */ | ||
351 | if (fsel > BCM2835_FSEL_GPIO_OUT) | ||
352 | return -EINVAL; | ||
353 | |||
354 | return (fsel == BCM2835_FSEL_GPIO_IN); | ||
355 | } | ||
356 | |||
345 | static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 357 | static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
346 | { | 358 | { |
347 | struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); | 359 | struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); |
@@ -370,6 +382,7 @@ static struct gpio_chip bcm2835_gpio_chip = { | |||
370 | .free = gpiochip_generic_free, | 382 | .free = gpiochip_generic_free, |
371 | .direction_input = bcm2835_gpio_direction_input, | 383 | .direction_input = bcm2835_gpio_direction_input, |
372 | .direction_output = bcm2835_gpio_direction_output, | 384 | .direction_output = bcm2835_gpio_direction_output, |
385 | .get_direction = bcm2835_gpio_get_direction, | ||
373 | .get = bcm2835_gpio_get, | 386 | .get = bcm2835_gpio_get, |
374 | .set = bcm2835_gpio_set, | 387 | .set = bcm2835_gpio_set, |
375 | .to_irq = bcm2835_gpio_to_irq, | 388 | .to_irq = bcm2835_gpio_to_irq, |
@@ -1027,7 +1040,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) | |||
1027 | return err; | 1040 | return err; |
1028 | } | 1041 | } |
1029 | 1042 | ||
1030 | pc->pctl_dev = pinctrl_register(&bcm2835_pinctrl_desc, dev, pc); | 1043 | pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc); |
1031 | if (IS_ERR(pc->pctl_dev)) { | 1044 | if (IS_ERR(pc->pctl_dev)) { |
1032 | gpiochip_remove(&pc->gpio_chip); | 1045 | gpiochip_remove(&pc->gpio_chip); |
1033 | return PTR_ERR(pc->pctl_dev); | 1046 | return PTR_ERR(pc->pctl_dev); |
@@ -1045,7 +1058,6 @@ static int bcm2835_pinctrl_remove(struct platform_device *pdev) | |||
1045 | { | 1058 | { |
1046 | struct bcm2835_pinctrl *pc = platform_get_drvdata(pdev); | 1059 | struct bcm2835_pinctrl *pc = platform_get_drvdata(pdev); |
1047 | 1060 | ||
1048 | pinctrl_unregister(pc->pctl_dev); | ||
1049 | gpiochip_remove(&pc->gpio_chip); | 1061 | gpiochip_remove(&pc->gpio_chip); |
1050 | 1062 | ||
1051 | return 0; | 1063 | return 0; |
diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-mux.c b/drivers/pinctrl/bcm/pinctrl-cygnus-mux.c index 9728f3db9126..d31c95701a92 100644 --- a/drivers/pinctrl/bcm/pinctrl-cygnus-mux.c +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-mux.c | |||
@@ -737,7 +737,7 @@ static const struct pinctrl_ops cygnus_pinctrl_ops = { | |||
737 | .get_group_pins = cygnus_get_group_pins, | 737 | .get_group_pins = cygnus_get_group_pins, |
738 | .pin_dbg_show = cygnus_pin_dbg_show, | 738 | .pin_dbg_show = cygnus_pin_dbg_show, |
739 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 739 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
740 | .dt_free_map = pinctrl_utils_dt_free_map, | 740 | .dt_free_map = pinctrl_utils_free_map, |
741 | }; | 741 | }; |
742 | 742 | ||
743 | static int cygnus_get_functions_count(struct pinctrl_dev *pctrl_dev) | 743 | static int cygnus_get_functions_count(struct pinctrl_dev *pctrl_dev) |
@@ -987,7 +987,7 @@ static int cygnus_pinmux_probe(struct platform_device *pdev) | |||
987 | cygnus_pinctrl_desc.pins = pins; | 987 | cygnus_pinctrl_desc.pins = pins; |
988 | cygnus_pinctrl_desc.npins = num_pins; | 988 | cygnus_pinctrl_desc.npins = num_pins; |
989 | 989 | ||
990 | pinctrl->pctl = pinctrl_register(&cygnus_pinctrl_desc, &pdev->dev, | 990 | pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &cygnus_pinctrl_desc, |
991 | pinctrl); | 991 | pinctrl); |
992 | if (IS_ERR(pinctrl->pctl)) { | 992 | if (IS_ERR(pinctrl->pctl)) { |
993 | dev_err(&pdev->dev, "unable to register Cygnus IOMUX pinctrl\n"); | 993 | dev_err(&pdev->dev, "unable to register Cygnus IOMUX pinctrl\n"); |
diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c index d530ab4b9d85..3670f5ea7a12 100644 --- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | |||
@@ -379,7 +379,7 @@ static const struct pinctrl_ops iproc_pctrl_ops = { | |||
379 | .get_groups_count = iproc_get_groups_count, | 379 | .get_groups_count = iproc_get_groups_count, |
380 | .get_group_name = iproc_get_group_name, | 380 | .get_group_name = iproc_get_group_name, |
381 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 381 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
382 | .dt_free_map = pinctrl_utils_dt_free_map, | 382 | .dt_free_map = pinctrl_utils_free_map, |
383 | }; | 383 | }; |
384 | 384 | ||
385 | static int iproc_gpio_set_pull(struct iproc_gpio *chip, unsigned gpio, | 385 | static int iproc_gpio_set_pull(struct iproc_gpio *chip, unsigned gpio, |
@@ -623,7 +623,7 @@ static int iproc_gpio_register_pinconf(struct iproc_gpio *chip) | |||
623 | pctldesc->npins = gc->ngpio; | 623 | pctldesc->npins = gc->ngpio; |
624 | pctldesc->confops = &iproc_pconf_ops; | 624 | pctldesc->confops = &iproc_pconf_ops; |
625 | 625 | ||
626 | chip->pctl = pinctrl_register(pctldesc, chip->dev, chip); | 626 | chip->pctl = devm_pinctrl_register(chip->dev, pctldesc, chip); |
627 | if (IS_ERR(chip->pctl)) { | 627 | if (IS_ERR(chip->pctl)) { |
628 | dev_err(chip->dev, "unable to register pinctrl device\n"); | 628 | dev_err(chip->dev, "unable to register pinctrl device\n"); |
629 | return PTR_ERR(chip->pctl); | 629 | return PTR_ERR(chip->pctl); |
@@ -632,11 +632,6 @@ static int iproc_gpio_register_pinconf(struct iproc_gpio *chip) | |||
632 | return 0; | 632 | return 0; |
633 | } | 633 | } |
634 | 634 | ||
635 | static void iproc_gpio_unregister_pinconf(struct iproc_gpio *chip) | ||
636 | { | ||
637 | pinctrl_unregister(chip->pctl); | ||
638 | } | ||
639 | |||
640 | static const struct of_device_id iproc_gpio_of_match[] = { | 635 | static const struct of_device_id iproc_gpio_of_match[] = { |
641 | { .compatible = "brcm,cygnus-ccm-gpio" }, | 636 | { .compatible = "brcm,cygnus-ccm-gpio" }, |
642 | { .compatible = "brcm,cygnus-asiu-gpio" }, | 637 | { .compatible = "brcm,cygnus-asiu-gpio" }, |
@@ -720,7 +715,7 @@ static int iproc_gpio_probe(struct platform_device *pdev) | |||
720 | handle_simple_irq, IRQ_TYPE_NONE); | 715 | handle_simple_irq, IRQ_TYPE_NONE); |
721 | if (ret) { | 716 | if (ret) { |
722 | dev_err(dev, "no GPIO irqchip\n"); | 717 | dev_err(dev, "no GPIO irqchip\n"); |
723 | goto err_unregister_pinconf; | 718 | goto err_rm_gpiochip; |
724 | } | 719 | } |
725 | 720 | ||
726 | gpiochip_set_chained_irqchip(gc, &iproc_gpio_irq_chip, irq, | 721 | gpiochip_set_chained_irqchip(gc, &iproc_gpio_irq_chip, irq, |
@@ -729,9 +724,6 @@ static int iproc_gpio_probe(struct platform_device *pdev) | |||
729 | 724 | ||
730 | return 0; | 725 | return 0; |
731 | 726 | ||
732 | err_unregister_pinconf: | ||
733 | iproc_gpio_unregister_pinconf(chip); | ||
734 | |||
735 | err_rm_gpiochip: | 727 | err_rm_gpiochip: |
736 | gpiochip_remove(gc); | 728 | gpiochip_remove(gc); |
737 | 729 | ||
diff --git a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c new file mode 100644 index 000000000000..3fefd14acc3e --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c | |||
@@ -0,0 +1,1117 @@ | |||
1 | /* Copyright (C) 2016 Broadcom Corporation | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of the GNU General Public License as | ||
5 | * published by the Free Software Foundation version 2. | ||
6 | * | ||
7 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
8 | * kind, whether express or implied; without even the implied warranty | ||
9 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * This file contains the Northstar2 IOMUX driver that supports group | ||
13 | * based PINMUX configuration. The PWM is functional only when the | ||
14 | * corresponding mfio pin group is selected as gpio. | ||
15 | */ | ||
16 | |||
17 | #include <linux/err.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/pinctrl/pinconf.h> | ||
21 | #include <linux/pinctrl/pinconf-generic.h> | ||
22 | #include <linux/pinctrl/pinctrl.h> | ||
23 | #include <linux/pinctrl/pinmux.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/slab.h> | ||
26 | |||
27 | #include "../core.h" | ||
28 | #include "../pinctrl-utils.h" | ||
29 | |||
30 | #define NS2_NUM_IOMUX 19 | ||
31 | #define NS2_NUM_PWM_MUX 4 | ||
32 | |||
33 | #define NS2_PIN_MUX_BASE0 0x00 | ||
34 | #define NS2_PIN_MUX_BASE1 0x01 | ||
35 | #define NS2_PIN_CONF_BASE 0x02 | ||
36 | #define NS2_MUX_PAD_FUNC1_OFFSET 0x04 | ||
37 | |||
38 | #define NS2_PIN_SRC_MASK 0x01 | ||
39 | #define NS2_PIN_PULL_MASK 0x03 | ||
40 | #define NS2_PIN_DRIVE_STRENGTH_MASK 0x07 | ||
41 | |||
42 | #define NS2_PIN_PULL_UP 0x01 | ||
43 | #define NS2_PIN_PULL_DOWN 0x02 | ||
44 | |||
45 | #define NS2_PIN_INPUT_EN_MASK 0x01 | ||
46 | |||
47 | /* | ||
48 | * Northstar2 IOMUX register description | ||
49 | * | ||
50 | * @base: base address number | ||
51 | * @offset: register offset for mux configuration of a group | ||
52 | * @shift: bit shift for mux configuration of a group | ||
53 | * @mask: mask bits | ||
54 | * @alt: alternate function to set to | ||
55 | */ | ||
56 | struct ns2_mux { | ||
57 | unsigned int base; | ||
58 | unsigned int offset; | ||
59 | unsigned int shift; | ||
60 | unsigned int mask; | ||
61 | unsigned int alt; | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * Keep track of Northstar2 IOMUX configuration and prevent double | ||
66 | * configuration | ||
67 | * | ||
68 | * @ns2_mux: Northstar2 IOMUX register description | ||
69 | * @is_configured: flag to indicate whether a mux setting has already | ||
70 | * been configured | ||
71 | */ | ||
72 | struct ns2_mux_log { | ||
73 | struct ns2_mux mux; | ||
74 | bool is_configured; | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | * Group based IOMUX configuration | ||
79 | * | ||
80 | * @name: name of the group | ||
81 | * @pins: array of pins used by this group | ||
82 | * @num_pins: total number of pins used by this group | ||
83 | * @mux: Northstar2 group based IOMUX configuration | ||
84 | */ | ||
85 | struct ns2_pin_group { | ||
86 | const char *name; | ||
87 | const unsigned int *pins; | ||
88 | const unsigned int num_pins; | ||
89 | const struct ns2_mux mux; | ||
90 | }; | ||
91 | |||
92 | /* | ||
93 | * Northstar2 mux function and supported pin groups | ||
94 | * | ||
95 | * @name: name of the function | ||
96 | * @groups: array of groups that can be supported by this function | ||
97 | * @num_groups: total number of groups that can be supported by function | ||
98 | */ | ||
99 | struct ns2_pin_function { | ||
100 | const char *name; | ||
101 | const char * const *groups; | ||
102 | const unsigned int num_groups; | ||
103 | }; | ||
104 | |||
105 | /* | ||
106 | * Northstar2 IOMUX pinctrl core | ||
107 | * | ||
108 | * @pctl: pointer to pinctrl_dev | ||
109 | * @dev: pointer to device | ||
110 | * @base0: first IOMUX register base | ||
111 | * @base1: second IOMUX register base | ||
112 | * @pinconf_base: configuration register base | ||
113 | * @groups: pointer to array of groups | ||
114 | * @num_groups: total number of groups | ||
115 | * @functions: pointer to array of functions | ||
116 | * @num_functions: total number of functions | ||
117 | * @mux_log: pointer to the array of mux logs | ||
118 | * @lock: lock to protect register access | ||
119 | */ | ||
120 | struct ns2_pinctrl { | ||
121 | struct pinctrl_dev *pctl; | ||
122 | struct device *dev; | ||
123 | void __iomem *base0; | ||
124 | void __iomem *base1; | ||
125 | void __iomem *pinconf_base; | ||
126 | |||
127 | const struct ns2_pin_group *groups; | ||
128 | unsigned int num_groups; | ||
129 | |||
130 | const struct ns2_pin_function *functions; | ||
131 | unsigned int num_functions; | ||
132 | |||
133 | struct ns2_mux_log *mux_log; | ||
134 | |||
135 | spinlock_t lock; | ||
136 | }; | ||
137 | |||
138 | /* | ||
139 | * Pin configuration info | ||
140 | * | ||
141 | * @base: base address number | ||
142 | * @offset: register offset from base | ||
143 | * @src_shift: slew rate control bit shift in the register | ||
144 | * @input_en: input enable control bit shift | ||
145 | * @pull_shift: pull-up/pull-down control bit shift in the register | ||
146 | * @drive_shift: drive strength control bit shift in the register | ||
147 | */ | ||
148 | struct ns2_pinconf { | ||
149 | unsigned int base; | ||
150 | unsigned int offset; | ||
151 | unsigned int src_shift; | ||
152 | unsigned int input_en; | ||
153 | unsigned int pull_shift; | ||
154 | unsigned int drive_shift; | ||
155 | }; | ||
156 | |||
157 | /* | ||
158 | * Description of a pin in Northstar2 | ||
159 | * | ||
160 | * @pin: pin number | ||
161 | * @name: pin name | ||
162 | * @pin_conf: pin configuration structure | ||
163 | */ | ||
164 | struct ns2_pin { | ||
165 | unsigned int pin; | ||
166 | char *name; | ||
167 | struct ns2_pinconf pin_conf; | ||
168 | }; | ||
169 | |||
170 | #define NS2_PIN_DESC(p, n, b, o, s, i, pu, d) \ | ||
171 | { \ | ||
172 | .pin = p, \ | ||
173 | .name = n, \ | ||
174 | .pin_conf = { \ | ||
175 | .base = b, \ | ||
176 | .offset = o, \ | ||
177 | .src_shift = s, \ | ||
178 | .input_en = i, \ | ||
179 | .pull_shift = pu, \ | ||
180 | .drive_shift = d, \ | ||
181 | } \ | ||
182 | } | ||
183 | |||
184 | /* | ||
185 | * List of pins in Northstar2 | ||
186 | */ | ||
187 | static struct ns2_pin ns2_pins[] = { | ||
188 | NS2_PIN_DESC(0, "mfio_0", -1, 0, 0, 0, 0, 0), | ||
189 | NS2_PIN_DESC(1, "mfio_1", -1, 0, 0, 0, 0, 0), | ||
190 | NS2_PIN_DESC(2, "mfio_2", -1, 0, 0, 0, 0, 0), | ||
191 | NS2_PIN_DESC(3, "mfio_3", -1, 0, 0, 0, 0, 0), | ||
192 | NS2_PIN_DESC(4, "mfio_4", -1, 0, 0, 0, 0, 0), | ||
193 | NS2_PIN_DESC(5, "mfio_5", -1, 0, 0, 0, 0, 0), | ||
194 | NS2_PIN_DESC(6, "mfio_6", -1, 0, 0, 0, 0, 0), | ||
195 | NS2_PIN_DESC(7, "mfio_7", -1, 0, 0, 0, 0, 0), | ||
196 | NS2_PIN_DESC(8, "mfio_8", -1, 0, 0, 0, 0, 0), | ||
197 | NS2_PIN_DESC(9, "mfio_9", -1, 0, 0, 0, 0, 0), | ||
198 | NS2_PIN_DESC(10, "mfio_10", -1, 0, 0, 0, 0, 0), | ||
199 | NS2_PIN_DESC(11, "mfio_11", -1, 0, 0, 0, 0, 0), | ||
200 | NS2_PIN_DESC(12, "mfio_12", -1, 0, 0, 0, 0, 0), | ||
201 | NS2_PIN_DESC(13, "mfio_13", -1, 0, 0, 0, 0, 0), | ||
202 | NS2_PIN_DESC(14, "mfio_14", -1, 0, 0, 0, 0, 0), | ||
203 | NS2_PIN_DESC(15, "mfio_15", -1, 0, 0, 0, 0, 0), | ||
204 | NS2_PIN_DESC(16, "mfio_16", -1, 0, 0, 0, 0, 0), | ||
205 | NS2_PIN_DESC(17, "mfio_17", -1, 0, 0, 0, 0, 0), | ||
206 | NS2_PIN_DESC(18, "mfio_18", -1, 0, 0, 0, 0, 0), | ||
207 | NS2_PIN_DESC(19, "mfio_19", -1, 0, 0, 0, 0, 0), | ||
208 | NS2_PIN_DESC(20, "mfio_20", -1, 0, 0, 0, 0, 0), | ||
209 | NS2_PIN_DESC(21, "mfio_21", -1, 0, 0, 0, 0, 0), | ||
210 | NS2_PIN_DESC(22, "mfio_22", -1, 0, 0, 0, 0, 0), | ||
211 | NS2_PIN_DESC(23, "mfio_23", -1, 0, 0, 0, 0, 0), | ||
212 | NS2_PIN_DESC(24, "mfio_24", -1, 0, 0, 0, 0, 0), | ||
213 | NS2_PIN_DESC(25, "mfio_25", -1, 0, 0, 0, 0, 0), | ||
214 | NS2_PIN_DESC(26, "mfio_26", -1, 0, 0, 0, 0, 0), | ||
215 | NS2_PIN_DESC(27, "mfio_27", -1, 0, 0, 0, 0, 0), | ||
216 | NS2_PIN_DESC(28, "mfio_28", -1, 0, 0, 0, 0, 0), | ||
217 | NS2_PIN_DESC(29, "mfio_29", -1, 0, 0, 0, 0, 0), | ||
218 | NS2_PIN_DESC(30, "mfio_30", -1, 0, 0, 0, 0, 0), | ||
219 | NS2_PIN_DESC(31, "mfio_31", -1, 0, 0, 0, 0, 0), | ||
220 | NS2_PIN_DESC(32, "mfio_32", -1, 0, 0, 0, 0, 0), | ||
221 | NS2_PIN_DESC(33, "mfio_33", -1, 0, 0, 0, 0, 0), | ||
222 | NS2_PIN_DESC(34, "mfio_34", -1, 0, 0, 0, 0, 0), | ||
223 | NS2_PIN_DESC(35, "mfio_35", -1, 0, 0, 0, 0, 0), | ||
224 | NS2_PIN_DESC(36, "mfio_36", -1, 0, 0, 0, 0, 0), | ||
225 | NS2_PIN_DESC(37, "mfio_37", -1, 0, 0, 0, 0, 0), | ||
226 | NS2_PIN_DESC(38, "mfio_38", -1, 0, 0, 0, 0, 0), | ||
227 | NS2_PIN_DESC(39, "mfio_39", -1, 0, 0, 0, 0, 0), | ||
228 | NS2_PIN_DESC(40, "mfio_40", -1, 0, 0, 0, 0, 0), | ||
229 | NS2_PIN_DESC(41, "mfio_41", -1, 0, 0, 0, 0, 0), | ||
230 | NS2_PIN_DESC(42, "mfio_42", -1, 0, 0, 0, 0, 0), | ||
231 | NS2_PIN_DESC(43, "mfio_43", -1, 0, 0, 0, 0, 0), | ||
232 | NS2_PIN_DESC(44, "mfio_44", -1, 0, 0, 0, 0, 0), | ||
233 | NS2_PIN_DESC(45, "mfio_45", -1, 0, 0, 0, 0, 0), | ||
234 | NS2_PIN_DESC(46, "mfio_46", -1, 0, 0, 0, 0, 0), | ||
235 | NS2_PIN_DESC(47, "mfio_47", -1, 0, 0, 0, 0, 0), | ||
236 | NS2_PIN_DESC(48, "mfio_48", -1, 0, 0, 0, 0, 0), | ||
237 | NS2_PIN_DESC(49, "mfio_49", -1, 0, 0, 0, 0, 0), | ||
238 | NS2_PIN_DESC(50, "mfio_50", -1, 0, 0, 0, 0, 0), | ||
239 | NS2_PIN_DESC(51, "mfio_51", -1, 0, 0, 0, 0, 0), | ||
240 | NS2_PIN_DESC(52, "mfio_52", -1, 0, 0, 0, 0, 0), | ||
241 | NS2_PIN_DESC(53, "mfio_53", -1, 0, 0, 0, 0, 0), | ||
242 | NS2_PIN_DESC(54, "mfio_54", -1, 0, 0, 0, 0, 0), | ||
243 | NS2_PIN_DESC(55, "mfio_55", -1, 0, 0, 0, 0, 0), | ||
244 | NS2_PIN_DESC(56, "mfio_56", -1, 0, 0, 0, 0, 0), | ||
245 | NS2_PIN_DESC(57, "mfio_57", -1, 0, 0, 0, 0, 0), | ||
246 | NS2_PIN_DESC(58, "mfio_58", -1, 0, 0, 0, 0, 0), | ||
247 | NS2_PIN_DESC(59, "mfio_59", -1, 0, 0, 0, 0, 0), | ||
248 | NS2_PIN_DESC(60, "mfio_60", -1, 0, 0, 0, 0, 0), | ||
249 | NS2_PIN_DESC(61, "mfio_61", -1, 0, 0, 0, 0, 0), | ||
250 | NS2_PIN_DESC(62, "mfio_62", -1, 0, 0, 0, 0, 0), | ||
251 | NS2_PIN_DESC(63, "qspi_wp", 2, 0x0, 31, 30, 27, 24), | ||
252 | NS2_PIN_DESC(64, "qspi_hold", 2, 0x0, 23, 22, 19, 16), | ||
253 | NS2_PIN_DESC(65, "qspi_cs", 2, 0x0, 15, 14, 11, 8), | ||
254 | NS2_PIN_DESC(66, "qspi_sck", 2, 0x0, 7, 6, 3, 0), | ||
255 | NS2_PIN_DESC(67, "uart3_sin", 2, 0x04, 31, 30, 27, 24), | ||
256 | NS2_PIN_DESC(68, "uart3_sout", 2, 0x04, 23, 22, 19, 16), | ||
257 | NS2_PIN_DESC(69, "qspi_mosi", 2, 0x04, 15, 14, 11, 8), | ||
258 | NS2_PIN_DESC(70, "qspi_miso", 2, 0x04, 7, 6, 3, 0), | ||
259 | NS2_PIN_DESC(71, "spi0_fss", 2, 0x08, 31, 30, 27, 24), | ||
260 | NS2_PIN_DESC(72, "spi0_rxd", 2, 0x08, 23, 22, 19, 16), | ||
261 | NS2_PIN_DESC(73, "spi0_txd", 2, 0x08, 15, 14, 11, 8), | ||
262 | NS2_PIN_DESC(74, "spi0_sck", 2, 0x08, 7, 6, 3, 0), | ||
263 | NS2_PIN_DESC(75, "spi1_fss", 2, 0x0c, 31, 30, 27, 24), | ||
264 | NS2_PIN_DESC(76, "spi1_rxd", 2, 0x0c, 23, 22, 19, 16), | ||
265 | NS2_PIN_DESC(77, "spi1_txd", 2, 0x0c, 15, 14, 11, 8), | ||
266 | NS2_PIN_DESC(78, "spi1_sck", 2, 0x0c, 7, 6, 3, 0), | ||
267 | NS2_PIN_DESC(79, "sdio0_data7", 2, 0x10, 31, 30, 27, 24), | ||
268 | NS2_PIN_DESC(80, "sdio0_emmc_rst", 2, 0x10, 23, 22, 19, 16), | ||
269 | NS2_PIN_DESC(81, "sdio0_led_on", 2, 0x10, 15, 14, 11, 8), | ||
270 | NS2_PIN_DESC(82, "sdio0_wp", 2, 0x10, 7, 6, 3, 0), | ||
271 | NS2_PIN_DESC(83, "sdio0_data3", 2, 0x14, 31, 30, 27, 24), | ||
272 | NS2_PIN_DESC(84, "sdio0_data4", 2, 0x14, 23, 22, 19, 16), | ||
273 | NS2_PIN_DESC(85, "sdio0_data5", 2, 0x14, 15, 14, 11, 8), | ||
274 | NS2_PIN_DESC(86, "sdio0_data6", 2, 0x14, 7, 6, 3, 0), | ||
275 | NS2_PIN_DESC(87, "sdio0_cmd", 2, 0x18, 31, 30, 27, 24), | ||
276 | NS2_PIN_DESC(88, "sdio0_data0", 2, 0x18, 23, 22, 19, 16), | ||
277 | NS2_PIN_DESC(89, "sdio0_data1", 2, 0x18, 15, 14, 11, 8), | ||
278 | NS2_PIN_DESC(90, "sdio0_data2", 2, 0x18, 7, 6, 3, 0), | ||
279 | NS2_PIN_DESC(91, "sdio1_led_on", 2, 0x1c, 31, 30, 27, 24), | ||
280 | NS2_PIN_DESC(92, "sdio1_wp", 2, 0x1c, 23, 22, 19, 16), | ||
281 | NS2_PIN_DESC(93, "sdio0_cd_l", 2, 0x1c, 15, 14, 11, 8), | ||
282 | NS2_PIN_DESC(94, "sdio0_clk", 2, 0x1c, 7, 6, 3, 0), | ||
283 | NS2_PIN_DESC(95, "sdio1_data5", 2, 0x20, 31, 30, 27, 24), | ||
284 | NS2_PIN_DESC(96, "sdio1_data6", 2, 0x20, 23, 22, 19, 16), | ||
285 | NS2_PIN_DESC(97, "sdio1_data7", 2, 0x20, 15, 14, 11, 8), | ||
286 | NS2_PIN_DESC(98, "sdio1_emmc_rst", 2, 0x20, 7, 6, 3, 0), | ||
287 | NS2_PIN_DESC(99, "sdio1_data1", 2, 0x24, 31, 30, 27, 24), | ||
288 | NS2_PIN_DESC(100, "sdio1_data2", 2, 0x24, 23, 22, 19, 16), | ||
289 | NS2_PIN_DESC(101, "sdio1_data3", 2, 0x24, 15, 14, 11, 8), | ||
290 | NS2_PIN_DESC(102, "sdio1_data4", 2, 0x24, 7, 6, 3, 0), | ||
291 | NS2_PIN_DESC(103, "sdio1_cd_l", 2, 0x28, 31, 30, 27, 24), | ||
292 | NS2_PIN_DESC(104, "sdio1_clk", 2, 0x28, 23, 22, 19, 16), | ||
293 | NS2_PIN_DESC(105, "sdio1_cmd", 2, 0x28, 15, 14, 11, 8), | ||
294 | NS2_PIN_DESC(106, "sdio1_data0", 2, 0x28, 7, 6, 3, 0), | ||
295 | NS2_PIN_DESC(107, "ext_mdio_0", 2, 0x2c, 15, 14, 11, 8), | ||
296 | NS2_PIN_DESC(108, "ext_mdc_0", 2, 0x2c, 7, 6, 3, 0), | ||
297 | NS2_PIN_DESC(109, "usb3_p1_vbus_ppc", 2, 0x34, 31, 30, 27, 24), | ||
298 | NS2_PIN_DESC(110, "usb3_p1_overcurrent", 2, 0x34, 23, 22, 19, 16), | ||
299 | NS2_PIN_DESC(111, "usb3_p0_vbus_ppc", 2, 0x34, 15, 14, 11, 8), | ||
300 | NS2_PIN_DESC(112, "usb3_p0_overcurrent", 2, 0x34, 7, 6, 3, 0), | ||
301 | NS2_PIN_DESC(113, "usb2_presence_indication", 2, 0x38, 31, 30, 27, 24), | ||
302 | NS2_PIN_DESC(114, "usb2_vbus_present", 2, 0x38, 23, 22, 19, 16), | ||
303 | NS2_PIN_DESC(115, "usb2_vbus_ppc", 2, 0x38, 15, 14, 11, 8), | ||
304 | NS2_PIN_DESC(116, "usb2_overcurrent", 2, 0x38, 7, 6, 3, 0), | ||
305 | NS2_PIN_DESC(117, "sata_led1", 2, 0x3c, 15, 14, 11, 8), | ||
306 | NS2_PIN_DESC(118, "sata_led0", 2, 0x3c, 7, 6, 3, 0), | ||
307 | }; | ||
308 | |||
309 | /* | ||
310 | * List of groups of pins | ||
311 | */ | ||
312 | |||
313 | static const unsigned int nand_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, | ||
314 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}; | ||
315 | static const unsigned int nor_data_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | ||
316 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; | ||
317 | |||
318 | static const unsigned int gpio_0_1_pins[] = {24, 25}; | ||
319 | static const unsigned int pwm_0_pins[] = {24}; | ||
320 | static const unsigned int pwm_1_pins[] = {25}; | ||
321 | |||
322 | static const unsigned int uart1_ext_clk_pins[] = {26}; | ||
323 | static const unsigned int nor_adv_pins[] = {26}; | ||
324 | |||
325 | static const unsigned int gpio_2_5_pins[] = {27, 28, 29, 30}; | ||
326 | static const unsigned int pcie_ab1_clk_wak_pins[] = {27, 28, 29, 30}; | ||
327 | static const unsigned int nor_addr_0_3_pins[] = {27, 28, 29, 30}; | ||
328 | static const unsigned int pwm_2_pins[] = {27}; | ||
329 | static const unsigned int pwm_3_pins[] = {28}; | ||
330 | |||
331 | static const unsigned int gpio_6_7_pins[] = {31, 32}; | ||
332 | static const unsigned int pcie_a3_clk_wak_pins[] = {31, 32}; | ||
333 | static const unsigned int nor_addr_4_5_pins[] = {31, 32}; | ||
334 | |||
335 | static const unsigned int gpio_8_9_pins[] = {33, 34}; | ||
336 | static const unsigned int pcie_b3_clk_wak_pins[] = {33, 34}; | ||
337 | static const unsigned int nor_addr_6_7_pins[] = {33, 34}; | ||
338 | |||
339 | static const unsigned int gpio_10_11_pins[] = {35, 36}; | ||
340 | static const unsigned int pcie_b2_clk_wak_pins[] = {35, 36}; | ||
341 | static const unsigned int nor_addr_8_9_pins[] = {35, 36}; | ||
342 | |||
343 | static const unsigned int gpio_12_13_pins[] = {37, 38}; | ||
344 | static const unsigned int pcie_a2_clk_wak_pins[] = {37, 38}; | ||
345 | static const unsigned int nor_addr_10_11_pins[] = {37, 38}; | ||
346 | |||
347 | static const unsigned int gpio_14_17_pins[] = {39, 40, 41, 42}; | ||
348 | static const unsigned int uart0_modem_pins[] = {39, 40, 41, 42}; | ||
349 | static const unsigned int nor_addr_12_15_pins[] = {39, 40, 41, 42}; | ||
350 | |||
351 | static const unsigned int gpio_18_19_pins[] = {43, 44}; | ||
352 | static const unsigned int uart0_rts_cts_pins[] = {43, 44}; | ||
353 | |||
354 | static const unsigned int gpio_20_21_pins[] = {45, 46}; | ||
355 | static const unsigned int uart0_in_out_pins[] = {45, 46}; | ||
356 | |||
357 | static const unsigned int gpio_22_23_pins[] = {47, 48}; | ||
358 | static const unsigned int uart1_dcd_dsr_pins[] = {47, 48}; | ||
359 | |||
360 | static const unsigned int gpio_24_25_pins[] = {49, 50}; | ||
361 | static const unsigned int uart1_ri_dtr_pins[] = {49, 50}; | ||
362 | |||
363 | static const unsigned int gpio_26_27_pins[] = {51, 52}; | ||
364 | static const unsigned int uart1_rts_cts_pins[] = {51, 52}; | ||
365 | |||
366 | static const unsigned int gpio_28_29_pins[] = {53, 54}; | ||
367 | static const unsigned int uart1_in_out_pins[] = {53, 54}; | ||
368 | |||
369 | static const unsigned int gpio_30_31_pins[] = {55, 56}; | ||
370 | static const unsigned int uart2_rts_cts_pins[] = {55, 56}; | ||
371 | |||
372 | #define NS2_PIN_GROUP(group_name, ba, off, sh, ma, al) \ | ||
373 | { \ | ||
374 | .name = __stringify(group_name) "_grp", \ | ||
375 | .pins = group_name ## _pins, \ | ||
376 | .num_pins = ARRAY_SIZE(group_name ## _pins), \ | ||
377 | .mux = { \ | ||
378 | .base = ba, \ | ||
379 | .offset = off, \ | ||
380 | .shift = sh, \ | ||
381 | .mask = ma, \ | ||
382 | .alt = al, \ | ||
383 | } \ | ||
384 | } | ||
385 | |||
386 | /* | ||
387 | * List of Northstar2 pin groups | ||
388 | */ | ||
389 | static const struct ns2_pin_group ns2_pin_groups[] = { | ||
390 | NS2_PIN_GROUP(nand, 0, 0, 31, 1, 0), | ||
391 | NS2_PIN_GROUP(nor_data, 0, 0, 31, 1, 1), | ||
392 | NS2_PIN_GROUP(gpio_0_1, 0, 0, 31, 1, 0), | ||
393 | |||
394 | NS2_PIN_GROUP(uart1_ext_clk, 0, 4, 30, 3, 1), | ||
395 | NS2_PIN_GROUP(nor_adv, 0, 4, 30, 3, 2), | ||
396 | |||
397 | NS2_PIN_GROUP(gpio_2_5, 0, 4, 28, 3, 0), | ||
398 | NS2_PIN_GROUP(pcie_ab1_clk_wak, 0, 4, 28, 3, 1), | ||
399 | NS2_PIN_GROUP(nor_addr_0_3, 0, 4, 28, 3, 2), | ||
400 | |||
401 | NS2_PIN_GROUP(gpio_6_7, 0, 4, 26, 3, 0), | ||
402 | NS2_PIN_GROUP(pcie_a3_clk_wak, 0, 4, 26, 3, 1), | ||
403 | NS2_PIN_GROUP(nor_addr_4_5, 0, 4, 26, 3, 2), | ||
404 | |||
405 | NS2_PIN_GROUP(gpio_8_9, 0, 4, 24, 3, 0), | ||
406 | NS2_PIN_GROUP(pcie_b3_clk_wak, 0, 4, 24, 3, 1), | ||
407 | NS2_PIN_GROUP(nor_addr_6_7, 0, 4, 24, 3, 2), | ||
408 | |||
409 | NS2_PIN_GROUP(gpio_10_11, 0, 4, 22, 3, 0), | ||
410 | NS2_PIN_GROUP(pcie_b2_clk_wak, 0, 4, 22, 3, 1), | ||
411 | NS2_PIN_GROUP(nor_addr_8_9, 0, 4, 22, 3, 2), | ||
412 | |||
413 | NS2_PIN_GROUP(gpio_12_13, 0, 4, 20, 3, 0), | ||
414 | NS2_PIN_GROUP(pcie_a2_clk_wak, 0, 4, 20, 3, 1), | ||
415 | NS2_PIN_GROUP(nor_addr_10_11, 0, 4, 20, 3, 2), | ||
416 | |||
417 | NS2_PIN_GROUP(gpio_14_17, 0, 4, 18, 3, 0), | ||
418 | NS2_PIN_GROUP(uart0_modem, 0, 4, 18, 3, 1), | ||
419 | NS2_PIN_GROUP(nor_addr_12_15, 0, 4, 18, 3, 2), | ||
420 | |||
421 | NS2_PIN_GROUP(gpio_18_19, 0, 4, 16, 3, 0), | ||
422 | NS2_PIN_GROUP(uart0_rts_cts, 0, 4, 16, 3, 1), | ||
423 | |||
424 | NS2_PIN_GROUP(gpio_20_21, 0, 4, 14, 3, 0), | ||
425 | NS2_PIN_GROUP(uart0_in_out, 0, 4, 14, 3, 1), | ||
426 | |||
427 | NS2_PIN_GROUP(gpio_22_23, 0, 4, 12, 3, 0), | ||
428 | NS2_PIN_GROUP(uart1_dcd_dsr, 0, 4, 12, 3, 1), | ||
429 | |||
430 | NS2_PIN_GROUP(gpio_24_25, 0, 4, 10, 3, 0), | ||
431 | NS2_PIN_GROUP(uart1_ri_dtr, 0, 4, 10, 3, 1), | ||
432 | |||
433 | NS2_PIN_GROUP(gpio_26_27, 0, 4, 8, 3, 0), | ||
434 | NS2_PIN_GROUP(uart1_rts_cts, 0, 4, 8, 3, 1), | ||
435 | |||
436 | NS2_PIN_GROUP(gpio_28_29, 0, 4, 6, 3, 0), | ||
437 | NS2_PIN_GROUP(uart1_in_out, 0, 4, 6, 3, 1), | ||
438 | |||
439 | NS2_PIN_GROUP(gpio_30_31, 0, 4, 4, 3, 0), | ||
440 | NS2_PIN_GROUP(uart2_rts_cts, 0, 4, 4, 3, 1), | ||
441 | |||
442 | NS2_PIN_GROUP(pwm_0, 1, 0, 0, 1, 1), | ||
443 | NS2_PIN_GROUP(pwm_1, 1, 0, 1, 1, 1), | ||
444 | NS2_PIN_GROUP(pwm_2, 1, 0, 2, 1, 1), | ||
445 | NS2_PIN_GROUP(pwm_3, 1, 0, 3, 1, 1), | ||
446 | }; | ||
447 | |||
448 | /* | ||
449 | * List of groups supported by functions | ||
450 | */ | ||
451 | |||
452 | static const char * const nand_grps[] = {"nand_grp"}; | ||
453 | |||
454 | static const char * const nor_grps[] = {"nor_data_grp", "nor_adv_grp", | ||
455 | "nor_addr_0_3_grp", "nor_addr_4_5_grp", "nor_addr_6_7_grp", | ||
456 | "nor_addr_8_9_grp", "nor_addr_10_11_grp", "nor_addr_12_15_grp"}; | ||
457 | |||
458 | static const char * const gpio_grps[] = {"gpio_0_1_grp", "gpio_2_5_grp", | ||
459 | "gpio_6_7_grp", "gpio_8_9_grp", "gpio_10_11_grp", "gpio_12_13_grp", | ||
460 | "gpio_14_17_grp", "gpio_18_19_grp", "gpio_20_21_grp", "gpio_22_23_grp", | ||
461 | "gpio_24_25_grp", "gpio_26_27_grp", "gpio_28_29_grp", | ||
462 | "gpio_30_31_grp"}; | ||
463 | |||
464 | static const char * const pcie_grps[] = {"pcie_ab1_clk_wak_grp", | ||
465 | "pcie_a3_clk_wak_grp", "pcie_b3_clk_wak_grp", "pcie_b2_clk_wak_grp", | ||
466 | "pcie_a2_clk_wak_grp"}; | ||
467 | |||
468 | static const char * const uart0_grps[] = {"uart0_modem_grp", | ||
469 | "uart0_rts_cts_grp", "uart0_in_out_grp"}; | ||
470 | |||
471 | static const char * const uart1_grps[] = {"uart1_ext_clk_grp", | ||
472 | "uart1_dcd_dsr_grp", "uart1_ri_dtr_grp", "uart1_rts_cts_grp", | ||
473 | "uart1_in_out_grp"}; | ||
474 | |||
475 | static const char * const uart2_grps[] = {"uart2_rts_cts_grp"}; | ||
476 | |||
477 | static const char * const pwm_grps[] = {"pwm_0_grp", "pwm_1_grp", | ||
478 | "pwm_2_grp", "pwm_3_grp"}; | ||
479 | |||
480 | #define NS2_PIN_FUNCTION(func) \ | ||
481 | { \ | ||
482 | .name = #func, \ | ||
483 | .groups = func ## _grps, \ | ||
484 | .num_groups = ARRAY_SIZE(func ## _grps), \ | ||
485 | } | ||
486 | |||
487 | /* | ||
488 | * List of supported functions | ||
489 | */ | ||
490 | static const struct ns2_pin_function ns2_pin_functions[] = { | ||
491 | NS2_PIN_FUNCTION(nand), | ||
492 | NS2_PIN_FUNCTION(nor), | ||
493 | NS2_PIN_FUNCTION(gpio), | ||
494 | NS2_PIN_FUNCTION(pcie), | ||
495 | NS2_PIN_FUNCTION(uart0), | ||
496 | NS2_PIN_FUNCTION(uart1), | ||
497 | NS2_PIN_FUNCTION(uart2), | ||
498 | NS2_PIN_FUNCTION(pwm), | ||
499 | }; | ||
500 | |||
501 | static int ns2_get_groups_count(struct pinctrl_dev *pctrl_dev) | ||
502 | { | ||
503 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
504 | |||
505 | return pinctrl->num_groups; | ||
506 | } | ||
507 | |||
508 | static const char *ns2_get_group_name(struct pinctrl_dev *pctrl_dev, | ||
509 | unsigned int selector) | ||
510 | { | ||
511 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
512 | |||
513 | return pinctrl->groups[selector].name; | ||
514 | } | ||
515 | |||
516 | static int ns2_get_group_pins(struct pinctrl_dev *pctrl_dev, | ||
517 | unsigned int selector, const unsigned int **pins, | ||
518 | unsigned int *num_pins) | ||
519 | { | ||
520 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
521 | |||
522 | *pins = pinctrl->groups[selector].pins; | ||
523 | *num_pins = pinctrl->groups[selector].num_pins; | ||
524 | |||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static void ns2_pin_dbg_show(struct pinctrl_dev *pctrl_dev, | ||
529 | struct seq_file *s, unsigned int offset) | ||
530 | { | ||
531 | seq_printf(s, " %s", dev_name(pctrl_dev->dev)); | ||
532 | } | ||
533 | |||
534 | static struct pinctrl_ops ns2_pinctrl_ops = { | ||
535 | .get_groups_count = ns2_get_groups_count, | ||
536 | .get_group_name = ns2_get_group_name, | ||
537 | .get_group_pins = ns2_get_group_pins, | ||
538 | .pin_dbg_show = ns2_pin_dbg_show, | ||
539 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | ||
540 | .dt_free_map = pinctrl_utils_free_map, | ||
541 | }; | ||
542 | |||
543 | static int ns2_get_functions_count(struct pinctrl_dev *pctrl_dev) | ||
544 | { | ||
545 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
546 | |||
547 | return pinctrl->num_functions; | ||
548 | } | ||
549 | |||
550 | static const char *ns2_get_function_name(struct pinctrl_dev *pctrl_dev, | ||
551 | unsigned int selector) | ||
552 | { | ||
553 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
554 | |||
555 | return pinctrl->functions[selector].name; | ||
556 | } | ||
557 | |||
558 | static int ns2_get_function_groups(struct pinctrl_dev *pctrl_dev, | ||
559 | unsigned int selector, | ||
560 | const char * const **groups, | ||
561 | unsigned int * const num_groups) | ||
562 | { | ||
563 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
564 | |||
565 | *groups = pinctrl->functions[selector].groups; | ||
566 | *num_groups = pinctrl->functions[selector].num_groups; | ||
567 | |||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | static int ns2_pinmux_set(struct ns2_pinctrl *pinctrl, | ||
572 | const struct ns2_pin_function *func, | ||
573 | const struct ns2_pin_group *grp, | ||
574 | struct ns2_mux_log *mux_log) | ||
575 | { | ||
576 | const struct ns2_mux *mux = &grp->mux; | ||
577 | int i; | ||
578 | u32 val, mask; | ||
579 | unsigned long flags; | ||
580 | void __iomem *base_address; | ||
581 | |||
582 | for (i = 0; i < NS2_NUM_IOMUX; i++) { | ||
583 | if ((mux->shift != mux_log[i].mux.shift) || | ||
584 | (mux->base != mux_log[i].mux.base) || | ||
585 | (mux->offset != mux_log[i].mux.offset)) | ||
586 | continue; | ||
587 | |||
588 | /* if this is a new configuration, just do it! */ | ||
589 | if (!mux_log[i].is_configured) | ||
590 | break; | ||
591 | |||
592 | /* | ||
593 | * IOMUX has been configured previously and one is trying to | ||
594 | * configure it to a different function | ||
595 | */ | ||
596 | if (mux_log[i].mux.alt != mux->alt) { | ||
597 | dev_err(pinctrl->dev, | ||
598 | "double configuration error detected!\n"); | ||
599 | dev_err(pinctrl->dev, "func:%s grp:%s\n", | ||
600 | func->name, grp->name); | ||
601 | return -EINVAL; | ||
602 | } | ||
603 | |||
604 | return 0; | ||
605 | } | ||
606 | if (i == NS2_NUM_IOMUX) | ||
607 | return -EINVAL; | ||
608 | |||
609 | mask = mux->mask; | ||
610 | mux_log[i].mux.alt = mux->alt; | ||
611 | mux_log[i].is_configured = true; | ||
612 | |||
613 | switch (mux->base) { | ||
614 | case NS2_PIN_MUX_BASE0: | ||
615 | base_address = pinctrl->base0; | ||
616 | break; | ||
617 | |||
618 | case NS2_PIN_MUX_BASE1: | ||
619 | base_address = pinctrl->base1; | ||
620 | break; | ||
621 | |||
622 | default: | ||
623 | return -EINVAL; | ||
624 | } | ||
625 | |||
626 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
627 | val = readl(base_address + grp->mux.offset); | ||
628 | val &= ~(mask << grp->mux.shift); | ||
629 | val |= grp->mux.alt << grp->mux.shift; | ||
630 | writel(val, (base_address + grp->mux.offset)); | ||
631 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
632 | |||
633 | return 0; | ||
634 | } | ||
635 | |||
636 | static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev, | ||
637 | unsigned int func_select, unsigned int grp_select) | ||
638 | { | ||
639 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); | ||
640 | const struct ns2_pin_function *func; | ||
641 | const struct ns2_pin_group *grp; | ||
642 | |||
643 | if (grp_select > pinctrl->num_groups || | ||
644 | func_select > pinctrl->num_functions) | ||
645 | return -EINVAL; | ||
646 | |||
647 | func = &pinctrl->functions[func_select]; | ||
648 | grp = &pinctrl->groups[grp_select]; | ||
649 | |||
650 | dev_dbg(pctrl_dev->dev, "func:%u name:%s grp:%u name:%s\n", | ||
651 | func_select, func->name, grp_select, grp->name); | ||
652 | |||
653 | dev_dbg(pctrl_dev->dev, "offset:0x%08x shift:%u alt:%u\n", | ||
654 | grp->mux.offset, grp->mux.shift, grp->mux.alt); | ||
655 | |||
656 | return ns2_pinmux_set(pinctrl, func, grp, pinctrl->mux_log); | ||
657 | } | ||
658 | |||
659 | static int ns2_pin_set_enable(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
660 | u16 enable) | ||
661 | { | ||
662 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
663 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
664 | unsigned long flags; | ||
665 | u32 val; | ||
666 | void __iomem *base_address; | ||
667 | |||
668 | base_address = pinctrl->pinconf_base; | ||
669 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
670 | val = readl(base_address + pin_data->pin_conf.offset); | ||
671 | val &= ~(NS2_PIN_SRC_MASK << pin_data->pin_conf.input_en); | ||
672 | |||
673 | if (!enable) | ||
674 | val |= NS2_PIN_INPUT_EN_MASK << pin_data->pin_conf.input_en; | ||
675 | |||
676 | writel(val, (base_address + pin_data->pin_conf.offset)); | ||
677 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
678 | |||
679 | dev_dbg(pctrldev->dev, "pin:%u set enable:%d\n", pin, enable); | ||
680 | return 0; | ||
681 | } | ||
682 | |||
683 | static int ns2_pin_get_enable(struct pinctrl_dev *pctrldev, unsigned int pin) | ||
684 | { | ||
685 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
686 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
687 | unsigned long flags; | ||
688 | int enable; | ||
689 | |||
690 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
691 | enable = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); | ||
692 | enable = (enable >> pin_data->pin_conf.input_en) & | ||
693 | NS2_PIN_INPUT_EN_MASK; | ||
694 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
695 | |||
696 | if (!enable) | ||
697 | enable = NS2_PIN_INPUT_EN_MASK; | ||
698 | else | ||
699 | enable = 0; | ||
700 | |||
701 | dev_dbg(pctrldev->dev, "pin:%u get disable:%d\n", pin, enable); | ||
702 | return enable; | ||
703 | } | ||
704 | |||
705 | static int ns2_pin_set_slew(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
706 | u16 slew) | ||
707 | { | ||
708 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
709 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
710 | unsigned long flags; | ||
711 | u32 val; | ||
712 | void __iomem *base_address; | ||
713 | |||
714 | base_address = pinctrl->pinconf_base; | ||
715 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
716 | val = readl(base_address + pin_data->pin_conf.offset); | ||
717 | val &= ~(NS2_PIN_SRC_MASK << pin_data->pin_conf.src_shift); | ||
718 | |||
719 | if (slew) | ||
720 | val |= NS2_PIN_SRC_MASK << pin_data->pin_conf.src_shift; | ||
721 | |||
722 | writel(val, (base_address + pin_data->pin_conf.offset)); | ||
723 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
724 | |||
725 | dev_dbg(pctrldev->dev, "pin:%u set slew:%d\n", pin, slew); | ||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static int ns2_pin_get_slew(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
730 | u16 *slew) | ||
731 | { | ||
732 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
733 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
734 | unsigned long flags; | ||
735 | u32 val; | ||
736 | |||
737 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
738 | val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); | ||
739 | *slew = (val >> pin_data->pin_conf.src_shift) & NS2_PIN_SRC_MASK; | ||
740 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
741 | |||
742 | dev_dbg(pctrldev->dev, "pin:%u get slew:%d\n", pin, *slew); | ||
743 | return 0; | ||
744 | } | ||
745 | |||
746 | static int ns2_pin_set_pull(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
747 | bool pull_up, bool pull_down) | ||
748 | { | ||
749 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
750 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
751 | unsigned long flags; | ||
752 | u32 val; | ||
753 | void __iomem *base_address; | ||
754 | |||
755 | base_address = pinctrl->pinconf_base; | ||
756 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
757 | val = readl(base_address + pin_data->pin_conf.offset); | ||
758 | val &= ~(NS2_PIN_PULL_MASK << pin_data->pin_conf.pull_shift); | ||
759 | |||
760 | if (pull_up == true) | ||
761 | val |= NS2_PIN_PULL_UP << pin_data->pin_conf.pull_shift; | ||
762 | if (pull_down == true) | ||
763 | val |= NS2_PIN_PULL_DOWN << pin_data->pin_conf.pull_shift; | ||
764 | writel(val, (base_address + pin_data->pin_conf.offset)); | ||
765 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
766 | |||
767 | dev_dbg(pctrldev->dev, "pin:%u set pullup:%d pulldown: %d\n", | ||
768 | pin, pull_up, pull_down); | ||
769 | return 0; | ||
770 | } | ||
771 | |||
772 | static void ns2_pin_get_pull(struct pinctrl_dev *pctrldev, | ||
773 | unsigned int pin, bool *pull_up, | ||
774 | bool *pull_down) | ||
775 | { | ||
776 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
777 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
778 | unsigned long flags; | ||
779 | u32 val; | ||
780 | |||
781 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
782 | val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); | ||
783 | val = (val >> pin_data->pin_conf.pull_shift) & NS2_PIN_PULL_MASK; | ||
784 | *pull_up = false; | ||
785 | *pull_down = false; | ||
786 | |||
787 | if (val == NS2_PIN_PULL_UP) | ||
788 | *pull_up = true; | ||
789 | |||
790 | if (val == NS2_PIN_PULL_DOWN) | ||
791 | *pull_down = true; | ||
792 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
793 | } | ||
794 | |||
795 | static int ns2_pin_set_strength(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
796 | u16 strength) | ||
797 | { | ||
798 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
799 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
800 | u32 val; | ||
801 | unsigned long flags; | ||
802 | void __iomem *base_address; | ||
803 | |||
804 | /* make sure drive strength is supported */ | ||
805 | if (strength < 2 || strength > 16 || (strength % 2)) | ||
806 | return -ENOTSUPP; | ||
807 | |||
808 | base_address = pinctrl->pinconf_base; | ||
809 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
810 | val = readl(base_address + pin_data->pin_conf.offset); | ||
811 | val &= ~(NS2_PIN_DRIVE_STRENGTH_MASK << pin_data->pin_conf.drive_shift); | ||
812 | val |= ((strength / 2) - 1) << pin_data->pin_conf.drive_shift; | ||
813 | writel(val, (base_address + pin_data->pin_conf.offset)); | ||
814 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
815 | |||
816 | dev_dbg(pctrldev->dev, "pin:%u set drive strength:%d mA\n", | ||
817 | pin, strength); | ||
818 | return 0; | ||
819 | } | ||
820 | |||
821 | static int ns2_pin_get_strength(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
822 | u16 *strength) | ||
823 | { | ||
824 | struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); | ||
825 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
826 | u32 val; | ||
827 | unsigned long flags; | ||
828 | |||
829 | spin_lock_irqsave(&pinctrl->lock, flags); | ||
830 | val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); | ||
831 | *strength = (val >> pin_data->pin_conf.drive_shift) & | ||
832 | NS2_PIN_DRIVE_STRENGTH_MASK; | ||
833 | *strength = (*strength + 1) * 2; | ||
834 | spin_unlock_irqrestore(&pinctrl->lock, flags); | ||
835 | |||
836 | dev_dbg(pctrldev->dev, "pin:%u get drive strength:%d mA\n", | ||
837 | pin, *strength); | ||
838 | return 0; | ||
839 | } | ||
840 | |||
841 | static int ns2_pin_config_get(struct pinctrl_dev *pctldev, unsigned int pin, | ||
842 | unsigned long *config) | ||
843 | { | ||
844 | struct ns2_pin *pin_data = pctldev->desc->pins[pin].drv_data; | ||
845 | enum pin_config_param param = pinconf_to_config_param(*config); | ||
846 | bool pull_up, pull_down; | ||
847 | u16 arg = 0; | ||
848 | int ret; | ||
849 | |||
850 | if (pin_data->pin_conf.base == -1) | ||
851 | return -ENOTSUPP; | ||
852 | |||
853 | switch (param) { | ||
854 | case PIN_CONFIG_BIAS_DISABLE: | ||
855 | ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); | ||
856 | if ((pull_up == false) && (pull_down == false)) | ||
857 | return 0; | ||
858 | else | ||
859 | return -EINVAL; | ||
860 | |||
861 | case PIN_CONFIG_BIAS_PULL_UP: | ||
862 | ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); | ||
863 | if (pull_up) | ||
864 | return 0; | ||
865 | else | ||
866 | return -EINVAL; | ||
867 | |||
868 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
869 | ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); | ||
870 | if (pull_down) | ||
871 | return 0; | ||
872 | else | ||
873 | return -EINVAL; | ||
874 | |||
875 | case PIN_CONFIG_DRIVE_STRENGTH: | ||
876 | ret = ns2_pin_get_strength(pctldev, pin, &arg); | ||
877 | if (ret) | ||
878 | return ret; | ||
879 | *config = pinconf_to_config_packed(param, arg); | ||
880 | return 0; | ||
881 | |||
882 | case PIN_CONFIG_SLEW_RATE: | ||
883 | ret = ns2_pin_get_slew(pctldev, pin, &arg); | ||
884 | if (ret) | ||
885 | return ret; | ||
886 | *config = pinconf_to_config_packed(param, arg); | ||
887 | return 0; | ||
888 | |||
889 | case PIN_CONFIG_INPUT_ENABLE: | ||
890 | ret = ns2_pin_get_enable(pctldev, pin); | ||
891 | if (ret) | ||
892 | return 0; | ||
893 | else | ||
894 | return -EINVAL; | ||
895 | |||
896 | default: | ||
897 | return -ENOTSUPP; | ||
898 | } | ||
899 | } | ||
900 | |||
901 | static int ns2_pin_config_set(struct pinctrl_dev *pctrldev, unsigned int pin, | ||
902 | unsigned long *configs, unsigned int num_configs) | ||
903 | { | ||
904 | struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; | ||
905 | enum pin_config_param param; | ||
906 | unsigned int i; | ||
907 | u16 arg; | ||
908 | int ret = -ENOTSUPP; | ||
909 | |||
910 | if (pin_data->pin_conf.base == -1) | ||
911 | return -ENOTSUPP; | ||
912 | |||
913 | for (i = 0; i < num_configs; i++) { | ||
914 | param = pinconf_to_config_param(configs[i]); | ||
915 | arg = pinconf_to_config_argument(configs[i]); | ||
916 | |||
917 | switch (param) { | ||
918 | case PIN_CONFIG_BIAS_DISABLE: | ||
919 | ret = ns2_pin_set_pull(pctrldev, pin, false, false); | ||
920 | if (ret < 0) | ||
921 | goto out; | ||
922 | break; | ||
923 | |||
924 | case PIN_CONFIG_BIAS_PULL_UP: | ||
925 | ret = ns2_pin_set_pull(pctrldev, pin, true, false); | ||
926 | if (ret < 0) | ||
927 | goto out; | ||
928 | break; | ||
929 | |||
930 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
931 | ret = ns2_pin_set_pull(pctrldev, pin, false, true); | ||
932 | if (ret < 0) | ||
933 | goto out; | ||
934 | break; | ||
935 | |||
936 | case PIN_CONFIG_DRIVE_STRENGTH: | ||
937 | ret = ns2_pin_set_strength(pctrldev, pin, arg); | ||
938 | if (ret < 0) | ||
939 | goto out; | ||
940 | break; | ||
941 | |||
942 | case PIN_CONFIG_SLEW_RATE: | ||
943 | ret = ns2_pin_set_slew(pctrldev, pin, arg); | ||
944 | if (ret < 0) | ||
945 | goto out; | ||
946 | break; | ||
947 | |||
948 | case PIN_CONFIG_INPUT_ENABLE: | ||
949 | ret = ns2_pin_set_enable(pctrldev, pin, arg); | ||
950 | if (ret < 0) | ||
951 | goto out; | ||
952 | break; | ||
953 | |||
954 | default: | ||
955 | dev_err(pctrldev->dev, "invalid configuration\n"); | ||
956 | return -ENOTSUPP; | ||
957 | } | ||
958 | } | ||
959 | out: | ||
960 | return ret; | ||
961 | } | ||
962 | static struct pinmux_ops ns2_pinmux_ops = { | ||
963 | .get_functions_count = ns2_get_functions_count, | ||
964 | .get_function_name = ns2_get_function_name, | ||
965 | .get_function_groups = ns2_get_function_groups, | ||
966 | .set_mux = ns2_pinmux_enable, | ||
967 | }; | ||
968 | |||
969 | static const struct pinconf_ops ns2_pinconf_ops = { | ||
970 | .is_generic = true, | ||
971 | .pin_config_get = ns2_pin_config_get, | ||
972 | .pin_config_set = ns2_pin_config_set, | ||
973 | }; | ||
974 | |||
975 | static struct pinctrl_desc ns2_pinctrl_desc = { | ||
976 | .name = "ns2-pinmux", | ||
977 | .pctlops = &ns2_pinctrl_ops, | ||
978 | .pmxops = &ns2_pinmux_ops, | ||
979 | .confops = &ns2_pinconf_ops, | ||
980 | }; | ||
981 | |||
982 | static int ns2_mux_log_init(struct ns2_pinctrl *pinctrl) | ||
983 | { | ||
984 | struct ns2_mux_log *log; | ||
985 | unsigned int i; | ||
986 | |||
987 | pinctrl->mux_log = devm_kcalloc(pinctrl->dev, NS2_NUM_IOMUX, | ||
988 | sizeof(struct ns2_mux_log), | ||
989 | GFP_KERNEL); | ||
990 | if (!pinctrl->mux_log) | ||
991 | return -ENOMEM; | ||
992 | |||
993 | for (i = 0; i < NS2_NUM_IOMUX; i++) | ||
994 | pinctrl->mux_log[i].is_configured = false; | ||
995 | /* Group 0 uses bit 31 in the IOMUX_PAD_FUNCTION_0 register */ | ||
996 | log = &pinctrl->mux_log[0]; | ||
997 | log->mux.base = NS2_PIN_MUX_BASE0; | ||
998 | log->mux.offset = 0; | ||
999 | log->mux.shift = 31; | ||
1000 | log->mux.alt = 0; | ||
1001 | |||
1002 | /* | ||
1003 | * Groups 1 through 14 use two bits each in the | ||
1004 | * IOMUX_PAD_FUNCTION_1 register starting with | ||
1005 | * bit position 30. | ||
1006 | */ | ||
1007 | for (i = 1; i < (NS2_NUM_IOMUX - NS2_NUM_PWM_MUX); i++) { | ||
1008 | log = &pinctrl->mux_log[i]; | ||
1009 | log->mux.base = NS2_PIN_MUX_BASE0; | ||
1010 | log->mux.offset = NS2_MUX_PAD_FUNC1_OFFSET; | ||
1011 | log->mux.shift = 32 - (i * 2); | ||
1012 | log->mux.alt = 0; | ||
1013 | } | ||
1014 | |||
1015 | /* | ||
1016 | * Groups 15 through 18 use one bit each in the | ||
1017 | * AUX_SEL register. | ||
1018 | */ | ||
1019 | for (i = 0; i < NS2_NUM_PWM_MUX; i++) { | ||
1020 | log = &pinctrl->mux_log[(NS2_NUM_IOMUX - NS2_NUM_PWM_MUX) + i]; | ||
1021 | log->mux.base = NS2_PIN_MUX_BASE1; | ||
1022 | log->mux.offset = 0; | ||
1023 | log->mux.shift = i; | ||
1024 | log->mux.alt = 0; | ||
1025 | } | ||
1026 | return 0; | ||
1027 | } | ||
1028 | |||
1029 | static int ns2_pinmux_probe(struct platform_device *pdev) | ||
1030 | { | ||
1031 | struct ns2_pinctrl *pinctrl; | ||
1032 | struct resource *res; | ||
1033 | int i, ret; | ||
1034 | struct pinctrl_pin_desc *pins; | ||
1035 | unsigned int num_pins = ARRAY_SIZE(ns2_pins); | ||
1036 | |||
1037 | pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); | ||
1038 | if (!pinctrl) | ||
1039 | return -ENOMEM; | ||
1040 | |||
1041 | pinctrl->dev = &pdev->dev; | ||
1042 | platform_set_drvdata(pdev, pinctrl); | ||
1043 | spin_lock_init(&pinctrl->lock); | ||
1044 | |||
1045 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1046 | pinctrl->base0 = devm_ioremap_resource(&pdev->dev, res); | ||
1047 | if (IS_ERR(pinctrl->base0)) { | ||
1048 | dev_err(&pdev->dev, "unable to map I/O space\n"); | ||
1049 | return PTR_ERR(pinctrl->base0); | ||
1050 | } | ||
1051 | |||
1052 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
1053 | pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start, | ||
1054 | resource_size(res)); | ||
1055 | if (!pinctrl->base1) { | ||
1056 | dev_err(&pdev->dev, "unable to map I/O space\n"); | ||
1057 | return -ENOMEM; | ||
1058 | } | ||
1059 | |||
1060 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
1061 | pinctrl->pinconf_base = devm_ioremap_resource(&pdev->dev, res); | ||
1062 | if (IS_ERR(pinctrl->pinconf_base)) { | ||
1063 | dev_err(&pdev->dev, "unable to map I/O space\n"); | ||
1064 | return PTR_ERR(pinctrl->pinconf_base); | ||
1065 | } | ||
1066 | |||
1067 | ret = ns2_mux_log_init(pinctrl); | ||
1068 | if (ret) { | ||
1069 | dev_err(&pdev->dev, "unable to initialize IOMUX log\n"); | ||
1070 | return ret; | ||
1071 | } | ||
1072 | |||
1073 | pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL); | ||
1074 | if (!pins) | ||
1075 | return -ENOMEM; | ||
1076 | |||
1077 | for (i = 0; i < num_pins; i++) { | ||
1078 | pins[i].number = ns2_pins[i].pin; | ||
1079 | pins[i].name = ns2_pins[i].name; | ||
1080 | pins[i].drv_data = &ns2_pins[i]; | ||
1081 | } | ||
1082 | |||
1083 | pinctrl->groups = ns2_pin_groups; | ||
1084 | pinctrl->num_groups = ARRAY_SIZE(ns2_pin_groups); | ||
1085 | pinctrl->functions = ns2_pin_functions; | ||
1086 | pinctrl->num_functions = ARRAY_SIZE(ns2_pin_functions); | ||
1087 | ns2_pinctrl_desc.pins = pins; | ||
1088 | ns2_pinctrl_desc.npins = num_pins; | ||
1089 | |||
1090 | pinctrl->pctl = pinctrl_register(&ns2_pinctrl_desc, &pdev->dev, | ||
1091 | pinctrl); | ||
1092 | if (!pinctrl->pctl) { | ||
1093 | dev_err(&pdev->dev, "unable to register IOMUX pinctrl\n"); | ||
1094 | return -EINVAL; | ||
1095 | } | ||
1096 | |||
1097 | return 0; | ||
1098 | } | ||
1099 | |||
1100 | static const struct of_device_id ns2_pinmux_of_match[] = { | ||
1101 | {.compatible = "brcm,ns2-pinmux"}, | ||
1102 | { } | ||
1103 | }; | ||
1104 | |||
1105 | static struct platform_driver ns2_pinmux_driver = { | ||
1106 | .driver = { | ||
1107 | .name = "ns2-pinmux", | ||
1108 | .of_match_table = ns2_pinmux_of_match, | ||
1109 | }, | ||
1110 | .probe = ns2_pinmux_probe, | ||
1111 | }; | ||
1112 | |||
1113 | static int __init ns2_pinmux_init(void) | ||
1114 | { | ||
1115 | return platform_driver_register(&ns2_pinmux_driver); | ||
1116 | } | ||
1117 | arch_initcall(ns2_pinmux_init); | ||
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index ac900435dc39..a8b37a9a8230 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c | |||
@@ -363,7 +363,7 @@ static const struct pinctrl_ops nsp_pctrl_ops = { | |||
363 | .get_groups_count = nsp_get_groups_count, | 363 | .get_groups_count = nsp_get_groups_count, |
364 | .get_group_name = nsp_get_group_name, | 364 | .get_group_name = nsp_get_group_name, |
365 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 365 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
366 | .dt_free_map = pinctrl_utils_dt_free_map, | 366 | .dt_free_map = pinctrl_utils_free_map, |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static int nsp_gpio_set_slew(struct nsp_gpio *chip, unsigned gpio, u16 slew) | 369 | static int nsp_gpio_set_slew(struct nsp_gpio *chip, unsigned gpio, u16 slew) |
@@ -609,7 +609,7 @@ static int nsp_gpio_register_pinconf(struct nsp_gpio *chip) | |||
609 | pctldesc->npins = gc->ngpio; | 609 | pctldesc->npins = gc->ngpio; |
610 | pctldesc->confops = &nsp_pconf_ops; | 610 | pctldesc->confops = &nsp_pconf_ops; |
611 | 611 | ||
612 | chip->pctl = pinctrl_register(pctldesc, chip->dev, chip); | 612 | chip->pctl = devm_pinctrl_register(chip->dev, pctldesc, chip); |
613 | if (IS_ERR(chip->pctl)) { | 613 | if (IS_ERR(chip->pctl)) { |
614 | dev_err(chip->dev, "unable to register pinctrl device\n"); | 614 | dev_err(chip->dev, "unable to register pinctrl device\n"); |
615 | return PTR_ERR(chip->pctl); | 615 | return PTR_ERR(chip->pctl); |
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c index 46f2b4818da3..8f0dc02f7624 100644 --- a/drivers/pinctrl/berlin/berlin.c +++ b/drivers/pinctrl/berlin/berlin.c | |||
@@ -104,7 +104,7 @@ static const struct pinctrl_ops berlin_pinctrl_ops = { | |||
104 | .get_groups_count = &berlin_pinctrl_get_group_count, | 104 | .get_groups_count = &berlin_pinctrl_get_group_count, |
105 | .get_group_name = &berlin_pinctrl_get_group_name, | 105 | .get_group_name = &berlin_pinctrl_get_group_name, |
106 | .dt_node_to_map = &berlin_pinctrl_dt_node_to_map, | 106 | .dt_node_to_map = &berlin_pinctrl_dt_node_to_map, |
107 | .dt_free_map = &pinctrl_utils_dt_free_map, | 107 | .dt_free_map = &pinctrl_utils_free_map, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | static int berlin_pinmux_get_functions_count(struct pinctrl_dev *pctrl_dev) | 110 | static int berlin_pinmux_get_functions_count(struct pinctrl_dev *pctrl_dev) |
@@ -316,7 +316,8 @@ int berlin_pinctrl_probe_regmap(struct platform_device *pdev, | |||
316 | return ret; | 316 | return ret; |
317 | } | 317 | } |
318 | 318 | ||
319 | pctrl->pctrl_dev = pinctrl_register(&berlin_pctrl_desc, dev, pctrl); | 319 | pctrl->pctrl_dev = devm_pinctrl_register(dev, &berlin_pctrl_desc, |
320 | pctrl); | ||
320 | if (IS_ERR(pctrl->pctrl_dev)) { | 321 | if (IS_ERR(pctrl->pctrl_dev)) { |
321 | dev_err(dev, "failed to register pinctrl driver\n"); | 322 | dev_err(dev, "failed to register pinctrl driver\n"); |
322 | return PTR_ERR(pctrl->pctrl_dev); | 323 | return PTR_ERR(pctrl->pctrl_dev); |
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index f67a8b7a4e18..98d2a1bb44cb 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -1872,6 +1872,69 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev) | |||
1872 | } | 1872 | } |
1873 | EXPORT_SYMBOL_GPL(pinctrl_unregister); | 1873 | EXPORT_SYMBOL_GPL(pinctrl_unregister); |
1874 | 1874 | ||
1875 | static void devm_pinctrl_dev_release(struct device *dev, void *res) | ||
1876 | { | ||
1877 | struct pinctrl_dev *pctldev = *(struct pinctrl_dev **)res; | ||
1878 | |||
1879 | pinctrl_unregister(pctldev); | ||
1880 | } | ||
1881 | |||
1882 | static int devm_pinctrl_dev_match(struct device *dev, void *res, void *data) | ||
1883 | { | ||
1884 | struct pctldev **r = res; | ||
1885 | |||
1886 | if (WARN_ON(!r || !*r)) | ||
1887 | return 0; | ||
1888 | |||
1889 | return *r == data; | ||
1890 | } | ||
1891 | |||
1892 | /** | ||
1893 | * devm_pinctrl_register() - Resource managed version of pinctrl_register(). | ||
1894 | * @dev: parent device for this pin controller | ||
1895 | * @pctldesc: descriptor for this pin controller | ||
1896 | * @driver_data: private pin controller data for this pin controller | ||
1897 | * | ||
1898 | * Returns an error pointer if pincontrol register failed. Otherwise | ||
1899 | * it returns valid pinctrl handle. | ||
1900 | * | ||
1901 | * The pinctrl device will be automatically released when the device is unbound. | ||
1902 | */ | ||
1903 | struct pinctrl_dev *devm_pinctrl_register(struct device *dev, | ||
1904 | struct pinctrl_desc *pctldesc, | ||
1905 | void *driver_data) | ||
1906 | { | ||
1907 | struct pinctrl_dev **ptr, *pctldev; | ||
1908 | |||
1909 | ptr = devres_alloc(devm_pinctrl_dev_release, sizeof(*ptr), GFP_KERNEL); | ||
1910 | if (!ptr) | ||
1911 | return ERR_PTR(-ENOMEM); | ||
1912 | |||
1913 | pctldev = pinctrl_register(pctldesc, dev, driver_data); | ||
1914 | if (IS_ERR(pctldev)) { | ||
1915 | devres_free(ptr); | ||
1916 | return pctldev; | ||
1917 | } | ||
1918 | |||
1919 | *ptr = pctldev; | ||
1920 | devres_add(dev, ptr); | ||
1921 | |||
1922 | return pctldev; | ||
1923 | } | ||
1924 | EXPORT_SYMBOL_GPL(devm_pinctrl_register); | ||
1925 | |||
1926 | /** | ||
1927 | * devm_pinctrl_unregister() - Resource managed version of pinctrl_unregister(). | ||
1928 | * @dev: device for which which resource was allocated | ||
1929 | * @pctldev: the pinctrl device to unregister. | ||
1930 | */ | ||
1931 | void devm_pinctrl_unregister(struct device *dev, struct pinctrl_dev *pctldev) | ||
1932 | { | ||
1933 | WARN_ON(devres_release(dev, devm_pinctrl_dev_release, | ||
1934 | devm_pinctrl_dev_match, pctldev)); | ||
1935 | } | ||
1936 | EXPORT_SYMBOL_GPL(devm_pinctrl_unregister); | ||
1937 | |||
1875 | static int __init pinctrl_init(void) | 1938 | static int __init pinctrl_init(void) |
1876 | { | 1939 | { |
1877 | pr_info("initialized pinctrl subsystem\n"); | 1940 | pr_info("initialized pinctrl subsystem\n"); |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 9cfa544072b5..47ccfcc8a647 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c | |||
@@ -789,7 +789,7 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
789 | ipctl->info = info; | 789 | ipctl->info = info; |
790 | ipctl->dev = info->dev; | 790 | ipctl->dev = info->dev; |
791 | platform_set_drvdata(pdev, ipctl); | 791 | platform_set_drvdata(pdev, ipctl); |
792 | ipctl->pctl = pinctrl_register(&imx_pinctrl_desc, &pdev->dev, ipctl); | 792 | ipctl->pctl = devm_pinctrl_register(&pdev->dev, &imx_pinctrl_desc, ipctl); |
793 | if (IS_ERR(ipctl->pctl)) { | 793 | if (IS_ERR(ipctl->pctl)) { |
794 | dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); | 794 | dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); |
795 | return PTR_ERR(ipctl->pctl); | 795 | return PTR_ERR(ipctl->pctl); |
@@ -799,12 +799,3 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
799 | 799 | ||
800 | return 0; | 800 | return 0; |
801 | } | 801 | } |
802 | |||
803 | int imx_pinctrl_remove(struct platform_device *pdev) | ||
804 | { | ||
805 | struct imx_pinctrl *ipctl = platform_get_drvdata(pdev); | ||
806 | |||
807 | pinctrl_unregister(ipctl->pctl); | ||
808 | |||
809 | return 0; | ||
810 | } | ||
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.h b/drivers/pinctrl/freescale/pinctrl-imx.h index 3b8bd81a39a4..8af8aa2897ab 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.h +++ b/drivers/pinctrl/freescale/pinctrl-imx.h | |||
@@ -99,5 +99,4 @@ struct imx_pinctrl_soc_info { | |||
99 | 99 | ||
100 | int imx_pinctrl_probe(struct platform_device *pdev, | 100 | int imx_pinctrl_probe(struct platform_device *pdev, |
101 | struct imx_pinctrl_soc_info *info); | 101 | struct imx_pinctrl_soc_info *info); |
102 | int imx_pinctrl_remove(struct platform_device *pdev); | ||
103 | #endif /* __DRIVERS_PINCTRL_IMX_H */ | 102 | #endif /* __DRIVERS_PINCTRL_IMX_H */ |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index acaf84cadca3..b4400cb19b61 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c | |||
@@ -635,7 +635,7 @@ int imx1_pinctrl_core_probe(struct platform_device *pdev, | |||
635 | ipctl->info = info; | 635 | ipctl->info = info; |
636 | ipctl->dev = info->dev; | 636 | ipctl->dev = info->dev; |
637 | platform_set_drvdata(pdev, ipctl); | 637 | platform_set_drvdata(pdev, ipctl); |
638 | ipctl->pctl = pinctrl_register(pctl_desc, &pdev->dev, ipctl); | 638 | ipctl->pctl = devm_pinctrl_register(&pdev->dev, pctl_desc, ipctl); |
639 | if (IS_ERR(ipctl->pctl)) { | 639 | if (IS_ERR(ipctl->pctl)) { |
640 | dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); | 640 | dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); |
641 | return PTR_ERR(ipctl->pctl); | 641 | return PTR_ERR(ipctl->pctl); |
@@ -652,12 +652,3 @@ int imx1_pinctrl_core_probe(struct platform_device *pdev, | |||
652 | 652 | ||
653 | return 0; | 653 | return 0; |
654 | } | 654 | } |
655 | |||
656 | int imx1_pinctrl_core_remove(struct platform_device *pdev) | ||
657 | { | ||
658 | struct imx1_pinctrl *ipctl = platform_get_drvdata(pdev); | ||
659 | |||
660 | pinctrl_unregister(ipctl->pctl); | ||
661 | |||
662 | return 0; | ||
663 | } | ||
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1.c b/drivers/pinctrl/freescale/pinctrl-imx1.c index d3bacb7d6d37..04723455db58 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1.c | |||
@@ -269,7 +269,6 @@ static struct platform_driver imx1_pinctrl_driver = { | |||
269 | .name = "imx1-pinctrl", | 269 | .name = "imx1-pinctrl", |
270 | .of_match_table = imx1_pinctrl_of_match, | 270 | .of_match_table = imx1_pinctrl_of_match, |
271 | }, | 271 | }, |
272 | .remove = imx1_pinctrl_core_remove, | ||
273 | }; | 272 | }; |
274 | module_platform_driver_probe(imx1_pinctrl_driver, imx1_pinctrl_probe); | 273 | module_platform_driver_probe(imx1_pinctrl_driver, imx1_pinctrl_probe); |
275 | 274 | ||
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1.h b/drivers/pinctrl/freescale/pinctrl-imx1.h index 692a54c15cda..174074308d6c 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1.h +++ b/drivers/pinctrl/freescale/pinctrl-imx1.h | |||
@@ -69,5 +69,4 @@ struct imx1_pinctrl_soc_info { | |||
69 | 69 | ||
70 | int imx1_pinctrl_core_probe(struct platform_device *pdev, | 70 | int imx1_pinctrl_core_probe(struct platform_device *pdev, |
71 | struct imx1_pinctrl_soc_info *info); | 71 | struct imx1_pinctrl_soc_info *info); |
72 | int imx1_pinctrl_core_remove(struct platform_device *pdev); | ||
73 | #endif /* __DRIVERS_PINCTRL_IMX1_H */ | 72 | #endif /* __DRIVERS_PINCTRL_IMX1_H */ |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx21.c b/drivers/pinctrl/freescale/pinctrl-imx21.c index 9d9aca3dbd7e..aa1221f4dbb7 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx21.c +++ b/drivers/pinctrl/freescale/pinctrl-imx21.c | |||
@@ -332,7 +332,6 @@ static struct platform_driver imx21_pinctrl_driver = { | |||
332 | .name = "imx21-pinctrl", | 332 | .name = "imx21-pinctrl", |
333 | .of_match_table = imx21_pinctrl_of_match, | 333 | .of_match_table = imx21_pinctrl_of_match, |
334 | }, | 334 | }, |
335 | .remove = imx1_pinctrl_core_remove, | ||
336 | }; | 335 | }; |
337 | module_platform_driver_probe(imx21_pinctrl_driver, imx21_pinctrl_probe); | 336 | module_platform_driver_probe(imx21_pinctrl_driver, imx21_pinctrl_probe); |
338 | 337 | ||
diff --git a/drivers/pinctrl/freescale/pinctrl-imx25.c b/drivers/pinctrl/freescale/pinctrl-imx25.c index 293ed4381cc0..81ad546d74bb 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx25.c +++ b/drivers/pinctrl/freescale/pinctrl-imx25.c | |||
@@ -331,7 +331,6 @@ static struct platform_driver imx25_pinctrl_driver = { | |||
331 | .of_match_table = of_match_ptr(imx25_pinctrl_of_match), | 331 | .of_match_table = of_match_ptr(imx25_pinctrl_of_match), |
332 | }, | 332 | }, |
333 | .probe = imx25_pinctrl_probe, | 333 | .probe = imx25_pinctrl_probe, |
334 | .remove = imx_pinctrl_remove, | ||
335 | }; | 334 | }; |
336 | 335 | ||
337 | static int __init imx25_pinctrl_init(void) | 336 | static int __init imx25_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx27.c b/drivers/pinctrl/freescale/pinctrl-imx27.c index a461d5881f37..f828fbbba4b9 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx27.c +++ b/drivers/pinctrl/freescale/pinctrl-imx27.c | |||
@@ -405,7 +405,6 @@ static struct platform_driver imx27_pinctrl_driver = { | |||
405 | .of_match_table = of_match_ptr(imx27_pinctrl_of_match), | 405 | .of_match_table = of_match_ptr(imx27_pinctrl_of_match), |
406 | }, | 406 | }, |
407 | .probe = imx27_pinctrl_probe, | 407 | .probe = imx27_pinctrl_probe, |
408 | .remove = imx1_pinctrl_core_remove, | ||
409 | }; | 408 | }; |
410 | 409 | ||
411 | static int __init imx27_pinctrl_init(void) | 410 | static int __init imx27_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx35.c b/drivers/pinctrl/freescale/pinctrl-imx35.c index 9109c10c5dab..13eb224a29a9 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx35.c +++ b/drivers/pinctrl/freescale/pinctrl-imx35.c | |||
@@ -1021,7 +1021,6 @@ static struct platform_driver imx35_pinctrl_driver = { | |||
1021 | .of_match_table = imx35_pinctrl_of_match, | 1021 | .of_match_table = imx35_pinctrl_of_match, |
1022 | }, | 1022 | }, |
1023 | .probe = imx35_pinctrl_probe, | 1023 | .probe = imx35_pinctrl_probe, |
1024 | .remove = imx_pinctrl_remove, | ||
1025 | }; | 1024 | }; |
1026 | 1025 | ||
1027 | static int __init imx35_pinctrl_init(void) | 1026 | static int __init imx35_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx50.c b/drivers/pinctrl/freescale/pinctrl-imx50.c index 8acc4d960cfa..95a36c88b66a 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx50.c +++ b/drivers/pinctrl/freescale/pinctrl-imx50.c | |||
@@ -408,7 +408,6 @@ static struct platform_driver imx50_pinctrl_driver = { | |||
408 | .of_match_table = of_match_ptr(imx50_pinctrl_of_match), | 408 | .of_match_table = of_match_ptr(imx50_pinctrl_of_match), |
409 | }, | 409 | }, |
410 | .probe = imx50_pinctrl_probe, | 410 | .probe = imx50_pinctrl_probe, |
411 | .remove = imx_pinctrl_remove, | ||
412 | }; | 411 | }; |
413 | 412 | ||
414 | static int __init imx50_pinctrl_init(void) | 413 | static int __init imx50_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx51.c b/drivers/pinctrl/freescale/pinctrl-imx51.c index 8dec494aa2c6..0863e5279896 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx51.c +++ b/drivers/pinctrl/freescale/pinctrl-imx51.c | |||
@@ -784,7 +784,6 @@ static struct platform_driver imx51_pinctrl_driver = { | |||
784 | .of_match_table = imx51_pinctrl_of_match, | 784 | .of_match_table = imx51_pinctrl_of_match, |
785 | }, | 785 | }, |
786 | .probe = imx51_pinctrl_probe, | 786 | .probe = imx51_pinctrl_probe, |
787 | .remove = imx_pinctrl_remove, | ||
788 | }; | 787 | }; |
789 | 788 | ||
790 | static int __init imx51_pinctrl_init(void) | 789 | static int __init imx51_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx53.c b/drivers/pinctrl/freescale/pinctrl-imx53.c index d39dfd6a3a44..64c9cbe2a5df 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx53.c +++ b/drivers/pinctrl/freescale/pinctrl-imx53.c | |||
@@ -471,7 +471,6 @@ static struct platform_driver imx53_pinctrl_driver = { | |||
471 | .of_match_table = imx53_pinctrl_of_match, | 471 | .of_match_table = imx53_pinctrl_of_match, |
472 | }, | 472 | }, |
473 | .probe = imx53_pinctrl_probe, | 473 | .probe = imx53_pinctrl_probe, |
474 | .remove = imx_pinctrl_remove, | ||
475 | }; | 474 | }; |
476 | 475 | ||
477 | static int __init imx53_pinctrl_init(void) | 476 | static int __init imx53_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx6dl.c b/drivers/pinctrl/freescale/pinctrl-imx6dl.c index 5a2cdb0549ce..de17bac8ad89 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx6dl.c +++ b/drivers/pinctrl/freescale/pinctrl-imx6dl.c | |||
@@ -477,7 +477,6 @@ static struct platform_driver imx6dl_pinctrl_driver = { | |||
477 | .of_match_table = imx6dl_pinctrl_of_match, | 477 | .of_match_table = imx6dl_pinctrl_of_match, |
478 | }, | 478 | }, |
479 | .probe = imx6dl_pinctrl_probe, | 479 | .probe = imx6dl_pinctrl_probe, |
480 | .remove = imx_pinctrl_remove, | ||
481 | }; | 480 | }; |
482 | 481 | ||
483 | static int __init imx6dl_pinctrl_init(void) | 482 | static int __init imx6dl_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx6q.c b/drivers/pinctrl/freescale/pinctrl-imx6q.c index 7d50a36b1086..55cd8a0e367d 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx6q.c +++ b/drivers/pinctrl/freescale/pinctrl-imx6q.c | |||
@@ -483,7 +483,6 @@ static struct platform_driver imx6q_pinctrl_driver = { | |||
483 | .of_match_table = imx6q_pinctrl_of_match, | 483 | .of_match_table = imx6q_pinctrl_of_match, |
484 | }, | 484 | }, |
485 | .probe = imx6q_pinctrl_probe, | 485 | .probe = imx6q_pinctrl_probe, |
486 | .remove = imx_pinctrl_remove, | ||
487 | }; | 486 | }; |
488 | 487 | ||
489 | static int __init imx6q_pinctrl_init(void) | 488 | static int __init imx6q_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx6sl.c b/drivers/pinctrl/freescale/pinctrl-imx6sl.c index e27d17fdc69d..bf455b8e73fc 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx6sl.c +++ b/drivers/pinctrl/freescale/pinctrl-imx6sl.c | |||
@@ -384,7 +384,6 @@ static struct platform_driver imx6sl_pinctrl_driver = { | |||
384 | .of_match_table = imx6sl_pinctrl_of_match, | 384 | .of_match_table = imx6sl_pinctrl_of_match, |
385 | }, | 385 | }, |
386 | .probe = imx6sl_pinctrl_probe, | 386 | .probe = imx6sl_pinctrl_probe, |
387 | .remove = imx_pinctrl_remove, | ||
388 | }; | 387 | }; |
389 | 388 | ||
390 | static int __init imx6sl_pinctrl_init(void) | 389 | static int __init imx6sl_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx6sx.c b/drivers/pinctrl/freescale/pinctrl-imx6sx.c index 117180c26c50..84118c388cc5 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx6sx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx6sx.c | |||
@@ -387,7 +387,6 @@ static struct platform_driver imx6sx_pinctrl_driver = { | |||
387 | .of_match_table = of_match_ptr(imx6sx_pinctrl_of_match), | 387 | .of_match_table = of_match_ptr(imx6sx_pinctrl_of_match), |
388 | }, | 388 | }, |
389 | .probe = imx6sx_pinctrl_probe, | 389 | .probe = imx6sx_pinctrl_probe, |
390 | .remove = imx_pinctrl_remove, | ||
391 | }; | 390 | }; |
392 | 391 | ||
393 | static int __init imx6sx_pinctrl_init(void) | 392 | static int __init imx6sx_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx6ul.c b/drivers/pinctrl/freescale/pinctrl-imx6ul.c index 78627c70c6ba..c707fdd933ec 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx6ul.c +++ b/drivers/pinctrl/freescale/pinctrl-imx6ul.c | |||
@@ -303,7 +303,6 @@ static struct platform_driver imx6ul_pinctrl_driver = { | |||
303 | .of_match_table = of_match_ptr(imx6ul_pinctrl_of_match), | 303 | .of_match_table = of_match_ptr(imx6ul_pinctrl_of_match), |
304 | }, | 304 | }, |
305 | .probe = imx6ul_pinctrl_probe, | 305 | .probe = imx6ul_pinctrl_probe, |
306 | .remove = imx_pinctrl_remove, | ||
307 | }; | 306 | }; |
308 | 307 | ||
309 | static int __init imx6ul_pinctrl_init(void) | 308 | static int __init imx6ul_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx7d.c b/drivers/pinctrl/freescale/pinctrl-imx7d.c index 1c89613eb4b7..d30d91f80dfd 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx7d.c +++ b/drivers/pinctrl/freescale/pinctrl-imx7d.c | |||
@@ -395,7 +395,6 @@ static struct platform_driver imx7d_pinctrl_driver = { | |||
395 | .of_match_table = of_match_ptr(imx7d_pinctrl_of_match), | 395 | .of_match_table = of_match_ptr(imx7d_pinctrl_of_match), |
396 | }, | 396 | }, |
397 | .probe = imx7d_pinctrl_probe, | 397 | .probe = imx7d_pinctrl_probe, |
398 | .remove = imx_pinctrl_remove, | ||
399 | }; | 398 | }; |
400 | 399 | ||
401 | static int __init imx7d_pinctrl_init(void) | 400 | static int __init imx7d_pinctrl_init(void) |
diff --git a/drivers/pinctrl/freescale/pinctrl-vf610.c b/drivers/pinctrl/freescale/pinctrl-vf610.c index 587d1ff6210e..6d81be096bc0 100644 --- a/drivers/pinctrl/freescale/pinctrl-vf610.c +++ b/drivers/pinctrl/freescale/pinctrl-vf610.c | |||
@@ -318,7 +318,6 @@ static struct platform_driver vf610_pinctrl_driver = { | |||
318 | .of_match_table = vf610_pinctrl_of_match, | 318 | .of_match_table = vf610_pinctrl_of_match, |
319 | }, | 319 | }, |
320 | .probe = vf610_pinctrl_probe, | 320 | .probe = vf610_pinctrl_probe, |
321 | .remove = imx_pinctrl_remove, | ||
322 | }; | 321 | }; |
323 | 322 | ||
324 | static int __init vf610_pinctrl_init(void) | 323 | static int __init vf610_pinctrl_init(void) |
diff --git a/drivers/pinctrl/intel/Kconfig b/drivers/pinctrl/intel/Kconfig index 4d2efad6553c..1c74e038b7b0 100644 --- a/drivers/pinctrl/intel/Kconfig +++ b/drivers/pinctrl/intel/Kconfig | |||
@@ -6,6 +6,9 @@ config PINCTRL_BAYTRAIL | |||
6 | bool "Intel Baytrail GPIO pin control" | 6 | bool "Intel Baytrail GPIO pin control" |
7 | depends on GPIOLIB && ACPI | 7 | depends on GPIOLIB && ACPI |
8 | select GPIOLIB_IRQCHIP | 8 | select GPIOLIB_IRQCHIP |
9 | select PINMUX | ||
10 | select PINCONF | ||
11 | select GENERIC_PINCONF | ||
9 | help | 12 | help |
10 | driver for memory mapped GPIO functionality on Intel Baytrail | 13 | driver for memory mapped GPIO functionality on Intel Baytrail |
11 | platforms. Supports 3 banks with 102, 28 and 44 gpios. | 14 | platforms. Supports 3 banks with 102, 28 and 44 gpios. |
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 21b79a446d5a..55182fc58c6a 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | #include <linux/bitops.h> | 21 | #include <linux/bitops.h> |
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/gpio.h> | ||
23 | #include <linux/gpio/driver.h> | 24 | #include <linux/gpio/driver.h> |
24 | #include <linux/acpi.h> | 25 | #include <linux/acpi.h> |
25 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
@@ -27,6 +28,9 @@ | |||
27 | #include <linux/io.h> | 28 | #include <linux/io.h> |
28 | #include <linux/pm_runtime.h> | 29 | #include <linux/pm_runtime.h> |
29 | #include <linux/pinctrl/pinctrl.h> | 30 | #include <linux/pinctrl/pinctrl.h> |
31 | #include <linux/pinctrl/pinmux.h> | ||
32 | #include <linux/pinctrl/pinconf.h> | ||
33 | #include <linux/pinctrl/pinconf-generic.h> | ||
30 | 34 | ||
31 | /* memory mapped register offsets */ | 35 | /* memory mapped register offsets */ |
32 | #define BYT_CONF0_REG 0x000 | 36 | #define BYT_CONF0_REG 0x000 |
@@ -34,6 +38,7 @@ | |||
34 | #define BYT_VAL_REG 0x008 | 38 | #define BYT_VAL_REG 0x008 |
35 | #define BYT_DFT_REG 0x00c | 39 | #define BYT_DFT_REG 0x00c |
36 | #define BYT_INT_STAT_REG 0x800 | 40 | #define BYT_INT_STAT_REG 0x800 |
41 | #define BYT_DEBOUNCE_REG 0x9d0 | ||
37 | 42 | ||
38 | /* BYT_CONF0_REG register bits */ | 43 | /* BYT_CONF0_REG register bits */ |
39 | #define BYT_IODEN BIT(31) | 44 | #define BYT_IODEN BIT(31) |
@@ -41,6 +46,7 @@ | |||
41 | #define BYT_TRIG_NEG BIT(26) | 46 | #define BYT_TRIG_NEG BIT(26) |
42 | #define BYT_TRIG_POS BIT(25) | 47 | #define BYT_TRIG_POS BIT(25) |
43 | #define BYT_TRIG_LVL BIT(24) | 48 | #define BYT_TRIG_LVL BIT(24) |
49 | #define BYT_DEBOUNCE_EN BIT(20) | ||
44 | #define BYT_PULL_STR_SHIFT 9 | 50 | #define BYT_PULL_STR_SHIFT 9 |
45 | #define BYT_PULL_STR_MASK (3 << BYT_PULL_STR_SHIFT) | 51 | #define BYT_PULL_STR_MASK (3 << BYT_PULL_STR_SHIFT) |
46 | #define BYT_PULL_STR_2K (0 << BYT_PULL_STR_SHIFT) | 52 | #define BYT_PULL_STR_2K (0 << BYT_PULL_STR_SHIFT) |
@@ -65,6 +71,16 @@ | |||
65 | BYT_PIN_MUX) | 71 | BYT_PIN_MUX) |
66 | #define BYT_VAL_RESTORE_MASK (BYT_DIR_MASK | BYT_LEVEL) | 72 | #define BYT_VAL_RESTORE_MASK (BYT_DIR_MASK | BYT_LEVEL) |
67 | 73 | ||
74 | /* BYT_DEBOUNCE_REG bits */ | ||
75 | #define BYT_DEBOUNCE_PULSE_MASK 0x7 | ||
76 | #define BYT_DEBOUNCE_PULSE_375US 1 | ||
77 | #define BYT_DEBOUNCE_PULSE_750US 2 | ||
78 | #define BYT_DEBOUNCE_PULSE_1500US 3 | ||
79 | #define BYT_DEBOUNCE_PULSE_3MS 4 | ||
80 | #define BYT_DEBOUNCE_PULSE_6MS 5 | ||
81 | #define BYT_DEBOUNCE_PULSE_12MS 6 | ||
82 | #define BYT_DEBOUNCE_PULSE_24MS 7 | ||
83 | |||
68 | #define BYT_NGPIO_SCORE 102 | 84 | #define BYT_NGPIO_SCORE 102 |
69 | #define BYT_NGPIO_NCORE 28 | 85 | #define BYT_NGPIO_NCORE 28 |
70 | #define BYT_NGPIO_SUS 44 | 86 | #define BYT_NGPIO_SUS 44 |
@@ -74,18 +90,227 @@ | |||
74 | #define BYT_SUS_ACPI_UID "3" | 90 | #define BYT_SUS_ACPI_UID "3" |
75 | 91 | ||
76 | /* | 92 | /* |
77 | * Baytrail gpio controller consist of three separate sub-controllers called | 93 | * This is the function value most pins have for GPIO muxing. If the value |
78 | * SCORE, NCORE and SUS. The sub-controllers are identified by their acpi UID. | 94 | * differs from the default one, it must be explicitly mentioned. Otherwise, the |
79 | * | 95 | * pin control implementation will set the muxing value to default GPIO if it |
80 | * GPIO numbering is _not_ ordered meaning that gpio # 0 in ACPI namespace does | 96 | * does not find a match for the requested function. |
81 | * _not_ correspond to the first gpio register at controller's gpio base. | ||
82 | * There is no logic or pattern in mapping gpio numbers to registers (pads) so | ||
83 | * each sub-controller needs to have its own mapping table | ||
84 | */ | 97 | */ |
98 | #define BYT_DEFAULT_GPIO_MUX 0 | ||
99 | |||
100 | struct byt_gpio_pin_context { | ||
101 | u32 conf0; | ||
102 | u32 val; | ||
103 | }; | ||
104 | |||
105 | struct byt_simple_func_mux { | ||
106 | const char *name; | ||
107 | unsigned short func; | ||
108 | }; | ||
109 | |||
110 | struct byt_mixed_func_mux { | ||
111 | const char *name; | ||
112 | const unsigned short *func_values; | ||
113 | }; | ||
114 | |||
115 | struct byt_pingroup { | ||
116 | const char *name; | ||
117 | const unsigned int *pins; | ||
118 | size_t npins; | ||
119 | unsigned short has_simple_funcs; | ||
120 | union { | ||
121 | const struct byt_simple_func_mux *simple_funcs; | ||
122 | const struct byt_mixed_func_mux *mixed_funcs; | ||
123 | }; | ||
124 | size_t nfuncs; | ||
125 | }; | ||
126 | |||
127 | struct byt_function { | ||
128 | const char *name; | ||
129 | const char * const *groups; | ||
130 | size_t ngroups; | ||
131 | }; | ||
132 | |||
133 | struct byt_community { | ||
134 | unsigned int pin_base; | ||
135 | size_t npins; | ||
136 | const unsigned int *pad_map; | ||
137 | void __iomem *reg_base; | ||
138 | }; | ||
85 | 139 | ||
86 | /* score_pins[gpio_nr] = pad_nr */ | 140 | #define SIMPLE_FUNC(n, f) \ |
141 | { \ | ||
142 | .name = (n), \ | ||
143 | .func = (f), \ | ||
144 | } | ||
145 | #define MIXED_FUNC(n, f) \ | ||
146 | { \ | ||
147 | .name = (n), \ | ||
148 | .func_values = (f), \ | ||
149 | } | ||
150 | |||
151 | #define PIN_GROUP_SIMPLE(n, p, f) \ | ||
152 | { \ | ||
153 | .name = (n), \ | ||
154 | .pins = (p), \ | ||
155 | .npins = ARRAY_SIZE((p)), \ | ||
156 | .has_simple_funcs = 1, \ | ||
157 | .simple_funcs = (f), \ | ||
158 | .nfuncs = ARRAY_SIZE((f)), \ | ||
159 | } | ||
160 | #define PIN_GROUP_MIXED(n, p, f) \ | ||
161 | { \ | ||
162 | .name = (n), \ | ||
163 | .pins = (p), \ | ||
164 | .npins = ARRAY_SIZE((p)), \ | ||
165 | .has_simple_funcs = 0, \ | ||
166 | .mixed_funcs = (f), \ | ||
167 | .nfuncs = ARRAY_SIZE((f)), \ | ||
168 | } | ||
169 | |||
170 | #define FUNCTION(n, g) \ | ||
171 | { \ | ||
172 | .name = (n), \ | ||
173 | .groups = (g), \ | ||
174 | .ngroups = ARRAY_SIZE((g)), \ | ||
175 | } | ||
176 | |||
177 | #define COMMUNITY(p, n, map) \ | ||
178 | { \ | ||
179 | .pin_base = (p), \ | ||
180 | .npins = (n), \ | ||
181 | .pad_map = (map),\ | ||
182 | } | ||
87 | 183 | ||
88 | static unsigned const score_pins[BYT_NGPIO_SCORE] = { | 184 | struct byt_pinctrl_soc_data { |
185 | const char *uid; | ||
186 | const struct pinctrl_pin_desc *pins; | ||
187 | size_t npins; | ||
188 | const struct byt_pingroup *groups; | ||
189 | size_t ngroups; | ||
190 | const struct byt_function *functions; | ||
191 | size_t nfunctions; | ||
192 | const struct byt_community *communities; | ||
193 | size_t ncommunities; | ||
194 | }; | ||
195 | |||
196 | struct byt_gpio { | ||
197 | struct gpio_chip chip; | ||
198 | struct platform_device *pdev; | ||
199 | struct pinctrl_dev *pctl_dev; | ||
200 | struct pinctrl_desc pctl_desc; | ||
201 | raw_spinlock_t lock; | ||
202 | const struct byt_pinctrl_soc_data *soc_data; | ||
203 | struct byt_community *communities_copy; | ||
204 | struct byt_gpio_pin_context *saved_context; | ||
205 | }; | ||
206 | |||
207 | /* SCORE pins, aka GPIOC_<pin_no> or GPIO_S0_SC[<pin_no>] */ | ||
208 | static const struct pinctrl_pin_desc byt_score_pins[] = { | ||
209 | PINCTRL_PIN(0, "SATA_GP0"), | ||
210 | PINCTRL_PIN(1, "SATA_GP1"), | ||
211 | PINCTRL_PIN(2, "SATA_LED#"), | ||
212 | PINCTRL_PIN(3, "PCIE_CLKREQ0"), | ||
213 | PINCTRL_PIN(4, "PCIE_CLKREQ1"), | ||
214 | PINCTRL_PIN(5, "PCIE_CLKREQ2"), | ||
215 | PINCTRL_PIN(6, "PCIE_CLKREQ3"), | ||
216 | PINCTRL_PIN(7, "SD3_WP"), | ||
217 | PINCTRL_PIN(8, "HDA_RST"), | ||
218 | PINCTRL_PIN(9, "HDA_SYNC"), | ||
219 | PINCTRL_PIN(10, "HDA_CLK"), | ||
220 | PINCTRL_PIN(11, "HDA_SDO"), | ||
221 | PINCTRL_PIN(12, "HDA_SDI0"), | ||
222 | PINCTRL_PIN(13, "HDA_SDI1"), | ||
223 | PINCTRL_PIN(14, "GPIO_S0_SC14"), | ||
224 | PINCTRL_PIN(15, "GPIO_S0_SC15"), | ||
225 | PINCTRL_PIN(16, "MMC1_CLK"), | ||
226 | PINCTRL_PIN(17, "MMC1_D0"), | ||
227 | PINCTRL_PIN(18, "MMC1_D1"), | ||
228 | PINCTRL_PIN(19, "MMC1_D2"), | ||
229 | PINCTRL_PIN(20, "MMC1_D3"), | ||
230 | PINCTRL_PIN(21, "MMC1_D4"), | ||
231 | PINCTRL_PIN(22, "MMC1_D5"), | ||
232 | PINCTRL_PIN(23, "MMC1_D6"), | ||
233 | PINCTRL_PIN(24, "MMC1_D7"), | ||
234 | PINCTRL_PIN(25, "MMC1_CMD"), | ||
235 | PINCTRL_PIN(26, "MMC1_RST"), | ||
236 | PINCTRL_PIN(27, "SD2_CLK"), | ||
237 | PINCTRL_PIN(28, "SD2_D0"), | ||
238 | PINCTRL_PIN(29, "SD2_D1"), | ||
239 | PINCTRL_PIN(30, "SD2_D2"), | ||
240 | PINCTRL_PIN(31, "SD2_D3_CD"), | ||
241 | PINCTRL_PIN(32, "SD2_CMD"), | ||
242 | PINCTRL_PIN(33, "SD3_CLK"), | ||
243 | PINCTRL_PIN(34, "SD3_D0"), | ||
244 | PINCTRL_PIN(35, "SD3_D1"), | ||
245 | PINCTRL_PIN(36, "SD3_D2"), | ||
246 | PINCTRL_PIN(37, "SD3_D3"), | ||
247 | PINCTRL_PIN(38, "SD3_CD"), | ||
248 | PINCTRL_PIN(39, "SD3_CMD"), | ||
249 | PINCTRL_PIN(40, "SD3_1P8EN"), | ||
250 | PINCTRL_PIN(41, "SD3_PWREN#"), | ||
251 | PINCTRL_PIN(42, "ILB_LPC_AD0"), | ||
252 | PINCTRL_PIN(43, "ILB_LPC_AD1"), | ||
253 | PINCTRL_PIN(44, "ILB_LPC_AD2"), | ||
254 | PINCTRL_PIN(45, "ILB_LPC_AD3"), | ||
255 | PINCTRL_PIN(46, "ILB_LPC_FRAME"), | ||
256 | PINCTRL_PIN(47, "ILB_LPC_CLK0"), | ||
257 | PINCTRL_PIN(48, "ILB_LPC_CLK1"), | ||
258 | PINCTRL_PIN(49, "ILB_LPC_CLKRUN"), | ||
259 | PINCTRL_PIN(50, "ILB_LPC_SERIRQ"), | ||
260 | PINCTRL_PIN(51, "PCU_SMB_DATA"), | ||
261 | PINCTRL_PIN(52, "PCU_SMB_CLK"), | ||
262 | PINCTRL_PIN(53, "PCU_SMB_ALERT"), | ||
263 | PINCTRL_PIN(54, "ILB_8254_SPKR"), | ||
264 | PINCTRL_PIN(55, "GPIO_S0_SC55"), | ||
265 | PINCTRL_PIN(56, "GPIO_S0_SC56"), | ||
266 | PINCTRL_PIN(57, "GPIO_S0_SC57"), | ||
267 | PINCTRL_PIN(58, "GPIO_S0_SC58"), | ||
268 | PINCTRL_PIN(59, "GPIO_S0_SC59"), | ||
269 | PINCTRL_PIN(60, "GPIO_S0_SC60"), | ||
270 | PINCTRL_PIN(61, "GPIO_S0_SC61"), | ||
271 | PINCTRL_PIN(62, "LPE_I2S2_CLK"), | ||
272 | PINCTRL_PIN(63, "LPE_I2S2_FRM"), | ||
273 | PINCTRL_PIN(64, "LPE_I2S2_DATAIN"), | ||
274 | PINCTRL_PIN(65, "LPE_I2S2_DATAOUT"), | ||
275 | PINCTRL_PIN(66, "SIO_SPI_CS"), | ||
276 | PINCTRL_PIN(67, "SIO_SPI_MISO"), | ||
277 | PINCTRL_PIN(68, "SIO_SPI_MOSI"), | ||
278 | PINCTRL_PIN(69, "SIO_SPI_CLK"), | ||
279 | PINCTRL_PIN(70, "SIO_UART1_RXD"), | ||
280 | PINCTRL_PIN(71, "SIO_UART1_TXD"), | ||
281 | PINCTRL_PIN(72, "SIO_UART1_RTS"), | ||
282 | PINCTRL_PIN(73, "SIO_UART1_CTS"), | ||
283 | PINCTRL_PIN(74, "SIO_UART2_RXD"), | ||
284 | PINCTRL_PIN(75, "SIO_UART2_TXD"), | ||
285 | PINCTRL_PIN(76, "SIO_UART2_RTS"), | ||
286 | PINCTRL_PIN(77, "SIO_UART2_CTS"), | ||
287 | PINCTRL_PIN(78, "SIO_I2C0_DATA"), | ||
288 | PINCTRL_PIN(79, "SIO_I2C0_CLK"), | ||
289 | PINCTRL_PIN(80, "SIO_I2C1_DATA"), | ||
290 | PINCTRL_PIN(81, "SIO_I2C1_CLK"), | ||
291 | PINCTRL_PIN(82, "SIO_I2C2_DATA"), | ||
292 | PINCTRL_PIN(83, "SIO_I2C2_CLK"), | ||
293 | PINCTRL_PIN(84, "SIO_I2C3_DATA"), | ||
294 | PINCTRL_PIN(85, "SIO_I2C3_CLK"), | ||
295 | PINCTRL_PIN(86, "SIO_I2C4_DATA"), | ||
296 | PINCTRL_PIN(87, "SIO_I2C4_CLK"), | ||
297 | PINCTRL_PIN(88, "SIO_I2C5_DATA"), | ||
298 | PINCTRL_PIN(89, "SIO_I2C5_CLK"), | ||
299 | PINCTRL_PIN(90, "SIO_I2C6_DATA"), | ||
300 | PINCTRL_PIN(91, "SIO_I2C6_CLK"), | ||
301 | PINCTRL_PIN(92, "GPIO_S0_SC92"), | ||
302 | PINCTRL_PIN(93, "GPIO_S0_SC93"), | ||
303 | PINCTRL_PIN(94, "SIO_PWM0"), | ||
304 | PINCTRL_PIN(95, "SIO_PWM1"), | ||
305 | PINCTRL_PIN(96, "PMC_PLT_CLK0"), | ||
306 | PINCTRL_PIN(97, "PMC_PLT_CLK1"), | ||
307 | PINCTRL_PIN(98, "PMC_PLT_CLK2"), | ||
308 | PINCTRL_PIN(99, "PMC_PLT_CLK3"), | ||
309 | PINCTRL_PIN(100, "PMC_PLT_CLK4"), | ||
310 | PINCTRL_PIN(101, "PMC_PLT_CLK5"), | ||
311 | }; | ||
312 | |||
313 | static const unsigned int byt_score_pins_map[BYT_NGPIO_SCORE] = { | ||
89 | 85, 89, 93, 96, 99, 102, 98, 101, 34, 37, | 314 | 85, 89, 93, 96, 99, 102, 98, 101, 34, 37, |
90 | 36, 38, 39, 35, 40, 84, 62, 61, 64, 59, | 315 | 36, 38, 39, 35, 40, 84, 62, 61, 64, 59, |
91 | 54, 56, 60, 55, 63, 57, 51, 50, 53, 47, | 316 | 54, 56, 60, 55, 63, 57, 51, 50, 53, 47, |
@@ -99,13 +324,263 @@ static unsigned const score_pins[BYT_NGPIO_SCORE] = { | |||
99 | 97, 100, | 324 | 97, 100, |
100 | }; | 325 | }; |
101 | 326 | ||
102 | static unsigned const ncore_pins[BYT_NGPIO_NCORE] = { | 327 | /* SCORE groups */ |
103 | 19, 18, 17, 20, 21, 22, 24, 25, 23, 16, | 328 | static const unsigned int byt_score_uart1_pins[] = { 70, 71, 72, 73 }; |
104 | 14, 15, 12, 26, 27, 1, 4, 8, 11, 0, | 329 | static const unsigned int byt_score_uart2_pins[] = { 74, 75, 76, 77 }; |
105 | 3, 6, 10, 13, 2, 5, 9, 7, | 330 | static const struct byt_simple_func_mux byt_score_uart_mux[] = { |
331 | SIMPLE_FUNC("uart", 1), | ||
332 | }; | ||
333 | |||
334 | static const unsigned int byt_score_pwm0_pins[] = { 94 }; | ||
335 | static const unsigned int byt_score_pwm1_pins[] = { 95 }; | ||
336 | static const struct byt_simple_func_mux byt_score_pwm_mux[] = { | ||
337 | SIMPLE_FUNC("pwm", 1), | ||
338 | }; | ||
339 | |||
340 | static const unsigned int byt_score_sio_spi_pins[] = { 66, 67, 68, 69 }; | ||
341 | static const struct byt_simple_func_mux byt_score_spi_mux[] = { | ||
342 | SIMPLE_FUNC("spi", 1), | ||
343 | }; | ||
344 | |||
345 | static const unsigned int byt_score_i2c5_pins[] = { 88, 89 }; | ||
346 | static const unsigned int byt_score_i2c6_pins[] = { 90, 91 }; | ||
347 | static const unsigned int byt_score_i2c4_pins[] = { 86, 87 }; | ||
348 | static const unsigned int byt_score_i2c3_pins[] = { 84, 85 }; | ||
349 | static const unsigned int byt_score_i2c2_pins[] = { 82, 83 }; | ||
350 | static const unsigned int byt_score_i2c1_pins[] = { 80, 81 }; | ||
351 | static const unsigned int byt_score_i2c0_pins[] = { 78, 79 }; | ||
352 | static const struct byt_simple_func_mux byt_score_i2c_mux[] = { | ||
353 | SIMPLE_FUNC("i2c", 1), | ||
354 | }; | ||
355 | |||
356 | static const unsigned int byt_score_ssp0_pins[] = { 8, 9, 10, 11 }; | ||
357 | static const unsigned int byt_score_ssp1_pins[] = { 12, 13, 14, 15 }; | ||
358 | static const unsigned int byt_score_ssp2_pins[] = { 62, 63, 64, 65 }; | ||
359 | static const struct byt_simple_func_mux byt_score_ssp_mux[] = { | ||
360 | SIMPLE_FUNC("ssp", 1), | ||
361 | }; | ||
362 | |||
363 | static const unsigned int byt_score_sdcard_pins[] = { | ||
364 | 7, 33, 34, 35, 36, 37, 38, 39, 40, 41, | ||
365 | }; | ||
366 | static const unsigned short byt_score_sdcard_mux_values[] = { | ||
367 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
368 | }; | ||
369 | static const struct byt_mixed_func_mux byt_score_sdcard_mux[] = { | ||
370 | MIXED_FUNC("sdcard", byt_score_sdcard_mux_values), | ||
371 | }; | ||
372 | |||
373 | static const unsigned int byt_score_sdio_pins[] = { 27, 28, 29, 30, 31, 32 }; | ||
374 | static const struct byt_simple_func_mux byt_score_sdio_mux[] = { | ||
375 | SIMPLE_FUNC("sdio", 1), | ||
376 | }; | ||
377 | |||
378 | static const unsigned int byt_score_emmc_pins[] = { | ||
379 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, | ||
380 | }; | ||
381 | static const struct byt_simple_func_mux byt_score_emmc_mux[] = { | ||
382 | SIMPLE_FUNC("emmc", 1), | ||
383 | }; | ||
384 | |||
385 | static const unsigned int byt_score_ilb_lpc_pins[] = { | ||
386 | 42, 43, 44, 45, 46, 47, 48, 49, 50, | ||
387 | }; | ||
388 | static const struct byt_simple_func_mux byt_score_lpc_mux[] = { | ||
389 | SIMPLE_FUNC("lpc", 1), | ||
390 | }; | ||
391 | |||
392 | static const unsigned int byt_score_sata_pins[] = { 0, 1, 2 }; | ||
393 | static const struct byt_simple_func_mux byt_score_sata_mux[] = { | ||
394 | SIMPLE_FUNC("sata", 1), | ||
395 | }; | ||
396 | |||
397 | static const unsigned int byt_score_plt_clk0_pins[] = { 96 }; | ||
398 | static const unsigned int byt_score_plt_clk1_pins[] = { 97 }; | ||
399 | static const unsigned int byt_score_plt_clk2_pins[] = { 98 }; | ||
400 | static const unsigned int byt_score_plt_clk4_pins[] = { 99 }; | ||
401 | static const unsigned int byt_score_plt_clk5_pins[] = { 100 }; | ||
402 | static const unsigned int byt_score_plt_clk3_pins[] = { 101 }; | ||
403 | static const struct byt_simple_func_mux byt_score_plt_clk_mux[] = { | ||
404 | SIMPLE_FUNC("plt_clk", 1), | ||
106 | }; | 405 | }; |
107 | 406 | ||
108 | static unsigned const sus_pins[BYT_NGPIO_SUS] = { | 407 | static const unsigned int byt_score_smbus_pins[] = { 51, 52, 53 }; |
408 | static const struct byt_simple_func_mux byt_score_smbus_mux[] = { | ||
409 | SIMPLE_FUNC("smbus", 1), | ||
410 | }; | ||
411 | |||
412 | static const struct byt_pingroup byt_score_groups[] = { | ||
413 | PIN_GROUP_SIMPLE("uart1_grp", | ||
414 | byt_score_uart1_pins, byt_score_uart_mux), | ||
415 | PIN_GROUP_SIMPLE("uart2_grp", | ||
416 | byt_score_uart2_pins, byt_score_uart_mux), | ||
417 | PIN_GROUP_SIMPLE("pwm0_grp", | ||
418 | byt_score_pwm0_pins, byt_score_pwm_mux), | ||
419 | PIN_GROUP_SIMPLE("pwm1_grp", | ||
420 | byt_score_pwm1_pins, byt_score_pwm_mux), | ||
421 | PIN_GROUP_SIMPLE("ssp2_grp", | ||
422 | byt_score_ssp2_pins, byt_score_pwm_mux), | ||
423 | PIN_GROUP_SIMPLE("sio_spi_grp", | ||
424 | byt_score_sio_spi_pins, byt_score_spi_mux), | ||
425 | PIN_GROUP_SIMPLE("i2c5_grp", | ||
426 | byt_score_i2c5_pins, byt_score_i2c_mux), | ||
427 | PIN_GROUP_SIMPLE("i2c6_grp", | ||
428 | byt_score_i2c6_pins, byt_score_i2c_mux), | ||
429 | PIN_GROUP_SIMPLE("i2c4_grp", | ||
430 | byt_score_i2c4_pins, byt_score_i2c_mux), | ||
431 | PIN_GROUP_SIMPLE("i2c3_grp", | ||
432 | byt_score_i2c3_pins, byt_score_i2c_mux), | ||
433 | PIN_GROUP_SIMPLE("i2c2_grp", | ||
434 | byt_score_i2c2_pins, byt_score_i2c_mux), | ||
435 | PIN_GROUP_SIMPLE("i2c1_grp", | ||
436 | byt_score_i2c1_pins, byt_score_i2c_mux), | ||
437 | PIN_GROUP_SIMPLE("i2c0_grp", | ||
438 | byt_score_i2c0_pins, byt_score_i2c_mux), | ||
439 | PIN_GROUP_SIMPLE("ssp0_grp", | ||
440 | byt_score_ssp0_pins, byt_score_ssp_mux), | ||
441 | PIN_GROUP_SIMPLE("ssp1_grp", | ||
442 | byt_score_ssp1_pins, byt_score_ssp_mux), | ||
443 | PIN_GROUP_MIXED("sdcard_grp", | ||
444 | byt_score_sdcard_pins, byt_score_sdcard_mux), | ||
445 | PIN_GROUP_SIMPLE("sdio_grp", | ||
446 | byt_score_sdio_pins, byt_score_sdio_mux), | ||
447 | PIN_GROUP_SIMPLE("emmc_grp", | ||
448 | byt_score_emmc_pins, byt_score_emmc_mux), | ||
449 | PIN_GROUP_SIMPLE("lpc_grp", | ||
450 | byt_score_ilb_lpc_pins, byt_score_lpc_mux), | ||
451 | PIN_GROUP_SIMPLE("sata_grp", | ||
452 | byt_score_sata_pins, byt_score_sata_mux), | ||
453 | PIN_GROUP_SIMPLE("plt_clk0_grp", | ||
454 | byt_score_plt_clk0_pins, byt_score_plt_clk_mux), | ||
455 | PIN_GROUP_SIMPLE("plt_clk1_grp", | ||
456 | byt_score_plt_clk1_pins, byt_score_plt_clk_mux), | ||
457 | PIN_GROUP_SIMPLE("plt_clk2_grp", | ||
458 | byt_score_plt_clk2_pins, byt_score_plt_clk_mux), | ||
459 | PIN_GROUP_SIMPLE("plt_clk3_grp", | ||
460 | byt_score_plt_clk3_pins, byt_score_plt_clk_mux), | ||
461 | PIN_GROUP_SIMPLE("plt_clk4_grp", | ||
462 | byt_score_plt_clk4_pins, byt_score_plt_clk_mux), | ||
463 | PIN_GROUP_SIMPLE("plt_clk5_grp", | ||
464 | byt_score_plt_clk5_pins, byt_score_plt_clk_mux), | ||
465 | PIN_GROUP_SIMPLE("smbus_grp", | ||
466 | byt_score_smbus_pins, byt_score_smbus_mux), | ||
467 | }; | ||
468 | |||
469 | static const char * const byt_score_uart_groups[] = { | ||
470 | "uart1_grp", "uart2_grp", | ||
471 | }; | ||
472 | static const char * const byt_score_pwm_groups[] = { | ||
473 | "pwm0_grp", "pwm1_grp", | ||
474 | }; | ||
475 | static const char * const byt_score_ssp_groups[] = { | ||
476 | "ssp0_grp", "ssp1_grp", "ssp2_grp", | ||
477 | }; | ||
478 | static const char * const byt_score_spi_groups[] = { "sio_spi_grp" }; | ||
479 | static const char * const byt_score_i2c_groups[] = { | ||
480 | "i2c0_grp", "i2c1_grp", "i2c2_grp", "i2c3_grp", "i2c4_grp", "i2c5_grp", | ||
481 | "i2c6_grp", | ||
482 | }; | ||
483 | static const char * const byt_score_sdcard_groups[] = { "sdcard_grp" }; | ||
484 | static const char * const byt_score_sdio_groups[] = { "sdio_grp" }; | ||
485 | static const char * const byt_score_emmc_groups[] = { "emmc_grp" }; | ||
486 | static const char * const byt_score_lpc_groups[] = { "lpc_grp" }; | ||
487 | static const char * const byt_score_sata_groups[] = { "sata_grp" }; | ||
488 | static const char * const byt_score_plt_clk_groups[] = { | ||
489 | "plt_clk0_grp", "plt_clk1_grp", "plt_clk2_grp", "plt_clk3_grp", | ||
490 | "plt_clk4_grp", "plt_clk5_grp", | ||
491 | }; | ||
492 | static const char * const byt_score_smbus_groups[] = { "smbus_grp" }; | ||
493 | static const char * const byt_score_gpio_groups[] = { | ||
494 | "uart1_grp", "uart2_grp", "pwm0_grp", "pwm1_grp", "ssp0_grp", | ||
495 | "ssp1_grp", "ssp2_grp", "sio_spi_grp", "i2c0_grp", "i2c1_grp", | ||
496 | "i2c2_grp", "i2c3_grp", "i2c4_grp", "i2c5_grp", "i2c6_grp", | ||
497 | "sdcard_grp", "sdio_grp", "emmc_grp", "lpc_grp", "sata_grp", | ||
498 | "plt_clk0_grp", "plt_clk1_grp", "plt_clk2_grp", "plt_clk3_grp", | ||
499 | "plt_clk4_grp", "plt_clk5_grp", "smbus_grp", | ||
500 | |||
501 | }; | ||
502 | |||
503 | static const struct byt_function byt_score_functions[] = { | ||
504 | FUNCTION("uart", byt_score_uart_groups), | ||
505 | FUNCTION("pwm", byt_score_pwm_groups), | ||
506 | FUNCTION("ssp", byt_score_ssp_groups), | ||
507 | FUNCTION("spi", byt_score_spi_groups), | ||
508 | FUNCTION("i2c", byt_score_i2c_groups), | ||
509 | FUNCTION("sdcard", byt_score_sdcard_groups), | ||
510 | FUNCTION("sdio", byt_score_sdio_groups), | ||
511 | FUNCTION("emmc", byt_score_emmc_groups), | ||
512 | FUNCTION("lpc", byt_score_lpc_groups), | ||
513 | FUNCTION("sata", byt_score_sata_groups), | ||
514 | FUNCTION("plt_clk", byt_score_plt_clk_groups), | ||
515 | FUNCTION("smbus", byt_score_smbus_groups), | ||
516 | FUNCTION("gpio", byt_score_gpio_groups), | ||
517 | }; | ||
518 | |||
519 | static const struct byt_community byt_score_communities[] = { | ||
520 | COMMUNITY(0, BYT_NGPIO_SCORE, byt_score_pins_map), | ||
521 | }; | ||
522 | |||
523 | static const struct byt_pinctrl_soc_data byt_score_soc_data = { | ||
524 | .uid = BYT_SCORE_ACPI_UID, | ||
525 | .pins = byt_score_pins, | ||
526 | .npins = ARRAY_SIZE(byt_score_pins), | ||
527 | .groups = byt_score_groups, | ||
528 | .ngroups = ARRAY_SIZE(byt_score_groups), | ||
529 | .functions = byt_score_functions, | ||
530 | .nfunctions = ARRAY_SIZE(byt_score_functions), | ||
531 | .communities = byt_score_communities, | ||
532 | .ncommunities = ARRAY_SIZE(byt_score_communities), | ||
533 | }; | ||
534 | |||
535 | /* SUS pins, aka GPIOS_<pin_no> or GPIO_S5[<pin_no>] */ | ||
536 | static const struct pinctrl_pin_desc byt_sus_pins[] = { | ||
537 | PINCTRL_PIN(0, "GPIO_S50"), | ||
538 | PINCTRL_PIN(1, "GPIO_S51"), | ||
539 | PINCTRL_PIN(2, "GPIO_S52"), | ||
540 | PINCTRL_PIN(3, "GPIO_S53"), | ||
541 | PINCTRL_PIN(4, "GPIO_S54"), | ||
542 | PINCTRL_PIN(5, "GPIO_S55"), | ||
543 | PINCTRL_PIN(6, "GPIO_S56"), | ||
544 | PINCTRL_PIN(7, "GPIO_S57"), | ||
545 | PINCTRL_PIN(8, "GPIO_S58"), | ||
546 | PINCTRL_PIN(9, "GPIO_S59"), | ||
547 | PINCTRL_PIN(10, "GPIO_S510"), | ||
548 | PINCTRL_PIN(11, "PMC_SUSPWRDNACK"), | ||
549 | PINCTRL_PIN(12, "PMC_SUSCLK0"), | ||
550 | PINCTRL_PIN(13, "GPIO_S513"), | ||
551 | PINCTRL_PIN(14, "USB_ULPI_RST"), | ||
552 | PINCTRL_PIN(15, "PMC_WAKE_PCIE0#"), | ||
553 | PINCTRL_PIN(16, "PMC_PWRBTN"), | ||
554 | PINCTRL_PIN(17, "GPIO_S517"), | ||
555 | PINCTRL_PIN(18, "PMC_SUS_STAT"), | ||
556 | PINCTRL_PIN(19, "USB_OC0"), | ||
557 | PINCTRL_PIN(20, "USB_OC1"), | ||
558 | PINCTRL_PIN(21, "PCU_SPI_CS1"), | ||
559 | PINCTRL_PIN(22, "GPIO_S522"), | ||
560 | PINCTRL_PIN(23, "GPIO_S523"), | ||
561 | PINCTRL_PIN(24, "GPIO_S524"), | ||
562 | PINCTRL_PIN(25, "GPIO_S525"), | ||
563 | PINCTRL_PIN(26, "GPIO_S526"), | ||
564 | PINCTRL_PIN(27, "GPIO_S527"), | ||
565 | PINCTRL_PIN(28, "GPIO_S528"), | ||
566 | PINCTRL_PIN(29, "GPIO_S529"), | ||
567 | PINCTRL_PIN(30, "GPIO_S530"), | ||
568 | PINCTRL_PIN(31, "USB_ULPI_CLK"), | ||
569 | PINCTRL_PIN(32, "USB_ULPI_DATA0"), | ||
570 | PINCTRL_PIN(33, "USB_ULPI_DATA1"), | ||
571 | PINCTRL_PIN(34, "USB_ULPI_DATA2"), | ||
572 | PINCTRL_PIN(35, "USB_ULPI_DATA3"), | ||
573 | PINCTRL_PIN(36, "USB_ULPI_DATA4"), | ||
574 | PINCTRL_PIN(37, "USB_ULPI_DATA5"), | ||
575 | PINCTRL_PIN(38, "USB_ULPI_DATA6"), | ||
576 | PINCTRL_PIN(39, "USB_ULPI_DATA7"), | ||
577 | PINCTRL_PIN(40, "USB_ULPI_DIR"), | ||
578 | PINCTRL_PIN(41, "USB_ULPI_NXT"), | ||
579 | PINCTRL_PIN(42, "USB_ULPI_STP"), | ||
580 | PINCTRL_PIN(43, "USB_ULPI_REFCLK"), | ||
581 | }; | ||
582 | |||
583 | static const unsigned int byt_sus_pins_map[BYT_NGPIO_SUS] = { | ||
109 | 29, 33, 30, 31, 32, 34, 36, 35, 38, 37, | 584 | 29, 33, 30, 31, 32, 34, 36, 35, 38, 37, |
110 | 18, 7, 11, 20, 17, 1, 8, 10, 19, 12, | 585 | 18, 7, 11, 20, 17, 1, 8, 10, 19, 12, |
111 | 0, 2, 23, 39, 28, 27, 22, 21, 24, 25, | 586 | 0, 2, 23, 39, 28, 27, 22, 21, 24, 25, |
@@ -113,86 +588,373 @@ static unsigned const sus_pins[BYT_NGPIO_SUS] = { | |||
113 | 52, 53, 59, 40, | 588 | 52, 53, 59, 40, |
114 | }; | 589 | }; |
115 | 590 | ||
116 | static struct pinctrl_gpio_range byt_ranges[] = { | 591 | static const unsigned int byt_sus_usb_over_current_pins[] = { 19, 20 }; |
117 | { | 592 | static const struct byt_simple_func_mux byt_sus_usb_oc_mux[] = { |
118 | .name = BYT_SCORE_ACPI_UID, /* match with acpi _UID in probe */ | 593 | SIMPLE_FUNC("usb", 0), |
119 | .npins = BYT_NGPIO_SCORE, | 594 | SIMPLE_FUNC("gpio", 1), |
120 | .pins = score_pins, | ||
121 | }, | ||
122 | { | ||
123 | .name = BYT_NCORE_ACPI_UID, | ||
124 | .npins = BYT_NGPIO_NCORE, | ||
125 | .pins = ncore_pins, | ||
126 | }, | ||
127 | { | ||
128 | .name = BYT_SUS_ACPI_UID, | ||
129 | .npins = BYT_NGPIO_SUS, | ||
130 | .pins = sus_pins, | ||
131 | }, | ||
132 | { | ||
133 | }, | ||
134 | }; | 595 | }; |
135 | 596 | ||
136 | struct byt_gpio_pin_context { | 597 | static const unsigned int byt_sus_usb_ulpi_pins[] = { |
137 | u32 conf0; | 598 | 14, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, |
138 | u32 val; | 599 | }; |
600 | static const unsigned short byt_sus_usb_ulpi_mode_values[] = { | ||
601 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
602 | }; | ||
603 | static const unsigned short byt_sus_usb_ulpi_gpio_mode_values[] = { | ||
604 | 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
605 | }; | ||
606 | static const struct byt_mixed_func_mux byt_sus_usb_ulpi_mux[] = { | ||
607 | MIXED_FUNC("usb", byt_sus_usb_ulpi_mode_values), | ||
608 | MIXED_FUNC("gpio", byt_sus_usb_ulpi_gpio_mode_values), | ||
139 | }; | 609 | }; |
140 | 610 | ||
141 | struct byt_gpio { | 611 | static const unsigned int byt_sus_pcu_spi_pins[] = { 21 }; |
142 | struct gpio_chip chip; | 612 | static const struct byt_simple_func_mux byt_sus_pcu_spi_mux[] = { |
143 | struct platform_device *pdev; | 613 | SIMPLE_FUNC("spi", 0), |
144 | raw_spinlock_t lock; | 614 | SIMPLE_FUNC("gpio", 1), |
145 | void __iomem *reg_base; | 615 | }; |
146 | struct pinctrl_gpio_range *range; | 616 | |
147 | struct byt_gpio_pin_context *saved_context; | 617 | static const struct byt_pingroup byt_sus_groups[] = { |
618 | PIN_GROUP_SIMPLE("usb_oc_grp", | ||
619 | byt_sus_usb_over_current_pins, byt_sus_usb_oc_mux), | ||
620 | PIN_GROUP_MIXED("usb_ulpi_grp", | ||
621 | byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mux), | ||
622 | PIN_GROUP_SIMPLE("pcu_spi_grp", | ||
623 | byt_sus_pcu_spi_pins, byt_sus_pcu_spi_mux), | ||
624 | }; | ||
625 | |||
626 | static const char * const byt_sus_usb_groups[] = { | ||
627 | "usb_oc_grp", "usb_ulpi_grp", | ||
628 | }; | ||
629 | static const char * const byt_sus_spi_groups[] = { "pcu_spi_grp" }; | ||
630 | static const char * const byt_sus_gpio_groups[] = { | ||
631 | "usb_oc_grp", "usb_ulpi_grp", "pcu_spi_grp", | ||
632 | }; | ||
633 | |||
634 | static const struct byt_function byt_sus_functions[] = { | ||
635 | FUNCTION("usb", byt_sus_usb_groups), | ||
636 | FUNCTION("spi", byt_sus_spi_groups), | ||
637 | FUNCTION("gpio", byt_sus_gpio_groups), | ||
638 | }; | ||
639 | |||
640 | static const struct byt_community byt_sus_communities[] = { | ||
641 | COMMUNITY(0, BYT_NGPIO_SUS, byt_sus_pins_map), | ||
642 | }; | ||
643 | |||
644 | static const struct byt_pinctrl_soc_data byt_sus_soc_data = { | ||
645 | .uid = BYT_SUS_ACPI_UID, | ||
646 | .pins = byt_sus_pins, | ||
647 | .npins = ARRAY_SIZE(byt_sus_pins), | ||
648 | .groups = byt_sus_groups, | ||
649 | .ngroups = ARRAY_SIZE(byt_sus_groups), | ||
650 | .functions = byt_sus_functions, | ||
651 | .nfunctions = ARRAY_SIZE(byt_sus_functions), | ||
652 | .communities = byt_sus_communities, | ||
653 | .ncommunities = ARRAY_SIZE(byt_sus_communities), | ||
148 | }; | 654 | }; |
149 | 655 | ||
150 | static void __iomem *byt_gpio_reg(struct gpio_chip *chip, unsigned offset, | 656 | static const struct pinctrl_pin_desc byt_ncore_pins[] = { |
151 | int reg) | 657 | PINCTRL_PIN(0, "GPIO_NCORE0"), |
658 | PINCTRL_PIN(1, "GPIO_NCORE1"), | ||
659 | PINCTRL_PIN(2, "GPIO_NCORE2"), | ||
660 | PINCTRL_PIN(3, "GPIO_NCORE3"), | ||
661 | PINCTRL_PIN(4, "GPIO_NCORE4"), | ||
662 | PINCTRL_PIN(5, "GPIO_NCORE5"), | ||
663 | PINCTRL_PIN(6, "GPIO_NCORE6"), | ||
664 | PINCTRL_PIN(7, "GPIO_NCORE7"), | ||
665 | PINCTRL_PIN(8, "GPIO_NCORE8"), | ||
666 | PINCTRL_PIN(9, "GPIO_NCORE9"), | ||
667 | PINCTRL_PIN(10, "GPIO_NCORE10"), | ||
668 | PINCTRL_PIN(11, "GPIO_NCORE11"), | ||
669 | PINCTRL_PIN(12, "GPIO_NCORE12"), | ||
670 | PINCTRL_PIN(13, "GPIO_NCORE13"), | ||
671 | PINCTRL_PIN(14, "GPIO_NCORE14"), | ||
672 | PINCTRL_PIN(15, "GPIO_NCORE15"), | ||
673 | PINCTRL_PIN(16, "GPIO_NCORE16"), | ||
674 | PINCTRL_PIN(17, "GPIO_NCORE17"), | ||
675 | PINCTRL_PIN(18, "GPIO_NCORE18"), | ||
676 | PINCTRL_PIN(19, "GPIO_NCORE19"), | ||
677 | PINCTRL_PIN(20, "GPIO_NCORE20"), | ||
678 | PINCTRL_PIN(21, "GPIO_NCORE21"), | ||
679 | PINCTRL_PIN(22, "GPIO_NCORE22"), | ||
680 | PINCTRL_PIN(23, "GPIO_NCORE23"), | ||
681 | PINCTRL_PIN(24, "GPIO_NCORE24"), | ||
682 | PINCTRL_PIN(25, "GPIO_NCORE25"), | ||
683 | PINCTRL_PIN(26, "GPIO_NCORE26"), | ||
684 | PINCTRL_PIN(27, "GPIO_NCORE27"), | ||
685 | }; | ||
686 | |||
687 | static unsigned const byt_ncore_pins_map[BYT_NGPIO_NCORE] = { | ||
688 | 19, 18, 17, 20, 21, 22, 24, 25, 23, 16, | ||
689 | 14, 15, 12, 26, 27, 1, 4, 8, 11, 0, | ||
690 | 3, 6, 10, 13, 2, 5, 9, 7, | ||
691 | }; | ||
692 | |||
693 | static const struct byt_community byt_ncore_communities[] = { | ||
694 | COMMUNITY(0, BYT_NGPIO_NCORE, byt_ncore_pins_map), | ||
695 | }; | ||
696 | |||
697 | static const struct byt_pinctrl_soc_data byt_ncore_soc_data = { | ||
698 | .uid = BYT_NCORE_ACPI_UID, | ||
699 | .pins = byt_ncore_pins, | ||
700 | .npins = ARRAY_SIZE(byt_ncore_pins), | ||
701 | .communities = byt_ncore_communities, | ||
702 | .ncommunities = ARRAY_SIZE(byt_ncore_communities), | ||
703 | }; | ||
704 | |||
705 | static const struct byt_pinctrl_soc_data *byt_soc_data[] = { | ||
706 | &byt_score_soc_data, | ||
707 | &byt_sus_soc_data, | ||
708 | &byt_ncore_soc_data, | ||
709 | NULL, | ||
710 | }; | ||
711 | |||
712 | static struct byt_community *byt_get_community(struct byt_gpio *vg, | ||
713 | unsigned int pin) | ||
152 | { | 714 | { |
153 | struct byt_gpio *vg = gpiochip_get_data(chip); | 715 | struct byt_community *comm; |
154 | u32 reg_offset; | 716 | int i; |
717 | |||
718 | for (i = 0; i < vg->soc_data->ncommunities; i++) { | ||
719 | comm = vg->communities_copy + i; | ||
720 | if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base) | ||
721 | return comm; | ||
722 | } | ||
155 | 723 | ||
724 | return NULL; | ||
725 | } | ||
726 | |||
727 | static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, | ||
728 | int reg) | ||
729 | { | ||
730 | struct byt_community *comm = byt_get_community(vg, offset); | ||
731 | u32 reg_offset = 0; | ||
732 | |||
733 | if (!comm) | ||
734 | return NULL; | ||
735 | |||
736 | offset -= comm->pin_base; | ||
156 | if (reg == BYT_INT_STAT_REG) | 737 | if (reg == BYT_INT_STAT_REG) |
157 | reg_offset = (offset / 32) * 4; | 738 | reg_offset = (offset / 32) * 4; |
158 | else | 739 | else |
159 | reg_offset = vg->range->pins[offset] * 16; | 740 | reg_offset = comm->pad_map[offset] * 16; |
741 | |||
742 | return comm->reg_base + reg_offset + reg; | ||
743 | } | ||
744 | |||
745 | static int byt_get_groups_count(struct pinctrl_dev *pctldev) | ||
746 | { | ||
747 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
748 | |||
749 | return vg->soc_data->ngroups; | ||
750 | } | ||
751 | |||
752 | static const char *byt_get_group_name(struct pinctrl_dev *pctldev, | ||
753 | unsigned int selector) | ||
754 | { | ||
755 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
756 | |||
757 | return vg->soc_data->groups[selector].name; | ||
758 | } | ||
759 | |||
760 | static int byt_get_group_pins(struct pinctrl_dev *pctldev, | ||
761 | unsigned int selector, | ||
762 | const unsigned int **pins, | ||
763 | unsigned int *num_pins) | ||
764 | { | ||
765 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
766 | |||
767 | *pins = vg->soc_data->groups[selector].pins; | ||
768 | *num_pins = vg->soc_data->groups[selector].npins; | ||
769 | |||
770 | return 0; | ||
771 | } | ||
772 | |||
773 | static const struct pinctrl_ops byt_pinctrl_ops = { | ||
774 | .get_groups_count = byt_get_groups_count, | ||
775 | .get_group_name = byt_get_group_name, | ||
776 | .get_group_pins = byt_get_group_pins, | ||
777 | }; | ||
778 | |||
779 | static int byt_get_functions_count(struct pinctrl_dev *pctldev) | ||
780 | { | ||
781 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
782 | |||
783 | return vg->soc_data->nfunctions; | ||
784 | } | ||
785 | |||
786 | static const char *byt_get_function_name(struct pinctrl_dev *pctldev, | ||
787 | unsigned int selector) | ||
788 | { | ||
789 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
790 | |||
791 | return vg->soc_data->functions[selector].name; | ||
792 | } | ||
793 | |||
794 | static int byt_get_function_groups(struct pinctrl_dev *pctldev, | ||
795 | unsigned int selector, | ||
796 | const char * const **groups, | ||
797 | unsigned int *num_groups) | ||
798 | { | ||
799 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
800 | |||
801 | *groups = vg->soc_data->functions[selector].groups; | ||
802 | *num_groups = vg->soc_data->functions[selector].ngroups; | ||
803 | |||
804 | return 0; | ||
805 | } | ||
806 | |||
807 | static int byt_get_group_simple_mux(const struct byt_pingroup group, | ||
808 | const char *func_name, | ||
809 | unsigned short *func) | ||
810 | { | ||
811 | int i; | ||
812 | |||
813 | for (i = 0; i < group.nfuncs; i++) { | ||
814 | if (!strcmp(group.simple_funcs[i].name, func_name)) { | ||
815 | *func = group.simple_funcs[i].func; | ||
816 | return 0; | ||
817 | } | ||
818 | } | ||
819 | |||
820 | return 1; | ||
821 | } | ||
822 | |||
823 | static int byt_get_group_mixed_mux(const struct byt_pingroup group, | ||
824 | const char *func_name, | ||
825 | const unsigned short **func) | ||
826 | { | ||
827 | int i; | ||
828 | |||
829 | for (i = 0; i < group.nfuncs; i++) { | ||
830 | if (!strcmp(group.mixed_funcs[i].name, func_name)) { | ||
831 | *func = group.mixed_funcs[i].func_values; | ||
832 | return 0; | ||
833 | } | ||
834 | } | ||
160 | 835 | ||
161 | return vg->reg_base + reg_offset + reg; | 836 | return 1; |
162 | } | 837 | } |
163 | 838 | ||
164 | static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned offset) | 839 | static void byt_set_group_simple_mux(struct byt_gpio *vg, |
840 | const struct byt_pingroup group, | ||
841 | unsigned short func) | ||
165 | { | 842 | { |
166 | void __iomem *reg = byt_gpio_reg(&vg->chip, offset, BYT_CONF0_REG); | ||
167 | unsigned long flags; | 843 | unsigned long flags; |
168 | u32 value; | 844 | int i; |
169 | 845 | ||
170 | raw_spin_lock_irqsave(&vg->lock, flags); | 846 | raw_spin_lock_irqsave(&vg->lock, flags); |
171 | value = readl(reg); | 847 | |
172 | value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL); | 848 | for (i = 0; i < group.npins; i++) { |
173 | writel(value, reg); | 849 | void __iomem *padcfg0; |
850 | u32 value; | ||
851 | |||
852 | padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG); | ||
853 | if (!padcfg0) { | ||
854 | dev_warn(&vg->pdev->dev, | ||
855 | "Group %s, pin %i not muxed (no padcfg0)\n", | ||
856 | group.name, i); | ||
857 | continue; | ||
858 | } | ||
859 | |||
860 | value = readl(padcfg0); | ||
861 | value &= ~BYT_PIN_MUX; | ||
862 | value |= func; | ||
863 | writel(value, padcfg0); | ||
864 | } | ||
865 | |||
866 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
867 | } | ||
868 | |||
869 | static void byt_set_group_mixed_mux(struct byt_gpio *vg, | ||
870 | const struct byt_pingroup group, | ||
871 | const unsigned short *func) | ||
872 | { | ||
873 | unsigned long flags; | ||
874 | int i; | ||
875 | |||
876 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
877 | |||
878 | for (i = 0; i < group.npins; i++) { | ||
879 | void __iomem *padcfg0; | ||
880 | u32 value; | ||
881 | |||
882 | padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG); | ||
883 | if (!padcfg0) { | ||
884 | dev_warn(&vg->pdev->dev, | ||
885 | "Group %s, pin %i not muxed (no padcfg0)\n", | ||
886 | group.name, i); | ||
887 | continue; | ||
888 | } | ||
889 | |||
890 | value = readl(padcfg0); | ||
891 | value &= ~BYT_PIN_MUX; | ||
892 | value |= func[i]; | ||
893 | writel(value, padcfg0); | ||
894 | } | ||
895 | |||
174 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 896 | raw_spin_unlock_irqrestore(&vg->lock, flags); |
175 | } | 897 | } |
176 | 898 | ||
899 | static int byt_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector, | ||
900 | unsigned int group_selector) | ||
901 | { | ||
902 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); | ||
903 | const struct byt_function func = vg->soc_data->functions[func_selector]; | ||
904 | const struct byt_pingroup group = vg->soc_data->groups[group_selector]; | ||
905 | const unsigned short *mixed_func; | ||
906 | unsigned short simple_func; | ||
907 | int ret = 1; | ||
908 | |||
909 | if (group.has_simple_funcs) | ||
910 | ret = byt_get_group_simple_mux(group, func.name, &simple_func); | ||
911 | else | ||
912 | ret = byt_get_group_mixed_mux(group, func.name, &mixed_func); | ||
913 | |||
914 | if (ret) | ||
915 | byt_set_group_simple_mux(vg, group, BYT_DEFAULT_GPIO_MUX); | ||
916 | else if (group.has_simple_funcs) | ||
917 | byt_set_group_simple_mux(vg, group, simple_func); | ||
918 | else | ||
919 | byt_set_group_mixed_mux(vg, group, mixed_func); | ||
920 | |||
921 | return 0; | ||
922 | } | ||
923 | |||
177 | static u32 byt_get_gpio_mux(struct byt_gpio *vg, unsigned offset) | 924 | static u32 byt_get_gpio_mux(struct byt_gpio *vg, unsigned offset) |
178 | { | 925 | { |
179 | /* SCORE pin 92-93 */ | 926 | /* SCORE pin 92-93 */ |
180 | if (!strcmp(vg->range->name, BYT_SCORE_ACPI_UID) && | 927 | if (!strcmp(vg->soc_data->uid, BYT_SCORE_ACPI_UID) && |
181 | offset >= 92 && offset <= 93) | 928 | offset >= 92 && offset <= 93) |
182 | return 1; | 929 | return 1; |
183 | 930 | ||
184 | /* SUS pin 11-21 */ | 931 | /* SUS pin 11-21 */ |
185 | if (!strcmp(vg->range->name, BYT_SUS_ACPI_UID) && | 932 | if (!strcmp(vg->soc_data->uid, BYT_SUS_ACPI_UID) && |
186 | offset >= 11 && offset <= 21) | 933 | offset >= 11 && offset <= 21) |
187 | return 1; | 934 | return 1; |
188 | 935 | ||
189 | return 0; | 936 | return 0; |
190 | } | 937 | } |
191 | 938 | ||
192 | static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) | 939 | static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned int offset) |
193 | { | 940 | { |
194 | struct byt_gpio *vg = gpiochip_get_data(chip); | 941 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
195 | void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG); | 942 | unsigned long flags; |
943 | u32 value; | ||
944 | |||
945 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
946 | value = readl(reg); | ||
947 | value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL); | ||
948 | writel(value, reg); | ||
949 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
950 | } | ||
951 | |||
952 | static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev, | ||
953 | struct pinctrl_gpio_range *range, | ||
954 | unsigned int offset) | ||
955 | { | ||
956 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); | ||
957 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); | ||
196 | u32 value, gpio_mux; | 958 | u32 value, gpio_mux; |
197 | unsigned long flags; | 959 | unsigned long flags; |
198 | 960 | ||
@@ -225,53 +987,318 @@ static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) | |||
225 | return 0; | 987 | return 0; |
226 | } | 988 | } |
227 | 989 | ||
228 | static void byt_gpio_free(struct gpio_chip *chip, unsigned offset) | 990 | static void byt_gpio_disable_free(struct pinctrl_dev *pctl_dev, |
991 | struct pinctrl_gpio_range *range, | ||
992 | unsigned int offset) | ||
229 | { | 993 | { |
230 | struct byt_gpio *vg = gpiochip_get_data(chip); | 994 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
231 | 995 | ||
232 | byt_gpio_clear_triggering(vg, offset); | 996 | byt_gpio_clear_triggering(vg, offset); |
233 | pm_runtime_put(&vg->pdev->dev); | 997 | pm_runtime_put(&vg->pdev->dev); |
234 | } | 998 | } |
235 | 999 | ||
236 | static int byt_irq_type(struct irq_data *d, unsigned type) | 1000 | static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev, |
1001 | struct pinctrl_gpio_range *range, | ||
1002 | unsigned int offset, | ||
1003 | bool input) | ||
237 | { | 1004 | { |
238 | struct byt_gpio *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); | 1005 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
239 | u32 offset = irqd_to_hwirq(d); | 1006 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
240 | u32 value; | 1007 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
241 | unsigned long flags; | 1008 | unsigned long flags; |
242 | void __iomem *reg = byt_gpio_reg(&vg->chip, offset, BYT_CONF0_REG); | 1009 | u32 value; |
243 | 1010 | ||
244 | if (offset >= vg->chip.ngpio) | 1011 | raw_spin_lock_irqsave(&vg->lock, flags); |
1012 | |||
1013 | value = readl(val_reg); | ||
1014 | value &= ~BYT_DIR_MASK; | ||
1015 | if (input) | ||
1016 | value |= BYT_OUTPUT_EN; | ||
1017 | else | ||
1018 | /* | ||
1019 | * Before making any direction modifications, do a check if gpio | ||
1020 | * is set for direct IRQ. On baytrail, setting GPIO to output | ||
1021 | * does not make sense, so let's at least warn the caller before | ||
1022 | * they shoot themselves in the foot. | ||
1023 | */ | ||
1024 | WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN, | ||
1025 | "Potential Error: Setting GPIO with direct_irq_en to output"); | ||
1026 | writel(value, val_reg); | ||
1027 | |||
1028 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1029 | |||
1030 | return 0; | ||
1031 | } | ||
1032 | |||
1033 | static const struct pinmux_ops byt_pinmux_ops = { | ||
1034 | .get_functions_count = byt_get_functions_count, | ||
1035 | .get_function_name = byt_get_function_name, | ||
1036 | .get_function_groups = byt_get_function_groups, | ||
1037 | .set_mux = byt_set_mux, | ||
1038 | .gpio_request_enable = byt_gpio_request_enable, | ||
1039 | .gpio_disable_free = byt_gpio_disable_free, | ||
1040 | .gpio_set_direction = byt_gpio_set_direction, | ||
1041 | }; | ||
1042 | |||
1043 | static void byt_get_pull_strength(u32 reg, u16 *strength) | ||
1044 | { | ||
1045 | switch (reg & BYT_PULL_STR_MASK) { | ||
1046 | case BYT_PULL_STR_2K: | ||
1047 | *strength = 2000; | ||
1048 | break; | ||
1049 | case BYT_PULL_STR_10K: | ||
1050 | *strength = 10000; | ||
1051 | break; | ||
1052 | case BYT_PULL_STR_20K: | ||
1053 | *strength = 20000; | ||
1054 | break; | ||
1055 | case BYT_PULL_STR_40K: | ||
1056 | *strength = 40000; | ||
1057 | break; | ||
1058 | } | ||
1059 | } | ||
1060 | |||
1061 | static int byt_set_pull_strength(u32 *reg, u16 strength) | ||
1062 | { | ||
1063 | *reg &= ~BYT_PULL_STR_MASK; | ||
1064 | |||
1065 | switch (strength) { | ||
1066 | case 2000: | ||
1067 | *reg |= BYT_PULL_STR_2K; | ||
1068 | break; | ||
1069 | case 10000: | ||
1070 | *reg |= BYT_PULL_STR_10K; | ||
1071 | break; | ||
1072 | case 20000: | ||
1073 | *reg |= BYT_PULL_STR_20K; | ||
1074 | break; | ||
1075 | case 40000: | ||
1076 | *reg |= BYT_PULL_STR_40K; | ||
1077 | break; | ||
1078 | default: | ||
245 | return -EINVAL; | 1079 | return -EINVAL; |
1080 | } | ||
1081 | |||
1082 | return 0; | ||
1083 | } | ||
1084 | |||
1085 | static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset, | ||
1086 | unsigned long *config) | ||
1087 | { | ||
1088 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); | ||
1089 | enum pin_config_param param = pinconf_to_config_param(*config); | ||
1090 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); | ||
1091 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); | ||
1092 | unsigned long flags; | ||
1093 | u32 conf, pull, val, debounce; | ||
1094 | u16 arg = 0; | ||
246 | 1095 | ||
247 | raw_spin_lock_irqsave(&vg->lock, flags); | 1096 | raw_spin_lock_irqsave(&vg->lock, flags); |
248 | value = readl(reg); | 1097 | conf = readl(conf_reg); |
1098 | pull = conf & BYT_PULL_ASSIGN_MASK; | ||
1099 | val = readl(val_reg); | ||
1100 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
249 | 1101 | ||
250 | WARN(value & BYT_DIRECT_IRQ_EN, | 1102 | switch (param) { |
251 | "Bad pad config for io mode, force direct_irq_en bit clearing"); | 1103 | case PIN_CONFIG_BIAS_DISABLE: |
1104 | if (pull) | ||
1105 | return -EINVAL; | ||
1106 | break; | ||
1107 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
1108 | /* Pull assignment is only applicable in input mode */ | ||
1109 | if ((val & BYT_INPUT_EN) || pull != BYT_PULL_ASSIGN_DOWN) | ||
1110 | return -EINVAL; | ||
252 | 1111 | ||
253 | /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits | 1112 | byt_get_pull_strength(conf, &arg); |
254 | * are used to indicate high and low level triggering | ||
255 | */ | ||
256 | value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG | | ||
257 | BYT_TRIG_LVL); | ||
258 | 1113 | ||
259 | writel(value, reg); | 1114 | break; |
1115 | case PIN_CONFIG_BIAS_PULL_UP: | ||
1116 | /* Pull assignment is only applicable in input mode */ | ||
1117 | if ((val & BYT_INPUT_EN) || pull != BYT_PULL_ASSIGN_UP) | ||
1118 | return -EINVAL; | ||
260 | 1119 | ||
261 | if (type & IRQ_TYPE_EDGE_BOTH) | 1120 | byt_get_pull_strength(conf, &arg); |
262 | irq_set_handler_locked(d, handle_edge_irq); | ||
263 | else if (type & IRQ_TYPE_LEVEL_MASK) | ||
264 | irq_set_handler_locked(d, handle_level_irq); | ||
265 | 1121 | ||
266 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1122 | break; |
1123 | case PIN_CONFIG_INPUT_DEBOUNCE: | ||
1124 | if (!(conf & BYT_DEBOUNCE_EN)) | ||
1125 | return -EINVAL; | ||
1126 | |||
1127 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
1128 | debounce = readl(byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG)); | ||
1129 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1130 | |||
1131 | switch (debounce & BYT_DEBOUNCE_PULSE_MASK) { | ||
1132 | case BYT_DEBOUNCE_PULSE_375US: | ||
1133 | arg = 375; | ||
1134 | break; | ||
1135 | case BYT_DEBOUNCE_PULSE_750US: | ||
1136 | arg = 750; | ||
1137 | break; | ||
1138 | case BYT_DEBOUNCE_PULSE_1500US: | ||
1139 | arg = 1500; | ||
1140 | break; | ||
1141 | case BYT_DEBOUNCE_PULSE_3MS: | ||
1142 | arg = 3000; | ||
1143 | break; | ||
1144 | case BYT_DEBOUNCE_PULSE_6MS: | ||
1145 | arg = 6000; | ||
1146 | break; | ||
1147 | case BYT_DEBOUNCE_PULSE_12MS: | ||
1148 | arg = 12000; | ||
1149 | break; | ||
1150 | case BYT_DEBOUNCE_PULSE_24MS: | ||
1151 | arg = 24000; | ||
1152 | break; | ||
1153 | default: | ||
1154 | return -EINVAL; | ||
1155 | } | ||
1156 | |||
1157 | break; | ||
1158 | default: | ||
1159 | return -ENOTSUPP; | ||
1160 | } | ||
1161 | |||
1162 | *config = pinconf_to_config_packed(param, arg); | ||
267 | 1163 | ||
268 | return 0; | 1164 | return 0; |
269 | } | 1165 | } |
270 | 1166 | ||
1167 | static int byt_pin_config_set(struct pinctrl_dev *pctl_dev, | ||
1168 | unsigned int offset, | ||
1169 | unsigned long *configs, | ||
1170 | unsigned int num_configs) | ||
1171 | { | ||
1172 | struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); | ||
1173 | unsigned int param, arg; | ||
1174 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); | ||
1175 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); | ||
1176 | unsigned long flags; | ||
1177 | u32 conf, val, debounce; | ||
1178 | int i, ret = 0; | ||
1179 | |||
1180 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
1181 | |||
1182 | conf = readl(conf_reg); | ||
1183 | val = readl(val_reg); | ||
1184 | |||
1185 | for (i = 0; i < num_configs; i++) { | ||
1186 | param = pinconf_to_config_param(configs[i]); | ||
1187 | arg = pinconf_to_config_argument(configs[i]); | ||
1188 | |||
1189 | switch (param) { | ||
1190 | case PIN_CONFIG_BIAS_DISABLE: | ||
1191 | conf &= ~BYT_PULL_ASSIGN_MASK; | ||
1192 | break; | ||
1193 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
1194 | /* Set default strength value in case none is given */ | ||
1195 | if (arg == 1) | ||
1196 | arg = 2000; | ||
1197 | |||
1198 | /* | ||
1199 | * Pull assignment is only applicable in input mode. If | ||
1200 | * chip is not in input mode, set it and warn about it. | ||
1201 | */ | ||
1202 | if (val & BYT_INPUT_EN) { | ||
1203 | val &= ~BYT_INPUT_EN; | ||
1204 | writel(val, val_reg); | ||
1205 | dev_warn(&vg->pdev->dev, | ||
1206 | "pin %u forcibly set to input mode\n", | ||
1207 | offset); | ||
1208 | } | ||
1209 | |||
1210 | conf &= ~BYT_PULL_ASSIGN_MASK; | ||
1211 | conf |= BYT_PULL_ASSIGN_DOWN; | ||
1212 | ret = byt_set_pull_strength(&conf, arg); | ||
1213 | |||
1214 | break; | ||
1215 | case PIN_CONFIG_BIAS_PULL_UP: | ||
1216 | /* Set default strength value in case none is given */ | ||
1217 | if (arg == 1) | ||
1218 | arg = 2000; | ||
1219 | |||
1220 | /* | ||
1221 | * Pull assignment is only applicable in input mode. If | ||
1222 | * chip is not in input mode, set it and warn about it. | ||
1223 | */ | ||
1224 | if (val & BYT_INPUT_EN) { | ||
1225 | val &= ~BYT_INPUT_EN; | ||
1226 | writel(val, val_reg); | ||
1227 | dev_warn(&vg->pdev->dev, | ||
1228 | "pin %u forcibly set to input mode\n", | ||
1229 | offset); | ||
1230 | } | ||
1231 | |||
1232 | conf &= ~BYT_PULL_ASSIGN_MASK; | ||
1233 | conf |= BYT_PULL_ASSIGN_UP; | ||
1234 | ret = byt_set_pull_strength(&conf, arg); | ||
1235 | |||
1236 | break; | ||
1237 | case PIN_CONFIG_INPUT_DEBOUNCE: | ||
1238 | debounce = readl(byt_gpio_reg(vg, offset, | ||
1239 | BYT_DEBOUNCE_REG)); | ||
1240 | conf &= ~BYT_DEBOUNCE_PULSE_MASK; | ||
1241 | |||
1242 | switch (arg) { | ||
1243 | case 375: | ||
1244 | conf |= BYT_DEBOUNCE_PULSE_375US; | ||
1245 | break; | ||
1246 | case 750: | ||
1247 | conf |= BYT_DEBOUNCE_PULSE_750US; | ||
1248 | break; | ||
1249 | case 1500: | ||
1250 | conf |= BYT_DEBOUNCE_PULSE_1500US; | ||
1251 | break; | ||
1252 | case 3000: | ||
1253 | conf |= BYT_DEBOUNCE_PULSE_3MS; | ||
1254 | break; | ||
1255 | case 6000: | ||
1256 | conf |= BYT_DEBOUNCE_PULSE_6MS; | ||
1257 | break; | ||
1258 | case 12000: | ||
1259 | conf |= BYT_DEBOUNCE_PULSE_12MS; | ||
1260 | break; | ||
1261 | case 24000: | ||
1262 | conf |= BYT_DEBOUNCE_PULSE_24MS; | ||
1263 | break; | ||
1264 | default: | ||
1265 | ret = -EINVAL; | ||
1266 | } | ||
1267 | |||
1268 | break; | ||
1269 | default: | ||
1270 | ret = -ENOTSUPP; | ||
1271 | } | ||
1272 | |||
1273 | if (ret) | ||
1274 | break; | ||
1275 | } | ||
1276 | |||
1277 | if (!ret) | ||
1278 | writel(conf, conf_reg); | ||
1279 | |||
1280 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1281 | |||
1282 | return ret; | ||
1283 | } | ||
1284 | |||
1285 | static const struct pinconf_ops byt_pinconf_ops = { | ||
1286 | .is_generic = true, | ||
1287 | .pin_config_get = byt_pin_config_get, | ||
1288 | .pin_config_set = byt_pin_config_set, | ||
1289 | }; | ||
1290 | |||
1291 | static const struct pinctrl_desc byt_pinctrl_desc = { | ||
1292 | .pctlops = &byt_pinctrl_ops, | ||
1293 | .pmxops = &byt_pinmux_ops, | ||
1294 | .confops = &byt_pinconf_ops, | ||
1295 | .owner = THIS_MODULE, | ||
1296 | }; | ||
1297 | |||
271 | static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) | 1298 | static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) |
272 | { | 1299 | { |
273 | void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); | ||
274 | struct byt_gpio *vg = gpiochip_get_data(chip); | 1300 | struct byt_gpio *vg = gpiochip_get_data(chip); |
1301 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); | ||
275 | unsigned long flags; | 1302 | unsigned long flags; |
276 | u32 val; | 1303 | u32 val; |
277 | 1304 | ||
@@ -285,69 +1312,58 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
285 | static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 1312 | static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
286 | { | 1313 | { |
287 | struct byt_gpio *vg = gpiochip_get_data(chip); | 1314 | struct byt_gpio *vg = gpiochip_get_data(chip); |
288 | void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); | 1315 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
289 | unsigned long flags; | 1316 | unsigned long flags; |
290 | u32 old_val; | 1317 | u32 old_val; |
291 | 1318 | ||
292 | raw_spin_lock_irqsave(&vg->lock, flags); | 1319 | if (!reg) |
1320 | return; | ||
293 | 1321 | ||
1322 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
294 | old_val = readl(reg); | 1323 | old_val = readl(reg); |
295 | |||
296 | if (value) | 1324 | if (value) |
297 | writel(old_val | BYT_LEVEL, reg); | 1325 | writel(old_val | BYT_LEVEL, reg); |
298 | else | 1326 | else |
299 | writel(old_val & ~BYT_LEVEL, reg); | 1327 | writel(old_val & ~BYT_LEVEL, reg); |
300 | |||
301 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1328 | raw_spin_unlock_irqrestore(&vg->lock, flags); |
302 | } | 1329 | } |
303 | 1330 | ||
304 | static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | 1331 | static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) |
305 | { | 1332 | { |
306 | struct byt_gpio *vg = gpiochip_get_data(chip); | 1333 | struct byt_gpio *vg = gpiochip_get_data(chip); |
307 | void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); | 1334 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
308 | unsigned long flags; | 1335 | unsigned long flags; |
309 | u32 value; | 1336 | u32 value; |
310 | 1337 | ||
1338 | if (!reg) | ||
1339 | return -EINVAL; | ||
1340 | |||
311 | raw_spin_lock_irqsave(&vg->lock, flags); | 1341 | raw_spin_lock_irqsave(&vg->lock, flags); |
1342 | value = readl(reg); | ||
1343 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
312 | 1344 | ||
313 | value = readl(reg) | BYT_DIR_MASK; | 1345 | if (!(value & BYT_OUTPUT_EN)) |
314 | value &= ~BYT_INPUT_EN; /* active low */ | 1346 | return GPIOF_DIR_OUT; |
315 | writel(value, reg); | 1347 | if (!(value & BYT_INPUT_EN)) |
1348 | return GPIOF_DIR_IN; | ||
316 | 1349 | ||
317 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1350 | return -EINVAL; |
1351 | } | ||
318 | 1352 | ||
319 | return 0; | 1353 | static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) |
1354 | { | ||
1355 | return pinctrl_gpio_direction_input(chip->base + offset); | ||
320 | } | 1356 | } |
321 | 1357 | ||
322 | static int byt_gpio_direction_output(struct gpio_chip *chip, | 1358 | static int byt_gpio_direction_output(struct gpio_chip *chip, |
323 | unsigned gpio, int value) | 1359 | unsigned int offset, int value) |
324 | { | 1360 | { |
325 | struct byt_gpio *vg = gpiochip_get_data(chip); | 1361 | int ret = pinctrl_gpio_direction_output(chip->base + offset); |
326 | void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG); | ||
327 | void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG); | ||
328 | unsigned long flags; | ||
329 | u32 reg_val; | ||
330 | |||
331 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
332 | 1362 | ||
333 | /* | 1363 | if (ret) |
334 | * Before making any direction modifications, do a check if gpio | 1364 | return ret; |
335 | * is set for direct IRQ. On baytrail, setting GPIO to output does | ||
336 | * not make sense, so let's at least warn the caller before they shoot | ||
337 | * themselves in the foot. | ||
338 | */ | ||
339 | WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN, | ||
340 | "Potential Error: Setting GPIO with direct_irq_en to output"); | ||
341 | |||
342 | reg_val = readl(reg) | BYT_DIR_MASK; | ||
343 | reg_val &= ~(BYT_OUTPUT_EN | BYT_INPUT_EN); | ||
344 | |||
345 | if (value) | ||
346 | writel(reg_val | BYT_LEVEL, reg); | ||
347 | else | ||
348 | writel(reg_val & ~BYT_LEVEL, reg); | ||
349 | 1365 | ||
350 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1366 | byt_gpio_set(chip, offset, value); |
351 | 1367 | ||
352 | return 0; | 1368 | return 0; |
353 | } | 1369 | } |
@@ -356,20 +1372,45 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
356 | { | 1372 | { |
357 | struct byt_gpio *vg = gpiochip_get_data(chip); | 1373 | struct byt_gpio *vg = gpiochip_get_data(chip); |
358 | int i; | 1374 | int i; |
359 | u32 conf0, val, offs; | 1375 | u32 conf0, val; |
360 | 1376 | ||
361 | for (i = 0; i < vg->chip.ngpio; i++) { | 1377 | for (i = 0; i < vg->soc_data->npins; i++) { |
1378 | const struct byt_community *comm; | ||
362 | const char *pull_str = NULL; | 1379 | const char *pull_str = NULL; |
363 | const char *pull = NULL; | 1380 | const char *pull = NULL; |
1381 | void __iomem *reg; | ||
364 | unsigned long flags; | 1382 | unsigned long flags; |
365 | const char *label; | 1383 | const char *label; |
366 | offs = vg->range->pins[i] * 16; | 1384 | unsigned int pin; |
367 | 1385 | ||
368 | raw_spin_lock_irqsave(&vg->lock, flags); | 1386 | raw_spin_lock_irqsave(&vg->lock, flags); |
369 | conf0 = readl(vg->reg_base + offs + BYT_CONF0_REG); | 1387 | pin = vg->soc_data->pins[i].number; |
370 | val = readl(vg->reg_base + offs + BYT_VAL_REG); | 1388 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); |
1389 | if (!reg) { | ||
1390 | seq_printf(s, | ||
1391 | "Could not retrieve pin %i conf0 reg\n", | ||
1392 | pin); | ||
1393 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1394 | continue; | ||
1395 | } | ||
1396 | conf0 = readl(reg); | ||
1397 | |||
1398 | reg = byt_gpio_reg(vg, pin, BYT_VAL_REG); | ||
1399 | if (!reg) { | ||
1400 | seq_printf(s, | ||
1401 | "Could not retrieve pin %i val reg\n", pin); | ||
1402 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1403 | continue; | ||
1404 | } | ||
1405 | val = readl(reg); | ||
371 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1406 | raw_spin_unlock_irqrestore(&vg->lock, flags); |
372 | 1407 | ||
1408 | comm = byt_get_community(vg, pin); | ||
1409 | if (!comm) { | ||
1410 | seq_printf(s, | ||
1411 | "Could not get community for pin %i\n", pin); | ||
1412 | continue; | ||
1413 | } | ||
373 | label = gpiochip_is_requested(chip, i); | 1414 | label = gpiochip_is_requested(chip, i); |
374 | if (!label) | 1415 | if (!label) |
375 | label = "Unrequested"; | 1416 | label = "Unrequested"; |
@@ -400,12 +1441,12 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
400 | 1441 | ||
401 | seq_printf(s, | 1442 | seq_printf(s, |
402 | " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s", | 1443 | " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s", |
403 | i, | 1444 | pin, |
404 | label, | 1445 | label, |
405 | val & BYT_INPUT_EN ? " " : "in", | 1446 | val & BYT_INPUT_EN ? " " : "in", |
406 | val & BYT_OUTPUT_EN ? " " : "out", | 1447 | val & BYT_OUTPUT_EN ? " " : "out", |
407 | val & BYT_LEVEL ? "hi" : "lo", | 1448 | val & BYT_LEVEL ? "hi" : "lo", |
408 | vg->range->pins[i], offs, | 1449 | comm->pad_map[i], comm->pad_map[i] * 32, |
409 | conf0 & 0x7, | 1450 | conf0 & 0x7, |
410 | conf0 & BYT_TRIG_NEG ? " fall" : " ", | 1451 | conf0 & BYT_TRIG_NEG ? " fall" : " ", |
411 | conf0 & BYT_TRIG_POS ? " rise" : " ", | 1452 | conf0 & BYT_TRIG_POS ? " rise" : " ", |
@@ -423,27 +1464,17 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
423 | } | 1464 | } |
424 | } | 1465 | } |
425 | 1466 | ||
426 | static void byt_gpio_irq_handler(struct irq_desc *desc) | 1467 | static const struct gpio_chip byt_gpio_chip = { |
427 | { | 1468 | .owner = THIS_MODULE, |
428 | struct irq_data *data = irq_desc_get_irq_data(desc); | 1469 | .request = gpiochip_generic_request, |
429 | struct byt_gpio *vg = gpiochip_get_data(irq_desc_get_handler_data(desc)); | 1470 | .free = gpiochip_generic_free, |
430 | struct irq_chip *chip = irq_data_get_irq_chip(data); | 1471 | .get_direction = byt_gpio_get_direction, |
431 | u32 base, pin; | 1472 | .direction_input = byt_gpio_direction_input, |
432 | void __iomem *reg; | 1473 | .direction_output = byt_gpio_direction_output, |
433 | unsigned long pending; | 1474 | .get = byt_gpio_get, |
434 | unsigned virq; | 1475 | .set = byt_gpio_set, |
435 | 1476 | .dbg_show = byt_gpio_dbg_show, | |
436 | /* check from GPIO controller which pin triggered the interrupt */ | 1477 | }; |
437 | for (base = 0; base < vg->chip.ngpio; base += 32) { | ||
438 | reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG); | ||
439 | pending = readl(reg); | ||
440 | for_each_set_bit(pin, &pending, 32) { | ||
441 | virq = irq_find_mapping(vg->chip.irqdomain, base + pin); | ||
442 | generic_handle_irq(virq); | ||
443 | } | ||
444 | } | ||
445 | chip->irq_eoi(data); | ||
446 | } | ||
447 | 1478 | ||
448 | static void byt_irq_ack(struct irq_data *d) | 1479 | static void byt_irq_ack(struct irq_data *d) |
449 | { | 1480 | { |
@@ -452,12 +1483,23 @@ static void byt_irq_ack(struct irq_data *d) | |||
452 | unsigned offset = irqd_to_hwirq(d); | 1483 | unsigned offset = irqd_to_hwirq(d); |
453 | void __iomem *reg; | 1484 | void __iomem *reg; |
454 | 1485 | ||
1486 | reg = byt_gpio_reg(vg, offset, BYT_INT_STAT_REG); | ||
1487 | if (!reg) | ||
1488 | return; | ||
1489 | |||
455 | raw_spin_lock(&vg->lock); | 1490 | raw_spin_lock(&vg->lock); |
456 | reg = byt_gpio_reg(&vg->chip, offset, BYT_INT_STAT_REG); | ||
457 | writel(BIT(offset % 32), reg); | 1491 | writel(BIT(offset % 32), reg); |
458 | raw_spin_unlock(&vg->lock); | 1492 | raw_spin_unlock(&vg->lock); |
459 | } | 1493 | } |
460 | 1494 | ||
1495 | static void byt_irq_mask(struct irq_data *d) | ||
1496 | { | ||
1497 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
1498 | struct byt_gpio *vg = gpiochip_get_data(gc); | ||
1499 | |||
1500 | byt_gpio_clear_triggering(vg, irqd_to_hwirq(d)); | ||
1501 | } | ||
1502 | |||
461 | static void byt_irq_unmask(struct irq_data *d) | 1503 | static void byt_irq_unmask(struct irq_data *d) |
462 | { | 1504 | { |
463 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 1505 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
@@ -467,7 +1509,9 @@ static void byt_irq_unmask(struct irq_data *d) | |||
467 | void __iomem *reg; | 1509 | void __iomem *reg; |
468 | u32 value; | 1510 | u32 value; |
469 | 1511 | ||
470 | reg = byt_gpio_reg(&vg->chip, offset, BYT_CONF0_REG); | 1512 | reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
1513 | if (!reg) | ||
1514 | return; | ||
471 | 1515 | ||
472 | raw_spin_lock_irqsave(&vg->lock, flags); | 1516 | raw_spin_lock_irqsave(&vg->lock, flags); |
473 | value = readl(reg); | 1517 | value = readl(reg); |
@@ -493,23 +1537,81 @@ static void byt_irq_unmask(struct irq_data *d) | |||
493 | raw_spin_unlock_irqrestore(&vg->lock, flags); | 1537 | raw_spin_unlock_irqrestore(&vg->lock, flags); |
494 | } | 1538 | } |
495 | 1539 | ||
496 | static void byt_irq_mask(struct irq_data *d) | 1540 | static int byt_irq_type(struct irq_data *d, unsigned int type) |
497 | { | 1541 | { |
498 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 1542 | struct byt_gpio *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
499 | struct byt_gpio *vg = gpiochip_get_data(gc); | 1543 | u32 offset = irqd_to_hwirq(d); |
1544 | u32 value; | ||
1545 | unsigned long flags; | ||
1546 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); | ||
500 | 1547 | ||
501 | byt_gpio_clear_triggering(vg, irqd_to_hwirq(d)); | 1548 | if (!reg || offset >= vg->chip.ngpio) |
1549 | return -EINVAL; | ||
1550 | |||
1551 | raw_spin_lock_irqsave(&vg->lock, flags); | ||
1552 | value = readl(reg); | ||
1553 | |||
1554 | WARN(value & BYT_DIRECT_IRQ_EN, | ||
1555 | "Bad pad config for io mode, force direct_irq_en bit clearing"); | ||
1556 | |||
1557 | /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits | ||
1558 | * are used to indicate high and low level triggering | ||
1559 | */ | ||
1560 | value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG | | ||
1561 | BYT_TRIG_LVL); | ||
1562 | |||
1563 | writel(value, reg); | ||
1564 | |||
1565 | if (type & IRQ_TYPE_EDGE_BOTH) | ||
1566 | irq_set_handler_locked(d, handle_edge_irq); | ||
1567 | else if (type & IRQ_TYPE_LEVEL_MASK) | ||
1568 | irq_set_handler_locked(d, handle_level_irq); | ||
1569 | |||
1570 | raw_spin_unlock_irqrestore(&vg->lock, flags); | ||
1571 | |||
1572 | return 0; | ||
502 | } | 1573 | } |
503 | 1574 | ||
504 | static struct irq_chip byt_irqchip = { | 1575 | static struct irq_chip byt_irqchip = { |
505 | .name = "BYT-GPIO", | 1576 | .name = "BYT-GPIO", |
506 | .irq_ack = byt_irq_ack, | 1577 | .irq_ack = byt_irq_ack, |
507 | .irq_mask = byt_irq_mask, | 1578 | .irq_mask = byt_irq_mask, |
508 | .irq_unmask = byt_irq_unmask, | 1579 | .irq_unmask = byt_irq_unmask, |
509 | .irq_set_type = byt_irq_type, | 1580 | .irq_set_type = byt_irq_type, |
510 | .flags = IRQCHIP_SKIP_SET_WAKE, | 1581 | .flags = IRQCHIP_SKIP_SET_WAKE, |
511 | }; | 1582 | }; |
512 | 1583 | ||
1584 | static void byt_gpio_irq_handler(struct irq_desc *desc) | ||
1585 | { | ||
1586 | struct irq_data *data = irq_desc_get_irq_data(desc); | ||
1587 | struct byt_gpio *vg = gpiochip_get_data( | ||
1588 | irq_desc_get_handler_data(desc)); | ||
1589 | struct irq_chip *chip = irq_data_get_irq_chip(data); | ||
1590 | u32 base, pin; | ||
1591 | void __iomem *reg; | ||
1592 | unsigned long pending; | ||
1593 | unsigned int virq; | ||
1594 | |||
1595 | /* check from GPIO controller which pin triggered the interrupt */ | ||
1596 | for (base = 0; base < vg->chip.ngpio; base += 32) { | ||
1597 | reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG); | ||
1598 | |||
1599 | if (!reg) { | ||
1600 | dev_warn(&vg->pdev->dev, | ||
1601 | "Pin %i: could not retrieve interrupt status register\n", | ||
1602 | base); | ||
1603 | continue; | ||
1604 | } | ||
1605 | |||
1606 | pending = readl(reg); | ||
1607 | for_each_set_bit(pin, &pending, 32) { | ||
1608 | virq = irq_find_mapping(vg->chip.irqdomain, base + pin); | ||
1609 | generic_handle_irq(virq); | ||
1610 | } | ||
1611 | } | ||
1612 | chip->irq_eoi(data); | ||
1613 | } | ||
1614 | |||
513 | static void byt_gpio_irq_init_hw(struct byt_gpio *vg) | 1615 | static void byt_gpio_irq_init_hw(struct byt_gpio *vg) |
514 | { | 1616 | { |
515 | void __iomem *reg; | 1617 | void __iomem *reg; |
@@ -521,8 +1623,18 @@ static void byt_gpio_irq_init_hw(struct byt_gpio *vg) | |||
521 | * do not use direct IRQ mode. This will prevent spurious | 1623 | * do not use direct IRQ mode. This will prevent spurious |
522 | * interrupts from misconfigured pins. | 1624 | * interrupts from misconfigured pins. |
523 | */ | 1625 | */ |
524 | for (i = 0; i < vg->chip.ngpio; i++) { | 1626 | for (i = 0; i < vg->soc_data->npins; i++) { |
525 | value = readl(byt_gpio_reg(&vg->chip, i, BYT_CONF0_REG)); | 1627 | unsigned int pin = vg->soc_data->pins[i].number; |
1628 | |||
1629 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); | ||
1630 | if (!reg) { | ||
1631 | dev_warn(&vg->pdev->dev, | ||
1632 | "Pin %i: could not retrieve conf0 register\n", | ||
1633 | i); | ||
1634 | continue; | ||
1635 | } | ||
1636 | |||
1637 | value = readl(reg); | ||
526 | if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i) && | 1638 | if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i) && |
527 | !(value & BYT_DIRECT_IRQ_EN)) { | 1639 | !(value & BYT_DIRECT_IRQ_EN)) { |
528 | byt_gpio_clear_triggering(vg, i); | 1640 | byt_gpio_clear_triggering(vg, i); |
@@ -531,8 +1643,16 @@ static void byt_gpio_irq_init_hw(struct byt_gpio *vg) | |||
531 | } | 1643 | } |
532 | 1644 | ||
533 | /* clear interrupt status trigger registers */ | 1645 | /* clear interrupt status trigger registers */ |
534 | for (base = 0; base < vg->chip.ngpio; base += 32) { | 1646 | for (base = 0; base < vg->soc_data->npins; base += 32) { |
535 | reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG); | 1647 | reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG); |
1648 | |||
1649 | if (!reg) { | ||
1650 | dev_warn(&vg->pdev->dev, | ||
1651 | "Pin %i: could not retrieve irq status reg\n", | ||
1652 | base); | ||
1653 | continue; | ||
1654 | } | ||
1655 | |||
536 | writel(0xffffffff, reg); | 1656 | writel(0xffffffff, reg); |
537 | /* make sure trigger bits are cleared, if not then a pin | 1657 | /* make sure trigger bits are cleared, if not then a pin |
538 | might be misconfigured in bios */ | 1658 | might be misconfigured in bios */ |
@@ -543,82 +1663,47 @@ static void byt_gpio_irq_init_hw(struct byt_gpio *vg) | |||
543 | } | 1663 | } |
544 | } | 1664 | } |
545 | 1665 | ||
546 | static int byt_gpio_probe(struct platform_device *pdev) | 1666 | static int byt_gpio_probe(struct byt_gpio *vg) |
547 | { | 1667 | { |
548 | struct byt_gpio *vg; | ||
549 | struct gpio_chip *gc; | 1668 | struct gpio_chip *gc; |
550 | struct resource *mem_rc, *irq_rc; | 1669 | struct resource *irq_rc; |
551 | struct device *dev = &pdev->dev; | ||
552 | struct acpi_device *acpi_dev; | ||
553 | struct pinctrl_gpio_range *range; | ||
554 | acpi_handle handle = ACPI_HANDLE(dev); | ||
555 | int ret; | 1670 | int ret; |
556 | 1671 | ||
557 | if (acpi_bus_get_device(handle, &acpi_dev)) | 1672 | /* Set up gpio chip */ |
558 | return -ENODEV; | 1673 | vg->chip = byt_gpio_chip; |
559 | 1674 | gc = &vg->chip; | |
560 | vg = devm_kzalloc(dev, sizeof(struct byt_gpio), GFP_KERNEL); | 1675 | gc->label = dev_name(&vg->pdev->dev); |
561 | if (!vg) { | 1676 | gc->base = -1; |
562 | dev_err(&pdev->dev, "can't allocate byt_gpio chip data\n"); | 1677 | gc->can_sleep = false; |
563 | return -ENOMEM; | 1678 | gc->parent = &vg->pdev->dev; |
564 | } | 1679 | gc->ngpio = vg->soc_data->npins; |
565 | |||
566 | for (range = byt_ranges; range->name; range++) { | ||
567 | if (!strcmp(acpi_dev->pnp.unique_id, range->name)) { | ||
568 | vg->chip.ngpio = range->npins; | ||
569 | vg->range = range; | ||
570 | break; | ||
571 | } | ||
572 | } | ||
573 | |||
574 | if (!vg->chip.ngpio || !vg->range) | ||
575 | return -ENODEV; | ||
576 | |||
577 | vg->pdev = pdev; | ||
578 | platform_set_drvdata(pdev, vg); | ||
579 | |||
580 | mem_rc = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
581 | vg->reg_base = devm_ioremap_resource(dev, mem_rc); | ||
582 | if (IS_ERR(vg->reg_base)) | ||
583 | return PTR_ERR(vg->reg_base); | ||
584 | |||
585 | raw_spin_lock_init(&vg->lock); | ||
586 | |||
587 | gc = &vg->chip; | ||
588 | gc->label = dev_name(&pdev->dev); | ||
589 | gc->owner = THIS_MODULE; | ||
590 | gc->request = byt_gpio_request; | ||
591 | gc->free = byt_gpio_free; | ||
592 | gc->direction_input = byt_gpio_direction_input; | ||
593 | gc->direction_output = byt_gpio_direction_output; | ||
594 | gc->get = byt_gpio_get; | ||
595 | gc->set = byt_gpio_set; | ||
596 | gc->dbg_show = byt_gpio_dbg_show; | ||
597 | gc->base = -1; | ||
598 | gc->can_sleep = false; | ||
599 | gc->parent = dev; | ||
600 | 1680 | ||
601 | #ifdef CONFIG_PM_SLEEP | 1681 | #ifdef CONFIG_PM_SLEEP |
602 | vg->saved_context = devm_kcalloc(&pdev->dev, gc->ngpio, | 1682 | vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio, |
603 | sizeof(*vg->saved_context), GFP_KERNEL); | 1683 | sizeof(*vg->saved_context), GFP_KERNEL); |
604 | #endif | 1684 | #endif |
605 | |||
606 | ret = gpiochip_add_data(gc, vg); | 1685 | ret = gpiochip_add_data(gc, vg); |
607 | if (ret) { | 1686 | if (ret) { |
608 | dev_err(&pdev->dev, "failed adding byt-gpio chip\n"); | 1687 | dev_err(&vg->pdev->dev, "failed adding byt-gpio chip\n"); |
609 | return ret; | 1688 | return ret; |
610 | } | 1689 | } |
611 | 1690 | ||
1691 | ret = gpiochip_add_pin_range(&vg->chip, dev_name(&vg->pdev->dev), | ||
1692 | 0, 0, vg->soc_data->npins); | ||
1693 | if (ret) { | ||
1694 | dev_err(&vg->pdev->dev, "failed to add GPIO pin range\n"); | ||
1695 | goto fail; | ||
1696 | } | ||
1697 | |||
612 | /* set up interrupts */ | 1698 | /* set up interrupts */ |
613 | irq_rc = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 1699 | irq_rc = platform_get_resource(vg->pdev, IORESOURCE_IRQ, 0); |
614 | if (irq_rc && irq_rc->start) { | 1700 | if (irq_rc && irq_rc->start) { |
615 | byt_gpio_irq_init_hw(vg); | 1701 | byt_gpio_irq_init_hw(vg); |
616 | ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0, | 1702 | ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0, |
617 | handle_simple_irq, IRQ_TYPE_NONE); | 1703 | handle_simple_irq, IRQ_TYPE_NONE); |
618 | if (ret) { | 1704 | if (ret) { |
619 | dev_err(dev, "failed to add irqchip\n"); | 1705 | dev_err(&vg->pdev->dev, "failed to add irqchip\n"); |
620 | gpiochip_remove(gc); | 1706 | goto fail; |
621 | return ret; | ||
622 | } | 1707 | } |
623 | 1708 | ||
624 | gpiochip_set_chained_irqchip(gc, &byt_irqchip, | 1709 | gpiochip_set_chained_irqchip(gc, &byt_irqchip, |
@@ -626,7 +1711,120 @@ static int byt_gpio_probe(struct platform_device *pdev) | |||
626 | byt_gpio_irq_handler); | 1711 | byt_gpio_irq_handler); |
627 | } | 1712 | } |
628 | 1713 | ||
629 | pm_runtime_enable(dev); | 1714 | return ret; |
1715 | |||
1716 | fail: | ||
1717 | gpiochip_remove(&vg->chip); | ||
1718 | |||
1719 | return ret; | ||
1720 | } | ||
1721 | |||
1722 | static int byt_set_soc_data(struct byt_gpio *vg, | ||
1723 | const struct byt_pinctrl_soc_data *soc_data) | ||
1724 | { | ||
1725 | int i; | ||
1726 | |||
1727 | vg->soc_data = soc_data; | ||
1728 | vg->communities_copy = devm_kcalloc(&vg->pdev->dev, | ||
1729 | soc_data->ncommunities, | ||
1730 | sizeof(*vg->communities_copy), | ||
1731 | GFP_KERNEL); | ||
1732 | if (!vg->communities_copy) | ||
1733 | return -ENOMEM; | ||
1734 | |||
1735 | for (i = 0; i < soc_data->ncommunities; i++) { | ||
1736 | struct byt_community *comm = vg->communities_copy + i; | ||
1737 | struct resource *mem_rc; | ||
1738 | |||
1739 | *comm = vg->soc_data->communities[i]; | ||
1740 | |||
1741 | mem_rc = platform_get_resource(vg->pdev, IORESOURCE_MEM, 0); | ||
1742 | comm->reg_base = devm_ioremap_resource(&vg->pdev->dev, mem_rc); | ||
1743 | if (IS_ERR(comm->reg_base)) | ||
1744 | return PTR_ERR(comm->reg_base); | ||
1745 | } | ||
1746 | |||
1747 | return 0; | ||
1748 | } | ||
1749 | |||
1750 | static const struct acpi_device_id byt_gpio_acpi_match[] = { | ||
1751 | { "INT33B2", (kernel_ulong_t)byt_soc_data }, | ||
1752 | { "INT33FC", (kernel_ulong_t)byt_soc_data }, | ||
1753 | { } | ||
1754 | }; | ||
1755 | MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); | ||
1756 | |||
1757 | static int byt_pinctrl_probe(struct platform_device *pdev) | ||
1758 | { | ||
1759 | const struct byt_pinctrl_soc_data *soc_data = NULL; | ||
1760 | const struct byt_pinctrl_soc_data **soc_table; | ||
1761 | const struct acpi_device_id *acpi_id; | ||
1762 | struct acpi_device *acpi_dev; | ||
1763 | struct byt_gpio *vg; | ||
1764 | int i, ret; | ||
1765 | |||
1766 | acpi_dev = ACPI_COMPANION(&pdev->dev); | ||
1767 | if (!acpi_dev) | ||
1768 | return -ENODEV; | ||
1769 | |||
1770 | acpi_id = acpi_match_device(byt_gpio_acpi_match, &pdev->dev); | ||
1771 | if (!acpi_id) | ||
1772 | return -ENODEV; | ||
1773 | |||
1774 | soc_table = (const struct byt_pinctrl_soc_data **)acpi_id->driver_data; | ||
1775 | |||
1776 | for (i = 0; soc_table[i]; i++) { | ||
1777 | if (!strcmp(acpi_dev->pnp.unique_id, soc_table[i]->uid)) { | ||
1778 | soc_data = soc_table[i]; | ||
1779 | break; | ||
1780 | } | ||
1781 | } | ||
1782 | |||
1783 | if (!soc_data) | ||
1784 | return -ENODEV; | ||
1785 | |||
1786 | vg = devm_kzalloc(&pdev->dev, sizeof(*vg), GFP_KERNEL); | ||
1787 | if (!vg) | ||
1788 | return -ENOMEM; | ||
1789 | |||
1790 | vg->pdev = pdev; | ||
1791 | ret = byt_set_soc_data(vg, soc_data); | ||
1792 | if (ret) { | ||
1793 | dev_err(&pdev->dev, "failed to set soc data\n"); | ||
1794 | return ret; | ||
1795 | } | ||
1796 | |||
1797 | vg->pctl_desc = byt_pinctrl_desc; | ||
1798 | vg->pctl_desc.name = dev_name(&pdev->dev); | ||
1799 | vg->pctl_desc.pins = vg->soc_data->pins; | ||
1800 | vg->pctl_desc.npins = vg->soc_data->npins; | ||
1801 | |||
1802 | vg->pctl_dev = pinctrl_register(&vg->pctl_desc, &pdev->dev, vg); | ||
1803 | if (IS_ERR(vg->pctl_dev)) { | ||
1804 | dev_err(&pdev->dev, "failed to register pinctrl driver\n"); | ||
1805 | return PTR_ERR(vg->pctl_dev); | ||
1806 | } | ||
1807 | |||
1808 | ret = byt_gpio_probe(vg); | ||
1809 | if (ret) { | ||
1810 | pinctrl_unregister(vg->pctl_dev); | ||
1811 | return ret; | ||
1812 | } | ||
1813 | |||
1814 | platform_set_drvdata(pdev, vg); | ||
1815 | raw_spin_lock_init(&vg->lock); | ||
1816 | pm_runtime_enable(&pdev->dev); | ||
1817 | |||
1818 | return 0; | ||
1819 | } | ||
1820 | |||
1821 | static int byt_pinctrl_remove(struct platform_device *pdev) | ||
1822 | { | ||
1823 | struct byt_gpio *vg = platform_get_drvdata(pdev); | ||
1824 | |||
1825 | pm_runtime_disable(&pdev->dev); | ||
1826 | gpiochip_remove(&vg->chip); | ||
1827 | pinctrl_unregister(vg->pctl_dev); | ||
630 | 1828 | ||
631 | return 0; | 1829 | return 0; |
632 | } | 1830 | } |
@@ -638,15 +1836,22 @@ static int byt_gpio_suspend(struct device *dev) | |||
638 | struct byt_gpio *vg = platform_get_drvdata(pdev); | 1836 | struct byt_gpio *vg = platform_get_drvdata(pdev); |
639 | int i; | 1837 | int i; |
640 | 1838 | ||
641 | for (i = 0; i < vg->chip.ngpio; i++) { | 1839 | for (i = 0; i < vg->soc_data->npins; i++) { |
642 | void __iomem *reg; | 1840 | void __iomem *reg; |
643 | u32 value; | 1841 | u32 value; |
644 | 1842 | unsigned int pin = vg->soc_data->pins[i].number; | |
645 | reg = byt_gpio_reg(&vg->chip, i, BYT_CONF0_REG); | 1843 | |
1844 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); | ||
1845 | if (!reg) { | ||
1846 | dev_warn(&vg->pdev->dev, | ||
1847 | "Pin %i: could not retrieve conf0 register\n", | ||
1848 | i); | ||
1849 | continue; | ||
1850 | } | ||
646 | value = readl(reg) & BYT_CONF0_RESTORE_MASK; | 1851 | value = readl(reg) & BYT_CONF0_RESTORE_MASK; |
647 | vg->saved_context[i].conf0 = value; | 1852 | vg->saved_context[i].conf0 = value; |
648 | 1853 | ||
649 | reg = byt_gpio_reg(&vg->chip, i, BYT_VAL_REG); | 1854 | reg = byt_gpio_reg(vg, pin, BYT_VAL_REG); |
650 | value = readl(reg) & BYT_VAL_RESTORE_MASK; | 1855 | value = readl(reg) & BYT_VAL_RESTORE_MASK; |
651 | vg->saved_context[i].val = value; | 1856 | vg->saved_context[i].val = value; |
652 | } | 1857 | } |
@@ -660,11 +1865,18 @@ static int byt_gpio_resume(struct device *dev) | |||
660 | struct byt_gpio *vg = platform_get_drvdata(pdev); | 1865 | struct byt_gpio *vg = platform_get_drvdata(pdev); |
661 | int i; | 1866 | int i; |
662 | 1867 | ||
663 | for (i = 0; i < vg->chip.ngpio; i++) { | 1868 | for (i = 0; i < vg->soc_data->npins; i++) { |
664 | void __iomem *reg; | 1869 | void __iomem *reg; |
665 | u32 value; | 1870 | u32 value; |
666 | 1871 | unsigned int pin = vg->soc_data->pins[i].number; | |
667 | reg = byt_gpio_reg(&vg->chip, i, BYT_CONF0_REG); | 1872 | |
1873 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); | ||
1874 | if (!reg) { | ||
1875 | dev_warn(&vg->pdev->dev, | ||
1876 | "Pin %i: could not retrieve conf0 register\n", | ||
1877 | i); | ||
1878 | continue; | ||
1879 | } | ||
668 | value = readl(reg); | 1880 | value = readl(reg); |
669 | if ((value & BYT_CONF0_RESTORE_MASK) != | 1881 | if ((value & BYT_CONF0_RESTORE_MASK) != |
670 | vg->saved_context[i].conf0) { | 1882 | vg->saved_context[i].conf0) { |
@@ -674,7 +1886,7 @@ static int byt_gpio_resume(struct device *dev) | |||
674 | dev_info(dev, "restored pin %d conf0 %#08x", i, value); | 1886 | dev_info(dev, "restored pin %d conf0 %#08x", i, value); |
675 | } | 1887 | } |
676 | 1888 | ||
677 | reg = byt_gpio_reg(&vg->chip, i, BYT_VAL_REG); | 1889 | reg = byt_gpio_reg(vg, pin, BYT_VAL_REG); |
678 | value = readl(reg); | 1890 | value = readl(reg); |
679 | if ((value & BYT_VAL_RESTORE_MASK) != | 1891 | if ((value & BYT_VAL_RESTORE_MASK) != |
680 | vg->saved_context[i].val) { | 1892 | vg->saved_context[i].val) { |
@@ -712,26 +1924,9 @@ static const struct dev_pm_ops byt_gpio_pm_ops = { | |||
712 | NULL) | 1924 | NULL) |
713 | }; | 1925 | }; |
714 | 1926 | ||
715 | static const struct acpi_device_id byt_gpio_acpi_match[] = { | ||
716 | { "INT33B2", 0 }, | ||
717 | { "INT33FC", 0 }, | ||
718 | { } | ||
719 | }; | ||
720 | MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); | ||
721 | |||
722 | static int byt_gpio_remove(struct platform_device *pdev) | ||
723 | { | ||
724 | struct byt_gpio *vg = platform_get_drvdata(pdev); | ||
725 | |||
726 | pm_runtime_disable(&pdev->dev); | ||
727 | gpiochip_remove(&vg->chip); | ||
728 | |||
729 | return 0; | ||
730 | } | ||
731 | |||
732 | static struct platform_driver byt_gpio_driver = { | 1927 | static struct platform_driver byt_gpio_driver = { |
733 | .probe = byt_gpio_probe, | 1928 | .probe = byt_pinctrl_probe, |
734 | .remove = byt_gpio_remove, | 1929 | .remove = byt_pinctrl_remove, |
735 | .driver = { | 1930 | .driver = { |
736 | .name = "byt_gpio", | 1931 | .name = "byt_gpio", |
737 | .pm = &byt_gpio_pm_ops, | 1932 | .pm = &byt_gpio_pm_ops, |
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index 4251e0747a3a..ac4f564f1c3e 100644 --- a/drivers/pinctrl/intel/pinctrl-cherryview.c +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c | |||
@@ -1526,17 +1526,16 @@ static int chv_pinctrl_probe(struct platform_device *pdev) | |||
1526 | pctrl->pctldesc.pins = pctrl->community->pins; | 1526 | pctrl->pctldesc.pins = pctrl->community->pins; |
1527 | pctrl->pctldesc.npins = pctrl->community->npins; | 1527 | pctrl->pctldesc.npins = pctrl->community->npins; |
1528 | 1528 | ||
1529 | pctrl->pctldev = pinctrl_register(&pctrl->pctldesc, &pdev->dev, pctrl); | 1529 | pctrl->pctldev = devm_pinctrl_register(&pdev->dev, &pctrl->pctldesc, |
1530 | pctrl); | ||
1530 | if (IS_ERR(pctrl->pctldev)) { | 1531 | if (IS_ERR(pctrl->pctldev)) { |
1531 | dev_err(&pdev->dev, "failed to register pinctrl driver\n"); | 1532 | dev_err(&pdev->dev, "failed to register pinctrl driver\n"); |
1532 | return PTR_ERR(pctrl->pctldev); | 1533 | return PTR_ERR(pctrl->pctldev); |
1533 | } | 1534 | } |
1534 | 1535 | ||
1535 | ret = chv_gpio_probe(pctrl, irq); | 1536 | ret = chv_gpio_probe(pctrl, irq); |
1536 | if (ret) { | 1537 | if (ret) |
1537 | pinctrl_unregister(pctrl->pctldev); | ||
1538 | return ret; | 1538 | return ret; |
1539 | } | ||
1540 | 1539 | ||
1541 | platform_set_drvdata(pdev, pctrl); | 1540 | platform_set_drvdata(pdev, pctrl); |
1542 | 1541 | ||
@@ -1548,7 +1547,6 @@ static int chv_pinctrl_remove(struct platform_device *pdev) | |||
1548 | struct chv_pinctrl *pctrl = platform_get_drvdata(pdev); | 1547 | struct chv_pinctrl *pctrl = platform_get_drvdata(pdev); |
1549 | 1548 | ||
1550 | gpiochip_remove(&pctrl->chip); | 1549 | gpiochip_remove(&pctrl->chip); |
1551 | pinctrl_unregister(pctrl->pctldev); | ||
1552 | 1550 | ||
1553 | return 0; | 1551 | return 0; |
1554 | } | 1552 | } |
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 6c2c816f8e5f..3584e50fa2c6 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c | |||
@@ -1045,17 +1045,16 @@ int intel_pinctrl_probe(struct platform_device *pdev, | |||
1045 | pctrl->pctldesc.pins = pctrl->soc->pins; | 1045 | pctrl->pctldesc.pins = pctrl->soc->pins; |
1046 | pctrl->pctldesc.npins = pctrl->soc->npins; | 1046 | pctrl->pctldesc.npins = pctrl->soc->npins; |
1047 | 1047 | ||
1048 | pctrl->pctldev = pinctrl_register(&pctrl->pctldesc, &pdev->dev, pctrl); | 1048 | pctrl->pctldev = devm_pinctrl_register(&pdev->dev, &pctrl->pctldesc, |
1049 | pctrl); | ||
1049 | if (IS_ERR(pctrl->pctldev)) { | 1050 | if (IS_ERR(pctrl->pctldev)) { |
1050 | dev_err(&pdev->dev, "failed to register pinctrl driver\n"); | 1051 | dev_err(&pdev->dev, "failed to register pinctrl driver\n"); |
1051 | return PTR_ERR(pctrl->pctldev); | 1052 | return PTR_ERR(pctrl->pctldev); |
1052 | } | 1053 | } |
1053 | 1054 | ||
1054 | ret = intel_gpio_probe(pctrl, irq); | 1055 | ret = intel_gpio_probe(pctrl, irq); |
1055 | if (ret) { | 1056 | if (ret) |
1056 | pinctrl_unregister(pctrl->pctldev); | ||
1057 | return ret; | 1057 | return ret; |
1058 | } | ||
1059 | 1058 | ||
1060 | platform_set_drvdata(pdev, pctrl); | 1059 | platform_set_drvdata(pdev, pctrl); |
1061 | 1060 | ||
@@ -1068,7 +1067,6 @@ int intel_pinctrl_remove(struct platform_device *pdev) | |||
1068 | struct intel_pinctrl *pctrl = platform_get_drvdata(pdev); | 1067 | struct intel_pinctrl *pctrl = platform_get_drvdata(pdev); |
1069 | 1068 | ||
1070 | gpiochip_remove(&pctrl->chip); | 1069 | gpiochip_remove(&pctrl->chip); |
1071 | pinctrl_unregister(pctrl->pctldev); | ||
1072 | 1070 | ||
1073 | return 0; | 1071 | return 0; |
1074 | } | 1072 | } |
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 6ab8c3ccdeea..207b13b618cf 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c | |||
@@ -605,7 +605,7 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
605 | ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map, | 605 | ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map, |
606 | &reserved_maps, num_maps); | 606 | &reserved_maps, num_maps); |
607 | if (ret < 0) { | 607 | if (ret < 0) { |
608 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 608 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
609 | of_node_put(np); | 609 | of_node_put(np); |
610 | return ret; | 610 | return ret; |
611 | } | 611 | } |
@@ -644,7 +644,7 @@ static int mtk_pctrl_get_group_pins(struct pinctrl_dev *pctldev, | |||
644 | 644 | ||
645 | static const struct pinctrl_ops mtk_pctrl_ops = { | 645 | static const struct pinctrl_ops mtk_pctrl_ops = { |
646 | .dt_node_to_map = mtk_pctrl_dt_node_to_map, | 646 | .dt_node_to_map = mtk_pctrl_dt_node_to_map, |
647 | .dt_free_map = pinctrl_utils_dt_free_map, | 647 | .dt_free_map = pinctrl_utils_free_map, |
648 | .get_groups_count = mtk_pctrl_get_groups_count, | 648 | .get_groups_count = mtk_pctrl_get_groups_count, |
649 | .get_group_name = mtk_pctrl_get_group_name, | 649 | .get_group_name = mtk_pctrl_get_group_name, |
650 | .get_group_pins = mtk_pctrl_get_group_pins, | 650 | .get_group_pins = mtk_pctrl_get_group_pins, |
@@ -1396,17 +1396,16 @@ int mtk_pctrl_init(struct platform_device *pdev, | |||
1396 | pctl->pctl_desc.pmxops = &mtk_pmx_ops; | 1396 | pctl->pctl_desc.pmxops = &mtk_pmx_ops; |
1397 | pctl->dev = &pdev->dev; | 1397 | pctl->dev = &pdev->dev; |
1398 | 1398 | ||
1399 | pctl->pctl_dev = pinctrl_register(&pctl->pctl_desc, &pdev->dev, pctl); | 1399 | pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->pctl_desc, |
1400 | pctl); | ||
1400 | if (IS_ERR(pctl->pctl_dev)) { | 1401 | if (IS_ERR(pctl->pctl_dev)) { |
1401 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); | 1402 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); |
1402 | return PTR_ERR(pctl->pctl_dev); | 1403 | return PTR_ERR(pctl->pctl_dev); |
1403 | } | 1404 | } |
1404 | 1405 | ||
1405 | pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL); | 1406 | pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL); |
1406 | if (!pctl->chip) { | 1407 | if (!pctl->chip) |
1407 | ret = -ENOMEM; | 1408 | return -ENOMEM; |
1408 | goto pctrl_error; | ||
1409 | } | ||
1410 | 1409 | ||
1411 | *pctl->chip = mtk_gpio_chip; | 1410 | *pctl->chip = mtk_gpio_chip; |
1412 | pctl->chip->ngpio = pctl->devdata->npins; | 1411 | pctl->chip->ngpio = pctl->devdata->npins; |
@@ -1415,10 +1414,8 @@ int mtk_pctrl_init(struct platform_device *pdev, | |||
1415 | pctl->chip->base = -1; | 1414 | pctl->chip->base = -1; |
1416 | 1415 | ||
1417 | ret = gpiochip_add_data(pctl->chip, pctl); | 1416 | ret = gpiochip_add_data(pctl->chip, pctl); |
1418 | if (ret) { | 1417 | if (ret) |
1419 | ret = -EINVAL; | 1418 | return -EINVAL; |
1420 | goto pctrl_error; | ||
1421 | } | ||
1422 | 1419 | ||
1423 | /* Register the GPIO to pin mappings. */ | 1420 | /* Register the GPIO to pin mappings. */ |
1424 | ret = gpiochip_add_pin_range(pctl->chip, dev_name(&pdev->dev), | 1421 | ret = gpiochip_add_pin_range(pctl->chip, dev_name(&pdev->dev), |
@@ -1496,8 +1493,6 @@ int mtk_pctrl_init(struct platform_device *pdev, | |||
1496 | 1493 | ||
1497 | chip_error: | 1494 | chip_error: |
1498 | gpiochip_remove(pctl->chip); | 1495 | gpiochip_remove(pctl->chip); |
1499 | pctrl_error: | ||
1500 | pinctrl_unregister(pctl->pctl_dev); | ||
1501 | return ret; | 1496 | return ret; |
1502 | } | 1497 | } |
1503 | 1498 | ||
diff --git a/drivers/pinctrl/meson/Makefile b/drivers/pinctrl/meson/Makefile index c751d22fdf29..24434f139947 100644 --- a/drivers/pinctrl/meson/Makefile +++ b/drivers/pinctrl/meson/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | obj-y += pinctrl-meson8.o pinctrl-meson8b.o | 1 | obj-y += pinctrl-meson8.o pinctrl-meson8b.o pinctrl-meson-gxbb.o |
2 | obj-y += pinctrl-meson.o | 2 | obj-y += pinctrl-meson.o |
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c new file mode 100644 index 000000000000..eeabafbbf598 --- /dev/null +++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c | |||
@@ -0,0 +1,432 @@ | |||
1 | /* | ||
2 | * Pin controller and GPIO driver for Amlogic Meson GXBB. | ||
3 | * | ||
4 | * Copyright (C) 2016 Endless Mobile, Inc. | ||
5 | * Author: Carlo Caione <carlo@endlessm.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
13 | */ | ||
14 | |||
15 | #include <dt-bindings/gpio/meson-gxbb-gpio.h> | ||
16 | #include "pinctrl-meson.h" | ||
17 | |||
18 | #define EE_OFF 14 | ||
19 | |||
20 | static const struct pinctrl_pin_desc meson_gxbb_periphs_pins[] = { | ||
21 | MESON_PIN(GPIOZ_0, EE_OFF), | ||
22 | MESON_PIN(GPIOZ_1, EE_OFF), | ||
23 | MESON_PIN(GPIOZ_2, EE_OFF), | ||
24 | MESON_PIN(GPIOZ_3, EE_OFF), | ||
25 | MESON_PIN(GPIOZ_4, EE_OFF), | ||
26 | MESON_PIN(GPIOZ_5, EE_OFF), | ||
27 | MESON_PIN(GPIOZ_6, EE_OFF), | ||
28 | MESON_PIN(GPIOZ_7, EE_OFF), | ||
29 | MESON_PIN(GPIOZ_8, EE_OFF), | ||
30 | MESON_PIN(GPIOZ_9, EE_OFF), | ||
31 | MESON_PIN(GPIOZ_10, EE_OFF), | ||
32 | MESON_PIN(GPIOZ_11, EE_OFF), | ||
33 | MESON_PIN(GPIOZ_12, EE_OFF), | ||
34 | MESON_PIN(GPIOZ_13, EE_OFF), | ||
35 | MESON_PIN(GPIOZ_14, EE_OFF), | ||
36 | MESON_PIN(GPIOZ_15, EE_OFF), | ||
37 | |||
38 | MESON_PIN(GPIOH_0, EE_OFF), | ||
39 | MESON_PIN(GPIOH_1, EE_OFF), | ||
40 | MESON_PIN(GPIOH_2, EE_OFF), | ||
41 | MESON_PIN(GPIOH_3, EE_OFF), | ||
42 | |||
43 | MESON_PIN(BOOT_0, EE_OFF), | ||
44 | MESON_PIN(BOOT_1, EE_OFF), | ||
45 | MESON_PIN(BOOT_2, EE_OFF), | ||
46 | MESON_PIN(BOOT_3, EE_OFF), | ||
47 | MESON_PIN(BOOT_4, EE_OFF), | ||
48 | MESON_PIN(BOOT_5, EE_OFF), | ||
49 | MESON_PIN(BOOT_6, EE_OFF), | ||
50 | MESON_PIN(BOOT_7, EE_OFF), | ||
51 | MESON_PIN(BOOT_8, EE_OFF), | ||
52 | MESON_PIN(BOOT_9, EE_OFF), | ||
53 | MESON_PIN(BOOT_10, EE_OFF), | ||
54 | MESON_PIN(BOOT_11, EE_OFF), | ||
55 | MESON_PIN(BOOT_12, EE_OFF), | ||
56 | MESON_PIN(BOOT_13, EE_OFF), | ||
57 | MESON_PIN(BOOT_14, EE_OFF), | ||
58 | MESON_PIN(BOOT_15, EE_OFF), | ||
59 | MESON_PIN(BOOT_16, EE_OFF), | ||
60 | MESON_PIN(BOOT_17, EE_OFF), | ||
61 | |||
62 | MESON_PIN(CARD_0, EE_OFF), | ||
63 | MESON_PIN(CARD_1, EE_OFF), | ||
64 | MESON_PIN(CARD_2, EE_OFF), | ||
65 | MESON_PIN(CARD_3, EE_OFF), | ||
66 | MESON_PIN(CARD_4, EE_OFF), | ||
67 | MESON_PIN(CARD_5, EE_OFF), | ||
68 | MESON_PIN(CARD_6, EE_OFF), | ||
69 | |||
70 | MESON_PIN(GPIODV_0, EE_OFF), | ||
71 | MESON_PIN(GPIODV_1, EE_OFF), | ||
72 | MESON_PIN(GPIODV_2, EE_OFF), | ||
73 | MESON_PIN(GPIODV_3, EE_OFF), | ||
74 | MESON_PIN(GPIODV_4, EE_OFF), | ||
75 | MESON_PIN(GPIODV_5, EE_OFF), | ||
76 | MESON_PIN(GPIODV_6, EE_OFF), | ||
77 | MESON_PIN(GPIODV_7, EE_OFF), | ||
78 | MESON_PIN(GPIODV_8, EE_OFF), | ||
79 | MESON_PIN(GPIODV_9, EE_OFF), | ||
80 | MESON_PIN(GPIODV_10, EE_OFF), | ||
81 | MESON_PIN(GPIODV_11, EE_OFF), | ||
82 | MESON_PIN(GPIODV_12, EE_OFF), | ||
83 | MESON_PIN(GPIODV_13, EE_OFF), | ||
84 | MESON_PIN(GPIODV_14, EE_OFF), | ||
85 | MESON_PIN(GPIODV_15, EE_OFF), | ||
86 | MESON_PIN(GPIODV_16, EE_OFF), | ||
87 | MESON_PIN(GPIODV_17, EE_OFF), | ||
88 | MESON_PIN(GPIODV_19, EE_OFF), | ||
89 | MESON_PIN(GPIODV_20, EE_OFF), | ||
90 | MESON_PIN(GPIODV_21, EE_OFF), | ||
91 | MESON_PIN(GPIODV_22, EE_OFF), | ||
92 | MESON_PIN(GPIODV_23, EE_OFF), | ||
93 | MESON_PIN(GPIODV_24, EE_OFF), | ||
94 | MESON_PIN(GPIODV_25, EE_OFF), | ||
95 | MESON_PIN(GPIODV_26, EE_OFF), | ||
96 | MESON_PIN(GPIODV_27, EE_OFF), | ||
97 | MESON_PIN(GPIODV_28, EE_OFF), | ||
98 | MESON_PIN(GPIODV_29, EE_OFF), | ||
99 | |||
100 | MESON_PIN(GPIOY_0, EE_OFF), | ||
101 | MESON_PIN(GPIOY_1, EE_OFF), | ||
102 | MESON_PIN(GPIOY_2, EE_OFF), | ||
103 | MESON_PIN(GPIOY_3, EE_OFF), | ||
104 | MESON_PIN(GPIOY_4, EE_OFF), | ||
105 | MESON_PIN(GPIOY_5, EE_OFF), | ||
106 | MESON_PIN(GPIOY_6, EE_OFF), | ||
107 | MESON_PIN(GPIOY_7, EE_OFF), | ||
108 | MESON_PIN(GPIOY_8, EE_OFF), | ||
109 | MESON_PIN(GPIOY_9, EE_OFF), | ||
110 | MESON_PIN(GPIOY_10, EE_OFF), | ||
111 | MESON_PIN(GPIOY_11, EE_OFF), | ||
112 | MESON_PIN(GPIOY_12, EE_OFF), | ||
113 | MESON_PIN(GPIOY_13, EE_OFF), | ||
114 | MESON_PIN(GPIOY_14, EE_OFF), | ||
115 | MESON_PIN(GPIOY_15, EE_OFF), | ||
116 | MESON_PIN(GPIOY_16, EE_OFF), | ||
117 | |||
118 | MESON_PIN(GPIOX_0, EE_OFF), | ||
119 | MESON_PIN(GPIOX_1, EE_OFF), | ||
120 | MESON_PIN(GPIOX_2, EE_OFF), | ||
121 | MESON_PIN(GPIOX_3, EE_OFF), | ||
122 | MESON_PIN(GPIOX_4, EE_OFF), | ||
123 | MESON_PIN(GPIOX_5, EE_OFF), | ||
124 | MESON_PIN(GPIOX_6, EE_OFF), | ||
125 | MESON_PIN(GPIOX_7, EE_OFF), | ||
126 | MESON_PIN(GPIOX_8, EE_OFF), | ||
127 | MESON_PIN(GPIOX_9, EE_OFF), | ||
128 | MESON_PIN(GPIOX_10, EE_OFF), | ||
129 | MESON_PIN(GPIOX_11, EE_OFF), | ||
130 | MESON_PIN(GPIOX_12, EE_OFF), | ||
131 | MESON_PIN(GPIOX_13, EE_OFF), | ||
132 | MESON_PIN(GPIOX_14, EE_OFF), | ||
133 | MESON_PIN(GPIOX_15, EE_OFF), | ||
134 | MESON_PIN(GPIOX_16, EE_OFF), | ||
135 | MESON_PIN(GPIOX_17, EE_OFF), | ||
136 | MESON_PIN(GPIOX_18, EE_OFF), | ||
137 | MESON_PIN(GPIOX_19, EE_OFF), | ||
138 | MESON_PIN(GPIOX_20, EE_OFF), | ||
139 | MESON_PIN(GPIOX_21, EE_OFF), | ||
140 | MESON_PIN(GPIOX_22, EE_OFF), | ||
141 | |||
142 | MESON_PIN(GPIOCLK_0, EE_OFF), | ||
143 | MESON_PIN(GPIOCLK_1, EE_OFF), | ||
144 | MESON_PIN(GPIOCLK_2, EE_OFF), | ||
145 | MESON_PIN(GPIOCLK_3, EE_OFF), | ||
146 | |||
147 | MESON_PIN(GPIO_TEST_N, EE_OFF), | ||
148 | }; | ||
149 | |||
150 | static const struct pinctrl_pin_desc meson_gxbb_aobus_pins[] = { | ||
151 | MESON_PIN(GPIOAO_0, 0), | ||
152 | MESON_PIN(GPIOAO_1, 0), | ||
153 | MESON_PIN(GPIOAO_2, 0), | ||
154 | MESON_PIN(GPIOAO_3, 0), | ||
155 | MESON_PIN(GPIOAO_4, 0), | ||
156 | MESON_PIN(GPIOAO_5, 0), | ||
157 | MESON_PIN(GPIOAO_6, 0), | ||
158 | MESON_PIN(GPIOAO_7, 0), | ||
159 | MESON_PIN(GPIOAO_8, 0), | ||
160 | MESON_PIN(GPIOAO_9, 0), | ||
161 | MESON_PIN(GPIOAO_10, 0), | ||
162 | MESON_PIN(GPIOAO_11, 0), | ||
163 | MESON_PIN(GPIOAO_12, 0), | ||
164 | MESON_PIN(GPIOAO_13, 0), | ||
165 | }; | ||
166 | |||
167 | static const unsigned int uart_tx_ao_a_pins[] = { PIN(GPIOAO_0, 0) }; | ||
168 | static const unsigned int uart_rx_ao_a_pins[] = { PIN(GPIOAO_1, 0) }; | ||
169 | static const unsigned int uart_cts_ao_a_pins[] = { PIN(GPIOAO_2, 0) }; | ||
170 | static const unsigned int uart_rts_ao_a_pins[] = { PIN(GPIOAO_3, 0) }; | ||
171 | |||
172 | static struct meson_pmx_group meson_gxbb_periphs_groups[] = { | ||
173 | GPIO_GROUP(GPIOZ_0, EE_OFF), | ||
174 | GPIO_GROUP(GPIOZ_1, EE_OFF), | ||
175 | GPIO_GROUP(GPIOZ_2, EE_OFF), | ||
176 | GPIO_GROUP(GPIOZ_3, EE_OFF), | ||
177 | GPIO_GROUP(GPIOZ_4, EE_OFF), | ||
178 | GPIO_GROUP(GPIOZ_5, EE_OFF), | ||
179 | GPIO_GROUP(GPIOZ_6, EE_OFF), | ||
180 | GPIO_GROUP(GPIOZ_7, EE_OFF), | ||
181 | GPIO_GROUP(GPIOZ_8, EE_OFF), | ||
182 | GPIO_GROUP(GPIOZ_9, EE_OFF), | ||
183 | GPIO_GROUP(GPIOZ_10, EE_OFF), | ||
184 | GPIO_GROUP(GPIOZ_11, EE_OFF), | ||
185 | GPIO_GROUP(GPIOZ_12, EE_OFF), | ||
186 | GPIO_GROUP(GPIOZ_13, EE_OFF), | ||
187 | GPIO_GROUP(GPIOZ_14, EE_OFF), | ||
188 | GPIO_GROUP(GPIOZ_15, EE_OFF), | ||
189 | |||
190 | GPIO_GROUP(GPIOH_0, EE_OFF), | ||
191 | GPIO_GROUP(GPIOH_1, EE_OFF), | ||
192 | GPIO_GROUP(GPIOH_2, EE_OFF), | ||
193 | GPIO_GROUP(GPIOH_3, EE_OFF), | ||
194 | |||
195 | GPIO_GROUP(BOOT_0, EE_OFF), | ||
196 | GPIO_GROUP(BOOT_1, EE_OFF), | ||
197 | GPIO_GROUP(BOOT_2, EE_OFF), | ||
198 | GPIO_GROUP(BOOT_3, EE_OFF), | ||
199 | GPIO_GROUP(BOOT_4, EE_OFF), | ||
200 | GPIO_GROUP(BOOT_5, EE_OFF), | ||
201 | GPIO_GROUP(BOOT_6, EE_OFF), | ||
202 | GPIO_GROUP(BOOT_7, EE_OFF), | ||
203 | GPIO_GROUP(BOOT_8, EE_OFF), | ||
204 | GPIO_GROUP(BOOT_9, EE_OFF), | ||
205 | GPIO_GROUP(BOOT_10, EE_OFF), | ||
206 | GPIO_GROUP(BOOT_11, EE_OFF), | ||
207 | GPIO_GROUP(BOOT_12, EE_OFF), | ||
208 | GPIO_GROUP(BOOT_13, EE_OFF), | ||
209 | GPIO_GROUP(BOOT_14, EE_OFF), | ||
210 | GPIO_GROUP(BOOT_15, EE_OFF), | ||
211 | GPIO_GROUP(BOOT_16, EE_OFF), | ||
212 | GPIO_GROUP(BOOT_17, EE_OFF), | ||
213 | |||
214 | GPIO_GROUP(CARD_0, EE_OFF), | ||
215 | GPIO_GROUP(CARD_1, EE_OFF), | ||
216 | GPIO_GROUP(CARD_2, EE_OFF), | ||
217 | GPIO_GROUP(CARD_3, EE_OFF), | ||
218 | GPIO_GROUP(CARD_4, EE_OFF), | ||
219 | GPIO_GROUP(CARD_5, EE_OFF), | ||
220 | GPIO_GROUP(CARD_6, EE_OFF), | ||
221 | |||
222 | GPIO_GROUP(GPIODV_0, EE_OFF), | ||
223 | GPIO_GROUP(GPIODV_1, EE_OFF), | ||
224 | GPIO_GROUP(GPIODV_2, EE_OFF), | ||
225 | GPIO_GROUP(GPIODV_3, EE_OFF), | ||
226 | GPIO_GROUP(GPIODV_4, EE_OFF), | ||
227 | GPIO_GROUP(GPIODV_5, EE_OFF), | ||
228 | GPIO_GROUP(GPIODV_6, EE_OFF), | ||
229 | GPIO_GROUP(GPIODV_7, EE_OFF), | ||
230 | GPIO_GROUP(GPIODV_8, EE_OFF), | ||
231 | GPIO_GROUP(GPIODV_9, EE_OFF), | ||
232 | GPIO_GROUP(GPIODV_10, EE_OFF), | ||
233 | GPIO_GROUP(GPIODV_11, EE_OFF), | ||
234 | GPIO_GROUP(GPIODV_12, EE_OFF), | ||
235 | GPIO_GROUP(GPIODV_13, EE_OFF), | ||
236 | GPIO_GROUP(GPIODV_14, EE_OFF), | ||
237 | GPIO_GROUP(GPIODV_15, EE_OFF), | ||
238 | GPIO_GROUP(GPIODV_16, EE_OFF), | ||
239 | GPIO_GROUP(GPIODV_17, EE_OFF), | ||
240 | GPIO_GROUP(GPIODV_19, EE_OFF), | ||
241 | GPIO_GROUP(GPIODV_20, EE_OFF), | ||
242 | GPIO_GROUP(GPIODV_21, EE_OFF), | ||
243 | GPIO_GROUP(GPIODV_22, EE_OFF), | ||
244 | GPIO_GROUP(GPIODV_23, EE_OFF), | ||
245 | GPIO_GROUP(GPIODV_24, EE_OFF), | ||
246 | GPIO_GROUP(GPIODV_25, EE_OFF), | ||
247 | GPIO_GROUP(GPIODV_26, EE_OFF), | ||
248 | GPIO_GROUP(GPIODV_27, EE_OFF), | ||
249 | GPIO_GROUP(GPIODV_28, EE_OFF), | ||
250 | GPIO_GROUP(GPIODV_29, EE_OFF), | ||
251 | |||
252 | GPIO_GROUP(GPIOY_0, EE_OFF), | ||
253 | GPIO_GROUP(GPIOY_1, EE_OFF), | ||
254 | GPIO_GROUP(GPIOY_2, EE_OFF), | ||
255 | GPIO_GROUP(GPIOY_3, EE_OFF), | ||
256 | GPIO_GROUP(GPIOY_4, EE_OFF), | ||
257 | GPIO_GROUP(GPIOY_5, EE_OFF), | ||
258 | GPIO_GROUP(GPIOY_6, EE_OFF), | ||
259 | GPIO_GROUP(GPIOY_7, EE_OFF), | ||
260 | GPIO_GROUP(GPIOY_8, EE_OFF), | ||
261 | GPIO_GROUP(GPIOY_9, EE_OFF), | ||
262 | GPIO_GROUP(GPIOY_10, EE_OFF), | ||
263 | GPIO_GROUP(GPIOY_11, EE_OFF), | ||
264 | GPIO_GROUP(GPIOY_12, EE_OFF), | ||
265 | GPIO_GROUP(GPIOY_13, EE_OFF), | ||
266 | GPIO_GROUP(GPIOY_14, EE_OFF), | ||
267 | GPIO_GROUP(GPIOY_15, EE_OFF), | ||
268 | GPIO_GROUP(GPIOY_16, EE_OFF), | ||
269 | |||
270 | GPIO_GROUP(GPIOX_0, EE_OFF), | ||
271 | GPIO_GROUP(GPIOX_1, EE_OFF), | ||
272 | GPIO_GROUP(GPIOX_2, EE_OFF), | ||
273 | GPIO_GROUP(GPIOX_3, EE_OFF), | ||
274 | GPIO_GROUP(GPIOX_4, EE_OFF), | ||
275 | GPIO_GROUP(GPIOX_5, EE_OFF), | ||
276 | GPIO_GROUP(GPIOX_6, EE_OFF), | ||
277 | GPIO_GROUP(GPIOX_7, EE_OFF), | ||
278 | GPIO_GROUP(GPIOX_8, EE_OFF), | ||
279 | GPIO_GROUP(GPIOX_9, EE_OFF), | ||
280 | GPIO_GROUP(GPIOX_10, EE_OFF), | ||
281 | GPIO_GROUP(GPIOX_11, EE_OFF), | ||
282 | GPIO_GROUP(GPIOX_12, EE_OFF), | ||
283 | GPIO_GROUP(GPIOX_13, EE_OFF), | ||
284 | GPIO_GROUP(GPIOX_14, EE_OFF), | ||
285 | GPIO_GROUP(GPIOX_15, EE_OFF), | ||
286 | GPIO_GROUP(GPIOX_16, EE_OFF), | ||
287 | GPIO_GROUP(GPIOX_17, EE_OFF), | ||
288 | GPIO_GROUP(GPIOX_18, EE_OFF), | ||
289 | GPIO_GROUP(GPIOX_19, EE_OFF), | ||
290 | GPIO_GROUP(GPIOX_20, EE_OFF), | ||
291 | GPIO_GROUP(GPIOX_21, EE_OFF), | ||
292 | GPIO_GROUP(GPIOX_22, EE_OFF), | ||
293 | |||
294 | GPIO_GROUP(GPIOCLK_0, EE_OFF), | ||
295 | GPIO_GROUP(GPIOCLK_1, EE_OFF), | ||
296 | GPIO_GROUP(GPIOCLK_2, EE_OFF), | ||
297 | GPIO_GROUP(GPIOCLK_3, EE_OFF), | ||
298 | |||
299 | GPIO_GROUP(GPIO_TEST_N, EE_OFF), | ||
300 | }; | ||
301 | |||
302 | static struct meson_pmx_group meson_gxbb_aobus_groups[] = { | ||
303 | GPIO_GROUP(GPIOAO_0, 0), | ||
304 | GPIO_GROUP(GPIOAO_1, 0), | ||
305 | GPIO_GROUP(GPIOAO_2, 0), | ||
306 | GPIO_GROUP(GPIOAO_3, 0), | ||
307 | GPIO_GROUP(GPIOAO_4, 0), | ||
308 | GPIO_GROUP(GPIOAO_5, 0), | ||
309 | GPIO_GROUP(GPIOAO_6, 0), | ||
310 | GPIO_GROUP(GPIOAO_7, 0), | ||
311 | GPIO_GROUP(GPIOAO_8, 0), | ||
312 | GPIO_GROUP(GPIOAO_9, 0), | ||
313 | GPIO_GROUP(GPIOAO_10, 0), | ||
314 | GPIO_GROUP(GPIOAO_11, 0), | ||
315 | GPIO_GROUP(GPIOAO_12, 0), | ||
316 | GPIO_GROUP(GPIOAO_13, 0), | ||
317 | |||
318 | /* bank AO */ | ||
319 | GROUP(uart_tx_ao_a, 0, 12), | ||
320 | GROUP(uart_rx_ao_a, 0, 11), | ||
321 | GROUP(uart_cts_ao_a, 0, 10), | ||
322 | GROUP(uart_rts_ao_a, 0, 9), | ||
323 | }; | ||
324 | |||
325 | static const char * const gpio_periphs_groups[] = { | ||
326 | "GPIOZ_0", "GPIOZ_1", "GPIOZ_2", "GPIOZ_3", "GPIOZ_4", | ||
327 | "GPIOZ_5", "GPIOZ_6", "GPIOZ_7", "GPIOZ_8", "GPIOZ_9", | ||
328 | "GPIOZ_10", "GPIOZ_11", "GPIOZ_12", "GPIOZ_13", "GPIOZ_14", | ||
329 | "GPIOZ_15", | ||
330 | |||
331 | "GPIOH_0", "GPIOH_1", "GPIOH_2", "GPIOH_3", | ||
332 | |||
333 | "BOOT_0", "BOOT_1", "BOOT_2", "BOOT_3", "BOOT_4", | ||
334 | "BOOT_5", "BOOT_6", "BOOT_7", "BOOT_8", "BOOT_9", | ||
335 | "BOOT_10", "BOOT_11", "BOOT_12", "BOOT_13", "BOOT_14", | ||
336 | "BOOT_15", "BOOT_16", "BOOT_17", | ||
337 | |||
338 | "CARD_0", "CARD_1", "CARD_2", "CARD_3", "CARD_4", | ||
339 | "CARD_5", "CARD_6", | ||
340 | |||
341 | "GPIODV_0", "GPIODV_1", "GPIODV_2", "GPIODV_3", "GPIODV_4", | ||
342 | "GPIODV_5", "GPIODV_6", "GPIODV_7", "GPIODV_8", "GPIODV_9", | ||
343 | "GPIODV_10", "GPIODV_11", "GPIODV_12", "GPIODV_13", "GPIODV_14", | ||
344 | "GPIODV_15", "GPIODV_16", "GPIODV_17", "GPIODV_18", "GPIODV_19", | ||
345 | "GPIODV_20", "GPIODV_21", "GPIODV_22", "GPIODV_23", "GPIODV_24", | ||
346 | "GPIODV_25", "GPIODV_26", "GPIODV_27", "GPIODV_28", "GPIODV_29", | ||
347 | |||
348 | "GPIOY_0", "GPIOY_1", "GPIOY_2", "GPIOY_3", "GPIOY_4", | ||
349 | "GPIOY_5", "GPIOY_6", "GPIOY_7", "GPIOY_8", "GPIOY_9", | ||
350 | "GPIOY_10", "GPIOY_11", "GPIOY_12", "GPIOY_13", "GPIOY_14", | ||
351 | "GPIOY_15", "GPIOY_16", | ||
352 | |||
353 | "GPIOX_0", "GPIOX_1", "GPIOX_2", "GPIOX_3", "GPIOX_4", | ||
354 | "GPIOX_5", "GPIOX_6", "GPIOX_7", "GPIOX_8", "GPIOX_9", | ||
355 | "GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14", | ||
356 | "GPIOX_15", "GPIOX_16", "GPIOX_17", "GPIOX_18", "GPIOX_19", | ||
357 | "GPIOX_20", "GPIOX_21", "GPIOX_22", | ||
358 | |||
359 | "GPIO_TEST_N", | ||
360 | }; | ||
361 | |||
362 | static const char * const gpio_aobus_groups[] = { | ||
363 | "GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4", | ||
364 | "GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9", | ||
365 | "GPIOAO_10", "GPIOAO_11", "GPIOAO_12", "GPIOAO_13", | ||
366 | }; | ||
367 | |||
368 | static const char * const uart_ao_groups[] = { | ||
369 | "uart_tx_ao_a", "uart_rx_ao_a", "uart_cts_ao_a", "uart_rts_ao_a" | ||
370 | }; | ||
371 | |||
372 | static struct meson_pmx_func meson_gxbb_periphs_functions[] = { | ||
373 | FUNCTION(gpio_periphs), | ||
374 | }; | ||
375 | |||
376 | static struct meson_pmx_func meson_gxbb_aobus_functions[] = { | ||
377 | FUNCTION(gpio_aobus), | ||
378 | FUNCTION(uart_ao), | ||
379 | }; | ||
380 | |||
381 | static struct meson_bank meson_gxbb_periphs_banks[] = { | ||
382 | /* name first last pullen pull dir out in */ | ||
383 | BANK("X", PIN(GPIOX_0, EE_OFF), PIN(GPIOX_22, EE_OFF), 4, 0, 4, 0, 12, 0, 13, 0, 14, 0), | ||
384 | BANK("Y", PIN(GPIOY_0, EE_OFF), PIN(GPIOY_16, EE_OFF), 1, 0, 1, 0, 3, 0, 4, 0, 5, 0), | ||
385 | BANK("DV", PIN(GPIODV_0, EE_OFF), PIN(GPIODV_29, EE_OFF), 0, 0, 0, 0, 0, 0, 1, 0, 2, 0), | ||
386 | BANK("H", PIN(GPIOH_0, EE_OFF), PIN(GPIOH_3, EE_OFF), 1, 20, 1, 20, 3, 20, 4, 20, 5, 20), | ||
387 | BANK("Z", PIN(GPIOZ_0, EE_OFF), PIN(GPIOZ_15, EE_OFF), 3, 0, 3, 0, 9, 0, 10, 0, 11, 0), | ||
388 | BANK("CARD", PIN(CARD_0, EE_OFF), PIN(CARD_6, EE_OFF), 2, 20, 2, 20, 6, 20, 7, 20, 8, 20), | ||
389 | BANK("BOOT", PIN(BOOT_0, EE_OFF), PIN(BOOT_17, EE_OFF), 2, 0, 2, 0, 6, 0, 7, 0, 8, 0), | ||
390 | BANK("CLK", PIN(GPIOCLK_0, EE_OFF), PIN(GPIOCLK_3, EE_OFF), 3, 28, 3, 28, 9, 28, 10, 28, 11, 28), | ||
391 | }; | ||
392 | |||
393 | static struct meson_bank meson_gxbb_aobus_banks[] = { | ||
394 | /* name first last pullen pull dir out in */ | ||
395 | BANK("AO", PIN(GPIOAO_0, 0), PIN(GPIOAO_13, 0), 0, 0, 0, 16, 0, 0, 0, 16, 1, 0), | ||
396 | }; | ||
397 | |||
398 | static struct meson_domain_data meson_gxbb_periphs_domain_data = { | ||
399 | .name = "periphs-banks", | ||
400 | .banks = meson_gxbb_periphs_banks, | ||
401 | .num_banks = ARRAY_SIZE(meson_gxbb_periphs_banks), | ||
402 | .pin_base = 14, | ||
403 | .num_pins = 120, | ||
404 | }; | ||
405 | |||
406 | static struct meson_domain_data meson_gxbb_aobus_domain_data = { | ||
407 | .name = "aobus-banks", | ||
408 | .banks = meson_gxbb_aobus_banks, | ||
409 | .num_banks = ARRAY_SIZE(meson_gxbb_aobus_banks), | ||
410 | .pin_base = 0, | ||
411 | .num_pins = 14, | ||
412 | }; | ||
413 | |||
414 | struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data = { | ||
415 | .pins = meson_gxbb_periphs_pins, | ||
416 | .groups = meson_gxbb_periphs_groups, | ||
417 | .funcs = meson_gxbb_periphs_functions, | ||
418 | .domain_data = &meson_gxbb_periphs_domain_data, | ||
419 | .num_pins = ARRAY_SIZE(meson_gxbb_periphs_pins), | ||
420 | .num_groups = ARRAY_SIZE(meson_gxbb_periphs_groups), | ||
421 | .num_funcs = ARRAY_SIZE(meson_gxbb_periphs_functions), | ||
422 | }; | ||
423 | |||
424 | struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data = { | ||
425 | .pins = meson_gxbb_aobus_pins, | ||
426 | .groups = meson_gxbb_aobus_groups, | ||
427 | .funcs = meson_gxbb_aobus_functions, | ||
428 | .domain_data = &meson_gxbb_aobus_domain_data, | ||
429 | .num_pins = ARRAY_SIZE(meson_gxbb_aobus_pins), | ||
430 | .num_groups = ARRAY_SIZE(meson_gxbb_aobus_groups), | ||
431 | .num_funcs = ARRAY_SIZE(meson_gxbb_aobus_functions), | ||
432 | }; | ||
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 0bdb8fd3afd1..11623c6b0cb3 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c | |||
@@ -171,7 +171,7 @@ static const struct pinctrl_ops meson_pctrl_ops = { | |||
171 | .get_group_name = meson_get_group_name, | 171 | .get_group_name = meson_get_group_name, |
172 | .get_group_pins = meson_get_group_pins, | 172 | .get_group_pins = meson_get_group_pins, |
173 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, | 173 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, |
174 | .dt_free_map = pinctrl_utils_dt_free_map, | 174 | .dt_free_map = pinctrl_utils_free_map, |
175 | .pin_dbg_show = meson_pin_dbg_show, | 175 | .pin_dbg_show = meson_pin_dbg_show, |
176 | }; | 176 | }; |
177 | 177 | ||
@@ -549,6 +549,14 @@ static const struct of_device_id meson_pinctrl_dt_match[] = { | |||
549 | .compatible = "amlogic,meson8b-aobus-pinctrl", | 549 | .compatible = "amlogic,meson8b-aobus-pinctrl", |
550 | .data = &meson8b_aobus_pinctrl_data, | 550 | .data = &meson8b_aobus_pinctrl_data, |
551 | }, | 551 | }, |
552 | { | ||
553 | .compatible = "amlogic,meson-gxbb-periphs-pinctrl", | ||
554 | .data = &meson_gxbb_periphs_pinctrl_data, | ||
555 | }, | ||
556 | { | ||
557 | .compatible = "amlogic,meson-gxbb-aobus-pinctrl", | ||
558 | .data = &meson_gxbb_aobus_pinctrl_data, | ||
559 | }, | ||
552 | { }, | 560 | { }, |
553 | }; | 561 | }; |
554 | 562 | ||
@@ -713,7 +721,7 @@ static int meson_pinctrl_probe(struct platform_device *pdev) | |||
713 | pc->desc.pins = pc->data->pins; | 721 | pc->desc.pins = pc->data->pins; |
714 | pc->desc.npins = pc->data->num_pins; | 722 | pc->desc.npins = pc->data->num_pins; |
715 | 723 | ||
716 | pc->pcdev = pinctrl_register(&pc->desc, pc->dev, pc); | 724 | pc->pcdev = devm_pinctrl_register(pc->dev, &pc->desc, pc); |
717 | if (IS_ERR(pc->pcdev)) { | 725 | if (IS_ERR(pc->pcdev)) { |
718 | dev_err(pc->dev, "can't register pinctrl device"); | 726 | dev_err(pc->dev, "can't register pinctrl device"); |
719 | return PTR_ERR(pc->pcdev); | 727 | return PTR_ERR(pc->pcdev); |
diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h index 9c93e0d494a3..d89442ea4a4d 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.h +++ b/drivers/pinctrl/meson/pinctrl-meson.h | |||
@@ -199,3 +199,5 @@ extern struct meson_pinctrl_data meson8_cbus_pinctrl_data; | |||
199 | extern struct meson_pinctrl_data meson8_aobus_pinctrl_data; | 199 | extern struct meson_pinctrl_data meson8_aobus_pinctrl_data; |
200 | extern struct meson_pinctrl_data meson8b_cbus_pinctrl_data; | 200 | extern struct meson_pinctrl_data meson8b_cbus_pinctrl_data; |
201 | extern struct meson_pinctrl_data meson8b_aobus_pinctrl_data; | 201 | extern struct meson_pinctrl_data meson8b_aobus_pinctrl_data; |
202 | extern struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data; | ||
203 | extern struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data; | ||
diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c index a100bcf4b17f..874f2edf8be3 100644 --- a/drivers/pinctrl/meson/pinctrl-meson8b.c +++ b/drivers/pinctrl/meson/pinctrl-meson8b.c | |||
@@ -564,7 +564,7 @@ static struct meson_pmx_group meson8b_cbus_groups[] = { | |||
564 | GROUP(eth_rx_clk, 6, 3), | 564 | GROUP(eth_rx_clk, 6, 3), |
565 | GROUP(eth_txd0_1, 6, 4), | 565 | GROUP(eth_txd0_1, 6, 4), |
566 | GROUP(eth_txd1_1, 6, 5), | 566 | GROUP(eth_txd1_1, 6, 5), |
567 | GROUP(eth_tx_en, 6, 0), | 567 | GROUP(eth_tx_en, 6, 6), |
568 | GROUP(eth_ref_clk, 6, 8), | 568 | GROUP(eth_ref_clk, 6, 8), |
569 | GROUP(eth_mdc, 6, 9), | 569 | GROUP(eth_mdc, 6, 9), |
570 | GROUP(eth_mdio_en, 6, 10), | 570 | GROUP(eth_mdio_en, 6, 10), |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-370.c b/drivers/pinctrl/mvebu/pinctrl-armada-370.c index 73dc1bc5f32c..9cc1cc3f5c34 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-370.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-370.c | |||
@@ -417,18 +417,12 @@ static int armada_370_pinctrl_probe(struct platform_device *pdev) | |||
417 | return mvebu_pinctrl_probe(pdev); | 417 | return mvebu_pinctrl_probe(pdev); |
418 | } | 418 | } |
419 | 419 | ||
420 | static int armada_370_pinctrl_remove(struct platform_device *pdev) | ||
421 | { | ||
422 | return mvebu_pinctrl_remove(pdev); | ||
423 | } | ||
424 | |||
425 | static struct platform_driver armada_370_pinctrl_driver = { | 420 | static struct platform_driver armada_370_pinctrl_driver = { |
426 | .driver = { | 421 | .driver = { |
427 | .name = "armada-370-pinctrl", | 422 | .name = "armada-370-pinctrl", |
428 | .of_match_table = armada_370_pinctrl_of_match, | 423 | .of_match_table = armada_370_pinctrl_of_match, |
429 | }, | 424 | }, |
430 | .probe = armada_370_pinctrl_probe, | 425 | .probe = armada_370_pinctrl_probe, |
431 | .remove = armada_370_pinctrl_remove, | ||
432 | }; | 426 | }; |
433 | 427 | ||
434 | module_platform_driver(armada_370_pinctrl_driver); | 428 | module_platform_driver(armada_370_pinctrl_driver); |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-375.c b/drivers/pinctrl/mvebu/pinctrl-armada-375.c index 54e9fbd0121f..070651431ca4 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-375.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-375.c | |||
@@ -435,18 +435,12 @@ static int armada_375_pinctrl_probe(struct platform_device *pdev) | |||
435 | return mvebu_pinctrl_probe(pdev); | 435 | return mvebu_pinctrl_probe(pdev); |
436 | } | 436 | } |
437 | 437 | ||
438 | static int armada_375_pinctrl_remove(struct platform_device *pdev) | ||
439 | { | ||
440 | return mvebu_pinctrl_remove(pdev); | ||
441 | } | ||
442 | |||
443 | static struct platform_driver armada_375_pinctrl_driver = { | 438 | static struct platform_driver armada_375_pinctrl_driver = { |
444 | .driver = { | 439 | .driver = { |
445 | .name = "armada-375-pinctrl", | 440 | .name = "armada-375-pinctrl", |
446 | .of_match_table = of_match_ptr(armada_375_pinctrl_of_match), | 441 | .of_match_table = of_match_ptr(armada_375_pinctrl_of_match), |
447 | }, | 442 | }, |
448 | .probe = armada_375_pinctrl_probe, | 443 | .probe = armada_375_pinctrl_probe, |
449 | .remove = armada_375_pinctrl_remove, | ||
450 | }; | 444 | }; |
451 | 445 | ||
452 | module_platform_driver(armada_375_pinctrl_driver); | 446 | module_platform_driver(armada_375_pinctrl_driver); |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c index 6ec82c62dff7..4e84c8e4938c 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c | |||
@@ -446,18 +446,12 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev) | |||
446 | return mvebu_pinctrl_probe(pdev); | 446 | return mvebu_pinctrl_probe(pdev); |
447 | } | 447 | } |
448 | 448 | ||
449 | static int armada_38x_pinctrl_remove(struct platform_device *pdev) | ||
450 | { | ||
451 | return mvebu_pinctrl_remove(pdev); | ||
452 | } | ||
453 | |||
454 | static struct platform_driver armada_38x_pinctrl_driver = { | 449 | static struct platform_driver armada_38x_pinctrl_driver = { |
455 | .driver = { | 450 | .driver = { |
456 | .name = "armada-38x-pinctrl", | 451 | .name = "armada-38x-pinctrl", |
457 | .of_match_table = of_match_ptr(armada_38x_pinctrl_of_match), | 452 | .of_match_table = of_match_ptr(armada_38x_pinctrl_of_match), |
458 | }, | 453 | }, |
459 | .probe = armada_38x_pinctrl_probe, | 454 | .probe = armada_38x_pinctrl_probe, |
460 | .remove = armada_38x_pinctrl_remove, | ||
461 | }; | 455 | }; |
462 | 456 | ||
463 | module_platform_driver(armada_38x_pinctrl_driver); | 457 | module_platform_driver(armada_38x_pinctrl_driver); |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-39x.c b/drivers/pinctrl/mvebu/pinctrl-armada-39x.c index fcfe9b478a2e..e288f8ba0bf1 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-39x.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-39x.c | |||
@@ -428,18 +428,12 @@ static int armada_39x_pinctrl_probe(struct platform_device *pdev) | |||
428 | return mvebu_pinctrl_probe(pdev); | 428 | return mvebu_pinctrl_probe(pdev); |
429 | } | 429 | } |
430 | 430 | ||
431 | static int armada_39x_pinctrl_remove(struct platform_device *pdev) | ||
432 | { | ||
433 | return mvebu_pinctrl_remove(pdev); | ||
434 | } | ||
435 | |||
436 | static struct platform_driver armada_39x_pinctrl_driver = { | 431 | static struct platform_driver armada_39x_pinctrl_driver = { |
437 | .driver = { | 432 | .driver = { |
438 | .name = "armada-39x-pinctrl", | 433 | .name = "armada-39x-pinctrl", |
439 | .of_match_table = of_match_ptr(armada_39x_pinctrl_of_match), | 434 | .of_match_table = of_match_ptr(armada_39x_pinctrl_of_match), |
440 | }, | 435 | }, |
441 | .probe = armada_39x_pinctrl_probe, | 436 | .probe = armada_39x_pinctrl_probe, |
442 | .remove = armada_39x_pinctrl_remove, | ||
443 | }; | 437 | }; |
444 | 438 | ||
445 | module_platform_driver(armada_39x_pinctrl_driver); | 439 | module_platform_driver(armada_39x_pinctrl_driver); |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c index bf70e0953576..e4ea71a9d985 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c | |||
@@ -502,18 +502,12 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) | |||
502 | return mvebu_pinctrl_probe(pdev); | 502 | return mvebu_pinctrl_probe(pdev); |
503 | } | 503 | } |
504 | 504 | ||
505 | static int armada_xp_pinctrl_remove(struct platform_device *pdev) | ||
506 | { | ||
507 | return mvebu_pinctrl_remove(pdev); | ||
508 | } | ||
509 | |||
510 | static struct platform_driver armada_xp_pinctrl_driver = { | 505 | static struct platform_driver armada_xp_pinctrl_driver = { |
511 | .driver = { | 506 | .driver = { |
512 | .name = "armada-xp-pinctrl", | 507 | .name = "armada-xp-pinctrl", |
513 | .of_match_table = armada_xp_pinctrl_of_match, | 508 | .of_match_table = armada_xp_pinctrl_of_match, |
514 | }, | 509 | }, |
515 | .probe = armada_xp_pinctrl_probe, | 510 | .probe = armada_xp_pinctrl_probe, |
516 | .remove = armada_xp_pinctrl_remove, | ||
517 | .suspend = armada_xp_pinctrl_suspend, | 511 | .suspend = armada_xp_pinctrl_suspend, |
518 | .resume = armada_xp_pinctrl_resume, | 512 | .resume = armada_xp_pinctrl_resume, |
519 | }; | 513 | }; |
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 95bfd0653e8f..f93ae0dcef9c 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c | |||
@@ -840,12 +840,9 @@ static int dove_pinctrl_probe(struct platform_device *pdev) | |||
840 | 840 | ||
841 | static int dove_pinctrl_remove(struct platform_device *pdev) | 841 | static int dove_pinctrl_remove(struct platform_device *pdev) |
842 | { | 842 | { |
843 | int ret; | ||
844 | |||
845 | ret = mvebu_pinctrl_remove(pdev); | ||
846 | if (!IS_ERR(clk)) | 843 | if (!IS_ERR(clk)) |
847 | clk_disable_unprepare(clk); | 844 | clk_disable_unprepare(clk); |
848 | return ret; | 845 | return 0; |
849 | } | 846 | } |
850 | 847 | ||
851 | static struct platform_driver dove_pinctrl_driver = { | 848 | static struct platform_driver dove_pinctrl_driver = { |
diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c index 0f07dc554a1d..a78e9a4997ba 100644 --- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c +++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c | |||
@@ -481,18 +481,12 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev) | |||
481 | return mvebu_pinctrl_probe(pdev); | 481 | return mvebu_pinctrl_probe(pdev); |
482 | } | 482 | } |
483 | 483 | ||
484 | static int kirkwood_pinctrl_remove(struct platform_device *pdev) | ||
485 | { | ||
486 | return mvebu_pinctrl_remove(pdev); | ||
487 | } | ||
488 | |||
489 | static struct platform_driver kirkwood_pinctrl_driver = { | 484 | static struct platform_driver kirkwood_pinctrl_driver = { |
490 | .driver = { | 485 | .driver = { |
491 | .name = "kirkwood-pinctrl", | 486 | .name = "kirkwood-pinctrl", |
492 | .of_match_table = kirkwood_pinctrl_of_match, | 487 | .of_match_table = kirkwood_pinctrl_of_match, |
493 | }, | 488 | }, |
494 | .probe = kirkwood_pinctrl_probe, | 489 | .probe = kirkwood_pinctrl_probe, |
495 | .remove = kirkwood_pinctrl_remove, | ||
496 | }; | 490 | }; |
497 | 491 | ||
498 | module_platform_driver(kirkwood_pinctrl_driver); | 492 | module_platform_driver(kirkwood_pinctrl_driver); |
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 3ef798fac81b..b6ec6db78351 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c | |||
@@ -711,7 +711,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) | |||
711 | return ret; | 711 | return ret; |
712 | } | 712 | } |
713 | 713 | ||
714 | pctl->pctldev = pinctrl_register(&pctl->desc, &pdev->dev, pctl); | 714 | pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pctl->desc, pctl); |
715 | if (IS_ERR(pctl->pctldev)) { | 715 | if (IS_ERR(pctl->pctldev)) { |
716 | dev_err(&pdev->dev, "unable to register pinctrl driver\n"); | 716 | dev_err(&pdev->dev, "unable to register pinctrl driver\n"); |
717 | return PTR_ERR(pctl->pctldev); | 717 | return PTR_ERR(pctl->pctldev); |
@@ -725,10 +725,3 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) | |||
725 | 725 | ||
726 | return 0; | 726 | return 0; |
727 | } | 727 | } |
728 | |||
729 | int mvebu_pinctrl_remove(struct platform_device *pdev) | ||
730 | { | ||
731 | struct mvebu_pinctrl *pctl = platform_get_drvdata(pdev); | ||
732 | pinctrl_unregister(pctl->pctldev); | ||
733 | return 0; | ||
734 | } | ||
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.h b/drivers/pinctrl/mvebu/pinctrl-mvebu.h index 65a98e6f7265..b75a5f4adf3b 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.h +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.h | |||
@@ -202,6 +202,5 @@ static inline int default_mpp_ctrl_set(void __iomem *base, unsigned int pid, | |||
202 | } | 202 | } |
203 | 203 | ||
204 | int mvebu_pinctrl_probe(struct platform_device *pdev); | 204 | int mvebu_pinctrl_probe(struct platform_device *pdev); |
205 | int mvebu_pinctrl_remove(struct platform_device *pdev); | ||
206 | 205 | ||
207 | #endif | 206 | #endif |
diff --git a/drivers/pinctrl/mvebu/pinctrl-orion.c b/drivers/pinctrl/mvebu/pinctrl-orion.c index 3b7122d826e4..345c3df669a0 100644 --- a/drivers/pinctrl/mvebu/pinctrl-orion.c +++ b/drivers/pinctrl/mvebu/pinctrl-orion.c | |||
@@ -239,18 +239,12 @@ static int orion_pinctrl_probe(struct platform_device *pdev) | |||
239 | return mvebu_pinctrl_probe(pdev); | 239 | return mvebu_pinctrl_probe(pdev); |
240 | } | 240 | } |
241 | 241 | ||
242 | static int orion_pinctrl_remove(struct platform_device *pdev) | ||
243 | { | ||
244 | return mvebu_pinctrl_remove(pdev); | ||
245 | } | ||
246 | |||
247 | static struct platform_driver orion_pinctrl_driver = { | 242 | static struct platform_driver orion_pinctrl_driver = { |
248 | .driver = { | 243 | .driver = { |
249 | .name = "orion-pinctrl", | 244 | .name = "orion-pinctrl", |
250 | .of_match_table = of_match_ptr(orion_pinctrl_of_match), | 245 | .of_match_table = of_match_ptr(orion_pinctrl_of_match), |
251 | }, | 246 | }, |
252 | .probe = orion_pinctrl_probe, | 247 | .probe = orion_pinctrl_probe, |
253 | .remove = orion_pinctrl_remove, | ||
254 | }; | 248 | }; |
255 | 249 | ||
256 | module_platform_driver(orion_pinctrl_driver); | 250 | module_platform_driver(orion_pinctrl_driver); |
diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index 1f7469c9857d..7d343c22c90c 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c | |||
@@ -937,7 +937,7 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
937 | ret = abx500_dt_subnode_to_map(pctldev, np, map, | 937 | ret = abx500_dt_subnode_to_map(pctldev, np, map, |
938 | &reserved_maps, num_maps); | 938 | &reserved_maps, num_maps); |
939 | if (ret < 0) { | 939 | if (ret < 0) { |
940 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 940 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
941 | return ret; | 941 | return ret; |
942 | } | 942 | } |
943 | } | 943 | } |
@@ -951,7 +951,7 @@ static const struct pinctrl_ops abx500_pinctrl_ops = { | |||
951 | .get_group_pins = abx500_get_group_pins, | 951 | .get_group_pins = abx500_get_group_pins, |
952 | .pin_dbg_show = abx500_pin_dbg_show, | 952 | .pin_dbg_show = abx500_pin_dbg_show, |
953 | .dt_node_to_map = abx500_dt_node_to_map, | 953 | .dt_node_to_map = abx500_dt_node_to_map, |
954 | .dt_free_map = pinctrl_utils_dt_free_map, | 954 | .dt_free_map = pinctrl_utils_free_map, |
955 | }; | 955 | }; |
956 | 956 | ||
957 | static int abx500_pin_config_get(struct pinctrl_dev *pctldev, | 957 | static int abx500_pin_config_get(struct pinctrl_dev *pctldev, |
@@ -1212,7 +1212,8 @@ static int abx500_gpio_probe(struct platform_device *pdev) | |||
1212 | 1212 | ||
1213 | abx500_pinctrl_desc.pins = pct->soc->pins; | 1213 | abx500_pinctrl_desc.pins = pct->soc->pins; |
1214 | abx500_pinctrl_desc.npins = pct->soc->npins; | 1214 | abx500_pinctrl_desc.npins = pct->soc->npins; |
1215 | pct->pctldev = pinctrl_register(&abx500_pinctrl_desc, &pdev->dev, pct); | 1215 | pct->pctldev = devm_pinctrl_register(&pdev->dev, &abx500_pinctrl_desc, |
1216 | pct); | ||
1216 | if (IS_ERR(pct->pctldev)) { | 1217 | if (IS_ERR(pct->pctldev)) { |
1217 | dev_err(&pdev->dev, | 1218 | dev_err(&pdev->dev, |
1218 | "could not register abx500 pinctrl driver\n"); | 1219 | "could not register abx500 pinctrl driver\n"); |
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index c8969dd49449..ccbfc325c778 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/of_device.h> | 25 | #include <linux/of_device.h> |
26 | #include <linux/of_address.h> | 26 | #include <linux/of_address.h> |
27 | #include <linux/bitops.h> | ||
27 | #include <linux/pinctrl/machine.h> | 28 | #include <linux/pinctrl/machine.h> |
28 | #include <linux/pinctrl/pinctrl.h> | 29 | #include <linux/pinctrl/pinctrl.h> |
29 | #include <linux/pinctrl/pinmux.h> | 30 | #include <linux/pinctrl/pinmux.h> |
@@ -292,15 +293,14 @@ static DEFINE_SPINLOCK(nmk_gpio_slpm_lock); | |||
292 | static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, | 293 | static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, |
293 | unsigned offset, int gpio_mode) | 294 | unsigned offset, int gpio_mode) |
294 | { | 295 | { |
295 | u32 bit = 1 << offset; | ||
296 | u32 afunc, bfunc; | 296 | u32 afunc, bfunc; |
297 | 297 | ||
298 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~bit; | 298 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~BIT(offset); |
299 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~bit; | 299 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~BIT(offset); |
300 | if (gpio_mode & NMK_GPIO_ALT_A) | 300 | if (gpio_mode & NMK_GPIO_ALT_A) |
301 | afunc |= bit; | 301 | afunc |= BIT(offset); |
302 | if (gpio_mode & NMK_GPIO_ALT_B) | 302 | if (gpio_mode & NMK_GPIO_ALT_B) |
303 | bfunc |= bit; | 303 | bfunc |= BIT(offset); |
304 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); | 304 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); |
305 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); | 305 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); |
306 | } | 306 | } |
@@ -308,55 +308,52 @@ static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, | |||
308 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, | 308 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, |
309 | unsigned offset, enum nmk_gpio_slpm mode) | 309 | unsigned offset, enum nmk_gpio_slpm mode) |
310 | { | 310 | { |
311 | u32 bit = 1 << offset; | ||
312 | u32 slpm; | 311 | u32 slpm; |
313 | 312 | ||
314 | slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC); | 313 | slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC); |
315 | if (mode == NMK_GPIO_SLPM_NOCHANGE) | 314 | if (mode == NMK_GPIO_SLPM_NOCHANGE) |
316 | slpm |= bit; | 315 | slpm |= BIT(offset); |
317 | else | 316 | else |
318 | slpm &= ~bit; | 317 | slpm &= ~BIT(offset); |
319 | writel(slpm, nmk_chip->addr + NMK_GPIO_SLPC); | 318 | writel(slpm, nmk_chip->addr + NMK_GPIO_SLPC); |
320 | } | 319 | } |
321 | 320 | ||
322 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, | 321 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, |
323 | unsigned offset, enum nmk_gpio_pull pull) | 322 | unsigned offset, enum nmk_gpio_pull pull) |
324 | { | 323 | { |
325 | u32 bit = 1 << offset; | ||
326 | u32 pdis; | 324 | u32 pdis; |
327 | 325 | ||
328 | pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); | 326 | pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); |
329 | if (pull == NMK_GPIO_PULL_NONE) { | 327 | if (pull == NMK_GPIO_PULL_NONE) { |
330 | pdis |= bit; | 328 | pdis |= BIT(offset); |
331 | nmk_chip->pull_up &= ~bit; | 329 | nmk_chip->pull_up &= ~BIT(offset); |
332 | } else { | 330 | } else { |
333 | pdis &= ~bit; | 331 | pdis &= ~BIT(offset); |
334 | } | 332 | } |
335 | 333 | ||
336 | writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); | 334 | writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); |
337 | 335 | ||
338 | if (pull == NMK_GPIO_PULL_UP) { | 336 | if (pull == NMK_GPIO_PULL_UP) { |
339 | nmk_chip->pull_up |= bit; | 337 | nmk_chip->pull_up |= BIT(offset); |
340 | writel(bit, nmk_chip->addr + NMK_GPIO_DATS); | 338 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATS); |
341 | } else if (pull == NMK_GPIO_PULL_DOWN) { | 339 | } else if (pull == NMK_GPIO_PULL_DOWN) { |
342 | nmk_chip->pull_up &= ~bit; | 340 | nmk_chip->pull_up &= ~BIT(offset); |
343 | writel(bit, nmk_chip->addr + NMK_GPIO_DATC); | 341 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATC); |
344 | } | 342 | } |
345 | } | 343 | } |
346 | 344 | ||
347 | static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip, | 345 | static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip, |
348 | unsigned offset, bool lowemi) | 346 | unsigned offset, bool lowemi) |
349 | { | 347 | { |
350 | u32 bit = BIT(offset); | 348 | bool enabled = nmk_chip->lowemi & BIT(offset); |
351 | bool enabled = nmk_chip->lowemi & bit; | ||
352 | 349 | ||
353 | if (lowemi == enabled) | 350 | if (lowemi == enabled) |
354 | return; | 351 | return; |
355 | 352 | ||
356 | if (lowemi) | 353 | if (lowemi) |
357 | nmk_chip->lowemi |= bit; | 354 | nmk_chip->lowemi |= BIT(offset); |
358 | else | 355 | else |
359 | nmk_chip->lowemi &= ~bit; | 356 | nmk_chip->lowemi &= ~BIT(offset); |
360 | 357 | ||
361 | writel_relaxed(nmk_chip->lowemi, | 358 | writel_relaxed(nmk_chip->lowemi, |
362 | nmk_chip->addr + NMK_GPIO_LOWEMI); | 359 | nmk_chip->addr + NMK_GPIO_LOWEMI); |
@@ -365,22 +362,22 @@ static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip, | |||
365 | static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip, | 362 | static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip, |
366 | unsigned offset) | 363 | unsigned offset) |
367 | { | 364 | { |
368 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); | 365 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRC); |
369 | } | 366 | } |
370 | 367 | ||
371 | static void __nmk_gpio_set_output(struct nmk_gpio_chip *nmk_chip, | 368 | static void __nmk_gpio_set_output(struct nmk_gpio_chip *nmk_chip, |
372 | unsigned offset, int val) | 369 | unsigned offset, int val) |
373 | { | 370 | { |
374 | if (val) | 371 | if (val) |
375 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATS); | 372 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATS); |
376 | else | 373 | else |
377 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATC); | 374 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATC); |
378 | } | 375 | } |
379 | 376 | ||
380 | static void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip, | 377 | static void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip, |
381 | unsigned offset, int val) | 378 | unsigned offset, int val) |
382 | { | 379 | { |
383 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRS); | 380 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRS); |
384 | __nmk_gpio_set_output(nmk_chip, offset, val); | 381 | __nmk_gpio_set_output(nmk_chip, offset, val); |
385 | } | 382 | } |
386 | 383 | ||
@@ -614,34 +611,7 @@ static int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, | |||
614 | return NMK_GPIO_ALT_C; | 611 | return NMK_GPIO_ALT_C; |
615 | } | 612 | } |
616 | 613 | ||
617 | int nmk_gpio_get_mode(int gpio) | ||
618 | { | ||
619 | struct nmk_gpio_chip *nmk_chip; | ||
620 | u32 afunc, bfunc, bit; | ||
621 | |||
622 | nmk_chip = nmk_gpio_chips[gpio / NMK_GPIO_PER_CHIP]; | ||
623 | if (!nmk_chip) | ||
624 | return -EINVAL; | ||
625 | |||
626 | bit = 1 << (gpio % NMK_GPIO_PER_CHIP); | ||
627 | |||
628 | clk_enable(nmk_chip->clk); | ||
629 | |||
630 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & bit; | ||
631 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & bit; | ||
632 | |||
633 | clk_disable(nmk_chip->clk); | ||
634 | |||
635 | return (afunc ? NMK_GPIO_ALT_A : 0) | (bfunc ? NMK_GPIO_ALT_B : 0); | ||
636 | } | ||
637 | EXPORT_SYMBOL(nmk_gpio_get_mode); | ||
638 | |||
639 | |||
640 | /* IRQ functions */ | 614 | /* IRQ functions */ |
641 | static inline int nmk_gpio_get_bitmask(int gpio) | ||
642 | { | ||
643 | return 1 << (gpio % NMK_GPIO_PER_CHIP); | ||
644 | } | ||
645 | 615 | ||
646 | static void nmk_gpio_irq_ack(struct irq_data *d) | 616 | static void nmk_gpio_irq_ack(struct irq_data *d) |
647 | { | 617 | { |
@@ -649,7 +619,7 @@ static void nmk_gpio_irq_ack(struct irq_data *d) | |||
649 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); | 619 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); |
650 | 620 | ||
651 | clk_enable(nmk_chip->clk); | 621 | clk_enable(nmk_chip->clk); |
652 | writel(nmk_gpio_get_bitmask(d->hwirq), nmk_chip->addr + NMK_GPIO_IC); | 622 | writel(BIT(d->hwirq), nmk_chip->addr + NMK_GPIO_IC); |
653 | clk_disable(nmk_chip->clk); | 623 | clk_disable(nmk_chip->clk); |
654 | } | 624 | } |
655 | 625 | ||
@@ -659,10 +629,9 @@ enum nmk_gpio_irq_type { | |||
659 | }; | 629 | }; |
660 | 630 | ||
661 | static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, | 631 | static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, |
662 | int gpio, enum nmk_gpio_irq_type which, | 632 | int offset, enum nmk_gpio_irq_type which, |
663 | bool enable) | 633 | bool enable) |
664 | { | 634 | { |
665 | u32 bitmask = nmk_gpio_get_bitmask(gpio); | ||
666 | u32 *rimscval; | 635 | u32 *rimscval; |
667 | u32 *fimscval; | 636 | u32 *fimscval; |
668 | u32 rimscreg; | 637 | u32 rimscreg; |
@@ -681,24 +650,24 @@ static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, | |||
681 | } | 650 | } |
682 | 651 | ||
683 | /* we must individually set/clear the two edges */ | 652 | /* we must individually set/clear the two edges */ |
684 | if (nmk_chip->edge_rising & bitmask) { | 653 | if (nmk_chip->edge_rising & BIT(offset)) { |
685 | if (enable) | 654 | if (enable) |
686 | *rimscval |= bitmask; | 655 | *rimscval |= BIT(offset); |
687 | else | 656 | else |
688 | *rimscval &= ~bitmask; | 657 | *rimscval &= ~BIT(offset); |
689 | writel(*rimscval, nmk_chip->addr + rimscreg); | 658 | writel(*rimscval, nmk_chip->addr + rimscreg); |
690 | } | 659 | } |
691 | if (nmk_chip->edge_falling & bitmask) { | 660 | if (nmk_chip->edge_falling & BIT(offset)) { |
692 | if (enable) | 661 | if (enable) |
693 | *fimscval |= bitmask; | 662 | *fimscval |= BIT(offset); |
694 | else | 663 | else |
695 | *fimscval &= ~bitmask; | 664 | *fimscval &= ~BIT(offset); |
696 | writel(*fimscval, nmk_chip->addr + fimscreg); | 665 | writel(*fimscval, nmk_chip->addr + fimscreg); |
697 | } | 666 | } |
698 | } | 667 | } |
699 | 668 | ||
700 | static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, | 669 | static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, |
701 | int gpio, bool on) | 670 | int offset, bool on) |
702 | { | 671 | { |
703 | /* | 672 | /* |
704 | * Ensure WAKEUP_ENABLE is on. No need to disable it if wakeup is | 673 | * Ensure WAKEUP_ENABLE is on. No need to disable it if wakeup is |
@@ -706,21 +675,19 @@ static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, | |||
706 | * wakeup is anyhow controlled by the RIMSC and FIMSC registers. | 675 | * wakeup is anyhow controlled by the RIMSC and FIMSC registers. |
707 | */ | 676 | */ |
708 | if (nmk_chip->sleepmode && on) { | 677 | if (nmk_chip->sleepmode && on) { |
709 | __nmk_gpio_set_slpm(nmk_chip, gpio % NMK_GPIO_PER_CHIP, | 678 | __nmk_gpio_set_slpm(nmk_chip, offset, |
710 | NMK_GPIO_SLPM_WAKEUP_ENABLE); | 679 | NMK_GPIO_SLPM_WAKEUP_ENABLE); |
711 | } | 680 | } |
712 | 681 | ||
713 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, on); | 682 | __nmk_gpio_irq_modify(nmk_chip, offset, WAKE, on); |
714 | } | 683 | } |
715 | 684 | ||
716 | static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable) | 685 | static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable) |
717 | { | 686 | { |
718 | struct nmk_gpio_chip *nmk_chip; | 687 | struct nmk_gpio_chip *nmk_chip; |
719 | unsigned long flags; | 688 | unsigned long flags; |
720 | u32 bitmask; | ||
721 | 689 | ||
722 | nmk_chip = irq_data_get_irq_chip_data(d); | 690 | nmk_chip = irq_data_get_irq_chip_data(d); |
723 | bitmask = nmk_gpio_get_bitmask(d->hwirq); | ||
724 | if (!nmk_chip) | 691 | if (!nmk_chip) |
725 | return -EINVAL; | 692 | return -EINVAL; |
726 | 693 | ||
@@ -730,7 +697,7 @@ static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable) | |||
730 | 697 | ||
731 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, enable); | 698 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, enable); |
732 | 699 | ||
733 | if (!(nmk_chip->real_wake & bitmask)) | 700 | if (!(nmk_chip->real_wake & BIT(d->hwirq))) |
734 | __nmk_gpio_set_wake(nmk_chip, d->hwirq, enable); | 701 | __nmk_gpio_set_wake(nmk_chip, d->hwirq, enable); |
735 | 702 | ||
736 | spin_unlock(&nmk_chip->lock); | 703 | spin_unlock(&nmk_chip->lock); |
@@ -754,12 +721,10 @@ static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on) | |||
754 | { | 721 | { |
755 | struct nmk_gpio_chip *nmk_chip; | 722 | struct nmk_gpio_chip *nmk_chip; |
756 | unsigned long flags; | 723 | unsigned long flags; |
757 | u32 bitmask; | ||
758 | 724 | ||
759 | nmk_chip = irq_data_get_irq_chip_data(d); | 725 | nmk_chip = irq_data_get_irq_chip_data(d); |
760 | if (!nmk_chip) | 726 | if (!nmk_chip) |
761 | return -EINVAL; | 727 | return -EINVAL; |
762 | bitmask = nmk_gpio_get_bitmask(d->hwirq); | ||
763 | 728 | ||
764 | clk_enable(nmk_chip->clk); | 729 | clk_enable(nmk_chip->clk); |
765 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); | 730 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); |
@@ -769,9 +734,9 @@ static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on) | |||
769 | __nmk_gpio_set_wake(nmk_chip, d->hwirq, on); | 734 | __nmk_gpio_set_wake(nmk_chip, d->hwirq, on); |
770 | 735 | ||
771 | if (on) | 736 | if (on) |
772 | nmk_chip->real_wake |= bitmask; | 737 | nmk_chip->real_wake |= BIT(d->hwirq); |
773 | else | 738 | else |
774 | nmk_chip->real_wake &= ~bitmask; | 739 | nmk_chip->real_wake &= ~BIT(d->hwirq); |
775 | 740 | ||
776 | spin_unlock(&nmk_chip->lock); | 741 | spin_unlock(&nmk_chip->lock); |
777 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); | 742 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); |
@@ -786,10 +751,8 @@ static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
786 | bool wake = irqd_is_wakeup_set(d); | 751 | bool wake = irqd_is_wakeup_set(d); |
787 | struct nmk_gpio_chip *nmk_chip; | 752 | struct nmk_gpio_chip *nmk_chip; |
788 | unsigned long flags; | 753 | unsigned long flags; |
789 | u32 bitmask; | ||
790 | 754 | ||
791 | nmk_chip = irq_data_get_irq_chip_data(d); | 755 | nmk_chip = irq_data_get_irq_chip_data(d); |
792 | bitmask = nmk_gpio_get_bitmask(d->hwirq); | ||
793 | if (!nmk_chip) | 756 | if (!nmk_chip) |
794 | return -EINVAL; | 757 | return -EINVAL; |
795 | if (type & IRQ_TYPE_LEVEL_HIGH) | 758 | if (type & IRQ_TYPE_LEVEL_HIGH) |
@@ -806,13 +769,13 @@ static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
806 | if (enabled || wake) | 769 | if (enabled || wake) |
807 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, false); | 770 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, false); |
808 | 771 | ||
809 | nmk_chip->edge_rising &= ~bitmask; | 772 | nmk_chip->edge_rising &= ~BIT(d->hwirq); |
810 | if (type & IRQ_TYPE_EDGE_RISING) | 773 | if (type & IRQ_TYPE_EDGE_RISING) |
811 | nmk_chip->edge_rising |= bitmask; | 774 | nmk_chip->edge_rising |= BIT(d->hwirq); |
812 | 775 | ||
813 | nmk_chip->edge_falling &= ~bitmask; | 776 | nmk_chip->edge_falling &= ~BIT(d->hwirq); |
814 | if (type & IRQ_TYPE_EDGE_FALLING) | 777 | if (type & IRQ_TYPE_EDGE_FALLING) |
815 | nmk_chip->edge_falling |= bitmask; | 778 | nmk_chip->edge_falling |= BIT(d->hwirq); |
816 | 779 | ||
817 | if (enabled) | 780 | if (enabled) |
818 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, true); | 781 | __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, true); |
@@ -884,13 +847,27 @@ static void nmk_gpio_latent_irq_handler(struct irq_desc *desc) | |||
884 | 847 | ||
885 | /* I/O Functions */ | 848 | /* I/O Functions */ |
886 | 849 | ||
850 | static int nmk_gpio_get_dir(struct gpio_chip *chip, unsigned offset) | ||
851 | { | ||
852 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); | ||
853 | int dir; | ||
854 | |||
855 | clk_enable(nmk_chip->clk); | ||
856 | |||
857 | dir = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset)); | ||
858 | |||
859 | clk_disable(nmk_chip->clk); | ||
860 | |||
861 | return dir; | ||
862 | } | ||
863 | |||
887 | static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) | 864 | static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) |
888 | { | 865 | { |
889 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); | 866 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); |
890 | 867 | ||
891 | clk_enable(nmk_chip->clk); | 868 | clk_enable(nmk_chip->clk); |
892 | 869 | ||
893 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); | 870 | writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRC); |
894 | 871 | ||
895 | clk_disable(nmk_chip->clk); | 872 | clk_disable(nmk_chip->clk); |
896 | 873 | ||
@@ -900,12 +877,11 @@ static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) | |||
900 | static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) | 877 | static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) |
901 | { | 878 | { |
902 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); | 879 | struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); |
903 | u32 bit = 1 << offset; | ||
904 | int value; | 880 | int value; |
905 | 881 | ||
906 | clk_enable(nmk_chip->clk); | 882 | clk_enable(nmk_chip->clk); |
907 | 883 | ||
908 | value = (readl(nmk_chip->addr + NMK_GPIO_DAT) & bit) != 0; | 884 | value = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & BIT(offset)); |
909 | 885 | ||
910 | clk_disable(nmk_chip->clk); | 886 | clk_disable(nmk_chip->clk); |
911 | 887 | ||
@@ -939,6 +915,19 @@ static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, | |||
939 | } | 915 | } |
940 | 916 | ||
941 | #ifdef CONFIG_DEBUG_FS | 917 | #ifdef CONFIG_DEBUG_FS |
918 | static int nmk_gpio_get_mode(struct nmk_gpio_chip *nmk_chip, int offset) | ||
919 | { | ||
920 | u32 afunc, bfunc; | ||
921 | |||
922 | clk_enable(nmk_chip->clk); | ||
923 | |||
924 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & BIT(offset); | ||
925 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & BIT(offset); | ||
926 | |||
927 | clk_disable(nmk_chip->clk); | ||
928 | |||
929 | return (afunc ? NMK_GPIO_ALT_A : 0) | (bfunc ? NMK_GPIO_ALT_B : 0); | ||
930 | } | ||
942 | 931 | ||
943 | #include <linux/seq_file.h> | 932 | #include <linux/seq_file.h> |
944 | 933 | ||
@@ -952,7 +941,6 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, | |||
952 | bool is_out; | 941 | bool is_out; |
953 | bool data_out; | 942 | bool data_out; |
954 | bool pull; | 943 | bool pull; |
955 | u32 bit = 1 << offset; | ||
956 | const char *modes[] = { | 944 | const char *modes[] = { |
957 | [NMK_GPIO_ALT_GPIO] = "gpio", | 945 | [NMK_GPIO_ALT_GPIO] = "gpio", |
958 | [NMK_GPIO_ALT_A] = "altA", | 946 | [NMK_GPIO_ALT_A] = "altA", |
@@ -970,10 +958,10 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, | |||
970 | }; | 958 | }; |
971 | 959 | ||
972 | clk_enable(nmk_chip->clk); | 960 | clk_enable(nmk_chip->clk); |
973 | is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit); | 961 | is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset)); |
974 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); | 962 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & BIT(offset)); |
975 | data_out = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & bit); | 963 | data_out = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & BIT(offset)); |
976 | mode = nmk_gpio_get_mode(gpio); | 964 | mode = nmk_gpio_get_mode(nmk_chip, offset); |
977 | if ((mode == NMK_GPIO_ALT_C) && pctldev) | 965 | if ((mode == NMK_GPIO_ALT_C) && pctldev) |
978 | mode = nmk_prcm_gpiocr_get_mode(pctldev, gpio); | 966 | mode = nmk_prcm_gpiocr_get_mode(pctldev, gpio); |
979 | 967 | ||
@@ -1007,11 +995,10 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, | |||
1007 | */ | 995 | */ |
1008 | if (irq > 0 && desc && desc->action) { | 996 | if (irq > 0 && desc && desc->action) { |
1009 | char *trigger; | 997 | char *trigger; |
1010 | u32 bitmask = nmk_gpio_get_bitmask(gpio); | ||
1011 | 998 | ||
1012 | if (nmk_chip->edge_rising & bitmask) | 999 | if (nmk_chip->edge_rising & BIT(offset)) |
1013 | trigger = "edge-rising"; | 1000 | trigger = "edge-rising"; |
1014 | else if (nmk_chip->edge_falling & bitmask) | 1001 | else if (nmk_chip->edge_falling & BIT(offset)) |
1015 | trigger = "edge-falling"; | 1002 | trigger = "edge-falling"; |
1016 | else | 1003 | else |
1017 | trigger = "edge-undefined"; | 1004 | trigger = "edge-undefined"; |
@@ -1246,6 +1233,7 @@ static int nmk_gpio_probe(struct platform_device *dev) | |||
1246 | chip = &nmk_chip->chip; | 1233 | chip = &nmk_chip->chip; |
1247 | chip->request = gpiochip_generic_request; | 1234 | chip->request = gpiochip_generic_request; |
1248 | chip->free = gpiochip_generic_free; | 1235 | chip->free = gpiochip_generic_free; |
1236 | chip->get_direction = nmk_gpio_get_dir; | ||
1249 | chip->direction_input = nmk_gpio_make_input; | 1237 | chip->direction_input = nmk_gpio_make_input; |
1250 | chip->get = nmk_gpio_get_input; | 1238 | chip->get = nmk_gpio_get_input; |
1251 | chip->direction_output = nmk_gpio_make_output; | 1239 | chip->direction_output = nmk_gpio_make_output; |
@@ -1612,7 +1600,7 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
1612 | ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map, | 1600 | ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map, |
1613 | &reserved_maps, num_maps); | 1601 | &reserved_maps, num_maps); |
1614 | if (ret < 0) { | 1602 | if (ret < 0) { |
1615 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 1603 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
1616 | return ret; | 1604 | return ret; |
1617 | } | 1605 | } |
1618 | } | 1606 | } |
@@ -1626,7 +1614,7 @@ static const struct pinctrl_ops nmk_pinctrl_ops = { | |||
1626 | .get_group_pins = nmk_get_group_pins, | 1614 | .get_group_pins = nmk_get_group_pins, |
1627 | .pin_dbg_show = nmk_pin_dbg_show, | 1615 | .pin_dbg_show = nmk_pin_dbg_show, |
1628 | .dt_node_to_map = nmk_pinctrl_dt_node_to_map, | 1616 | .dt_node_to_map = nmk_pinctrl_dt_node_to_map, |
1629 | .dt_free_map = pinctrl_utils_dt_free_map, | 1617 | .dt_free_map = pinctrl_utils_free_map, |
1630 | }; | 1618 | }; |
1631 | 1619 | ||
1632 | static int nmk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev) | 1620 | static int nmk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev) |
@@ -2044,7 +2032,7 @@ static int nmk_pinctrl_probe(struct platform_device *pdev) | |||
2044 | nmk_pinctrl_desc.npins = npct->soc->npins; | 2032 | nmk_pinctrl_desc.npins = npct->soc->npins; |
2045 | npct->dev = &pdev->dev; | 2033 | npct->dev = &pdev->dev; |
2046 | 2034 | ||
2047 | npct->pctl = pinctrl_register(&nmk_pinctrl_desc, &pdev->dev, npct); | 2035 | npct->pctl = devm_pinctrl_register(&pdev->dev, &nmk_pinctrl_desc, npct); |
2048 | if (IS_ERR(npct->pctl)) { | 2036 | if (IS_ERR(npct->pctl)) { |
2049 | dev_err(&pdev->dev, "could not register Nomadik pinctrl driver\n"); | 2037 | dev_err(&pdev->dev, "could not register Nomadik pinctrl driver\n"); |
2050 | return PTR_ERR(npct->pctl); | 2038 | return PTR_ERR(npct->pctl); |
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index 79e6159712c2..d5bf9fae2ddd 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c | |||
@@ -386,7 +386,7 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
386 | return 0; | 386 | return 0; |
387 | 387 | ||
388 | exit: | 388 | exit: |
389 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 389 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
390 | return ret; | 390 | return ret; |
391 | } | 391 | } |
392 | EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map); | 392 | EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map); |
diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c index ecb57635a37e..54569a7eac59 100644 --- a/drivers/pinctrl/pinctrl-adi2.c +++ b/drivers/pinctrl/pinctrl-adi2.c | |||
@@ -1058,7 +1058,8 @@ static int adi_pinctrl_probe(struct platform_device *pdev) | |||
1058 | adi_pinmux_desc.npins = pinctrl->soc->npins; | 1058 | adi_pinmux_desc.npins = pinctrl->soc->npins; |
1059 | 1059 | ||
1060 | /* Now register the pin controller and all pins it handles */ | 1060 | /* Now register the pin controller and all pins it handles */ |
1061 | pinctrl->pctl = pinctrl_register(&adi_pinmux_desc, &pdev->dev, pinctrl); | 1061 | pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &adi_pinmux_desc, |
1062 | pinctrl); | ||
1062 | if (IS_ERR(pinctrl->pctl)) { | 1063 | if (IS_ERR(pinctrl->pctl)) { |
1063 | dev_err(&pdev->dev, "could not register pinctrl ADI2 driver\n"); | 1064 | dev_err(&pdev->dev, "could not register pinctrl ADI2 driver\n"); |
1064 | return PTR_ERR(pinctrl->pctl); | 1065 | return PTR_ERR(pinctrl->pctl); |
@@ -1069,18 +1070,8 @@ static int adi_pinctrl_probe(struct platform_device *pdev) | |||
1069 | return 0; | 1070 | return 0; |
1070 | } | 1071 | } |
1071 | 1072 | ||
1072 | static int adi_pinctrl_remove(struct platform_device *pdev) | ||
1073 | { | ||
1074 | struct adi_pinctrl *pinctrl = platform_get_drvdata(pdev); | ||
1075 | |||
1076 | pinctrl_unregister(pinctrl->pctl); | ||
1077 | |||
1078 | return 0; | ||
1079 | } | ||
1080 | |||
1081 | static struct platform_driver adi_pinctrl_driver = { | 1073 | static struct platform_driver adi_pinctrl_driver = { |
1082 | .probe = adi_pinctrl_probe, | 1074 | .probe = adi_pinctrl_probe, |
1083 | .remove = adi_pinctrl_remove, | ||
1084 | .driver = { | 1075 | .driver = { |
1085 | .name = DRIVER_NAME, | 1076 | .name = DRIVER_NAME, |
1086 | }, | 1077 | }, |
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 5c025f5b5048..634b4d30eefb 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c | |||
@@ -580,7 +580,7 @@ static const struct pinctrl_ops amd_pinctrl_ops = { | |||
580 | .get_group_pins = amd_get_group_pins, | 580 | .get_group_pins = amd_get_group_pins, |
581 | #ifdef CONFIG_OF | 581 | #ifdef CONFIG_OF |
582 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 582 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
583 | .dt_free_map = pinctrl_utils_dt_free_map, | 583 | .dt_free_map = pinctrl_utils_free_map, |
584 | #endif | 584 | #endif |
585 | }; | 585 | }; |
586 | 586 | ||
@@ -783,8 +783,8 @@ static int amd_gpio_probe(struct platform_device *pdev) | |||
783 | gpio_dev->ngroups = ARRAY_SIZE(kerncz_groups); | 783 | gpio_dev->ngroups = ARRAY_SIZE(kerncz_groups); |
784 | 784 | ||
785 | amd_pinctrl_desc.name = dev_name(&pdev->dev); | 785 | amd_pinctrl_desc.name = dev_name(&pdev->dev); |
786 | gpio_dev->pctrl = pinctrl_register(&amd_pinctrl_desc, | 786 | gpio_dev->pctrl = devm_pinctrl_register(&pdev->dev, &amd_pinctrl_desc, |
787 | &pdev->dev, gpio_dev); | 787 | gpio_dev); |
788 | if (IS_ERR(gpio_dev->pctrl)) { | 788 | if (IS_ERR(gpio_dev->pctrl)) { |
789 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 789 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
790 | return PTR_ERR(gpio_dev->pctrl); | 790 | return PTR_ERR(gpio_dev->pctrl); |
@@ -792,7 +792,7 @@ static int amd_gpio_probe(struct platform_device *pdev) | |||
792 | 792 | ||
793 | ret = gpiochip_add_data(&gpio_dev->gc, gpio_dev); | 793 | ret = gpiochip_add_data(&gpio_dev->gc, gpio_dev); |
794 | if (ret) | 794 | if (ret) |
795 | goto out1; | 795 | return ret; |
796 | 796 | ||
797 | ret = gpiochip_add_pin_range(&gpio_dev->gc, dev_name(&pdev->dev), | 797 | ret = gpiochip_add_pin_range(&gpio_dev->gc, dev_name(&pdev->dev), |
798 | 0, 0, TOTAL_NUMBER_OF_PINS); | 798 | 0, 0, TOTAL_NUMBER_OF_PINS); |
@@ -825,8 +825,6 @@ static int amd_gpio_probe(struct platform_device *pdev) | |||
825 | out2: | 825 | out2: |
826 | gpiochip_remove(&gpio_dev->gc); | 826 | gpiochip_remove(&gpio_dev->gc); |
827 | 827 | ||
828 | out1: | ||
829 | pinctrl_unregister(gpio_dev->pctrl); | ||
830 | return ret; | 828 | return ret; |
831 | } | 829 | } |
832 | 830 | ||
@@ -837,13 +835,13 @@ static int amd_gpio_remove(struct platform_device *pdev) | |||
837 | gpio_dev = platform_get_drvdata(pdev); | 835 | gpio_dev = platform_get_drvdata(pdev); |
838 | 836 | ||
839 | gpiochip_remove(&gpio_dev->gc); | 837 | gpiochip_remove(&gpio_dev->gc); |
840 | pinctrl_unregister(gpio_dev->pctrl); | ||
841 | 838 | ||
842 | return 0; | 839 | return 0; |
843 | } | 840 | } |
844 | 841 | ||
845 | static const struct acpi_device_id amd_gpio_acpi_match[] = { | 842 | static const struct acpi_device_id amd_gpio_acpi_match[] = { |
846 | { "AMD0030", 0 }, | 843 | { "AMD0030", 0 }, |
844 | { "AMDI0030", 0}, | ||
847 | { }, | 845 | { }, |
848 | }; | 846 | }; |
849 | MODULE_DEVICE_TABLE(acpi, amd_gpio_acpi_match); | 847 | MODULE_DEVICE_TABLE(acpi, amd_gpio_acpi_match); |
diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c index e844fdc6d3a8..4e9fe7854e8a 100644 --- a/drivers/pinctrl/pinctrl-as3722.c +++ b/drivers/pinctrl/pinctrl-as3722.c | |||
@@ -201,7 +201,7 @@ static const struct pinctrl_ops as3722_pinctrl_ops = { | |||
201 | .get_group_name = as3722_pinctrl_get_group_name, | 201 | .get_group_name = as3722_pinctrl_get_group_name, |
202 | .get_group_pins = as3722_pinctrl_get_group_pins, | 202 | .get_group_pins = as3722_pinctrl_get_group_pins, |
203 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 203 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
204 | .dt_free_map = pinctrl_utils_dt_free_map, | 204 | .dt_free_map = pinctrl_utils_free_map, |
205 | }; | 205 | }; |
206 | 206 | ||
207 | static int as3722_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) | 207 | static int as3722_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) |
@@ -569,8 +569,8 @@ static int as3722_pinctrl_probe(struct platform_device *pdev) | |||
569 | as3722_pinctrl_desc.name = dev_name(&pdev->dev); | 569 | as3722_pinctrl_desc.name = dev_name(&pdev->dev); |
570 | as3722_pinctrl_desc.pins = as3722_pins_desc; | 570 | as3722_pinctrl_desc.pins = as3722_pins_desc; |
571 | as3722_pinctrl_desc.npins = ARRAY_SIZE(as3722_pins_desc); | 571 | as3722_pinctrl_desc.npins = ARRAY_SIZE(as3722_pins_desc); |
572 | as_pci->pctl = pinctrl_register(&as3722_pinctrl_desc, | 572 | as_pci->pctl = devm_pinctrl_register(&pdev->dev, &as3722_pinctrl_desc, |
573 | &pdev->dev, as_pci); | 573 | as_pci); |
574 | if (IS_ERR(as_pci->pctl)) { | 574 | if (IS_ERR(as_pci->pctl)) { |
575 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 575 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
576 | return PTR_ERR(as_pci->pctl); | 576 | return PTR_ERR(as_pci->pctl); |
@@ -582,7 +582,7 @@ static int as3722_pinctrl_probe(struct platform_device *pdev) | |||
582 | ret = gpiochip_add_data(&as_pci->gpio_chip, as_pci); | 582 | ret = gpiochip_add_data(&as_pci->gpio_chip, as_pci); |
583 | if (ret < 0) { | 583 | if (ret < 0) { |
584 | dev_err(&pdev->dev, "Couldn't register gpiochip, %d\n", ret); | 584 | dev_err(&pdev->dev, "Couldn't register gpiochip, %d\n", ret); |
585 | goto fail_chip_add; | 585 | return ret; |
586 | } | 586 | } |
587 | 587 | ||
588 | ret = gpiochip_add_pin_range(&as_pci->gpio_chip, dev_name(&pdev->dev), | 588 | ret = gpiochip_add_pin_range(&as_pci->gpio_chip, dev_name(&pdev->dev), |
@@ -596,8 +596,6 @@ static int as3722_pinctrl_probe(struct platform_device *pdev) | |||
596 | 596 | ||
597 | fail_range_add: | 597 | fail_range_add: |
598 | gpiochip_remove(&as_pci->gpio_chip); | 598 | gpiochip_remove(&as_pci->gpio_chip); |
599 | fail_chip_add: | ||
600 | pinctrl_unregister(as_pci->pctl); | ||
601 | return ret; | 599 | return ret; |
602 | } | 600 | } |
603 | 601 | ||
@@ -606,7 +604,6 @@ static int as3722_pinctrl_remove(struct platform_device *pdev) | |||
606 | struct as3722_pctrl_info *as_pci = platform_get_drvdata(pdev); | 604 | struct as3722_pctrl_info *as_pci = platform_get_drvdata(pdev); |
607 | 605 | ||
608 | gpiochip_remove(&as_pci->gpio_chip); | 606 | gpiochip_remove(&as_pci->gpio_chip); |
609 | pinctrl_unregister(as_pci->pctl); | ||
610 | return 0; | 607 | return 0; |
611 | } | 608 | } |
612 | 609 | ||
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 2c447130b954..a025b40d246b 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c | |||
@@ -579,7 +579,7 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
579 | } | 579 | } |
580 | 580 | ||
581 | if (ret < 0) { | 581 | if (ret < 0) { |
582 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 582 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
583 | dev_err(pctldev->dev, "can't create maps for node %s\n", | 583 | dev_err(pctldev->dev, "can't create maps for node %s\n", |
584 | np_config->full_name); | 584 | np_config->full_name); |
585 | } | 585 | } |
@@ -592,7 +592,7 @@ static const struct pinctrl_ops atmel_pctlops = { | |||
592 | .get_group_name = atmel_pctl_get_group_name, | 592 | .get_group_name = atmel_pctl_get_group_name, |
593 | .get_group_pins = atmel_pctl_get_group_pins, | 593 | .get_group_pins = atmel_pctl_get_group_pins, |
594 | .dt_node_to_map = atmel_pctl_dt_node_to_map, | 594 | .dt_node_to_map = atmel_pctl_dt_node_to_map, |
595 | .dt_free_map = pinctrl_utils_dt_free_map, | 595 | .dt_free_map = pinctrl_utils_free_map, |
596 | }; | 596 | }; |
597 | 597 | ||
598 | static int atmel_pmx_get_functions_count(struct pinctrl_dev *pctldev) | 598 | static int atmel_pmx_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -1036,18 +1036,19 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) | |||
1036 | goto clk_prepare_enable_error; | 1036 | goto clk_prepare_enable_error; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | atmel_pioctrl->pinctrl_dev = pinctrl_register(&atmel_pinctrl_desc, | 1039 | atmel_pioctrl->pinctrl_dev = devm_pinctrl_register(&pdev->dev, |
1040 | &pdev->dev, | 1040 | &atmel_pinctrl_desc, |
1041 | atmel_pioctrl); | 1041 | atmel_pioctrl); |
1042 | if (!atmel_pioctrl->pinctrl_dev) { | 1042 | if (IS_ERR(atmel_pioctrl->pinctrl_dev)) { |
1043 | ret = PTR_ERR(atmel_pioctrl->pinctrl_dev); | ||
1043 | dev_err(dev, "pinctrl registration failed\n"); | 1044 | dev_err(dev, "pinctrl registration failed\n"); |
1044 | goto pinctrl_register_error; | 1045 | goto clk_unprep; |
1045 | } | 1046 | } |
1046 | 1047 | ||
1047 | ret = gpiochip_add_data(atmel_pioctrl->gpio_chip, atmel_pioctrl); | 1048 | ret = gpiochip_add_data(atmel_pioctrl->gpio_chip, atmel_pioctrl); |
1048 | if (ret) { | 1049 | if (ret) { |
1049 | dev_err(dev, "failed to add gpiochip\n"); | 1050 | dev_err(dev, "failed to add gpiochip\n"); |
1050 | goto gpiochip_add_error; | 1051 | goto clk_unprep; |
1051 | } | 1052 | } |
1052 | 1053 | ||
1053 | ret = gpiochip_add_pin_range(atmel_pioctrl->gpio_chip, dev_name(dev), | 1054 | ret = gpiochip_add_pin_range(atmel_pioctrl->gpio_chip, dev_name(dev), |
@@ -1061,15 +1062,15 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) | |||
1061 | 1062 | ||
1062 | return 0; | 1063 | return 0; |
1063 | 1064 | ||
1064 | clk_prepare_enable_error: | ||
1065 | irq_domain_remove(atmel_pioctrl->irq_domain); | ||
1066 | pinctrl_register_error: | ||
1067 | clk_disable_unprepare(atmel_pioctrl->clk); | ||
1068 | gpiochip_add_error: | ||
1069 | pinctrl_unregister(atmel_pioctrl->pinctrl_dev); | ||
1070 | gpiochip_add_pin_range_error: | 1065 | gpiochip_add_pin_range_error: |
1071 | gpiochip_remove(atmel_pioctrl->gpio_chip); | 1066 | gpiochip_remove(atmel_pioctrl->gpio_chip); |
1072 | 1067 | ||
1068 | clk_unprep: | ||
1069 | clk_disable_unprepare(atmel_pioctrl->clk); | ||
1070 | |||
1071 | clk_prepare_enable_error: | ||
1072 | irq_domain_remove(atmel_pioctrl->irq_domain); | ||
1073 | |||
1073 | return ret; | 1074 | return ret; |
1074 | } | 1075 | } |
1075 | 1076 | ||
@@ -1079,7 +1080,6 @@ int atmel_pinctrl_remove(struct platform_device *pdev) | |||
1079 | 1080 | ||
1080 | irq_domain_remove(atmel_pioctrl->irq_domain); | 1081 | irq_domain_remove(atmel_pioctrl->irq_domain); |
1081 | clk_disable_unprepare(atmel_pioctrl->clk); | 1082 | clk_disable_unprepare(atmel_pioctrl->clk); |
1082 | pinctrl_unregister(atmel_pioctrl->pinctrl_dev); | ||
1083 | gpiochip_remove(atmel_pioctrl->gpio_chip); | 1083 | gpiochip_remove(atmel_pioctrl->gpio_chip); |
1084 | 1084 | ||
1085 | return 0; | 1085 | return 0; |
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 523b6b794d1f..b7c0d6f7c046 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c | |||
@@ -1252,7 +1252,8 @@ static int at91_pinctrl_probe(struct platform_device *pdev) | |||
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | platform_set_drvdata(pdev, info); | 1254 | platform_set_drvdata(pdev, info); |
1255 | info->pctl = pinctrl_register(&at91_pinctrl_desc, &pdev->dev, info); | 1255 | info->pctl = devm_pinctrl_register(&pdev->dev, &at91_pinctrl_desc, |
1256 | info); | ||
1256 | 1257 | ||
1257 | if (IS_ERR(info->pctl)) { | 1258 | if (IS_ERR(info->pctl)) { |
1258 | dev_err(&pdev->dev, "could not register AT91 pinctrl driver\n"); | 1259 | dev_err(&pdev->dev, "could not register AT91 pinctrl driver\n"); |
@@ -1269,15 +1270,6 @@ static int at91_pinctrl_probe(struct platform_device *pdev) | |||
1269 | return 0; | 1270 | return 0; |
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | static int at91_pinctrl_remove(struct platform_device *pdev) | ||
1273 | { | ||
1274 | struct at91_pinctrl *info = platform_get_drvdata(pdev); | ||
1275 | |||
1276 | pinctrl_unregister(info->pctl); | ||
1277 | |||
1278 | return 0; | ||
1279 | } | ||
1280 | |||
1281 | static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | 1273 | static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) |
1282 | { | 1274 | { |
1283 | struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); | 1275 | struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
@@ -1660,7 +1652,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, | |||
1660 | } | 1652 | } |
1661 | 1653 | ||
1662 | /* This structure is replicated for each GPIO block allocated at probe time */ | 1654 | /* This structure is replicated for each GPIO block allocated at probe time */ |
1663 | static struct gpio_chip at91_gpio_template = { | 1655 | static const struct gpio_chip at91_gpio_template = { |
1664 | .request = gpiochip_generic_request, | 1656 | .request = gpiochip_generic_request, |
1665 | .free = gpiochip_generic_free, | 1657 | .free = gpiochip_generic_free, |
1666 | .get_direction = at91_gpio_get_direction, | 1658 | .get_direction = at91_gpio_get_direction, |
@@ -1730,14 +1722,9 @@ static int at91_gpio_probe(struct platform_device *pdev) | |||
1730 | goto err; | 1722 | goto err; |
1731 | } | 1723 | } |
1732 | 1724 | ||
1733 | ret = clk_prepare(at91_chip->clock); | 1725 | ret = clk_prepare_enable(at91_chip->clock); |
1734 | if (ret) | ||
1735 | goto clk_prepare_err; | ||
1736 | |||
1737 | /* enable PIO controller's clock */ | ||
1738 | ret = clk_enable(at91_chip->clock); | ||
1739 | if (ret) { | 1726 | if (ret) { |
1740 | dev_err(&pdev->dev, "failed to enable clock, ignoring.\n"); | 1727 | dev_err(&pdev->dev, "failed to prepare and enable clock, ignoring.\n"); |
1741 | goto clk_enable_err; | 1728 | goto clk_enable_err; |
1742 | } | 1729 | } |
1743 | 1730 | ||
@@ -1797,10 +1784,8 @@ static int at91_gpio_probe(struct platform_device *pdev) | |||
1797 | irq_setup_err: | 1784 | irq_setup_err: |
1798 | gpiochip_remove(chip); | 1785 | gpiochip_remove(chip); |
1799 | gpiochip_add_err: | 1786 | gpiochip_add_err: |
1800 | clk_disable(at91_chip->clock); | ||
1801 | clk_enable_err: | 1787 | clk_enable_err: |
1802 | clk_unprepare(at91_chip->clock); | 1788 | clk_disable_unprepare(at91_chip->clock); |
1803 | clk_prepare_err: | ||
1804 | err: | 1789 | err: |
1805 | dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); | 1790 | dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); |
1806 | 1791 | ||
@@ -1821,7 +1806,6 @@ static struct platform_driver at91_pinctrl_driver = { | |||
1821 | .of_match_table = at91_pinctrl_of_match, | 1806 | .of_match_table = at91_pinctrl_of_match, |
1822 | }, | 1807 | }, |
1823 | .probe = at91_pinctrl_probe, | 1808 | .probe = at91_pinctrl_probe, |
1824 | .remove = at91_pinctrl_remove, | ||
1825 | }; | 1809 | }; |
1826 | 1810 | ||
1827 | static struct platform_driver * const drivers[] = { | 1811 | static struct platform_driver * const drivers[] = { |
diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index f1343d6ca823..30ee56427f56 100644 --- a/drivers/pinctrl/pinctrl-digicolor.c +++ b/drivers/pinctrl/pinctrl-digicolor.c | |||
@@ -84,7 +84,7 @@ static struct pinctrl_ops dc_pinctrl_ops = { | |||
84 | .get_group_name = dc_get_group_name, | 84 | .get_group_name = dc_get_group_name, |
85 | .get_group_pins = dc_get_group_pins, | 85 | .get_group_pins = dc_get_group_pins, |
86 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 86 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
87 | .dt_free_map = pinctrl_utils_dt_free_map, | 87 | .dt_free_map = pinctrl_utils_free_map, |
88 | }; | 88 | }; |
89 | 89 | ||
90 | static const char *const dc_functions[] = { | 90 | static const char *const dc_functions[] = { |
@@ -280,7 +280,7 @@ static int dc_pinctrl_probe(struct platform_device *pdev) | |||
280 | struct pinctrl_desc *pctl_desc; | 280 | struct pinctrl_desc *pctl_desc; |
281 | char *pin_names; | 281 | char *pin_names; |
282 | int name_len = strlen("GP_xx") + 1; | 282 | int name_len = strlen("GP_xx") + 1; |
283 | int i, j, ret; | 283 | int i, j; |
284 | 284 | ||
285 | pmap = devm_kzalloc(&pdev->dev, sizeof(*pmap), GFP_KERNEL); | 285 | pmap = devm_kzalloc(&pdev->dev, sizeof(*pmap), GFP_KERNEL); |
286 | if (!pmap) | 286 | if (!pmap) |
@@ -326,26 +326,19 @@ static int dc_pinctrl_probe(struct platform_device *pdev) | |||
326 | 326 | ||
327 | pmap->dev = &pdev->dev; | 327 | pmap->dev = &pdev->dev; |
328 | 328 | ||
329 | pmap->pctl = pinctrl_register(pctl_desc, &pdev->dev, pmap); | 329 | pmap->pctl = devm_pinctrl_register(&pdev->dev, pctl_desc, pmap); |
330 | if (IS_ERR(pmap->pctl)) { | 330 | if (IS_ERR(pmap->pctl)) { |
331 | dev_err(&pdev->dev, "pinctrl driver registration failed\n"); | 331 | dev_err(&pdev->dev, "pinctrl driver registration failed\n"); |
332 | return PTR_ERR(pmap->pctl); | 332 | return PTR_ERR(pmap->pctl); |
333 | } | 333 | } |
334 | 334 | ||
335 | ret = dc_gpiochip_add(pmap, pdev->dev.of_node); | 335 | return dc_gpiochip_add(pmap, pdev->dev.of_node); |
336 | if (ret < 0) { | ||
337 | pinctrl_unregister(pmap->pctl); | ||
338 | return ret; | ||
339 | } | ||
340 | |||
341 | return 0; | ||
342 | } | 336 | } |
343 | 337 | ||
344 | static int dc_pinctrl_remove(struct platform_device *pdev) | 338 | static int dc_pinctrl_remove(struct platform_device *pdev) |
345 | { | 339 | { |
346 | struct dc_pinmap *pmap = platform_get_drvdata(pdev); | 340 | struct dc_pinmap *pmap = platform_get_drvdata(pdev); |
347 | 341 | ||
348 | pinctrl_unregister(pmap->pctl); | ||
349 | gpiochip_remove(&pmap->chip); | 342 | gpiochip_remove(&pmap->chip); |
350 | 343 | ||
351 | return 0; | 344 | return 0; |
diff --git a/drivers/pinctrl/pinctrl-lantiq.c b/drivers/pinctrl/pinctrl-lantiq.c index fc38a8540544..a4d647424600 100644 --- a/drivers/pinctrl/pinctrl-lantiq.c +++ b/drivers/pinctrl/pinctrl-lantiq.c | |||
@@ -336,7 +336,7 @@ int ltq_pinctrl_register(struct platform_device *pdev, | |||
336 | desc->pmxops = <q_pmx_ops; | 336 | desc->pmxops = <q_pmx_ops; |
337 | info->dev = &pdev->dev; | 337 | info->dev = &pdev->dev; |
338 | 338 | ||
339 | info->pctrl = pinctrl_register(desc, &pdev->dev, info); | 339 | info->pctrl = devm_pinctrl_register(&pdev->dev, desc, info); |
340 | if (IS_ERR(info->pctrl)) { | 340 | if (IS_ERR(info->pctrl)) { |
341 | dev_err(&pdev->dev, "failed to register LTQ pinmux driver\n"); | 341 | dev_err(&pdev->dev, "failed to register LTQ pinmux driver\n"); |
342 | return PTR_ERR(info->pctrl); | 342 | return PTR_ERR(info->pctrl); |
diff --git a/drivers/pinctrl/pinctrl-lpc18xx.c b/drivers/pinctrl/pinctrl-lpc18xx.c index b1767f7e45d1..8a931c7ba2ff 100644 --- a/drivers/pinctrl/pinctrl-lpc18xx.c +++ b/drivers/pinctrl/pinctrl-lpc18xx.c | |||
@@ -1252,7 +1252,7 @@ static const struct pinctrl_ops lpc18xx_pctl_ops = { | |||
1252 | .get_group_name = lpc18xx_pctl_get_group_name, | 1252 | .get_group_name = lpc18xx_pctl_get_group_name, |
1253 | .get_group_pins = lpc18xx_pctl_get_group_pins, | 1253 | .get_group_pins = lpc18xx_pctl_get_group_pins, |
1254 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 1254 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
1255 | .dt_free_map = pinctrl_utils_dt_free_map, | 1255 | .dt_free_map = pinctrl_utils_free_map, |
1256 | }; | 1256 | }; |
1257 | 1257 | ||
1258 | static struct pinctrl_desc lpc18xx_scu_desc = { | 1258 | static struct pinctrl_desc lpc18xx_scu_desc = { |
@@ -1355,7 +1355,7 @@ static int lpc18xx_scu_probe(struct platform_device *pdev) | |||
1355 | 1355 | ||
1356 | platform_set_drvdata(pdev, scu); | 1356 | platform_set_drvdata(pdev, scu); |
1357 | 1357 | ||
1358 | scu->pctl = pinctrl_register(&lpc18xx_scu_desc, &pdev->dev, scu); | 1358 | scu->pctl = devm_pinctrl_register(&pdev->dev, &lpc18xx_scu_desc, scu); |
1359 | if (IS_ERR(scu->pctl)) { | 1359 | if (IS_ERR(scu->pctl)) { |
1360 | dev_err(&pdev->dev, "Could not register pinctrl driver\n"); | 1360 | dev_err(&pdev->dev, "Could not register pinctrl driver\n"); |
1361 | clk_disable_unprepare(scu->clk); | 1361 | clk_disable_unprepare(scu->clk); |
@@ -1369,7 +1369,6 @@ static int lpc18xx_scu_remove(struct platform_device *pdev) | |||
1369 | { | 1369 | { |
1370 | struct lpc18xx_scu_data *scu = platform_get_drvdata(pdev); | 1370 | struct lpc18xx_scu_data *scu = platform_get_drvdata(pdev); |
1371 | 1371 | ||
1372 | pinctrl_unregister(scu->pctl); | ||
1373 | clk_disable_unprepare(scu->clk); | 1372 | clk_disable_unprepare(scu->clk); |
1374 | 1373 | ||
1375 | return 0; | 1374 | return 0; |
diff --git a/drivers/pinctrl/pinctrl-palmas.c b/drivers/pinctrl/pinctrl-palmas.c index f7e168044baf..8edb3f8c72c8 100644 --- a/drivers/pinctrl/pinctrl-palmas.c +++ b/drivers/pinctrl/pinctrl-palmas.c | |||
@@ -656,7 +656,7 @@ static const struct pinctrl_ops palmas_pinctrl_ops = { | |||
656 | .get_group_name = palmas_pinctrl_get_group_name, | 656 | .get_group_name = palmas_pinctrl_get_group_name, |
657 | .get_group_pins = palmas_pinctrl_get_group_pins, | 657 | .get_group_pins = palmas_pinctrl_get_group_pins, |
658 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 658 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
659 | .dt_free_map = pinctrl_utils_dt_free_map, | 659 | .dt_free_map = pinctrl_utils_free_map, |
660 | }; | 660 | }; |
661 | 661 | ||
662 | static int palmas_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) | 662 | static int palmas_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) |
@@ -1043,7 +1043,8 @@ static int palmas_pinctrl_probe(struct platform_device *pdev) | |||
1043 | palmas_pinctrl_desc.name = dev_name(&pdev->dev); | 1043 | palmas_pinctrl_desc.name = dev_name(&pdev->dev); |
1044 | palmas_pinctrl_desc.pins = palmas_pins_desc; | 1044 | palmas_pinctrl_desc.pins = palmas_pins_desc; |
1045 | palmas_pinctrl_desc.npins = ARRAY_SIZE(palmas_pins_desc); | 1045 | palmas_pinctrl_desc.npins = ARRAY_SIZE(palmas_pins_desc); |
1046 | pci->pctl = pinctrl_register(&palmas_pinctrl_desc, &pdev->dev, pci); | 1046 | pci->pctl = devm_pinctrl_register(&pdev->dev, &palmas_pinctrl_desc, |
1047 | pci); | ||
1047 | if (IS_ERR(pci->pctl)) { | 1048 | if (IS_ERR(pci->pctl)) { |
1048 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 1049 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
1049 | return PTR_ERR(pci->pctl); | 1050 | return PTR_ERR(pci->pctl); |
@@ -1051,21 +1052,12 @@ static int palmas_pinctrl_probe(struct platform_device *pdev) | |||
1051 | return 0; | 1052 | return 0; |
1052 | } | 1053 | } |
1053 | 1054 | ||
1054 | static int palmas_pinctrl_remove(struct platform_device *pdev) | ||
1055 | { | ||
1056 | struct palmas_pctrl_chip_info *pci = platform_get_drvdata(pdev); | ||
1057 | |||
1058 | pinctrl_unregister(pci->pctl); | ||
1059 | return 0; | ||
1060 | } | ||
1061 | |||
1062 | static struct platform_driver palmas_pinctrl_driver = { | 1055 | static struct platform_driver palmas_pinctrl_driver = { |
1063 | .driver = { | 1056 | .driver = { |
1064 | .name = "palmas-pinctrl", | 1057 | .name = "palmas-pinctrl", |
1065 | .of_match_table = palmas_pinctrl_of_match, | 1058 | .of_match_table = palmas_pinctrl_of_match, |
1066 | }, | 1059 | }, |
1067 | .probe = palmas_pinctrl_probe, | 1060 | .probe = palmas_pinctrl_probe, |
1068 | .remove = palmas_pinctrl_remove, | ||
1069 | }; | 1061 | }; |
1070 | 1062 | ||
1071 | module_platform_driver(palmas_pinctrl_driver); | 1063 | module_platform_driver(palmas_pinctrl_driver); |
diff --git a/drivers/pinctrl/pinctrl-pic32.c b/drivers/pinctrl/pinctrl-pic32.c index 0b07d4bdab95..31ceb958b3fe 100644 --- a/drivers/pinctrl/pinctrl-pic32.c +++ b/drivers/pinctrl/pinctrl-pic32.c | |||
@@ -1743,7 +1743,7 @@ static const struct pinctrl_ops pic32_pinctrl_ops = { | |||
1743 | .get_group_name = pic32_pinctrl_get_group_name, | 1743 | .get_group_name = pic32_pinctrl_get_group_name, |
1744 | .get_group_pins = pic32_pinctrl_get_group_pins, | 1744 | .get_group_pins = pic32_pinctrl_get_group_pins, |
1745 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 1745 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
1746 | .dt_free_map = pinctrl_utils_dt_free_map, | 1746 | .dt_free_map = pinctrl_utils_free_map, |
1747 | }; | 1747 | }; |
1748 | 1748 | ||
1749 | static int pic32_pinmux_get_functions_count(struct pinctrl_dev *pctldev) | 1749 | static int pic32_pinmux_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -2194,7 +2194,8 @@ static int pic32_pinctrl_probe(struct platform_device *pdev) | |||
2194 | pic32_pinctrl_desc.custom_params = pic32_mpp_bindings; | 2194 | pic32_pinctrl_desc.custom_params = pic32_mpp_bindings; |
2195 | pic32_pinctrl_desc.num_custom_params = ARRAY_SIZE(pic32_mpp_bindings); | 2195 | pic32_pinctrl_desc.num_custom_params = ARRAY_SIZE(pic32_mpp_bindings); |
2196 | 2196 | ||
2197 | pctl->pctldev = pinctrl_register(&pic32_pinctrl_desc, &pdev->dev, pctl); | 2197 | pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pic32_pinctrl_desc, |
2198 | pctl); | ||
2198 | if (IS_ERR(pctl->pctldev)) { | 2199 | if (IS_ERR(pctl->pctldev)) { |
2199 | dev_err(&pdev->dev, "Failed to register pinctrl device\n"); | 2200 | dev_err(&pdev->dev, "Failed to register pinctrl device\n"); |
2200 | return PTR_ERR(pctl->pctldev); | 2201 | return PTR_ERR(pctl->pctldev); |
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index 2673cd9d106e..c6d410ef8de0 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c | |||
@@ -913,7 +913,7 @@ static const struct pinctrl_ops pistachio_pinctrl_ops = { | |||
913 | .get_group_name = pistachio_pinctrl_get_group_name, | 913 | .get_group_name = pistachio_pinctrl_get_group_name, |
914 | .get_group_pins = pistachio_pinctrl_get_group_pins, | 914 | .get_group_pins = pistachio_pinctrl_get_group_pins, |
915 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, | 915 | .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, |
916 | .dt_free_map = pinctrl_utils_dt_free_map, | 916 | .dt_free_map = pinctrl_utils_free_map, |
917 | }; | 917 | }; |
918 | 918 | ||
919 | static int pistachio_pinmux_get_functions_count(struct pinctrl_dev *pctldev) | 919 | static int pistachio_pinmux_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -1457,8 +1457,8 @@ static int pistachio_pinctrl_probe(struct platform_device *pdev) | |||
1457 | pistachio_pinctrl_desc.pins = pctl->pins; | 1457 | pistachio_pinctrl_desc.pins = pctl->pins; |
1458 | pistachio_pinctrl_desc.npins = pctl->npins; | 1458 | pistachio_pinctrl_desc.npins = pctl->npins; |
1459 | 1459 | ||
1460 | pctl->pctldev = pinctrl_register(&pistachio_pinctrl_desc, &pdev->dev, | 1460 | pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pistachio_pinctrl_desc, |
1461 | pctl); | 1461 | pctl); |
1462 | if (IS_ERR(pctl->pctldev)) { | 1462 | if (IS_ERR(pctl->pctldev)) { |
1463 | dev_err(&pdev->dev, "Failed to register pinctrl device\n"); | 1463 | dev_err(&pdev->dev, "Failed to register pinctrl device\n"); |
1464 | return PTR_ERR(pctl->pctldev); | 1464 | return PTR_ERR(pctl->pctldev); |
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index bf032b9b4c57..a91026e8cd7c 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
@@ -99,6 +99,15 @@ enum rockchip_pin_drv_type { | |||
99 | }; | 99 | }; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * enum type index corresponding to rockchip_pull_list arrays index. | ||
103 | */ | ||
104 | enum rockchip_pin_pull_type { | ||
105 | PULL_TYPE_IO_DEFAULT = 0, | ||
106 | PULL_TYPE_IO_1V8_ONLY, | ||
107 | PULL_TYPE_MAX | ||
108 | }; | ||
109 | |||
110 | /** | ||
102 | * @drv_type: drive strength variant using rockchip_perpin_drv_type | 111 | * @drv_type: drive strength variant using rockchip_perpin_drv_type |
103 | * @offset: if initialized to -1 it will be autocalculated, by specifying | 112 | * @offset: if initialized to -1 it will be autocalculated, by specifying |
104 | * an initial offset value the relevant source offset can be reset | 113 | * an initial offset value the relevant source offset can be reset |
@@ -123,6 +132,7 @@ struct rockchip_drv { | |||
123 | * @bank_num: number of the bank, to account for holes | 132 | * @bank_num: number of the bank, to account for holes |
124 | * @iomux: array describing the 4 iomux sources of the bank | 133 | * @iomux: array describing the 4 iomux sources of the bank |
125 | * @drv: array describing the 4 drive strength sources of the bank | 134 | * @drv: array describing the 4 drive strength sources of the bank |
135 | * @pull_type: array describing the 4 pull type sources of the bank | ||
126 | * @valid: are all necessary informations present | 136 | * @valid: are all necessary informations present |
127 | * @of_node: dt node of this bank | 137 | * @of_node: dt node of this bank |
128 | * @drvdata: common pinctrl basedata | 138 | * @drvdata: common pinctrl basedata |
@@ -143,6 +153,7 @@ struct rockchip_pin_bank { | |||
143 | u8 bank_num; | 153 | u8 bank_num; |
144 | struct rockchip_iomux iomux[4]; | 154 | struct rockchip_iomux iomux[4]; |
145 | struct rockchip_drv drv[4]; | 155 | struct rockchip_drv drv[4]; |
156 | enum rockchip_pin_pull_type pull_type[4]; | ||
146 | bool valid; | 157 | bool valid; |
147 | struct device_node *of_node; | 158 | struct device_node *of_node; |
148 | struct rockchip_pinctrl *drvdata; | 159 | struct rockchip_pinctrl *drvdata; |
@@ -198,6 +209,31 @@ struct rockchip_pin_bank { | |||
198 | }, \ | 209 | }, \ |
199 | } | 210 | } |
200 | 211 | ||
212 | #define PIN_BANK_DRV_FLAGS_PULL_FLAGS(id, pins, label, drv0, drv1, \ | ||
213 | drv2, drv3, pull0, pull1, \ | ||
214 | pull2, pull3) \ | ||
215 | { \ | ||
216 | .bank_num = id, \ | ||
217 | .nr_pins = pins, \ | ||
218 | .name = label, \ | ||
219 | .iomux = { \ | ||
220 | { .offset = -1 }, \ | ||
221 | { .offset = -1 }, \ | ||
222 | { .offset = -1 }, \ | ||
223 | { .offset = -1 }, \ | ||
224 | }, \ | ||
225 | .drv = { \ | ||
226 | { .drv_type = drv0, .offset = -1 }, \ | ||
227 | { .drv_type = drv1, .offset = -1 }, \ | ||
228 | { .drv_type = drv2, .offset = -1 }, \ | ||
229 | { .drv_type = drv3, .offset = -1 }, \ | ||
230 | }, \ | ||
231 | .pull_type[0] = pull0, \ | ||
232 | .pull_type[1] = pull1, \ | ||
233 | .pull_type[2] = pull2, \ | ||
234 | .pull_type[3] = pull3, \ | ||
235 | } | ||
236 | |||
201 | #define PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(id, pins, label, iom0, iom1, \ | 237 | #define PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(id, pins, label, iom0, iom1, \ |
202 | iom2, iom3, drv0, drv1, drv2, \ | 238 | iom2, iom3, drv0, drv1, drv2, \ |
203 | drv3, offset0, offset1, \ | 239 | drv3, offset0, offset1, \ |
@@ -220,6 +256,34 @@ struct rockchip_pin_bank { | |||
220 | }, \ | 256 | }, \ |
221 | } | 257 | } |
222 | 258 | ||
259 | #define PIN_BANK_IOMUX_FLAGS_DRV_FLAGS_OFFSET_PULL_FLAGS(id, pins, \ | ||
260 | label, iom0, iom1, iom2, \ | ||
261 | iom3, drv0, drv1, drv2, \ | ||
262 | drv3, offset0, offset1, \ | ||
263 | offset2, offset3, pull0, \ | ||
264 | pull1, pull2, pull3) \ | ||
265 | { \ | ||
266 | .bank_num = id, \ | ||
267 | .nr_pins = pins, \ | ||
268 | .name = label, \ | ||
269 | .iomux = { \ | ||
270 | { .type = iom0, .offset = -1 }, \ | ||
271 | { .type = iom1, .offset = -1 }, \ | ||
272 | { .type = iom2, .offset = -1 }, \ | ||
273 | { .type = iom3, .offset = -1 }, \ | ||
274 | }, \ | ||
275 | .drv = { \ | ||
276 | { .drv_type = drv0, .offset = offset0 }, \ | ||
277 | { .drv_type = drv1, .offset = offset1 }, \ | ||
278 | { .drv_type = drv2, .offset = offset2 }, \ | ||
279 | { .drv_type = drv3, .offset = offset3 }, \ | ||
280 | }, \ | ||
281 | .pull_type[0] = pull0, \ | ||
282 | .pull_type[1] = pull1, \ | ||
283 | .pull_type[2] = pull2, \ | ||
284 | .pull_type[3] = pull3, \ | ||
285 | } | ||
286 | |||
223 | /** | 287 | /** |
224 | */ | 288 | */ |
225 | struct rockchip_pin_ctrl { | 289 | struct rockchip_pin_ctrl { |
@@ -1020,12 +1084,27 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank, | |||
1020 | return ret; | 1084 | return ret; |
1021 | } | 1085 | } |
1022 | 1086 | ||
1087 | static int rockchip_pull_list[PULL_TYPE_MAX][4] = { | ||
1088 | { | ||
1089 | PIN_CONFIG_BIAS_DISABLE, | ||
1090 | PIN_CONFIG_BIAS_PULL_UP, | ||
1091 | PIN_CONFIG_BIAS_PULL_DOWN, | ||
1092 | PIN_CONFIG_BIAS_BUS_HOLD | ||
1093 | }, | ||
1094 | { | ||
1095 | PIN_CONFIG_BIAS_DISABLE, | ||
1096 | PIN_CONFIG_BIAS_PULL_DOWN, | ||
1097 | PIN_CONFIG_BIAS_DISABLE, | ||
1098 | PIN_CONFIG_BIAS_PULL_UP | ||
1099 | }, | ||
1100 | }; | ||
1101 | |||
1023 | static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) | 1102 | static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) |
1024 | { | 1103 | { |
1025 | struct rockchip_pinctrl *info = bank->drvdata; | 1104 | struct rockchip_pinctrl *info = bank->drvdata; |
1026 | struct rockchip_pin_ctrl *ctrl = info->ctrl; | 1105 | struct rockchip_pin_ctrl *ctrl = info->ctrl; |
1027 | struct regmap *regmap; | 1106 | struct regmap *regmap; |
1028 | int reg, ret; | 1107 | int reg, ret, pull_type; |
1029 | u8 bit; | 1108 | u8 bit; |
1030 | u32 data; | 1109 | u32 data; |
1031 | 1110 | ||
@@ -1048,22 +1127,11 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) | |||
1048 | case RK3288: | 1127 | case RK3288: |
1049 | case RK3368: | 1128 | case RK3368: |
1050 | case RK3399: | 1129 | case RK3399: |
1130 | pull_type = bank->pull_type[pin_num / 8]; | ||
1051 | data >>= bit; | 1131 | data >>= bit; |
1052 | data &= (1 << RK3188_PULL_BITS_PER_PIN) - 1; | 1132 | data &= (1 << RK3188_PULL_BITS_PER_PIN) - 1; |
1053 | 1133 | ||
1054 | switch (data) { | 1134 | return rockchip_pull_list[pull_type][data]; |
1055 | case 0: | ||
1056 | return PIN_CONFIG_BIAS_DISABLE; | ||
1057 | case 1: | ||
1058 | return PIN_CONFIG_BIAS_PULL_UP; | ||
1059 | case 2: | ||
1060 | return PIN_CONFIG_BIAS_PULL_DOWN; | ||
1061 | case 3: | ||
1062 | return PIN_CONFIG_BIAS_BUS_HOLD; | ||
1063 | } | ||
1064 | |||
1065 | dev_err(info->dev, "unknown pull setting\n"); | ||
1066 | return -EIO; | ||
1067 | default: | 1135 | default: |
1068 | dev_err(info->dev, "unsupported pinctrl type\n"); | 1136 | dev_err(info->dev, "unsupported pinctrl type\n"); |
1069 | return -EINVAL; | 1137 | return -EINVAL; |
@@ -1076,7 +1144,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, | |||
1076 | struct rockchip_pinctrl *info = bank->drvdata; | 1144 | struct rockchip_pinctrl *info = bank->drvdata; |
1077 | struct rockchip_pin_ctrl *ctrl = info->ctrl; | 1145 | struct rockchip_pin_ctrl *ctrl = info->ctrl; |
1078 | struct regmap *regmap; | 1146 | struct regmap *regmap; |
1079 | int reg, ret; | 1147 | int reg, ret, i, pull_type; |
1080 | unsigned long flags; | 1148 | unsigned long flags; |
1081 | u8 bit; | 1149 | u8 bit; |
1082 | u32 data, rmask; | 1150 | u32 data, rmask; |
@@ -1105,30 +1173,28 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, | |||
1105 | case RK3288: | 1173 | case RK3288: |
1106 | case RK3368: | 1174 | case RK3368: |
1107 | case RK3399: | 1175 | case RK3399: |
1176 | pull_type = bank->pull_type[pin_num / 8]; | ||
1177 | ret = -EINVAL; | ||
1178 | for (i = 0; i < ARRAY_SIZE(rockchip_pull_list[pull_type]); | ||
1179 | i++) { | ||
1180 | if (rockchip_pull_list[pull_type][i] == pull) { | ||
1181 | ret = i; | ||
1182 | break; | ||
1183 | } | ||
1184 | } | ||
1185 | |||
1186 | if (ret < 0) { | ||
1187 | dev_err(info->dev, "unsupported pull setting %d\n", | ||
1188 | pull); | ||
1189 | return ret; | ||
1190 | } | ||
1191 | |||
1108 | spin_lock_irqsave(&bank->slock, flags); | 1192 | spin_lock_irqsave(&bank->slock, flags); |
1109 | 1193 | ||
1110 | /* enable the write to the equivalent lower bits */ | 1194 | /* enable the write to the equivalent lower bits */ |
1111 | data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16); | 1195 | data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16); |
1112 | rmask = data | (data >> 16); | 1196 | rmask = data | (data >> 16); |
1113 | 1197 | data |= (ret << bit); | |
1114 | switch (pull) { | ||
1115 | case PIN_CONFIG_BIAS_DISABLE: | ||
1116 | break; | ||
1117 | case PIN_CONFIG_BIAS_PULL_UP: | ||
1118 | data |= (1 << bit); | ||
1119 | break; | ||
1120 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
1121 | data |= (2 << bit); | ||
1122 | break; | ||
1123 | case PIN_CONFIG_BIAS_BUS_HOLD: | ||
1124 | data |= (3 << bit); | ||
1125 | break; | ||
1126 | default: | ||
1127 | spin_unlock_irqrestore(&bank->slock, flags); | ||
1128 | dev_err(info->dev, "unsupported pull setting %d\n", | ||
1129 | pull); | ||
1130 | return -EINVAL; | ||
1131 | } | ||
1132 | 1198 | ||
1133 | ret = regmap_update_bits(regmap, reg, rmask, data); | 1199 | ret = regmap_update_bits(regmap, reg, rmask, data); |
1134 | 1200 | ||
@@ -1208,6 +1274,16 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, | |||
1208 | return 0; | 1274 | return 0; |
1209 | } | 1275 | } |
1210 | 1276 | ||
1277 | static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | ||
1278 | { | ||
1279 | struct rockchip_pin_bank *bank = gpiochip_get_data(chip); | ||
1280 | u32 data; | ||
1281 | |||
1282 | data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); | ||
1283 | |||
1284 | return !(data & BIT(offset)); | ||
1285 | } | ||
1286 | |||
1211 | /* | 1287 | /* |
1212 | * The calls to gpio_direction_output() and gpio_direction_input() | 1288 | * The calls to gpio_direction_output() and gpio_direction_input() |
1213 | * leads to this function call (via the pinctrl_gpio_direction_{input|output}() | 1289 | * leads to this function call (via the pinctrl_gpio_direction_{input|output}() |
@@ -1636,7 +1712,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, | |||
1636 | if (ret) | 1712 | if (ret) |
1637 | return ret; | 1713 | return ret; |
1638 | 1714 | ||
1639 | info->pctl_dev = pinctrl_register(ctrldesc, &pdev->dev, info); | 1715 | info->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, info); |
1640 | if (IS_ERR(info->pctl_dev)) { | 1716 | if (IS_ERR(info->pctl_dev)) { |
1641 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); | 1717 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); |
1642 | return PTR_ERR(info->pctl_dev); | 1718 | return PTR_ERR(info->pctl_dev); |
@@ -1741,6 +1817,7 @@ static const struct gpio_chip rockchip_gpiolib_chip = { | |||
1741 | .free = gpiochip_generic_free, | 1817 | .free = gpiochip_generic_free, |
1742 | .set = rockchip_gpio_set, | 1818 | .set = rockchip_gpio_set, |
1743 | .get = rockchip_gpio_get, | 1819 | .get = rockchip_gpio_get, |
1820 | .get_direction = rockchip_gpio_get_direction, | ||
1744 | .direction_input = rockchip_gpio_direction_input, | 1821 | .direction_input = rockchip_gpio_direction_input, |
1745 | .direction_output = rockchip_gpio_direction_output, | 1822 | .direction_output = rockchip_gpio_direction_output, |
1746 | .to_irq = rockchip_gpio_to_irq, | 1823 | .to_irq = rockchip_gpio_to_irq, |
@@ -2541,19 +2618,24 @@ static struct rockchip_pin_ctrl rk3368_pin_ctrl = { | |||
2541 | }; | 2618 | }; |
2542 | 2619 | ||
2543 | static struct rockchip_pin_bank rk3399_pin_banks[] = { | 2620 | static struct rockchip_pin_bank rk3399_pin_banks[] = { |
2544 | PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(0, 32, "gpio0", IOMUX_SOURCE_PMU, | 2621 | PIN_BANK_IOMUX_FLAGS_DRV_FLAGS_OFFSET_PULL_FLAGS(0, 32, "gpio0", |
2545 | IOMUX_SOURCE_PMU, | 2622 | IOMUX_SOURCE_PMU, |
2546 | IOMUX_SOURCE_PMU, | 2623 | IOMUX_SOURCE_PMU, |
2547 | IOMUX_SOURCE_PMU, | 2624 | IOMUX_SOURCE_PMU, |
2548 | DRV_TYPE_IO_1V8_ONLY, | 2625 | IOMUX_SOURCE_PMU, |
2549 | DRV_TYPE_IO_1V8_ONLY, | 2626 | DRV_TYPE_IO_1V8_ONLY, |
2550 | DRV_TYPE_IO_DEFAULT, | 2627 | DRV_TYPE_IO_1V8_ONLY, |
2551 | DRV_TYPE_IO_DEFAULT, | 2628 | DRV_TYPE_IO_DEFAULT, |
2552 | 0x0, | 2629 | DRV_TYPE_IO_DEFAULT, |
2553 | 0x8, | 2630 | 0x0, |
2554 | -1, | 2631 | 0x8, |
2555 | -1 | 2632 | -1, |
2556 | ), | 2633 | -1, |
2634 | PULL_TYPE_IO_1V8_ONLY, | ||
2635 | PULL_TYPE_IO_1V8_ONLY, | ||
2636 | PULL_TYPE_IO_DEFAULT, | ||
2637 | PULL_TYPE_IO_DEFAULT | ||
2638 | ), | ||
2557 | PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(1, 32, "gpio1", IOMUX_SOURCE_PMU, | 2639 | PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(1, 32, "gpio1", IOMUX_SOURCE_PMU, |
2558 | IOMUX_SOURCE_PMU, | 2640 | IOMUX_SOURCE_PMU, |
2559 | IOMUX_SOURCE_PMU, | 2641 | IOMUX_SOURCE_PMU, |
@@ -2567,11 +2649,15 @@ static struct rockchip_pin_bank rk3399_pin_banks[] = { | |||
2567 | 0x30, | 2649 | 0x30, |
2568 | 0x38 | 2650 | 0x38 |
2569 | ), | 2651 | ), |
2570 | PIN_BANK_DRV_FLAGS(2, 32, "gpio2", DRV_TYPE_IO_1V8_OR_3V0, | 2652 | PIN_BANK_DRV_FLAGS_PULL_FLAGS(2, 32, "gpio2", DRV_TYPE_IO_1V8_OR_3V0, |
2571 | DRV_TYPE_IO_1V8_OR_3V0, | 2653 | DRV_TYPE_IO_1V8_OR_3V0, |
2572 | DRV_TYPE_IO_1V8_ONLY, | 2654 | DRV_TYPE_IO_1V8_ONLY, |
2573 | DRV_TYPE_IO_1V8_ONLY | 2655 | DRV_TYPE_IO_1V8_ONLY, |
2574 | ), | 2656 | PULL_TYPE_IO_DEFAULT, |
2657 | PULL_TYPE_IO_DEFAULT, | ||
2658 | PULL_TYPE_IO_1V8_ONLY, | ||
2659 | PULL_TYPE_IO_1V8_ONLY | ||
2660 | ), | ||
2575 | PIN_BANK_DRV_FLAGS(3, 32, "gpio3", DRV_TYPE_IO_3V3_ONLY, | 2661 | PIN_BANK_DRV_FLAGS(3, 32, "gpio3", DRV_TYPE_IO_3V3_ONLY, |
2576 | DRV_TYPE_IO_3V3_ONLY, | 2662 | DRV_TYPE_IO_3V3_ONLY, |
2577 | DRV_TYPE_IO_3V3_ONLY, | 2663 | DRV_TYPE_IO_3V3_ONLY, |
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index cab66c64149f..d0ba968af5bb 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c | |||
@@ -1724,7 +1724,7 @@ static int st_pctl_probe(struct platform_device *pdev) | |||
1724 | pctl_desc->confops = &st_confops; | 1724 | pctl_desc->confops = &st_confops; |
1725 | pctl_desc->name = dev_name(&pdev->dev); | 1725 | pctl_desc->name = dev_name(&pdev->dev); |
1726 | 1726 | ||
1727 | info->pctl = pinctrl_register(pctl_desc, &pdev->dev, info); | 1727 | info->pctl = devm_pinctrl_register(&pdev->dev, pctl_desc, info); |
1728 | if (IS_ERR(info->pctl)) { | 1728 | if (IS_ERR(info->pctl)) { |
1729 | dev_err(&pdev->dev, "Failed pinctrl registration\n"); | 1729 | dev_err(&pdev->dev, "Failed pinctrl registration\n"); |
1730 | return PTR_ERR(info->pctl); | 1730 | return PTR_ERR(info->pctl); |
diff --git a/drivers/pinctrl/pinctrl-tb10x.c b/drivers/pinctrl/pinctrl-tb10x.c index 6546b9bb2e06..edfba506e958 100644 --- a/drivers/pinctrl/pinctrl-tb10x.c +++ b/drivers/pinctrl/pinctrl-tb10x.c | |||
@@ -582,7 +582,7 @@ static struct pinctrl_ops tb10x_pinctrl_ops = { | |||
582 | .get_group_name = tb10x_get_group_name, | 582 | .get_group_name = tb10x_get_group_name, |
583 | .get_group_pins = tb10x_get_group_pins, | 583 | .get_group_pins = tb10x_get_group_pins, |
584 | .dt_node_to_map = tb10x_dt_node_to_map, | 584 | .dt_node_to_map = tb10x_dt_node_to_map, |
585 | .dt_free_map = pinctrl_utils_dt_free_map, | 585 | .dt_free_map = pinctrl_utils_free_map, |
586 | }; | 586 | }; |
587 | 587 | ||
588 | static int tb10x_get_functions_count(struct pinctrl_dev *pctl) | 588 | static int tb10x_get_functions_count(struct pinctrl_dev *pctl) |
@@ -806,7 +806,7 @@ static int tb10x_pinctrl_probe(struct platform_device *pdev) | |||
806 | } | 806 | } |
807 | } | 807 | } |
808 | 808 | ||
809 | state->pctl = pinctrl_register(&tb10x_pindesc, dev, state); | 809 | state->pctl = devm_pinctrl_register(dev, &tb10x_pindesc, state); |
810 | if (IS_ERR(state->pctl)) { | 810 | if (IS_ERR(state->pctl)) { |
811 | dev_err(dev, "could not register TB10x pin driver\n"); | 811 | dev_err(dev, "could not register TB10x pin driver\n"); |
812 | ret = PTR_ERR(state->pctl); | 812 | ret = PTR_ERR(state->pctl); |
@@ -824,7 +824,6 @@ static int tb10x_pinctrl_remove(struct platform_device *pdev) | |||
824 | { | 824 | { |
825 | struct tb10x_pinctrl *state = platform_get_drvdata(pdev); | 825 | struct tb10x_pinctrl *state = platform_get_drvdata(pdev); |
826 | 826 | ||
827 | pinctrl_unregister(state->pctl); | ||
828 | mutex_destroy(&state->mutex); | 827 | mutex_destroy(&state->mutex); |
829 | 828 | ||
830 | return 0; | 829 | return 0; |
diff --git a/drivers/pinctrl/pinctrl-tz1090-pdc.c b/drivers/pinctrl/pinctrl-tz1090-pdc.c index b89ad3c0c731..e70e36283b3b 100644 --- a/drivers/pinctrl/pinctrl-tz1090-pdc.c +++ b/drivers/pinctrl/pinctrl-tz1090-pdc.c | |||
@@ -947,7 +947,8 @@ static int tz1090_pdc_pinctrl_probe(struct platform_device *pdev) | |||
947 | if (IS_ERR(pmx->regs)) | 947 | if (IS_ERR(pmx->regs)) |
948 | return PTR_ERR(pmx->regs); | 948 | return PTR_ERR(pmx->regs); |
949 | 949 | ||
950 | pmx->pctl = pinctrl_register(&tz1090_pdc_pinctrl_desc, &pdev->dev, pmx); | 950 | pmx->pctl = devm_pinctrl_register(&pdev->dev, &tz1090_pdc_pinctrl_desc, |
951 | pmx); | ||
951 | if (IS_ERR(pmx->pctl)) { | 952 | if (IS_ERR(pmx->pctl)) { |
952 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 953 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
953 | return PTR_ERR(pmx->pctl); | 954 | return PTR_ERR(pmx->pctl); |
@@ -960,15 +961,6 @@ static int tz1090_pdc_pinctrl_probe(struct platform_device *pdev) | |||
960 | return 0; | 961 | return 0; |
961 | } | 962 | } |
962 | 963 | ||
963 | static int tz1090_pdc_pinctrl_remove(struct platform_device *pdev) | ||
964 | { | ||
965 | struct tz1090_pdc_pmx *pmx = platform_get_drvdata(pdev); | ||
966 | |||
967 | pinctrl_unregister(pmx->pctl); | ||
968 | |||
969 | return 0; | ||
970 | } | ||
971 | |||
972 | static const struct of_device_id tz1090_pdc_pinctrl_of_match[] = { | 964 | static const struct of_device_id tz1090_pdc_pinctrl_of_match[] = { |
973 | { .compatible = "img,tz1090-pdc-pinctrl", }, | 965 | { .compatible = "img,tz1090-pdc-pinctrl", }, |
974 | { }, | 966 | { }, |
@@ -980,7 +972,6 @@ static struct platform_driver tz1090_pdc_pinctrl_driver = { | |||
980 | .of_match_table = tz1090_pdc_pinctrl_of_match, | 972 | .of_match_table = tz1090_pdc_pinctrl_of_match, |
981 | }, | 973 | }, |
982 | .probe = tz1090_pdc_pinctrl_probe, | 974 | .probe = tz1090_pdc_pinctrl_probe, |
983 | .remove = tz1090_pdc_pinctrl_remove, | ||
984 | }; | 975 | }; |
985 | 976 | ||
986 | static int __init tz1090_pdc_pinctrl_init(void) | 977 | static int __init tz1090_pdc_pinctrl_init(void) |
diff --git a/drivers/pinctrl/pinctrl-tz1090.c b/drivers/pinctrl/pinctrl-tz1090.c index 5425299d759d..04cbe530bf29 100644 --- a/drivers/pinctrl/pinctrl-tz1090.c +++ b/drivers/pinctrl/pinctrl-tz1090.c | |||
@@ -1962,7 +1962,8 @@ static int tz1090_pinctrl_probe(struct platform_device *pdev) | |||
1962 | if (IS_ERR(pmx->regs)) | 1962 | if (IS_ERR(pmx->regs)) |
1963 | return PTR_ERR(pmx->regs); | 1963 | return PTR_ERR(pmx->regs); |
1964 | 1964 | ||
1965 | pmx->pctl = pinctrl_register(&tz1090_pinctrl_desc, &pdev->dev, pmx); | 1965 | pmx->pctl = devm_pinctrl_register(&pdev->dev, &tz1090_pinctrl_desc, |
1966 | pmx); | ||
1966 | if (IS_ERR(pmx->pctl)) { | 1967 | if (IS_ERR(pmx->pctl)) { |
1967 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 1968 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
1968 | return PTR_ERR(pmx->pctl); | 1969 | return PTR_ERR(pmx->pctl); |
@@ -1975,15 +1976,6 @@ static int tz1090_pinctrl_probe(struct platform_device *pdev) | |||
1975 | return 0; | 1976 | return 0; |
1976 | } | 1977 | } |
1977 | 1978 | ||
1978 | static int tz1090_pinctrl_remove(struct platform_device *pdev) | ||
1979 | { | ||
1980 | struct tz1090_pmx *pmx = platform_get_drvdata(pdev); | ||
1981 | |||
1982 | pinctrl_unregister(pmx->pctl); | ||
1983 | |||
1984 | return 0; | ||
1985 | } | ||
1986 | |||
1987 | static const struct of_device_id tz1090_pinctrl_of_match[] = { | 1979 | static const struct of_device_id tz1090_pinctrl_of_match[] = { |
1988 | { .compatible = "img,tz1090-pinctrl", }, | 1980 | { .compatible = "img,tz1090-pinctrl", }, |
1989 | { }, | 1981 | { }, |
@@ -1995,7 +1987,6 @@ static struct platform_driver tz1090_pinctrl_driver = { | |||
1995 | .of_match_table = tz1090_pinctrl_of_match, | 1987 | .of_match_table = tz1090_pinctrl_of_match, |
1996 | }, | 1988 | }, |
1997 | .probe = tz1090_pinctrl_probe, | 1989 | .probe = tz1090_pinctrl_probe, |
1998 | .remove = tz1090_pinctrl_remove, | ||
1999 | }; | 1990 | }; |
2000 | 1991 | ||
2001 | static int __init tz1090_pinctrl_init(void) | 1992 | static int __init tz1090_pinctrl_init(void) |
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c index c076021f37d2..d1af908a7060 100644 --- a/drivers/pinctrl/pinctrl-u300.c +++ b/drivers/pinctrl/pinctrl-u300.c | |||
@@ -1067,7 +1067,7 @@ static int u300_pmx_probe(struct platform_device *pdev) | |||
1067 | if (IS_ERR(upmx->virtbase)) | 1067 | if (IS_ERR(upmx->virtbase)) |
1068 | return PTR_ERR(upmx->virtbase); | 1068 | return PTR_ERR(upmx->virtbase); |
1069 | 1069 | ||
1070 | upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx); | 1070 | upmx->pctl = devm_pinctrl_register(&pdev->dev, &u300_pmx_desc, upmx); |
1071 | if (IS_ERR(upmx->pctl)) { | 1071 | if (IS_ERR(upmx->pctl)) { |
1072 | dev_err(&pdev->dev, "could not register U300 pinmux driver\n"); | 1072 | dev_err(&pdev->dev, "could not register U300 pinmux driver\n"); |
1073 | return PTR_ERR(upmx->pctl); | 1073 | return PTR_ERR(upmx->pctl); |
@@ -1080,15 +1080,6 @@ static int u300_pmx_probe(struct platform_device *pdev) | |||
1080 | return 0; | 1080 | return 0; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | static int u300_pmx_remove(struct platform_device *pdev) | ||
1084 | { | ||
1085 | struct u300_pmx *upmx = platform_get_drvdata(pdev); | ||
1086 | |||
1087 | pinctrl_unregister(upmx->pctl); | ||
1088 | |||
1089 | return 0; | ||
1090 | } | ||
1091 | |||
1092 | static const struct of_device_id u300_pinctrl_match[] = { | 1083 | static const struct of_device_id u300_pinctrl_match[] = { |
1093 | { .compatible = "stericsson,pinctrl-u300" }, | 1084 | { .compatible = "stericsson,pinctrl-u300" }, |
1094 | {}, | 1085 | {}, |
@@ -1101,7 +1092,6 @@ static struct platform_driver u300_pmx_driver = { | |||
1101 | .of_match_table = u300_pinctrl_match, | 1092 | .of_match_table = u300_pinctrl_match, |
1102 | }, | 1093 | }, |
1103 | .probe = u300_pmx_probe, | 1094 | .probe = u300_pmx_probe, |
1104 | .remove = u300_pmx_remove, | ||
1105 | }; | 1095 | }; |
1106 | 1096 | ||
1107 | static int __init u300_pmx_init(void) | 1097 | static int __init u300_pmx_init(void) |
diff --git a/drivers/pinctrl/pinctrl-utils.c b/drivers/pinctrl/pinctrl-utils.c index d77693f2cc1b..9189fbafb102 100644 --- a/drivers/pinctrl/pinctrl-utils.c +++ b/drivers/pinctrl/pinctrl-utils.c | |||
@@ -122,7 +122,7 @@ int pinctrl_utils_add_config(struct pinctrl_dev *pctldev, | |||
122 | } | 122 | } |
123 | EXPORT_SYMBOL_GPL(pinctrl_utils_add_config); | 123 | EXPORT_SYMBOL_GPL(pinctrl_utils_add_config); |
124 | 124 | ||
125 | void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev, | 125 | void pinctrl_utils_free_map(struct pinctrl_dev *pctldev, |
126 | struct pinctrl_map *map, unsigned num_maps) | 126 | struct pinctrl_map *map, unsigned num_maps) |
127 | { | 127 | { |
128 | int i; | 128 | int i; |
@@ -139,4 +139,4 @@ void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev, | |||
139 | } | 139 | } |
140 | kfree(map); | 140 | kfree(map); |
141 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map); | 142 | EXPORT_SYMBOL_GPL(pinctrl_utils_free_map); |
diff --git a/drivers/pinctrl/pinctrl-utils.h b/drivers/pinctrl/pinctrl-utils.h index d0ffe1ce200f..8f9f2d28c5b8 100644 --- a/drivers/pinctrl/pinctrl-utils.h +++ b/drivers/pinctrl/pinctrl-utils.h | |||
@@ -37,7 +37,7 @@ int pinctrl_utils_add_map_configs(struct pinctrl_dev *pctldev, | |||
37 | int pinctrl_utils_add_config(struct pinctrl_dev *pctldev, | 37 | int pinctrl_utils_add_config(struct pinctrl_dev *pctldev, |
38 | unsigned long **configs, unsigned *num_configs, | 38 | unsigned long **configs, unsigned *num_configs, |
39 | unsigned long config); | 39 | unsigned long config); |
40 | void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev, | 40 | void pinctrl_utils_free_map(struct pinctrl_dev *pctldev, |
41 | struct pinctrl_map *map, unsigned num_maps); | 41 | struct pinctrl_map *map, unsigned num_maps); |
42 | 42 | ||
43 | #endif /* __PINCTRL_UTILS_H__ */ | 43 | #endif /* __PINCTRL_UTILS_H__ */ |
diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c index 76f1abd71e31..8fdc60c5aeaf 100644 --- a/drivers/pinctrl/pinctrl-zynq.c +++ b/drivers/pinctrl/pinctrl-zynq.c | |||
@@ -862,7 +862,7 @@ static const struct pinctrl_ops zynq_pctrl_ops = { | |||
862 | .get_group_name = zynq_pctrl_get_group_name, | 862 | .get_group_name = zynq_pctrl_get_group_name, |
863 | .get_group_pins = zynq_pctrl_get_group_pins, | 863 | .get_group_pins = zynq_pctrl_get_group_pins, |
864 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, | 864 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, |
865 | .dt_free_map = pinctrl_utils_dt_free_map, | 865 | .dt_free_map = pinctrl_utils_free_map, |
866 | }; | 866 | }; |
867 | 867 | ||
868 | /* pinmux */ | 868 | /* pinmux */ |
@@ -1195,7 +1195,7 @@ static int zynq_pinctrl_probe(struct platform_device *pdev) | |||
1195 | pctrl->funcs = zynq_pmux_functions; | 1195 | pctrl->funcs = zynq_pmux_functions; |
1196 | pctrl->nfuncs = ARRAY_SIZE(zynq_pmux_functions); | 1196 | pctrl->nfuncs = ARRAY_SIZE(zynq_pmux_functions); |
1197 | 1197 | ||
1198 | pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl); | 1198 | pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &zynq_desc, pctrl); |
1199 | if (IS_ERR(pctrl->pctrl)) | 1199 | if (IS_ERR(pctrl->pctrl)) |
1200 | return PTR_ERR(pctrl->pctrl); | 1200 | return PTR_ERR(pctrl->pctrl); |
1201 | 1201 | ||
@@ -1206,15 +1206,6 @@ static int zynq_pinctrl_probe(struct platform_device *pdev) | |||
1206 | return 0; | 1206 | return 0; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | static int zynq_pinctrl_remove(struct platform_device *pdev) | ||
1210 | { | ||
1211 | struct zynq_pinctrl *pctrl = platform_get_drvdata(pdev); | ||
1212 | |||
1213 | pinctrl_unregister(pctrl->pctrl); | ||
1214 | |||
1215 | return 0; | ||
1216 | } | ||
1217 | |||
1218 | static const struct of_device_id zynq_pinctrl_of_match[] = { | 1209 | static const struct of_device_id zynq_pinctrl_of_match[] = { |
1219 | { .compatible = "xlnx,pinctrl-zynq" }, | 1210 | { .compatible = "xlnx,pinctrl-zynq" }, |
1220 | { } | 1211 | { } |
@@ -1227,7 +1218,6 @@ static struct platform_driver zynq_pinctrl_driver = { | |||
1227 | .of_match_table = zynq_pinctrl_of_match, | 1218 | .of_match_table = zynq_pinctrl_of_match, |
1228 | }, | 1219 | }, |
1229 | .probe = zynq_pinctrl_probe, | 1220 | .probe = zynq_pinctrl_probe, |
1230 | .remove = zynq_pinctrl_remove, | ||
1231 | }; | 1221 | }; |
1232 | 1222 | ||
1233 | static int __init zynq_pinctrl_init(void) | 1223 | static int __init zynq_pinctrl_init(void) |
diff --git a/drivers/pinctrl/pxa/Kconfig b/drivers/pinctrl/pxa/Kconfig index 990667ff772c..c29bdcfa80af 100644 --- a/drivers/pinctrl/pxa/Kconfig +++ b/drivers/pinctrl/pxa/Kconfig | |||
@@ -6,12 +6,20 @@ config PINCTRL_PXA | |||
6 | select PINCONF | 6 | select PINCONF |
7 | select GENERIC_PINCONF | 7 | select GENERIC_PINCONF |
8 | 8 | ||
9 | config PINCTRL_PXA25X | ||
10 | tristate "Marvell PXA25x pin controller driver" | ||
11 | select PINCTRL_PXA | ||
12 | default y if PXA25x | ||
13 | help | ||
14 | This is the pinctrl, pinmux, pinconf driver for the Marvell | ||
15 | PXA2xx block found in the pxa25x platforms. | ||
16 | |||
9 | config PINCTRL_PXA27X | 17 | config PINCTRL_PXA27X |
10 | tristate "Marvell PXA27x pin controller driver" | 18 | tristate "Marvell PXA27x pin controller driver" |
11 | select PINCTRL_PXA | 19 | select PINCTRL_PXA |
12 | default y if PXA27x | 20 | default y if PXA27x |
13 | help | 21 | help |
14 | This is the pinctrl, pinmux, pinconf driver for the Marvell | 22 | This is the pinctrl, pinmux, pinconf driver for the Marvell |
15 | PXA2xx block found in the pxa25x and pxa27x platforms. | 23 | PXA2xx block found in the pxa27x platforms. |
16 | 24 | ||
17 | endif | 25 | endif |
diff --git a/drivers/pinctrl/pxa/Makefile b/drivers/pinctrl/pxa/Makefile index f1d56af2bfc0..ca2ade1a177b 100644 --- a/drivers/pinctrl/pxa/Makefile +++ b/drivers/pinctrl/pxa/Makefile | |||
@@ -1,2 +1,3 @@ | |||
1 | # Marvell PXA pin control drivers | 1 | # Marvell PXA pin control drivers |
2 | obj-$(CONFIG_PINCTRL_PXA25X) += pinctrl-pxa2xx.o pinctrl-pxa25x.o | ||
2 | obj-$(CONFIG_PINCTRL_PXA27X) += pinctrl-pxa2xx.o pinctrl-pxa27x.o | 3 | obj-$(CONFIG_PINCTRL_PXA27X) += pinctrl-pxa2xx.o pinctrl-pxa27x.o |
diff --git a/drivers/pinctrl/pxa/pinctrl-pxa25x.c b/drivers/pinctrl/pxa/pinctrl-pxa25x.c new file mode 100644 index 000000000000..b98ecb3c0683 --- /dev/null +++ b/drivers/pinctrl/pxa/pinctrl-pxa25x.c | |||
@@ -0,0 +1,274 @@ | |||
1 | /* | ||
2 | * Marvell PXA25x family pin control | ||
3 | * | ||
4 | * Copyright (C) 2016 Robert Jarzmik | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/of.h> | ||
14 | #include <linux/of_device.h> | ||
15 | #include <linux/pinctrl/pinctrl.h> | ||
16 | |||
17 | #include "pinctrl-pxa2xx.h" | ||
18 | |||
19 | static const struct pxa_desc_pin pxa25x_pins[] = { | ||
20 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(0)), | ||
21 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(1), | ||
22 | PXA_FUNCTION(0, 1, "GP_RST")), | ||
23 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(2)), | ||
24 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(3)), | ||
25 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(4)), | ||
26 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(5)), | ||
27 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(6), | ||
28 | PXA_FUNCTION(1, 1, "MMCCLK")), | ||
29 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(7), | ||
30 | PXA_FUNCTION(1, 1, "48_MHz")), | ||
31 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(8), | ||
32 | PXA_FUNCTION(1, 1, "MMCCS0")), | ||
33 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(9), | ||
34 | PXA_FUNCTION(1, 1, "MMCCS1")), | ||
35 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(10), | ||
36 | PXA_FUNCTION(1, 1, "RTCCLK")), | ||
37 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(11), | ||
38 | PXA_FUNCTION(1, 1, "3_6_MHz")), | ||
39 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(12), | ||
40 | PXA_FUNCTION(1, 1, "32_kHz")), | ||
41 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(13), | ||
42 | PXA_FUNCTION(1, 2, "MBGNT")), | ||
43 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(14), | ||
44 | PXA_FUNCTION(0, 1, "MBREQ")), | ||
45 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(15), | ||
46 | PXA_FUNCTION(1, 2, "nCS_1")), | ||
47 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(16), | ||
48 | PXA_FUNCTION(1, 2, "PWM0")), | ||
49 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(17), | ||
50 | PXA_FUNCTION(1, 2, "PWM1")), | ||
51 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(18), | ||
52 | PXA_FUNCTION(0, 1, "RDY")), | ||
53 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(19), | ||
54 | PXA_FUNCTION(0, 1, "DREQ[1]")), | ||
55 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(20), | ||
56 | PXA_FUNCTION(0, 1, "DREQ[0]")), | ||
57 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(21)), | ||
58 | PXA_GPIO_ONLY_PIN(PXA_PINCTRL_PIN(22)), | ||
59 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(23), | ||
60 | PXA_FUNCTION(1, 2, "SCLK")), | ||
61 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(24), | ||
62 | PXA_FUNCTION(1, 2, "SFRM")), | ||
63 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(25), | ||
64 | PXA_FUNCTION(1, 2, "TXD")), | ||
65 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(26), | ||
66 | PXA_FUNCTION(0, 1, "RXD")), | ||
67 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(27), | ||
68 | PXA_FUNCTION(0, 1, "EXTCLK")), | ||
69 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(28), | ||
70 | PXA_FUNCTION(0, 1, "BITCLK"), | ||
71 | PXA_FUNCTION(0, 2, "BITCLK"), | ||
72 | PXA_FUNCTION(1, 1, "BITCLK")), | ||
73 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(29), | ||
74 | PXA_FUNCTION(0, 1, "SDATA_IN0"), | ||
75 | PXA_FUNCTION(0, 2, "SDATA_IN")), | ||
76 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(30), | ||
77 | PXA_FUNCTION(1, 1, "SDATA_OUT"), | ||
78 | PXA_FUNCTION(1, 2, "SDATA_OUT")), | ||
79 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(31), | ||
80 | PXA_FUNCTION(1, 1, "SYNC"), | ||
81 | PXA_FUNCTION(1, 2, "SYNC")), | ||
82 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(32), | ||
83 | PXA_FUNCTION(0, 1, "SDATA_IN1"), | ||
84 | PXA_FUNCTION(1, 1, "SYSCLK")), | ||
85 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(33), | ||
86 | PXA_FUNCTION(1, 2, "nCS[5]")), | ||
87 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(34), | ||
88 | PXA_FUNCTION(0, 1, "FFRXD"), | ||
89 | PXA_FUNCTION(1, 2, "MMCCS0")), | ||
90 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(35), | ||
91 | PXA_FUNCTION(0, 1, "CTS")), | ||
92 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(36), | ||
93 | PXA_FUNCTION(0, 1, "DCD")), | ||
94 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(37), | ||
95 | PXA_FUNCTION(0, 1, "DSR")), | ||
96 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(38), | ||
97 | PXA_FUNCTION(0, 1, "RI")), | ||
98 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(39), | ||
99 | PXA_FUNCTION(1, 1, "MMCC1"), | ||
100 | PXA_FUNCTION(1, 2, "FFTXD")), | ||
101 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(40), | ||
102 | PXA_FUNCTION(1, 2, "DTR")), | ||
103 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(41), | ||
104 | PXA_FUNCTION(1, 2, "RTS")), | ||
105 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(42), | ||
106 | PXA_FUNCTION(0, 1, "BTRXD"), | ||
107 | PXA_FUNCTION(0, 3, "HWRXD")), | ||
108 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(43), | ||
109 | PXA_FUNCTION(1, 2, "BTTXD"), | ||
110 | PXA_FUNCTION(1, 3, "HWTXD")), | ||
111 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(44), | ||
112 | PXA_FUNCTION(0, 1, "BTCTS"), | ||
113 | PXA_FUNCTION(0, 3, "HWCTS")), | ||
114 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(45), | ||
115 | PXA_FUNCTION(1, 2, "BTRTS"), | ||
116 | PXA_FUNCTION(1, 3, "HWRTS")), | ||
117 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(46), | ||
118 | PXA_FUNCTION(0, 1, "ICP_RXD"), | ||
119 | PXA_FUNCTION(0, 2, "RXD")), | ||
120 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(47), | ||
121 | PXA_FUNCTION(1, 1, "TXD"), | ||
122 | PXA_FUNCTION(1, 2, "ICP_TXD")), | ||
123 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(48), | ||
124 | PXA_FUNCTION(1, 1, "HWTXD"), | ||
125 | PXA_FUNCTION(1, 2, "nPOE")), | ||
126 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(49), | ||
127 | PXA_FUNCTION(0, 1, "HWRXD"), | ||
128 | PXA_FUNCTION(1, 2, "nPWE")), | ||
129 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(50), | ||
130 | PXA_FUNCTION(0, 1, "HWCTS"), | ||
131 | PXA_FUNCTION(1, 2, "nPIOR")), | ||
132 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(51), | ||
133 | PXA_FUNCTION(1, 1, "HWRTS"), | ||
134 | PXA_FUNCTION(1, 2, "nPIOW")), | ||
135 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(52), | ||
136 | PXA_FUNCTION(1, 2, "nPCE[1]")), | ||
137 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(53), | ||
138 | PXA_FUNCTION(1, 1, "MMCCLK"), | ||
139 | PXA_FUNCTION(1, 2, "nPCE[2]")), | ||
140 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(54), | ||
141 | PXA_FUNCTION(1, 1, "MMCCLK"), | ||
142 | PXA_FUNCTION(1, 2, "nPSKTSEL")), | ||
143 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(55), | ||
144 | PXA_FUNCTION(1, 2, "nPREG")), | ||
145 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(56), | ||
146 | PXA_FUNCTION(0, 1, "nPWAIT")), | ||
147 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(57), | ||
148 | PXA_FUNCTION(0, 1, "nIOIS16")), | ||
149 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(58), | ||
150 | PXA_FUNCTION(1, 2, "LDD<0>")), | ||
151 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(59), | ||
152 | PXA_FUNCTION(1, 2, "LDD<1>")), | ||
153 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(60), | ||
154 | PXA_FUNCTION(1, 2, "LDD<2>")), | ||
155 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(61), | ||
156 | PXA_FUNCTION(1, 2, "LDD<3>")), | ||
157 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(62), | ||
158 | PXA_FUNCTION(1, 2, "LDD<4>")), | ||
159 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(63), | ||
160 | PXA_FUNCTION(1, 2, "LDD<5>")), | ||
161 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(64), | ||
162 | PXA_FUNCTION(1, 2, "LDD<6>")), | ||
163 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(65), | ||
164 | PXA_FUNCTION(1, 2, "LDD<7>")), | ||
165 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(66), | ||
166 | PXA_FUNCTION(0, 1, "MBREQ"), | ||
167 | PXA_FUNCTION(1, 2, "LDD<8>")), | ||
168 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(67), | ||
169 | PXA_FUNCTION(1, 1, "MMCCS0"), | ||
170 | PXA_FUNCTION(1, 2, "LDD<9>")), | ||
171 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(68), | ||
172 | PXA_FUNCTION(1, 1, "MMCCS1"), | ||
173 | PXA_FUNCTION(1, 2, "LDD<10>")), | ||
174 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(69), | ||
175 | PXA_FUNCTION(1, 1, "MMCCLK"), | ||
176 | PXA_FUNCTION(1, 2, "LDD<11>")), | ||
177 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(70), | ||
178 | PXA_FUNCTION(1, 1, "RTCCLK"), | ||
179 | PXA_FUNCTION(1, 2, "LDD<12>")), | ||
180 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(71), | ||
181 | PXA_FUNCTION(1, 1, "3_6_MHz"), | ||
182 | PXA_FUNCTION(1, 2, "LDD<13>")), | ||
183 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(72), | ||
184 | PXA_FUNCTION(1, 1, "32_kHz"), | ||
185 | PXA_FUNCTION(1, 2, "LDD<14>")), | ||
186 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(73), | ||
187 | PXA_FUNCTION(1, 1, "MBGNT"), | ||
188 | PXA_FUNCTION(1, 2, "LDD<15>")), | ||
189 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(74), | ||
190 | PXA_FUNCTION(1, 2, "LCD_FCLK")), | ||
191 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(75), | ||
192 | PXA_FUNCTION(1, 2, "LCD_LCLK")), | ||
193 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(76), | ||
194 | PXA_FUNCTION(1, 2, "LCD_PCLK")), | ||
195 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(77), | ||
196 | PXA_FUNCTION(1, 2, "LCD_ACBIAS")), | ||
197 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(78), | ||
198 | PXA_FUNCTION(1, 2, "nCS<2>")), | ||
199 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(79), | ||
200 | PXA_FUNCTION(1, 2, "nCS<3>")), | ||
201 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(80), | ||
202 | PXA_FUNCTION(1, 2, "nCS<4>")), | ||
203 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(81), | ||
204 | PXA_FUNCTION(0, 1, "NSSPSCLK"), | ||
205 | PXA_FUNCTION(1, 1, "NSSPSCLK")), | ||
206 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(82), | ||
207 | PXA_FUNCTION(0, 1, "NSSPSFRM"), | ||
208 | PXA_FUNCTION(1, 1, "NSSPSFRM")), | ||
209 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(83), | ||
210 | PXA_FUNCTION(0, 2, "NSSPRXD"), | ||
211 | PXA_FUNCTION(1, 1, "NSSPTXD")), | ||
212 | PXA_GPIO_PIN(PXA_PINCTRL_PIN(84), | ||
213 | PXA_FUNCTION(0, 2, "NSSPRXD"), | ||
214 | PXA_FUNCTION(1, 1, "NSSPTXD")), | ||
215 | }; | ||
216 | |||
217 | static int pxa25x_pinctrl_probe(struct platform_device *pdev) | ||
218 | { | ||
219 | int ret, i; | ||
220 | void __iomem *base_af[8]; | ||
221 | void __iomem *base_dir[4]; | ||
222 | void __iomem *base_sleep[4]; | ||
223 | struct resource *res; | ||
224 | |||
225 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
226 | base_af[0] = devm_ioremap_resource(&pdev->dev, res); | ||
227 | if (IS_ERR(base_af[0])) | ||
228 | return PTR_ERR(base_af[0]); | ||
229 | |||
230 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
231 | base_dir[0] = devm_ioremap_resource(&pdev->dev, res); | ||
232 | if (IS_ERR(base_dir[0])) | ||
233 | return PTR_ERR(base_dir[0]); | ||
234 | |||
235 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
236 | base_dir[3] = devm_ioremap_resource(&pdev->dev, res); | ||
237 | if (IS_ERR(base_dir[3])) | ||
238 | return PTR_ERR(base_dir[3]); | ||
239 | |||
240 | res = platform_get_resource(pdev, IORESOURCE_MEM, 3); | ||
241 | base_sleep[0] = devm_ioremap_resource(&pdev->dev, res); | ||
242 | if (IS_ERR(base_sleep[0])) | ||
243 | return PTR_ERR(base_sleep[0]); | ||
244 | |||
245 | for (i = 0; i < ARRAY_SIZE(base_af); i++) | ||
246 | base_af[i] = base_af[0] + sizeof(base_af[0]) * i; | ||
247 | for (i = 0; i < 3; i++) | ||
248 | base_dir[i] = base_dir[0] + sizeof(base_dir[0]) * i; | ||
249 | for (i = 0; i < ARRAY_SIZE(base_sleep); i++) | ||
250 | base_sleep[i] = base_sleep[0] + sizeof(base_af[0]) * i; | ||
251 | |||
252 | ret = pxa2xx_pinctrl_init(pdev, pxa25x_pins, ARRAY_SIZE(pxa25x_pins), | ||
253 | base_af, base_dir, base_sleep); | ||
254 | return ret; | ||
255 | } | ||
256 | |||
257 | static const struct of_device_id pxa25x_pinctrl_match[] = { | ||
258 | { .compatible = "marvell,pxa25x-pinctrl", }, | ||
259 | {} | ||
260 | }; | ||
261 | MODULE_DEVICE_TABLE(of, pxa25x_pinctrl_match); | ||
262 | |||
263 | static struct platform_driver pxa25x_pinctrl_driver = { | ||
264 | .probe = pxa25x_pinctrl_probe, | ||
265 | .driver = { | ||
266 | .name = "pxa25x-pinctrl", | ||
267 | .of_match_table = pxa25x_pinctrl_match, | ||
268 | }, | ||
269 | }; | ||
270 | module_platform_driver(pxa25x_pinctrl_driver); | ||
271 | |||
272 | MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>"); | ||
273 | MODULE_DESCRIPTION("Marvell PXA25x pinctrl driver"); | ||
274 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c index f553313bc2ef..866aa3ce1ac9 100644 --- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c +++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c | |||
@@ -57,7 +57,7 @@ static int pxa2xx_pctrl_get_group_pins(struct pinctrl_dev *pctldev, | |||
57 | static const struct pinctrl_ops pxa2xx_pctl_ops = { | 57 | static const struct pinctrl_ops pxa2xx_pctl_ops = { |
58 | #ifdef CONFIG_OF | 58 | #ifdef CONFIG_OF |
59 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, | 59 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, |
60 | .dt_free_map = pinctrl_utils_dt_free_map, | 60 | .dt_free_map = pinctrl_utils_free_map, |
61 | #endif | 61 | #endif |
62 | .get_groups_count = pxa2xx_pctrl_get_groups_count, | 62 | .get_groups_count = pxa2xx_pctrl_get_groups_count, |
63 | .get_group_name = pxa2xx_pctrl_get_group_name, | 63 | .get_group_name = pxa2xx_pctrl_get_group_name, |
@@ -416,7 +416,7 @@ int pxa2xx_pinctrl_init(struct platform_device *pdev, | |||
416 | if (ret) | 416 | if (ret) |
417 | return ret; | 417 | return ret; |
418 | 418 | ||
419 | pctl->pctl_dev = pinctrl_register(&pctl->desc, &pdev->dev, pctl); | 419 | pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->desc, pctl); |
420 | if (IS_ERR(pctl->pctl_dev)) { | 420 | if (IS_ERR(pctl->pctl_dev)) { |
421 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); | 421 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); |
422 | return PTR_ERR(pctl->pctl_dev); | 422 | return PTR_ERR(pctl->pctl_dev); |
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 8777cf083eef..1a44e1d03390 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c | |||
@@ -101,7 +101,7 @@ static const struct pinctrl_ops msm_pinctrl_ops = { | |||
101 | .get_group_name = msm_get_group_name, | 101 | .get_group_name = msm_get_group_name, |
102 | .get_group_pins = msm_get_group_pins, | 102 | .get_group_pins = msm_get_group_pins, |
103 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 103 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
104 | .dt_free_map = pinctrl_utils_dt_free_map, | 104 | .dt_free_map = pinctrl_utils_free_map, |
105 | }; | 105 | }; |
106 | 106 | ||
107 | static int msm_get_functions_count(struct pinctrl_dev *pctldev) | 107 | static int msm_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -898,17 +898,16 @@ int msm_pinctrl_probe(struct platform_device *pdev, | |||
898 | msm_pinctrl_desc.name = dev_name(&pdev->dev); | 898 | msm_pinctrl_desc.name = dev_name(&pdev->dev); |
899 | msm_pinctrl_desc.pins = pctrl->soc->pins; | 899 | msm_pinctrl_desc.pins = pctrl->soc->pins; |
900 | msm_pinctrl_desc.npins = pctrl->soc->npins; | 900 | msm_pinctrl_desc.npins = pctrl->soc->npins; |
901 | pctrl->pctrl = pinctrl_register(&msm_pinctrl_desc, &pdev->dev, pctrl); | 901 | pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &msm_pinctrl_desc, |
902 | pctrl); | ||
902 | if (IS_ERR(pctrl->pctrl)) { | 903 | if (IS_ERR(pctrl->pctrl)) { |
903 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 904 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
904 | return PTR_ERR(pctrl->pctrl); | 905 | return PTR_ERR(pctrl->pctrl); |
905 | } | 906 | } |
906 | 907 | ||
907 | ret = msm_gpio_init(pctrl); | 908 | ret = msm_gpio_init(pctrl); |
908 | if (ret) { | 909 | if (ret) |
909 | pinctrl_unregister(pctrl->pctrl); | ||
910 | return ret; | 910 | return ret; |
911 | } | ||
912 | 911 | ||
913 | platform_set_drvdata(pdev, pctrl); | 912 | platform_set_drvdata(pdev, pctrl); |
914 | 913 | ||
@@ -923,7 +922,6 @@ int msm_pinctrl_remove(struct platform_device *pdev) | |||
923 | struct msm_pinctrl *pctrl = platform_get_drvdata(pdev); | 922 | struct msm_pinctrl *pctrl = platform_get_drvdata(pdev); |
924 | 923 | ||
925 | gpiochip_remove(&pctrl->chip); | 924 | gpiochip_remove(&pctrl->chip); |
926 | pinctrl_unregister(pctrl->pctrl); | ||
927 | 925 | ||
928 | unregister_restart_handler(&pctrl->restart_nb); | 926 | unregister_restart_handler(&pctrl->restart_nb); |
929 | 927 | ||
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 4e12ded3c773..686accb89f52 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | |||
@@ -212,7 +212,7 @@ static const struct pinctrl_ops pmic_gpio_pinctrl_ops = { | |||
212 | .get_group_name = pmic_gpio_get_group_name, | 212 | .get_group_name = pmic_gpio_get_group_name, |
213 | .get_group_pins = pmic_gpio_get_group_pins, | 213 | .get_group_pins = pmic_gpio_get_group_pins, |
214 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 214 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
215 | .dt_free_map = pinctrl_utils_dt_free_map, | 215 | .dt_free_map = pinctrl_utils_free_map, |
216 | }; | 216 | }; |
217 | 217 | ||
218 | static int pmic_gpio_get_functions_count(struct pinctrl_dev *pctldev) | 218 | static int pmic_gpio_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -764,14 +764,14 @@ static int pmic_gpio_probe(struct platform_device *pdev) | |||
764 | state->chip.of_gpio_n_cells = 2; | 764 | state->chip.of_gpio_n_cells = 2; |
765 | state->chip.can_sleep = false; | 765 | state->chip.can_sleep = false; |
766 | 766 | ||
767 | state->ctrl = pinctrl_register(pctrldesc, dev, state); | 767 | state->ctrl = devm_pinctrl_register(dev, pctrldesc, state); |
768 | if (IS_ERR(state->ctrl)) | 768 | if (IS_ERR(state->ctrl)) |
769 | return PTR_ERR(state->ctrl); | 769 | return PTR_ERR(state->ctrl); |
770 | 770 | ||
771 | ret = gpiochip_add_data(&state->chip, state); | 771 | ret = gpiochip_add_data(&state->chip, state); |
772 | if (ret) { | 772 | if (ret) { |
773 | dev_err(state->dev, "can't add gpio chip\n"); | 773 | dev_err(state->dev, "can't add gpio chip\n"); |
774 | goto err_chip; | 774 | return ret; |
775 | } | 775 | } |
776 | 776 | ||
777 | ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); | 777 | ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); |
@@ -784,8 +784,6 @@ static int pmic_gpio_probe(struct platform_device *pdev) | |||
784 | 784 | ||
785 | err_range: | 785 | err_range: |
786 | gpiochip_remove(&state->chip); | 786 | gpiochip_remove(&state->chip); |
787 | err_chip: | ||
788 | pinctrl_unregister(state->ctrl); | ||
789 | return ret; | 787 | return ret; |
790 | } | 788 | } |
791 | 789 | ||
@@ -794,7 +792,6 @@ static int pmic_gpio_remove(struct platform_device *pdev) | |||
794 | struct pmic_gpio_state *state = platform_get_drvdata(pdev); | 792 | struct pmic_gpio_state *state = platform_get_drvdata(pdev); |
795 | 793 | ||
796 | gpiochip_remove(&state->chip); | 794 | gpiochip_remove(&state->chip); |
797 | pinctrl_unregister(state->ctrl); | ||
798 | return 0; | 795 | return 0; |
799 | } | 796 | } |
800 | 797 | ||
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index 2a3e5490a483..1735ffef9d5c 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | |||
@@ -235,7 +235,7 @@ static const struct pinctrl_ops pmic_mpp_pinctrl_ops = { | |||
235 | .get_group_name = pmic_mpp_get_group_name, | 235 | .get_group_name = pmic_mpp_get_group_name, |
236 | .get_group_pins = pmic_mpp_get_group_pins, | 236 | .get_group_pins = pmic_mpp_get_group_pins, |
237 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 237 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
238 | .dt_free_map = pinctrl_utils_dt_free_map, | 238 | .dt_free_map = pinctrl_utils_free_map, |
239 | }; | 239 | }; |
240 | 240 | ||
241 | static int pmic_mpp_get_functions_count(struct pinctrl_dev *pctldev) | 241 | static int pmic_mpp_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -877,14 +877,14 @@ static int pmic_mpp_probe(struct platform_device *pdev) | |||
877 | state->chip.of_gpio_n_cells = 2; | 877 | state->chip.of_gpio_n_cells = 2; |
878 | state->chip.can_sleep = false; | 878 | state->chip.can_sleep = false; |
879 | 879 | ||
880 | state->ctrl = pinctrl_register(pctrldesc, dev, state); | 880 | state->ctrl = devm_pinctrl_register(dev, pctrldesc, state); |
881 | if (IS_ERR(state->ctrl)) | 881 | if (IS_ERR(state->ctrl)) |
882 | return PTR_ERR(state->ctrl); | 882 | return PTR_ERR(state->ctrl); |
883 | 883 | ||
884 | ret = gpiochip_add_data(&state->chip, state); | 884 | ret = gpiochip_add_data(&state->chip, state); |
885 | if (ret) { | 885 | if (ret) { |
886 | dev_err(state->dev, "can't add gpio chip\n"); | 886 | dev_err(state->dev, "can't add gpio chip\n"); |
887 | goto err_chip; | 887 | return ret; |
888 | } | 888 | } |
889 | 889 | ||
890 | ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); | 890 | ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); |
@@ -897,8 +897,6 @@ static int pmic_mpp_probe(struct platform_device *pdev) | |||
897 | 897 | ||
898 | err_range: | 898 | err_range: |
899 | gpiochip_remove(&state->chip); | 899 | gpiochip_remove(&state->chip); |
900 | err_chip: | ||
901 | pinctrl_unregister(state->ctrl); | ||
902 | return ret; | 900 | return ret; |
903 | } | 901 | } |
904 | 902 | ||
@@ -907,7 +905,6 @@ static int pmic_mpp_remove(struct platform_device *pdev) | |||
907 | struct pmic_mpp_state *state = platform_get_drvdata(pdev); | 905 | struct pmic_mpp_state *state = platform_get_drvdata(pdev); |
908 | 906 | ||
909 | gpiochip_remove(&state->chip); | 907 | gpiochip_remove(&state->chip); |
910 | pinctrl_unregister(state->ctrl); | ||
911 | return 0; | 908 | return 0; |
912 | } | 909 | } |
913 | 910 | ||
diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index cd8580d9741d..d3f5501d17ee 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | |||
@@ -200,7 +200,7 @@ static const struct pinctrl_ops pm8xxx_pinctrl_ops = { | |||
200 | .get_group_name = pm8xxx_get_group_name, | 200 | .get_group_name = pm8xxx_get_group_name, |
201 | .get_group_pins = pm8xxx_get_group_pins, | 201 | .get_group_pins = pm8xxx_get_group_pins, |
202 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 202 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
203 | .dt_free_map = pinctrl_utils_dt_free_map, | 203 | .dt_free_map = pinctrl_utils_free_map, |
204 | }; | 204 | }; |
205 | 205 | ||
206 | static int pm8xxx_get_functions_count(struct pinctrl_dev *pctldev) | 206 | static int pm8xxx_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -729,7 +729,7 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) | |||
729 | pctrl->desc.custom_conf_items = pm8xxx_conf_items; | 729 | pctrl->desc.custom_conf_items = pm8xxx_conf_items; |
730 | #endif | 730 | #endif |
731 | 731 | ||
732 | pctrl->pctrl = pinctrl_register(&pctrl->desc, &pdev->dev, pctrl); | 732 | pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &pctrl->desc, pctrl); |
733 | if (IS_ERR(pctrl->pctrl)) { | 733 | if (IS_ERR(pctrl->pctrl)) { |
734 | dev_err(&pdev->dev, "couldn't register pm8xxx gpio driver\n"); | 734 | dev_err(&pdev->dev, "couldn't register pm8xxx gpio driver\n"); |
735 | return PTR_ERR(pctrl->pctrl); | 735 | return PTR_ERR(pctrl->pctrl); |
@@ -745,7 +745,7 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) | |||
745 | ret = gpiochip_add_data(&pctrl->chip, pctrl); | 745 | ret = gpiochip_add_data(&pctrl->chip, pctrl); |
746 | if (ret) { | 746 | if (ret) { |
747 | dev_err(&pdev->dev, "failed register gpiochip\n"); | 747 | dev_err(&pdev->dev, "failed register gpiochip\n"); |
748 | goto unregister_pinctrl; | 748 | return ret; |
749 | } | 749 | } |
750 | 750 | ||
751 | ret = gpiochip_add_pin_range(&pctrl->chip, | 751 | ret = gpiochip_add_pin_range(&pctrl->chip, |
@@ -765,9 +765,6 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) | |||
765 | unregister_gpiochip: | 765 | unregister_gpiochip: |
766 | gpiochip_remove(&pctrl->chip); | 766 | gpiochip_remove(&pctrl->chip); |
767 | 767 | ||
768 | unregister_pinctrl: | ||
769 | pinctrl_unregister(pctrl->pctrl); | ||
770 | |||
771 | return ret; | 768 | return ret; |
772 | } | 769 | } |
773 | 770 | ||
@@ -777,8 +774,6 @@ static int pm8xxx_gpio_remove(struct platform_device *pdev) | |||
777 | 774 | ||
778 | gpiochip_remove(&pctrl->chip); | 775 | gpiochip_remove(&pctrl->chip); |
779 | 776 | ||
780 | pinctrl_unregister(pctrl->pctrl); | ||
781 | |||
782 | return 0; | 777 | return 0; |
783 | } | 778 | } |
784 | 779 | ||
diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 54a5402a9079..9191727aff5e 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | |||
@@ -277,7 +277,7 @@ static const struct pinctrl_ops pm8xxx_pinctrl_ops = { | |||
277 | .get_group_name = pm8xxx_get_group_name, | 277 | .get_group_name = pm8xxx_get_group_name, |
278 | .get_group_pins = pm8xxx_get_group_pins, | 278 | .get_group_pins = pm8xxx_get_group_pins, |
279 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, | 279 | .dt_node_to_map = pinconf_generic_dt_node_to_map_group, |
280 | .dt_free_map = pinctrl_utils_dt_free_map, | 280 | .dt_free_map = pinctrl_utils_free_map, |
281 | }; | 281 | }; |
282 | 282 | ||
283 | static int pm8xxx_get_functions_count(struct pinctrl_dev *pctldev) | 283 | static int pm8xxx_get_functions_count(struct pinctrl_dev *pctldev) |
@@ -820,7 +820,7 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev) | |||
820 | pctrl->desc.custom_conf_items = pm8xxx_conf_items; | 820 | pctrl->desc.custom_conf_items = pm8xxx_conf_items; |
821 | #endif | 821 | #endif |
822 | 822 | ||
823 | pctrl->pctrl = pinctrl_register(&pctrl->desc, &pdev->dev, pctrl); | 823 | pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &pctrl->desc, pctrl); |
824 | if (IS_ERR(pctrl->pctrl)) { | 824 | if (IS_ERR(pctrl->pctrl)) { |
825 | dev_err(&pdev->dev, "couldn't register pm8xxx mpp driver\n"); | 825 | dev_err(&pdev->dev, "couldn't register pm8xxx mpp driver\n"); |
826 | return PTR_ERR(pctrl->pctrl); | 826 | return PTR_ERR(pctrl->pctrl); |
@@ -836,7 +836,7 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev) | |||
836 | ret = gpiochip_add_data(&pctrl->chip, pctrl); | 836 | ret = gpiochip_add_data(&pctrl->chip, pctrl); |
837 | if (ret) { | 837 | if (ret) { |
838 | dev_err(&pdev->dev, "failed register gpiochip\n"); | 838 | dev_err(&pdev->dev, "failed register gpiochip\n"); |
839 | goto unregister_pinctrl; | 839 | return ret; |
840 | } | 840 | } |
841 | 841 | ||
842 | ret = gpiochip_add_pin_range(&pctrl->chip, | 842 | ret = gpiochip_add_pin_range(&pctrl->chip, |
@@ -856,9 +856,6 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev) | |||
856 | unregister_gpiochip: | 856 | unregister_gpiochip: |
857 | gpiochip_remove(&pctrl->chip); | 857 | gpiochip_remove(&pctrl->chip); |
858 | 858 | ||
859 | unregister_pinctrl: | ||
860 | pinctrl_unregister(pctrl->pctrl); | ||
861 | |||
862 | return ret; | 859 | return ret; |
863 | } | 860 | } |
864 | 861 | ||
@@ -868,8 +865,6 @@ static int pm8xxx_mpp_remove(struct platform_device *pdev) | |||
868 | 865 | ||
869 | gpiochip_remove(&pctrl->chip); | 866 | gpiochip_remove(&pctrl->chip); |
870 | 867 | ||
871 | pinctrl_unregister(pctrl->pctrl); | ||
872 | |||
873 | return 0; | 868 | return 0; |
874 | } | 869 | } |
875 | 870 | ||
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c index 00ab63abf1d9..fb71fc3e5aa0 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c | |||
@@ -107,6 +107,7 @@ struct exynos5440_pmx_func { | |||
107 | * @nr_groups: number of pin groups available. | 107 | * @nr_groups: number of pin groups available. |
108 | * @pmx_functions: list of pin functions parsed from device tree. | 108 | * @pmx_functions: list of pin functions parsed from device tree. |
109 | * @nr_functions: number of pin functions available. | 109 | * @nr_functions: number of pin functions available. |
110 | * @range: gpio range to register with pinctrl | ||
110 | */ | 111 | */ |
111 | struct exynos5440_pinctrl_priv_data { | 112 | struct exynos5440_pinctrl_priv_data { |
112 | void __iomem *reg_base; | 113 | void __iomem *reg_base; |
@@ -117,6 +118,7 @@ struct exynos5440_pinctrl_priv_data { | |||
117 | unsigned int nr_groups; | 118 | unsigned int nr_groups; |
118 | const struct exynos5440_pmx_func *pmx_functions; | 119 | const struct exynos5440_pmx_func *pmx_functions; |
119 | unsigned int nr_functions; | 120 | unsigned int nr_functions; |
121 | struct pinctrl_gpio_range range; | ||
120 | }; | 122 | }; |
121 | 123 | ||
122 | /** | 124 | /** |
@@ -742,7 +744,6 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, | |||
742 | struct pinctrl_desc *ctrldesc; | 744 | struct pinctrl_desc *ctrldesc; |
743 | struct pinctrl_dev *pctl_dev; | 745 | struct pinctrl_dev *pctl_dev; |
744 | struct pinctrl_pin_desc *pindesc, *pdesc; | 746 | struct pinctrl_pin_desc *pindesc, *pdesc; |
745 | struct pinctrl_gpio_range grange; | ||
746 | char *pin_names; | 747 | char *pin_names; |
747 | int pin, ret; | 748 | int pin, ret; |
748 | 749 | ||
@@ -788,18 +789,18 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, | |||
788 | if (ret) | 789 | if (ret) |
789 | return ret; | 790 | return ret; |
790 | 791 | ||
791 | pctl_dev = pinctrl_register(ctrldesc, &pdev->dev, priv); | 792 | pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, priv); |
792 | if (IS_ERR(pctl_dev)) { | 793 | if (IS_ERR(pctl_dev)) { |
793 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); | 794 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); |
794 | return PTR_ERR(pctl_dev); | 795 | return PTR_ERR(pctl_dev); |
795 | } | 796 | } |
796 | 797 | ||
797 | grange.name = "exynos5440-pctrl-gpio-range"; | 798 | priv->range.name = "exynos5440-pctrl-gpio-range"; |
798 | grange.id = 0; | 799 | priv->range.id = 0; |
799 | grange.base = 0; | 800 | priv->range.base = 0; |
800 | grange.npins = EXYNOS5440_MAX_PINS; | 801 | priv->range.npins = EXYNOS5440_MAX_PINS; |
801 | grange.gc = priv->gc; | 802 | priv->range.gc = priv->gc; |
802 | pinctrl_add_gpio_range(pctl_dev, &grange); | 803 | pinctrl_add_gpio_range(pctl_dev, &priv->range); |
803 | return 0; | 804 | return 0; |
804 | } | 805 | } |
805 | 806 | ||
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 5cc97f85db02..ed0b70881e19 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c | |||
@@ -884,7 +884,8 @@ static int samsung_pinctrl_register(struct platform_device *pdev, | |||
884 | if (ret) | 884 | if (ret) |
885 | return ret; | 885 | return ret; |
886 | 886 | ||
887 | drvdata->pctl_dev = pinctrl_register(ctrldesc, &pdev->dev, drvdata); | 887 | drvdata->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, |
888 | drvdata); | ||
888 | if (IS_ERR(drvdata->pctl_dev)) { | 889 | if (IS_ERR(drvdata->pctl_dev)) { |
889 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); | 890 | dev_err(&pdev->dev, "could not register pinctrl driver\n"); |
890 | return PTR_ERR(drvdata->pctl_dev); | 891 | return PTR_ERR(drvdata->pctl_dev); |
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index ee0c1f2567d9..9b9cee06ec59 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c | |||
@@ -175,6 +175,21 @@ void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned int reg_width, | |||
175 | BUG(); | 175 | BUG(); |
176 | } | 176 | } |
177 | 177 | ||
178 | u32 sh_pfc_read_reg(struct sh_pfc *pfc, u32 reg, unsigned int width) | ||
179 | { | ||
180 | return sh_pfc_read_raw_reg(sh_pfc_phys_to_virt(pfc, reg), width); | ||
181 | } | ||
182 | |||
183 | void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width, u32 data) | ||
184 | { | ||
185 | if (pfc->info->unlock_reg) | ||
186 | sh_pfc_write_raw_reg( | ||
187 | sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg), 32, | ||
188 | ~data); | ||
189 | |||
190 | sh_pfc_write_raw_reg(sh_pfc_phys_to_virt(pfc, reg), width, data); | ||
191 | } | ||
192 | |||
178 | static void sh_pfc_config_reg_helper(struct sh_pfc *pfc, | 193 | static void sh_pfc_config_reg_helper(struct sh_pfc *pfc, |
179 | const struct pinmux_cfg_reg *crp, | 194 | const struct pinmux_cfg_reg *crp, |
180 | unsigned int in_pos, | 195 | unsigned int in_pos, |
@@ -585,12 +600,9 @@ static int sh_pfc_probe(struct platform_device *pdev) | |||
585 | 600 | ||
586 | static int sh_pfc_remove(struct platform_device *pdev) | 601 | static int sh_pfc_remove(struct platform_device *pdev) |
587 | { | 602 | { |
588 | struct sh_pfc *pfc = platform_get_drvdata(pdev); | ||
589 | |||
590 | #ifdef CONFIG_PINCTRL_SH_PFC_GPIO | 603 | #ifdef CONFIG_PINCTRL_SH_PFC_GPIO |
591 | sh_pfc_unregister_gpiochip(pfc); | 604 | sh_pfc_unregister_gpiochip(platform_get_drvdata(pdev)); |
592 | #endif | 605 | #endif |
593 | sh_pfc_unregister_pinctrl(pfc); | ||
594 | 606 | ||
595 | return 0; | 607 | return 0; |
596 | } | 608 | } |
diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h index 62f53b22ae85..dc1b2adb24c5 100644 --- a/drivers/pinctrl/sh-pfc/core.h +++ b/drivers/pinctrl/sh-pfc/core.h | |||
@@ -50,18 +50,19 @@ struct sh_pfc { | |||
50 | struct sh_pfc_chip *func; | 50 | struct sh_pfc_chip *func; |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | struct sh_pfc_pinctrl *pinctrl; | ||
54 | }; | 53 | }; |
55 | 54 | ||
56 | int sh_pfc_register_gpiochip(struct sh_pfc *pfc); | 55 | int sh_pfc_register_gpiochip(struct sh_pfc *pfc); |
57 | int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc); | 56 | int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc); |
58 | 57 | ||
59 | int sh_pfc_register_pinctrl(struct sh_pfc *pfc); | 58 | int sh_pfc_register_pinctrl(struct sh_pfc *pfc); |
60 | int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc); | ||
61 | 59 | ||
62 | u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned int reg_width); | 60 | u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned int reg_width); |
63 | void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned int reg_width, | 61 | void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned int reg_width, |
64 | u32 data); | 62 | u32 data); |
63 | u32 sh_pfc_read_reg(struct sh_pfc *pfc, u32 reg, unsigned int width); | ||
64 | void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width, | ||
65 | u32 data); | ||
65 | 66 | ||
66 | int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); | 67 | int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); |
67 | int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type); | 68 | int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type); |
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c index 0f4d48f9400b..eed8daa464cc 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c | |||
@@ -21,16 +21,21 @@ | |||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/io.h> | ||
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
25 | 26 | ||
26 | #include "core.h" | 27 | #include "core.h" |
27 | #include "sh_pfc.h" | 28 | #include "sh_pfc.h" |
28 | 29 | ||
30 | /* | ||
31 | * All pins assigned to GPIO bank 3 can be used for SD interfaces in | ||
32 | * which case they support both 3.3V and 1.8V signalling. | ||
33 | */ | ||
29 | #define CPU_ALL_PORT(fn, sfx) \ | 34 | #define CPU_ALL_PORT(fn, sfx) \ |
30 | PORT_GP_32(0, fn, sfx), \ | 35 | PORT_GP_32(0, fn, sfx), \ |
31 | PORT_GP_30(1, fn, sfx), \ | 36 | PORT_GP_30(1, fn, sfx), \ |
32 | PORT_GP_30(2, fn, sfx), \ | 37 | PORT_GP_30(2, fn, sfx), \ |
33 | PORT_GP_32(3, fn, sfx), \ | 38 | PORT_GP_CFG_32(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \ |
34 | PORT_GP_32(4, fn, sfx), \ | 39 | PORT_GP_32(4, fn, sfx), \ |
35 | PORT_GP_32(5, fn, sfx) | 40 | PORT_GP_32(5, fn, sfx) |
36 | 41 | ||
@@ -4691,6 +4696,47 @@ static const char * const vin3_groups[] = { | |||
4691 | "vin3_clk", | 4696 | "vin3_clk", |
4692 | }; | 4697 | }; |
4693 | 4698 | ||
4699 | #define IOCTRL6 0x8c | ||
4700 | |||
4701 | static int r8a7790_get_io_voltage(struct sh_pfc *pfc, unsigned int pin) | ||
4702 | { | ||
4703 | u32 data, mask; | ||
4704 | |||
4705 | if (WARN(pin < RCAR_GP_PIN(3, 0) || pin > RCAR_GP_PIN(3, 31), "invalid pin %#x", pin)) | ||
4706 | return -EINVAL; | ||
4707 | |||
4708 | data = ioread32(pfc->windows->virt + IOCTRL6), | ||
4709 | /* Bits in IOCTRL6 are numbered in opposite order to pins */ | ||
4710 | mask = 0x80000000 >> (pin & 0x1f); | ||
4711 | |||
4712 | return (data & mask) ? 3300 : 1800; | ||
4713 | } | ||
4714 | |||
4715 | static int r8a7790_set_io_voltage(struct sh_pfc *pfc, unsigned int pin, u16 mV) | ||
4716 | { | ||
4717 | u32 data, mask; | ||
4718 | |||
4719 | if (WARN(pin < RCAR_GP_PIN(3, 0) || pin > RCAR_GP_PIN(3, 31), "invalid pin %#x", pin)) | ||
4720 | return -EINVAL; | ||
4721 | |||
4722 | if (mV != 1800 && mV != 3300) | ||
4723 | return -EINVAL; | ||
4724 | |||
4725 | data = ioread32(pfc->windows->virt + IOCTRL6); | ||
4726 | /* Bits in IOCTRL6 are numbered in opposite order to pins */ | ||
4727 | mask = 0x80000000 >> (pin & 0x1f); | ||
4728 | |||
4729 | if (mV == 3300) | ||
4730 | data |= mask; | ||
4731 | else | ||
4732 | data &= ~mask; | ||
4733 | |||
4734 | iowrite32(~data, pfc->windows->virt); /* unlock reg */ | ||
4735 | iowrite32(data, pfc->windows->virt + IOCTRL6); | ||
4736 | |||
4737 | return 0; | ||
4738 | } | ||
4739 | |||
4694 | static const struct sh_pfc_function pinmux_functions[] = { | 4740 | static const struct sh_pfc_function pinmux_functions[] = { |
4695 | SH_PFC_FUNCTION(audio_clk), | 4741 | SH_PFC_FUNCTION(audio_clk), |
4696 | SH_PFC_FUNCTION(avb), | 4742 | SH_PFC_FUNCTION(avb), |
@@ -5690,8 +5736,14 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = { | |||
5690 | { }, | 5736 | { }, |
5691 | }; | 5737 | }; |
5692 | 5738 | ||
5739 | static const struct sh_pfc_soc_operations pinmux_ops = { | ||
5740 | .get_io_voltage = r8a7790_get_io_voltage, | ||
5741 | .set_io_voltage = r8a7790_set_io_voltage, | ||
5742 | }; | ||
5743 | |||
5693 | const struct sh_pfc_soc_info r8a7790_pinmux_info = { | 5744 | const struct sh_pfc_soc_info r8a7790_pinmux_info = { |
5694 | .name = "r8a77900_pfc", | 5745 | .name = "r8a77900_pfc", |
5746 | .ops = &pinmux_ops, | ||
5695 | .unlock_reg = 0xe6060000, /* PMMR */ | 5747 | .unlock_reg = 0xe6060000, /* PMMR */ |
5696 | 5748 | ||
5697 | .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END }, | 5749 | .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END }, |
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c index 38912cff597b..8bc2cf0c594e 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c | |||
@@ -1682,6 +1682,179 @@ static const unsigned int avb_avtp_match_b_pins[] = { | |||
1682 | static const unsigned int avb_avtp_match_b_mux[] = { | 1682 | static const unsigned int avb_avtp_match_b_mux[] = { |
1683 | AVB_AVTP_MATCH_B_MARK, | 1683 | AVB_AVTP_MATCH_B_MARK, |
1684 | }; | 1684 | }; |
1685 | /* - DU --------------------------------------------------------------------- */ | ||
1686 | static const unsigned int du0_rgb666_pins[] = { | ||
1687 | /* R[7:2], G[7:2], B[7:2] */ | ||
1688 | RCAR_GP_PIN(2, 7), RCAR_GP_PIN(2, 6), RCAR_GP_PIN(2, 5), | ||
1689 | RCAR_GP_PIN(2, 4), RCAR_GP_PIN(2, 3), RCAR_GP_PIN(2, 2), | ||
1690 | RCAR_GP_PIN(2, 15), RCAR_GP_PIN(2, 14), RCAR_GP_PIN(2, 13), | ||
1691 | RCAR_GP_PIN(2, 12), RCAR_GP_PIN(2, 11), RCAR_GP_PIN(2, 10), | ||
1692 | RCAR_GP_PIN(2, 23), RCAR_GP_PIN(2, 22), RCAR_GP_PIN(2, 21), | ||
1693 | RCAR_GP_PIN(2, 20), RCAR_GP_PIN(2, 19), RCAR_GP_PIN(2, 18), | ||
1694 | }; | ||
1695 | static const unsigned int du0_rgb666_mux[] = { | ||
1696 | DU0_DR7_MARK, DU0_DR6_MARK, DU0_DR5_MARK, DU0_DR4_MARK, | ||
1697 | DU0_DR3_MARK, DU0_DR2_MARK, | ||
1698 | DU0_DG7_MARK, DU0_DG6_MARK, DU0_DG5_MARK, DU0_DG4_MARK, | ||
1699 | DU0_DG3_MARK, DU0_DG2_MARK, | ||
1700 | DU0_DB7_MARK, DU0_DB6_MARK, DU0_DB5_MARK, DU0_DB4_MARK, | ||
1701 | DU0_DB3_MARK, DU0_DB2_MARK, | ||
1702 | }; | ||
1703 | static const unsigned int du0_rgb888_pins[] = { | ||
1704 | /* R[7:0], G[7:0], B[7:0] */ | ||
1705 | RCAR_GP_PIN(2, 7), RCAR_GP_PIN(2, 6), RCAR_GP_PIN(2, 5), | ||
1706 | RCAR_GP_PIN(2, 4), RCAR_GP_PIN(2, 3), RCAR_GP_PIN(2, 2), | ||
1707 | RCAR_GP_PIN(2, 1), RCAR_GP_PIN(2, 0), | ||
1708 | RCAR_GP_PIN(2, 15), RCAR_GP_PIN(2, 14), RCAR_GP_PIN(2, 13), | ||
1709 | RCAR_GP_PIN(2, 12), RCAR_GP_PIN(2, 11), RCAR_GP_PIN(2, 10), | ||
1710 | RCAR_GP_PIN(2, 9), RCAR_GP_PIN(2, 8), | ||
1711 | RCAR_GP_PIN(2, 23), RCAR_GP_PIN(2, 22), RCAR_GP_PIN(2, 21), | ||
1712 | RCAR_GP_PIN(2, 20), RCAR_GP_PIN(2, 19), RCAR_GP_PIN(2, 18), | ||
1713 | RCAR_GP_PIN(2, 17), RCAR_GP_PIN(2, 16), | ||
1714 | }; | ||
1715 | static const unsigned int du0_rgb888_mux[] = { | ||
1716 | DU0_DR7_MARK, DU0_DR6_MARK, DU0_DR5_MARK, DU0_DR4_MARK, | ||
1717 | DU0_DR3_MARK, DU0_DR2_MARK, DU0_DR1_MARK, DU0_DR0_MARK, | ||
1718 | DU0_DG7_MARK, DU0_DG6_MARK, DU0_DG5_MARK, DU0_DG4_MARK, | ||
1719 | DU0_DG3_MARK, DU0_DG2_MARK, DU0_DG1_MARK, DU0_DG0_MARK, | ||
1720 | DU0_DB7_MARK, DU0_DB6_MARK, DU0_DB5_MARK, DU0_DB4_MARK, | ||
1721 | DU0_DB3_MARK, DU0_DB2_MARK, DU0_DB1_MARK, DU0_DB0_MARK, | ||
1722 | }; | ||
1723 | static const unsigned int du0_clk0_out_pins[] = { | ||
1724 | /* DOTCLKOUT0 */ | ||
1725 | RCAR_GP_PIN(2, 25), | ||
1726 | }; | ||
1727 | static const unsigned int du0_clk0_out_mux[] = { | ||
1728 | DU0_DOTCLKOUT0_MARK | ||
1729 | }; | ||
1730 | static const unsigned int du0_clk1_out_pins[] = { | ||
1731 | /* DOTCLKOUT1 */ | ||
1732 | RCAR_GP_PIN(2, 26), | ||
1733 | }; | ||
1734 | static const unsigned int du0_clk1_out_mux[] = { | ||
1735 | DU0_DOTCLKOUT1_MARK | ||
1736 | }; | ||
1737 | static const unsigned int du0_clk_in_pins[] = { | ||
1738 | /* CLKIN */ | ||
1739 | RCAR_GP_PIN(2, 24), | ||
1740 | }; | ||
1741 | static const unsigned int du0_clk_in_mux[] = { | ||
1742 | DU0_DOTCLKIN_MARK | ||
1743 | }; | ||
1744 | static const unsigned int du0_sync_pins[] = { | ||
1745 | /* EXVSYNC/VSYNC, EXHSYNC/HSYNC */ | ||
1746 | RCAR_GP_PIN(2, 28), RCAR_GP_PIN(2, 27), | ||
1747 | }; | ||
1748 | static const unsigned int du0_sync_mux[] = { | ||
1749 | DU0_EXVSYNC_DU0_VSYNC_MARK, DU0_EXHSYNC_DU0_HSYNC_MARK | ||
1750 | }; | ||
1751 | static const unsigned int du0_oddf_pins[] = { | ||
1752 | /* EXODDF/ODDF/DISP/CDE */ | ||
1753 | RCAR_GP_PIN(2, 29), | ||
1754 | }; | ||
1755 | static const unsigned int du0_oddf_mux[] = { | ||
1756 | DU0_EXODDF_DU0_ODDF_DISP_CDE_MARK, | ||
1757 | }; | ||
1758 | static const unsigned int du0_cde_pins[] = { | ||
1759 | /* CDE */ | ||
1760 | RCAR_GP_PIN(2, 31), | ||
1761 | }; | ||
1762 | static const unsigned int du0_cde_mux[] = { | ||
1763 | DU0_CDE_MARK, | ||
1764 | }; | ||
1765 | static const unsigned int du0_disp_pins[] = { | ||
1766 | /* DISP */ | ||
1767 | RCAR_GP_PIN(2, 30), | ||
1768 | }; | ||
1769 | static const unsigned int du0_disp_mux[] = { | ||
1770 | DU0_DISP_MARK | ||
1771 | }; | ||
1772 | static const unsigned int du1_rgb666_pins[] = { | ||
1773 | /* R[7:2], G[7:2], B[7:2] */ | ||
1774 | RCAR_GP_PIN(4, 7), RCAR_GP_PIN(4, 6), RCAR_GP_PIN(4, 5), | ||
1775 | RCAR_GP_PIN(4, 4), RCAR_GP_PIN(4, 3), RCAR_GP_PIN(4, 2), | ||
1776 | RCAR_GP_PIN(4, 15), RCAR_GP_PIN(4, 14), RCAR_GP_PIN(4, 13), | ||
1777 | RCAR_GP_PIN(4, 12), RCAR_GP_PIN(4, 11), RCAR_GP_PIN(4, 10), | ||
1778 | RCAR_GP_PIN(4, 23), RCAR_GP_PIN(4, 22), RCAR_GP_PIN(4, 21), | ||
1779 | RCAR_GP_PIN(4, 20), RCAR_GP_PIN(4, 19), RCAR_GP_PIN(4, 18), | ||
1780 | }; | ||
1781 | static const unsigned int du1_rgb666_mux[] = { | ||
1782 | DU1_DR7_MARK, DU1_DR6_MARK, DU1_DR5_MARK, DU1_DR4_MARK, | ||
1783 | DU1_DR3_MARK, DU1_DR2_MARK, | ||
1784 | DU1_DG7_MARK, DU1_DG6_MARK, DU1_DG5_MARK, DU1_DG4_MARK, | ||
1785 | DU1_DG3_MARK, DU1_DG2_MARK, | ||
1786 | DU1_DB7_MARK, DU1_DB6_MARK, DU1_DB5_MARK, DU1_DB4_MARK, | ||
1787 | DU1_DB3_MARK, DU1_DB2_MARK, | ||
1788 | }; | ||
1789 | static const unsigned int du1_rgb888_pins[] = { | ||
1790 | /* R[7:0], G[7:0], B[7:0] */ | ||
1791 | RCAR_GP_PIN(4, 7), RCAR_GP_PIN(4, 6), RCAR_GP_PIN(4, 5), | ||
1792 | RCAR_GP_PIN(4, 4), RCAR_GP_PIN(4, 3), RCAR_GP_PIN(4, 2), | ||
1793 | RCAR_GP_PIN(4, 1), RCAR_GP_PIN(4, 0), | ||
1794 | RCAR_GP_PIN(4, 15), RCAR_GP_PIN(4, 14), RCAR_GP_PIN(4, 13), | ||
1795 | RCAR_GP_PIN(4, 12), RCAR_GP_PIN(4, 11), RCAR_GP_PIN(4, 10), | ||
1796 | RCAR_GP_PIN(4, 9), RCAR_GP_PIN(4, 8), | ||
1797 | RCAR_GP_PIN(4, 23), RCAR_GP_PIN(4, 22), RCAR_GP_PIN(4, 21), | ||
1798 | RCAR_GP_PIN(4, 20), RCAR_GP_PIN(4, 19), RCAR_GP_PIN(4, 18), | ||
1799 | RCAR_GP_PIN(4, 17), RCAR_GP_PIN(4, 16), | ||
1800 | }; | ||
1801 | static const unsigned int du1_rgb888_mux[] = { | ||
1802 | DU1_DR7_MARK, DU1_DR6_MARK, DU1_DR5_MARK, DU1_DR4_MARK, | ||
1803 | DU1_DR3_MARK, DU1_DR2_MARK, DU1_DR1_MARK, DU1_DR0_MARK, | ||
1804 | DU1_DG7_MARK, DU1_DG6_MARK, DU1_DG5_MARK, DU1_DG4_MARK, | ||
1805 | DU1_DG3_MARK, DU1_DG2_MARK, DU1_DG1_MARK, DU1_DG0_MARK, | ||
1806 | DU1_DB7_MARK, DU1_DB6_MARK, DU1_DB5_MARK, DU1_DB4_MARK, | ||
1807 | DU1_DB3_MARK, DU1_DB2_MARK, DU1_DB1_MARK, DU1_DB0_MARK, | ||
1808 | }; | ||
1809 | static const unsigned int du1_clk0_out_pins[] = { | ||
1810 | /* DOTCLKOUT0 */ | ||
1811 | RCAR_GP_PIN(4, 25), | ||
1812 | }; | ||
1813 | static const unsigned int du1_clk0_out_mux[] = { | ||
1814 | DU1_DOTCLKOUT0_MARK | ||
1815 | }; | ||
1816 | static const unsigned int du1_clk1_out_pins[] = { | ||
1817 | /* DOTCLKOUT1 */ | ||
1818 | RCAR_GP_PIN(4, 26), | ||
1819 | }; | ||
1820 | static const unsigned int du1_clk1_out_mux[] = { | ||
1821 | DU1_DOTCLKOUT1_MARK | ||
1822 | }; | ||
1823 | static const unsigned int du1_clk_in_pins[] = { | ||
1824 | /* DOTCLKIN */ | ||
1825 | RCAR_GP_PIN(4, 24), | ||
1826 | }; | ||
1827 | static const unsigned int du1_clk_in_mux[] = { | ||
1828 | DU1_DOTCLKIN_MARK | ||
1829 | }; | ||
1830 | static const unsigned int du1_sync_pins[] = { | ||
1831 | /* EXVSYNC/VSYNC, EXHSYNC/HSYNC */ | ||
1832 | RCAR_GP_PIN(4, 28), RCAR_GP_PIN(4, 27), | ||
1833 | }; | ||
1834 | static const unsigned int du1_sync_mux[] = { | ||
1835 | DU1_EXVSYNC_DU1_VSYNC_MARK, DU1_EXHSYNC_DU1_HSYNC_MARK | ||
1836 | }; | ||
1837 | static const unsigned int du1_oddf_pins[] = { | ||
1838 | /* EXODDF/ODDF/DISP/CDE */ | ||
1839 | RCAR_GP_PIN(4, 29), | ||
1840 | }; | ||
1841 | static const unsigned int du1_oddf_mux[] = { | ||
1842 | DU1_EXODDF_DU1_ODDF_DISP_CDE_MARK, | ||
1843 | }; | ||
1844 | static const unsigned int du1_cde_pins[] = { | ||
1845 | /* CDE */ | ||
1846 | RCAR_GP_PIN(4, 31), | ||
1847 | }; | ||
1848 | static const unsigned int du1_cde_mux[] = { | ||
1849 | DU1_CDE_MARK | ||
1850 | }; | ||
1851 | static const unsigned int du1_disp_pins[] = { | ||
1852 | /* DISP */ | ||
1853 | RCAR_GP_PIN(4, 30), | ||
1854 | }; | ||
1855 | static const unsigned int du1_disp_mux[] = { | ||
1856 | DU1_DISP_MARK | ||
1857 | }; | ||
1685 | /* - ETH -------------------------------------------------------------------- */ | 1858 | /* - ETH -------------------------------------------------------------------- */ |
1686 | static const unsigned int eth_link_pins[] = { | 1859 | static const unsigned int eth_link_pins[] = { |
1687 | /* LINK */ | 1860 | /* LINK */ |
@@ -3364,6 +3537,24 @@ static const struct sh_pfc_pin_group pinmux_groups[] = { | |||
3364 | SH_PFC_PIN_GROUP(avb_avtp_match), | 3537 | SH_PFC_PIN_GROUP(avb_avtp_match), |
3365 | SH_PFC_PIN_GROUP(avb_avtp_capture_b), | 3538 | SH_PFC_PIN_GROUP(avb_avtp_capture_b), |
3366 | SH_PFC_PIN_GROUP(avb_avtp_match_b), | 3539 | SH_PFC_PIN_GROUP(avb_avtp_match_b), |
3540 | SH_PFC_PIN_GROUP(du0_rgb666), | ||
3541 | SH_PFC_PIN_GROUP(du0_rgb888), | ||
3542 | SH_PFC_PIN_GROUP(du0_clk0_out), | ||
3543 | SH_PFC_PIN_GROUP(du0_clk1_out), | ||
3544 | SH_PFC_PIN_GROUP(du0_clk_in), | ||
3545 | SH_PFC_PIN_GROUP(du0_sync), | ||
3546 | SH_PFC_PIN_GROUP(du0_oddf), | ||
3547 | SH_PFC_PIN_GROUP(du0_cde), | ||
3548 | SH_PFC_PIN_GROUP(du0_disp), | ||
3549 | SH_PFC_PIN_GROUP(du1_rgb666), | ||
3550 | SH_PFC_PIN_GROUP(du1_rgb888), | ||
3551 | SH_PFC_PIN_GROUP(du1_clk0_out), | ||
3552 | SH_PFC_PIN_GROUP(du1_clk1_out), | ||
3553 | SH_PFC_PIN_GROUP(du1_clk_in), | ||
3554 | SH_PFC_PIN_GROUP(du1_sync), | ||
3555 | SH_PFC_PIN_GROUP(du1_oddf), | ||
3556 | SH_PFC_PIN_GROUP(du1_cde), | ||
3557 | SH_PFC_PIN_GROUP(du1_disp), | ||
3367 | SH_PFC_PIN_GROUP(eth_link), | 3558 | SH_PFC_PIN_GROUP(eth_link), |
3368 | SH_PFC_PIN_GROUP(eth_magic), | 3559 | SH_PFC_PIN_GROUP(eth_magic), |
3369 | SH_PFC_PIN_GROUP(eth_mdio), | 3560 | SH_PFC_PIN_GROUP(eth_mdio), |
@@ -3622,6 +3813,30 @@ static const char * const avb_groups[] = { | |||
3622 | "avb_avtp_match_b", | 3813 | "avb_avtp_match_b", |
3623 | }; | 3814 | }; |
3624 | 3815 | ||
3816 | static const char * const du0_groups[] = { | ||
3817 | "du0_rgb666", | ||
3818 | "du0_rgb888", | ||
3819 | "du0_clk0_out", | ||
3820 | "du0_clk1_out", | ||
3821 | "du0_clk_in", | ||
3822 | "du0_sync", | ||
3823 | "du0_oddf", | ||
3824 | "du0_cde", | ||
3825 | "du0_disp", | ||
3826 | }; | ||
3827 | |||
3828 | static const char * const du1_groups[] = { | ||
3829 | "du1_rgb666", | ||
3830 | "du1_rgb888", | ||
3831 | "du1_clk0_out", | ||
3832 | "du1_clk1_out", | ||
3833 | "du1_clk_in", | ||
3834 | "du1_sync", | ||
3835 | "du1_oddf", | ||
3836 | "du1_cde", | ||
3837 | "du1_disp", | ||
3838 | }; | ||
3839 | |||
3625 | static const char * const eth_groups[] = { | 3840 | static const char * const eth_groups[] = { |
3626 | "eth_link", | 3841 | "eth_link", |
3627 | "eth_magic", | 3842 | "eth_magic", |
@@ -3969,6 +4184,8 @@ static const char * const vin1_groups[] = { | |||
3969 | static const struct sh_pfc_function pinmux_functions[] = { | 4184 | static const struct sh_pfc_function pinmux_functions[] = { |
3970 | SH_PFC_FUNCTION(audio_clk), | 4185 | SH_PFC_FUNCTION(audio_clk), |
3971 | SH_PFC_FUNCTION(avb), | 4186 | SH_PFC_FUNCTION(avb), |
4187 | SH_PFC_FUNCTION(du0), | ||
4188 | SH_PFC_FUNCTION(du1), | ||
3972 | SH_PFC_FUNCTION(eth), | 4189 | SH_PFC_FUNCTION(eth), |
3973 | SH_PFC_FUNCTION(hscif0), | 4190 | SH_PFC_FUNCTION(hscif0), |
3974 | SH_PFC_FUNCTION(hscif1), | 4191 | SH_PFC_FUNCTION(hscif1), |
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c index 5979dabc02fa..44632b1a5c97 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c | |||
@@ -14,14 +14,14 @@ | |||
14 | #include "sh_pfc.h" | 14 | #include "sh_pfc.h" |
15 | 15 | ||
16 | #define CPU_ALL_PORT(fn, sfx) \ | 16 | #define CPU_ALL_PORT(fn, sfx) \ |
17 | PORT_GP_16(0, fn, sfx), \ | 17 | PORT_GP_CFG_16(0, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
18 | PORT_GP_28(1, fn, sfx), \ | 18 | PORT_GP_CFG_28(1, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
19 | PORT_GP_15(2, fn, sfx), \ | 19 | PORT_GP_CFG_15(2, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
20 | PORT_GP_16(3, fn, sfx), \ | 20 | PORT_GP_CFG_16(3, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
21 | PORT_GP_18(4, fn, sfx), \ | 21 | PORT_GP_CFG_18(4, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
22 | PORT_GP_26(5, fn, sfx), \ | 22 | PORT_GP_CFG_26(5, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
23 | PORT_GP_32(6, fn, sfx), \ | 23 | PORT_GP_CFG_32(6, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH), \ |
24 | PORT_GP_4(7, fn, sfx) | 24 | PORT_GP_CFG_4(7, fn, sfx, SH_PFC_PIN_CFG_DRIVE_STRENGTH) |
25 | /* | 25 | /* |
26 | * F_() : just information | 26 | * F_() : just information |
27 | * FM() : macro for FN_xxx / xxx_MARK | 27 | * FM() : macro for FN_xxx / xxx_MARK |
@@ -4564,6 +4564,207 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = { | |||
4564 | { }, | 4564 | { }, |
4565 | }; | 4565 | }; |
4566 | 4566 | ||
4567 | static const struct pinmux_drive_reg pinmux_drive_regs[] = { | ||
4568 | { PINMUX_DRIVE_REG("DRVCTRL3", 0xe606030c) { | ||
4569 | { RCAR_GP_PIN(2, 9), 8, 3 }, /* AVB_MDC */ | ||
4570 | { RCAR_GP_PIN(2, 10), 4, 3 }, /* AVB_MAGIC */ | ||
4571 | { RCAR_GP_PIN(2, 11), 0, 3 }, /* AVB_PHY_INT */ | ||
4572 | } }, | ||
4573 | { PINMUX_DRIVE_REG("DRVCTRL4", 0xe6060310) { | ||
4574 | { RCAR_GP_PIN(2, 12), 28, 3 }, /* AVB_LINK */ | ||
4575 | { RCAR_GP_PIN(2, 13), 24, 3 }, /* AVB_AVTP_MATCH */ | ||
4576 | { RCAR_GP_PIN(2, 14), 20, 3 }, /* AVB_AVTP_CAPTURE */ | ||
4577 | { RCAR_GP_PIN(2, 0), 16, 3 }, /* IRQ0 */ | ||
4578 | { RCAR_GP_PIN(2, 1), 12, 3 }, /* IRQ1 */ | ||
4579 | { RCAR_GP_PIN(2, 2), 8, 3 }, /* IRQ2 */ | ||
4580 | { RCAR_GP_PIN(2, 3), 4, 3 }, /* IRQ3 */ | ||
4581 | { RCAR_GP_PIN(2, 4), 0, 3 }, /* IRQ4 */ | ||
4582 | } }, | ||
4583 | { PINMUX_DRIVE_REG("DRVCTRL5", 0xe6060314) { | ||
4584 | { RCAR_GP_PIN(2, 5), 28, 3 }, /* IRQ5 */ | ||
4585 | { RCAR_GP_PIN(2, 6), 24, 3 }, /* PWM0 */ | ||
4586 | { RCAR_GP_PIN(2, 7), 20, 3 }, /* PWM1 */ | ||
4587 | { RCAR_GP_PIN(2, 8), 16, 3 }, /* PWM2 */ | ||
4588 | { RCAR_GP_PIN(1, 0), 12, 3 }, /* A0 */ | ||
4589 | { RCAR_GP_PIN(1, 1), 8, 3 }, /* A1 */ | ||
4590 | { RCAR_GP_PIN(1, 2), 4, 3 }, /* A2 */ | ||
4591 | { RCAR_GP_PIN(1, 3), 0, 3 }, /* A3 */ | ||
4592 | } }, | ||
4593 | { PINMUX_DRIVE_REG("DRVCTRL6", 0xe6060318) { | ||
4594 | { RCAR_GP_PIN(1, 4), 28, 3 }, /* A4 */ | ||
4595 | { RCAR_GP_PIN(1, 5), 24, 3 }, /* A5 */ | ||
4596 | { RCAR_GP_PIN(1, 6), 20, 3 }, /* A6 */ | ||
4597 | { RCAR_GP_PIN(1, 7), 16, 3 }, /* A7 */ | ||
4598 | { RCAR_GP_PIN(1, 8), 12, 3 }, /* A8 */ | ||
4599 | { RCAR_GP_PIN(1, 9), 8, 3 }, /* A9 */ | ||
4600 | { RCAR_GP_PIN(1, 10), 4, 3 }, /* A10 */ | ||
4601 | { RCAR_GP_PIN(1, 11), 0, 3 }, /* A11 */ | ||
4602 | } }, | ||
4603 | { PINMUX_DRIVE_REG("DRVCTRL7", 0xe606031c) { | ||
4604 | { RCAR_GP_PIN(1, 12), 28, 3 }, /* A12 */ | ||
4605 | { RCAR_GP_PIN(1, 13), 24, 3 }, /* A13 */ | ||
4606 | { RCAR_GP_PIN(1, 14), 20, 3 }, /* A14 */ | ||
4607 | { RCAR_GP_PIN(1, 15), 16, 3 }, /* A15 */ | ||
4608 | { RCAR_GP_PIN(1, 16), 12, 3 }, /* A16 */ | ||
4609 | { RCAR_GP_PIN(1, 17), 8, 3 }, /* A17 */ | ||
4610 | { RCAR_GP_PIN(1, 18), 4, 3 }, /* A18 */ | ||
4611 | { RCAR_GP_PIN(1, 19), 0, 3 }, /* A19 */ | ||
4612 | } }, | ||
4613 | { PINMUX_DRIVE_REG("DRVCTRL8", 0xe6060320) { | ||
4614 | { RCAR_GP_PIN(1, 20), 24, 3 }, /* CS0 */ | ||
4615 | { RCAR_GP_PIN(1, 21), 20, 3 }, /* CS1_A26 */ | ||
4616 | { RCAR_GP_PIN(1, 22), 16, 3 }, /* BS */ | ||
4617 | { RCAR_GP_PIN(1, 23), 12, 3 }, /* RD */ | ||
4618 | { RCAR_GP_PIN(1, 24), 8, 3 }, /* RD_WR */ | ||
4619 | { RCAR_GP_PIN(1, 25), 4, 3 }, /* WE0 */ | ||
4620 | { RCAR_GP_PIN(1, 26), 0, 3 }, /* WE1 */ | ||
4621 | } }, | ||
4622 | { PINMUX_DRIVE_REG("DRVCTRL9", 0xe6060324) { | ||
4623 | { RCAR_GP_PIN(1, 27), 28, 3 }, /* EX_WAIT0 */ | ||
4624 | { RCAR_GP_PIN(0, 0), 20, 3 }, /* D0 */ | ||
4625 | { RCAR_GP_PIN(0, 1), 16, 3 }, /* D1 */ | ||
4626 | { RCAR_GP_PIN(0, 2), 12, 3 }, /* D2 */ | ||
4627 | { RCAR_GP_PIN(0, 3), 8, 3 }, /* D3 */ | ||
4628 | { RCAR_GP_PIN(0, 4), 4, 3 }, /* D4 */ | ||
4629 | { RCAR_GP_PIN(0, 5), 0, 3 }, /* D5 */ | ||
4630 | } }, | ||
4631 | { PINMUX_DRIVE_REG("DRVCTRL10", 0xe6060328) { | ||
4632 | { RCAR_GP_PIN(0, 6), 28, 3 }, /* D6 */ | ||
4633 | { RCAR_GP_PIN(0, 7), 24, 3 }, /* D7 */ | ||
4634 | { RCAR_GP_PIN(0, 8), 20, 3 }, /* D8 */ | ||
4635 | { RCAR_GP_PIN(0, 9), 16, 3 }, /* D9 */ | ||
4636 | { RCAR_GP_PIN(0, 10), 12, 3 }, /* D10 */ | ||
4637 | { RCAR_GP_PIN(0, 11), 8, 3 }, /* D11 */ | ||
4638 | { RCAR_GP_PIN(0, 12), 4, 3 }, /* D12 */ | ||
4639 | { RCAR_GP_PIN(0, 13), 0, 3 }, /* D13 */ | ||
4640 | } }, | ||
4641 | { PINMUX_DRIVE_REG("DRVCTRL11", 0xe606032c) { | ||
4642 | { RCAR_GP_PIN(0, 14), 28, 3 }, /* D14 */ | ||
4643 | { RCAR_GP_PIN(0, 15), 24, 3 }, /* D15 */ | ||
4644 | { RCAR_GP_PIN(7, 0), 20, 3 }, /* AVS1 */ | ||
4645 | { RCAR_GP_PIN(7, 1), 16, 3 }, /* AVS2 */ | ||
4646 | { RCAR_GP_PIN(7, 2), 12, 3 }, /* HDMI0_CEC */ | ||
4647 | { RCAR_GP_PIN(7, 3), 8, 3 }, /* HDMI1_CEC */ | ||
4648 | } }, | ||
4649 | { PINMUX_DRIVE_REG("DRVCTRL13", 0xe6060334) { | ||
4650 | { RCAR_GP_PIN(3, 0), 20, 3 }, /* SD0_CLK */ | ||
4651 | { RCAR_GP_PIN(3, 1), 16, 3 }, /* SD0_CMD */ | ||
4652 | { RCAR_GP_PIN(3, 2), 12, 3 }, /* SD0_DAT0 */ | ||
4653 | { RCAR_GP_PIN(3, 3), 8, 3 }, /* SD0_DAT1 */ | ||
4654 | { RCAR_GP_PIN(3, 4), 4, 3 }, /* SD0_DAT2 */ | ||
4655 | { RCAR_GP_PIN(3, 5), 0, 3 }, /* SD0_DAT3 */ | ||
4656 | } }, | ||
4657 | { PINMUX_DRIVE_REG("DRVCTRL14", 0xe6060338) { | ||
4658 | { RCAR_GP_PIN(3, 6), 28, 3 }, /* SD1_CLK */ | ||
4659 | { RCAR_GP_PIN(3, 7), 24, 3 }, /* SD1_CMD */ | ||
4660 | { RCAR_GP_PIN(3, 8), 20, 3 }, /* SD1_DAT0 */ | ||
4661 | { RCAR_GP_PIN(3, 9), 16, 3 }, /* SD1_DAT1 */ | ||
4662 | { RCAR_GP_PIN(3, 10), 12, 3 }, /* SD1_DAT2 */ | ||
4663 | { RCAR_GP_PIN(3, 11), 8, 3 }, /* SD1_DAT3 */ | ||
4664 | { RCAR_GP_PIN(4, 0), 4, 3 }, /* SD2_CLK */ | ||
4665 | { RCAR_GP_PIN(4, 1), 0, 3 }, /* SD2_CMD */ | ||
4666 | } }, | ||
4667 | { PINMUX_DRIVE_REG("DRVCTRL15", 0xe606033c) { | ||
4668 | { RCAR_GP_PIN(4, 2), 28, 3 }, /* SD2_DAT0 */ | ||
4669 | { RCAR_GP_PIN(4, 3), 24, 3 }, /* SD2_DAT1 */ | ||
4670 | { RCAR_GP_PIN(4, 4), 20, 3 }, /* SD2_DAT2 */ | ||
4671 | { RCAR_GP_PIN(4, 5), 16, 3 }, /* SD2_DAT3 */ | ||
4672 | { RCAR_GP_PIN(4, 6), 12, 3 }, /* SD2_DS */ | ||
4673 | { RCAR_GP_PIN(4, 7), 8, 3 }, /* SD3_CLK */ | ||
4674 | { RCAR_GP_PIN(4, 8), 4, 3 }, /* SD3_CMD */ | ||
4675 | { RCAR_GP_PIN(4, 9), 0, 3 }, /* SD3_DAT0 */ | ||
4676 | } }, | ||
4677 | { PINMUX_DRIVE_REG("DRVCTRL16", 0xe6060340) { | ||
4678 | { RCAR_GP_PIN(4, 10), 28, 3 }, /* SD3_DAT1 */ | ||
4679 | { RCAR_GP_PIN(4, 11), 24, 3 }, /* SD3_DAT2 */ | ||
4680 | { RCAR_GP_PIN(4, 12), 20, 3 }, /* SD3_DAT3 */ | ||
4681 | { RCAR_GP_PIN(4, 13), 16, 3 }, /* SD3_DAT4 */ | ||
4682 | { RCAR_GP_PIN(4, 14), 12, 3 }, /* SD3_DAT5 */ | ||
4683 | { RCAR_GP_PIN(4, 15), 8, 3 }, /* SD3_DAT6 */ | ||
4684 | { RCAR_GP_PIN(4, 16), 4, 3 }, /* SD3_DAT7 */ | ||
4685 | { RCAR_GP_PIN(4, 17), 0, 3 }, /* SD3_DS */ | ||
4686 | } }, | ||
4687 | { PINMUX_DRIVE_REG("DRVCTRL17", 0xe6060344) { | ||
4688 | { RCAR_GP_PIN(3, 12), 28, 3 }, /* SD0_CD */ | ||
4689 | { RCAR_GP_PIN(3, 13), 24, 3 }, /* SD0_WP */ | ||
4690 | { RCAR_GP_PIN(3, 14), 20, 3 }, /* SD1_CD */ | ||
4691 | { RCAR_GP_PIN(3, 15), 16, 3 }, /* SD1_WP */ | ||
4692 | { RCAR_GP_PIN(5, 0), 12, 3 }, /* SCK0 */ | ||
4693 | { RCAR_GP_PIN(5, 1), 8, 3 }, /* RX0 */ | ||
4694 | { RCAR_GP_PIN(5, 2), 4, 3 }, /* TX0 */ | ||
4695 | { RCAR_GP_PIN(5, 3), 0, 3 }, /* CTS0 */ | ||
4696 | } }, | ||
4697 | { PINMUX_DRIVE_REG("DRVCTRL18", 0xe6060348) { | ||
4698 | { RCAR_GP_PIN(5, 4), 28, 3 }, /* RTS0_TANS */ | ||
4699 | { RCAR_GP_PIN(5, 5), 24, 3 }, /* RX1 */ | ||
4700 | { RCAR_GP_PIN(5, 6), 20, 3 }, /* TX1 */ | ||
4701 | { RCAR_GP_PIN(5, 7), 16, 3 }, /* CTS1 */ | ||
4702 | { RCAR_GP_PIN(5, 8), 12, 3 }, /* RTS1_TANS */ | ||
4703 | { RCAR_GP_PIN(5, 9), 8, 3 }, /* SCK2 */ | ||
4704 | { RCAR_GP_PIN(5, 10), 4, 3 }, /* TX2 */ | ||
4705 | { RCAR_GP_PIN(5, 11), 0, 3 }, /* RX2 */ | ||
4706 | } }, | ||
4707 | { PINMUX_DRIVE_REG("DRVCTRL19", 0xe606034c) { | ||
4708 | { RCAR_GP_PIN(5, 12), 28, 3 }, /* HSCK0 */ | ||
4709 | { RCAR_GP_PIN(5, 13), 24, 3 }, /* HRX0 */ | ||
4710 | { RCAR_GP_PIN(5, 14), 20, 3 }, /* HTX0 */ | ||
4711 | { RCAR_GP_PIN(5, 15), 16, 3 }, /* HCTS0 */ | ||
4712 | { RCAR_GP_PIN(5, 16), 12, 3 }, /* HRTS0 */ | ||
4713 | { RCAR_GP_PIN(5, 17), 8, 3 }, /* MSIOF0_SCK */ | ||
4714 | { RCAR_GP_PIN(5, 18), 4, 3 }, /* MSIOF0_SYNC */ | ||
4715 | { RCAR_GP_PIN(5, 19), 0, 3 }, /* MSIOF0_SS1 */ | ||
4716 | } }, | ||
4717 | { PINMUX_DRIVE_REG("DRVCTRL20", 0xe6060350) { | ||
4718 | { RCAR_GP_PIN(5, 20), 28, 3 }, /* MSIOF0_TXD */ | ||
4719 | { RCAR_GP_PIN(5, 21), 24, 3 }, /* MSIOF0_SS2 */ | ||
4720 | { RCAR_GP_PIN(5, 22), 20, 3 }, /* MSIOF0_RXD */ | ||
4721 | { RCAR_GP_PIN(5, 23), 16, 3 }, /* MLB_CLK */ | ||
4722 | { RCAR_GP_PIN(5, 24), 12, 3 }, /* MLB_SIG */ | ||
4723 | { RCAR_GP_PIN(5, 25), 8, 3 }, /* MLB_DAT */ | ||
4724 | { RCAR_GP_PIN(6, 0), 0, 3 }, /* SSI_SCK01239 */ | ||
4725 | } }, | ||
4726 | { PINMUX_DRIVE_REG("DRVCTRL21", 0xe6060354) { | ||
4727 | { RCAR_GP_PIN(6, 1), 28, 3 }, /* SSI_WS01239 */ | ||
4728 | { RCAR_GP_PIN(6, 2), 24, 3 }, /* SSI_SDATA0 */ | ||
4729 | { RCAR_GP_PIN(6, 3), 20, 3 }, /* SSI_SDATA1 */ | ||
4730 | { RCAR_GP_PIN(6, 4), 16, 3 }, /* SSI_SDATA2 */ | ||
4731 | { RCAR_GP_PIN(6, 5), 12, 3 }, /* SSI_SCK34 */ | ||
4732 | { RCAR_GP_PIN(6, 6), 8, 3 }, /* SSI_WS34 */ | ||
4733 | { RCAR_GP_PIN(6, 7), 4, 3 }, /* SSI_SDATA3 */ | ||
4734 | { RCAR_GP_PIN(6, 8), 0, 3 }, /* SSI_SCK4 */ | ||
4735 | } }, | ||
4736 | { PINMUX_DRIVE_REG("DRVCTRL22", 0xe6060358) { | ||
4737 | { RCAR_GP_PIN(6, 9), 28, 3 }, /* SSI_WS4 */ | ||
4738 | { RCAR_GP_PIN(6, 10), 24, 3 }, /* SSI_SDATA4 */ | ||
4739 | { RCAR_GP_PIN(6, 11), 20, 3 }, /* SSI_SCK5 */ | ||
4740 | { RCAR_GP_PIN(6, 12), 16, 3 }, /* SSI_WS5 */ | ||
4741 | { RCAR_GP_PIN(6, 13), 12, 3 }, /* SSI_SDATA5 */ | ||
4742 | { RCAR_GP_PIN(6, 14), 8, 3 }, /* SSI_SCK6 */ | ||
4743 | { RCAR_GP_PIN(6, 15), 4, 3 }, /* SSI_WS6 */ | ||
4744 | { RCAR_GP_PIN(6, 16), 0, 3 }, /* SSI_SDATA6 */ | ||
4745 | } }, | ||
4746 | { PINMUX_DRIVE_REG("DRVCTRL23", 0xe606035c) { | ||
4747 | { RCAR_GP_PIN(6, 17), 28, 3 }, /* SSI_SCK78 */ | ||
4748 | { RCAR_GP_PIN(6, 18), 24, 3 }, /* SSI_WS78 */ | ||
4749 | { RCAR_GP_PIN(6, 19), 20, 3 }, /* SSI_SDATA7 */ | ||
4750 | { RCAR_GP_PIN(6, 20), 16, 3 }, /* SSI_SDATA8 */ | ||
4751 | { RCAR_GP_PIN(6, 21), 12, 3 }, /* SSI_SDATA9 */ | ||
4752 | { RCAR_GP_PIN(6, 22), 8, 3 }, /* AUDIO_CLKA */ | ||
4753 | { RCAR_GP_PIN(6, 23), 4, 3 }, /* AUDIO_CLKB */ | ||
4754 | { RCAR_GP_PIN(6, 24), 0, 3 }, /* USB0_PWEN */ | ||
4755 | } }, | ||
4756 | { PINMUX_DRIVE_REG("DRVCTRL24", 0xe6060360) { | ||
4757 | { RCAR_GP_PIN(6, 25), 28, 3 }, /* USB0_OVC */ | ||
4758 | { RCAR_GP_PIN(6, 26), 24, 3 }, /* USB1_PWEN */ | ||
4759 | { RCAR_GP_PIN(6, 27), 20, 3 }, /* USB1_OVC */ | ||
4760 | { RCAR_GP_PIN(6, 28), 16, 3 }, /* USB30_PWEN */ | ||
4761 | { RCAR_GP_PIN(6, 29), 12, 3 }, /* USB30_OVC */ | ||
4762 | { RCAR_GP_PIN(6, 30), 8, 3 }, /* USB31_PWEN */ | ||
4763 | { RCAR_GP_PIN(6, 31), 4, 3 }, /* USB31_OVC */ | ||
4764 | } }, | ||
4765 | { }, | ||
4766 | }; | ||
4767 | |||
4567 | const struct sh_pfc_soc_info r8a7795_pinmux_info = { | 4768 | const struct sh_pfc_soc_info r8a7795_pinmux_info = { |
4568 | .name = "r8a77950_pfc", | 4769 | .name = "r8a77950_pfc", |
4569 | .unlock_reg = 0xe6060000, /* PMMR */ | 4770 | .unlock_reg = 0xe6060000, /* PMMR */ |
@@ -4578,6 +4779,7 @@ const struct sh_pfc_soc_info r8a7795_pinmux_info = { | |||
4578 | .nr_functions = ARRAY_SIZE(pinmux_functions), | 4779 | .nr_functions = ARRAY_SIZE(pinmux_functions), |
4579 | 4780 | ||
4580 | .cfg_regs = pinmux_config_regs, | 4781 | .cfg_regs = pinmux_config_regs, |
4782 | .drive_regs = pinmux_drive_regs, | ||
4581 | 4783 | ||
4582 | .pinmux_data = pinmux_data, | 4784 | .pinmux_data = pinmux_data, |
4583 | .pinmux_data_size = ARRAY_SIZE(pinmux_data), | 4785 | .pinmux_data_size = ARRAY_SIZE(pinmux_data), |
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 87b0a599afaf..fdb445d68b9a 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c | |||
@@ -476,6 +476,91 @@ static const struct pinmux_ops sh_pfc_pinmux_ops = { | |||
476 | .gpio_set_direction = sh_pfc_gpio_set_direction, | 476 | .gpio_set_direction = sh_pfc_gpio_set_direction, |
477 | }; | 477 | }; |
478 | 478 | ||
479 | static u32 sh_pfc_pinconf_find_drive_strength_reg(struct sh_pfc *pfc, | ||
480 | unsigned int pin, unsigned int *offset, unsigned int *size) | ||
481 | { | ||
482 | const struct pinmux_drive_reg_field *field; | ||
483 | const struct pinmux_drive_reg *reg; | ||
484 | unsigned int i; | ||
485 | |||
486 | for (reg = pfc->info->drive_regs; reg->reg; ++reg) { | ||
487 | for (i = 0; i < ARRAY_SIZE(reg->fields); ++i) { | ||
488 | field = ®->fields[i]; | ||
489 | |||
490 | if (field->size && field->pin == pin) { | ||
491 | *offset = field->offset; | ||
492 | *size = field->size; | ||
493 | |||
494 | return reg->reg; | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | |||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | static int sh_pfc_pinconf_get_drive_strength(struct sh_pfc *pfc, | ||
503 | unsigned int pin) | ||
504 | { | ||
505 | unsigned long flags; | ||
506 | unsigned int offset; | ||
507 | unsigned int size; | ||
508 | u32 reg; | ||
509 | u32 val; | ||
510 | |||
511 | reg = sh_pfc_pinconf_find_drive_strength_reg(pfc, pin, &offset, &size); | ||
512 | if (!reg) | ||
513 | return -EINVAL; | ||
514 | |||
515 | spin_lock_irqsave(&pfc->lock, flags); | ||
516 | val = sh_pfc_read_reg(pfc, reg, 32); | ||
517 | spin_unlock_irqrestore(&pfc->lock, flags); | ||
518 | |||
519 | val = (val >> offset) & GENMASK(size - 1, 0); | ||
520 | |||
521 | /* Convert the value to mA based on a full drive strength value of 24mA. | ||
522 | * We can make the full value configurable later if needed. | ||
523 | */ | ||
524 | return (val + 1) * (size == 2 ? 6 : 3); | ||
525 | } | ||
526 | |||
527 | static int sh_pfc_pinconf_set_drive_strength(struct sh_pfc *pfc, | ||
528 | unsigned int pin, u16 strength) | ||
529 | { | ||
530 | unsigned long flags; | ||
531 | unsigned int offset; | ||
532 | unsigned int size; | ||
533 | unsigned int step; | ||
534 | u32 reg; | ||
535 | u32 val; | ||
536 | |||
537 | reg = sh_pfc_pinconf_find_drive_strength_reg(pfc, pin, &offset, &size); | ||
538 | if (!reg) | ||
539 | return -EINVAL; | ||
540 | |||
541 | step = size == 2 ? 6 : 3; | ||
542 | |||
543 | if (strength < step || strength > 24) | ||
544 | return -EINVAL; | ||
545 | |||
546 | /* Convert the value from mA based on a full drive strength value of | ||
547 | * 24mA. We can make the full value configurable later if needed. | ||
548 | */ | ||
549 | strength = strength / step - 1; | ||
550 | |||
551 | spin_lock_irqsave(&pfc->lock, flags); | ||
552 | |||
553 | val = sh_pfc_read_reg(pfc, reg, 32); | ||
554 | val &= ~GENMASK(offset + size - 1, offset); | ||
555 | val |= strength << offset; | ||
556 | |||
557 | sh_pfc_write_reg(pfc, reg, 32, val); | ||
558 | |||
559 | spin_unlock_irqrestore(&pfc->lock, flags); | ||
560 | |||
561 | return 0; | ||
562 | } | ||
563 | |||
479 | /* Check whether the requested parameter is supported for a pin. */ | 564 | /* Check whether the requested parameter is supported for a pin. */ |
480 | static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin, | 565 | static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin, |
481 | enum pin_config_param param) | 566 | enum pin_config_param param) |
@@ -493,6 +578,9 @@ static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin, | |||
493 | case PIN_CONFIG_BIAS_PULL_DOWN: | 578 | case PIN_CONFIG_BIAS_PULL_DOWN: |
494 | return pin->configs & SH_PFC_PIN_CFG_PULL_DOWN; | 579 | return pin->configs & SH_PFC_PIN_CFG_PULL_DOWN; |
495 | 580 | ||
581 | case PIN_CONFIG_DRIVE_STRENGTH: | ||
582 | return pin->configs & SH_PFC_PIN_CFG_DRIVE_STRENGTH; | ||
583 | |||
496 | case PIN_CONFIG_POWER_SOURCE: | 584 | case PIN_CONFIG_POWER_SOURCE: |
497 | return pin->configs & SH_PFC_PIN_CFG_IO_VOLTAGE; | 585 | return pin->configs & SH_PFC_PIN_CFG_IO_VOLTAGE; |
498 | 586 | ||
@@ -532,6 +620,17 @@ static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin, | |||
532 | break; | 620 | break; |
533 | } | 621 | } |
534 | 622 | ||
623 | case PIN_CONFIG_DRIVE_STRENGTH: { | ||
624 | int ret; | ||
625 | |||
626 | ret = sh_pfc_pinconf_get_drive_strength(pfc, _pin); | ||
627 | if (ret < 0) | ||
628 | return ret; | ||
629 | |||
630 | *config = ret; | ||
631 | break; | ||
632 | } | ||
633 | |||
535 | case PIN_CONFIG_POWER_SOURCE: { | 634 | case PIN_CONFIG_POWER_SOURCE: { |
536 | int ret; | 635 | int ret; |
537 | 636 | ||
@@ -584,6 +683,18 @@ static int sh_pfc_pinconf_set(struct pinctrl_dev *pctldev, unsigned _pin, | |||
584 | 683 | ||
585 | break; | 684 | break; |
586 | 685 | ||
686 | case PIN_CONFIG_DRIVE_STRENGTH: { | ||
687 | unsigned int arg = | ||
688 | pinconf_to_config_argument(configs[i]); | ||
689 | int ret; | ||
690 | |||
691 | ret = sh_pfc_pinconf_set_drive_strength(pfc, _pin, arg); | ||
692 | if (ret < 0) | ||
693 | return ret; | ||
694 | |||
695 | break; | ||
696 | } | ||
697 | |||
587 | case PIN_CONFIG_POWER_SOURCE: { | 698 | case PIN_CONFIG_POWER_SOURCE: { |
588 | unsigned int arg = | 699 | unsigned int arg = |
589 | pinconf_to_config_argument(configs[i]); | 700 | pinconf_to_config_argument(configs[i]); |
@@ -678,7 +789,6 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc) | |||
678 | return -ENOMEM; | 789 | return -ENOMEM; |
679 | 790 | ||
680 | pmx->pfc = pfc; | 791 | pmx->pfc = pfc; |
681 | pfc->pinctrl = pmx; | ||
682 | 792 | ||
683 | ret = sh_pfc_map_pins(pfc, pmx); | 793 | ret = sh_pfc_map_pins(pfc, pmx); |
684 | if (ret < 0) | 794 | if (ret < 0) |
@@ -692,19 +802,9 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc) | |||
692 | pmx->pctl_desc.pins = pmx->pins; | 802 | pmx->pctl_desc.pins = pmx->pins; |
693 | pmx->pctl_desc.npins = pfc->info->nr_pins; | 803 | pmx->pctl_desc.npins = pfc->info->nr_pins; |
694 | 804 | ||
695 | pmx->pctl = pinctrl_register(&pmx->pctl_desc, pfc->dev, pmx); | 805 | pmx->pctl = devm_pinctrl_register(pfc->dev, &pmx->pctl_desc, pmx); |
696 | if (IS_ERR(pmx->pctl)) | 806 | if (IS_ERR(pmx->pctl)) |
697 | return PTR_ERR(pmx->pctl); | 807 | return PTR_ERR(pmx->pctl); |
698 | 808 | ||
699 | return 0; | 809 | return 0; |
700 | } | 810 | } |
701 | |||
702 | int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc) | ||
703 | { | ||
704 | struct sh_pfc_pinctrl *pmx = pfc->pinctrl; | ||
705 | |||
706 | pinctrl_unregister(pmx->pctl); | ||
707 | |||
708 | pfc->pinctrl = NULL; | ||
709 | return 0; | ||
710 | } | ||
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h index a490834e2089..656ea32f776c 100644 --- a/drivers/pinctrl/sh-pfc/sh_pfc.h +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h | |||
@@ -28,6 +28,7 @@ enum { | |||
28 | #define SH_PFC_PIN_CFG_PULL_UP (1 << 2) | 28 | #define SH_PFC_PIN_CFG_PULL_UP (1 << 2) |
29 | #define SH_PFC_PIN_CFG_PULL_DOWN (1 << 3) | 29 | #define SH_PFC_PIN_CFG_PULL_DOWN (1 << 3) |
30 | #define SH_PFC_PIN_CFG_IO_VOLTAGE (1 << 4) | 30 | #define SH_PFC_PIN_CFG_IO_VOLTAGE (1 << 4) |
31 | #define SH_PFC_PIN_CFG_DRIVE_STRENGTH (1 << 5) | ||
31 | #define SH_PFC_PIN_CFG_NO_GPIO (1 << 31) | 32 | #define SH_PFC_PIN_CFG_NO_GPIO (1 << 31) |
32 | 33 | ||
33 | struct sh_pfc_pin { | 34 | struct sh_pfc_pin { |
@@ -131,6 +132,21 @@ struct pinmux_cfg_reg { | |||
131 | { var_fw0, var_fwn, 0 }, \ | 132 | { var_fw0, var_fwn, 0 }, \ |
132 | .enum_ids = (const u16 []) | 133 | .enum_ids = (const u16 []) |
133 | 134 | ||
135 | struct pinmux_drive_reg_field { | ||
136 | u16 pin; | ||
137 | u8 offset; | ||
138 | u8 size; | ||
139 | }; | ||
140 | |||
141 | struct pinmux_drive_reg { | ||
142 | u32 reg; | ||
143 | const struct pinmux_drive_reg_field fields[8]; | ||
144 | }; | ||
145 | |||
146 | #define PINMUX_DRIVE_REG(name, r) \ | ||
147 | .reg = r, \ | ||
148 | .fields = | ||
149 | |||
134 | struct pinmux_data_reg { | 150 | struct pinmux_data_reg { |
135 | u32 reg; | 151 | u32 reg; |
136 | u8 reg_width; | 152 | u8 reg_width; |
@@ -199,6 +215,7 @@ struct sh_pfc_soc_info { | |||
199 | #endif | 215 | #endif |
200 | 216 | ||
201 | const struct pinmux_cfg_reg *cfg_regs; | 217 | const struct pinmux_cfg_reg *cfg_regs; |
218 | const struct pinmux_drive_reg *drive_regs; | ||
202 | const struct pinmux_data_reg *data_regs; | 219 | const struct pinmux_data_reg *data_regs; |
203 | 220 | ||
204 | const u16 *pinmux_data; | 221 | const u16 *pinmux_data; |
@@ -276,7 +293,7 @@ struct sh_pfc_soc_info { | |||
276 | * - msel: Module selector | 293 | * - msel: Module selector |
277 | */ | 294 | */ |
278 | #define PINMUX_IPSR_MSEL(ipsr, fn, msel) \ | 295 | #define PINMUX_IPSR_MSEL(ipsr, fn, msel) \ |
279 | PINMUX_DATA(fn##_MARK, FN_##msel, FN_##ipsr, FN_##fn) | 296 | PINMUX_DATA(fn##_MARK, FN_##msel, FN_##fn, FN_##ipsr) |
280 | 297 | ||
281 | /* | 298 | /* |
282 | * Describe a pinmux configuration for a single-function pin with GPIO | 299 | * Describe a pinmux configuration for a single-function pin with GPIO |
diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c index 0afaf79a4e51..4db52ba38d8d 100644 --- a/drivers/pinctrl/spear/pinctrl-spear.c +++ b/drivers/pinctrl/spear/pinctrl-spear.c | |||
@@ -395,7 +395,7 @@ int spear_pinctrl_probe(struct platform_device *pdev, | |||
395 | spear_pinctrl_desc.pins = machdata->pins; | 395 | spear_pinctrl_desc.pins = machdata->pins; |
396 | spear_pinctrl_desc.npins = machdata->npins; | 396 | spear_pinctrl_desc.npins = machdata->npins; |
397 | 397 | ||
398 | pmx->pctl = pinctrl_register(&spear_pinctrl_desc, &pdev->dev, pmx); | 398 | pmx->pctl = devm_pinctrl_register(&pdev->dev, &spear_pinctrl_desc, pmx); |
399 | if (IS_ERR(pmx->pctl)) { | 399 | if (IS_ERR(pmx->pctl)) { |
400 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 400 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
401 | return PTR_ERR(pmx->pctl); | 401 | return PTR_ERR(pmx->pctl); |
@@ -403,12 +403,3 @@ int spear_pinctrl_probe(struct platform_device *pdev, | |||
403 | 403 | ||
404 | return 0; | 404 | return 0; |
405 | } | 405 | } |
406 | |||
407 | int spear_pinctrl_remove(struct platform_device *pdev) | ||
408 | { | ||
409 | struct spear_pmx *pmx = platform_get_drvdata(pdev); | ||
410 | |||
411 | pinctrl_unregister(pmx->pctl); | ||
412 | |||
413 | return 0; | ||
414 | } | ||
diff --git a/drivers/pinctrl/spear/pinctrl-spear.h b/drivers/pinctrl/spear/pinctrl-spear.h index 27c2cc8d83ad..aa5cf7032231 100644 --- a/drivers/pinctrl/spear/pinctrl-spear.h +++ b/drivers/pinctrl/spear/pinctrl-spear.h | |||
@@ -197,7 +197,6 @@ void pmx_init_gpio_pingroup_addr(struct spear_gpio_pingroup *gpio_pingroup, | |||
197 | unsigned count, u16 reg); | 197 | unsigned count, u16 reg); |
198 | int spear_pinctrl_probe(struct platform_device *pdev, | 198 | int spear_pinctrl_probe(struct platform_device *pdev, |
199 | struct spear_pinctrl_machdata *machdata); | 199 | struct spear_pinctrl_machdata *machdata); |
200 | int spear_pinctrl_remove(struct platform_device *pdev); | ||
201 | 200 | ||
202 | #define SPEAR_PIN_0_TO_101 \ | 201 | #define SPEAR_PIN_0_TO_101 \ |
203 | PINCTRL_PIN(0, "PLGPIO0"), \ | 202 | PINCTRL_PIN(0, "PLGPIO0"), \ |
diff --git a/drivers/pinctrl/spear/pinctrl-spear1310.c b/drivers/pinctrl/spear/pinctrl-spear1310.c index 92611bb757ac..18210681c737 100644 --- a/drivers/pinctrl/spear/pinctrl-spear1310.c +++ b/drivers/pinctrl/spear/pinctrl-spear1310.c | |||
@@ -2704,18 +2704,12 @@ static int spear1310_pinctrl_probe(struct platform_device *pdev) | |||
2704 | return spear_pinctrl_probe(pdev, &spear1310_machdata); | 2704 | return spear_pinctrl_probe(pdev, &spear1310_machdata); |
2705 | } | 2705 | } |
2706 | 2706 | ||
2707 | static int spear1310_pinctrl_remove(struct platform_device *pdev) | ||
2708 | { | ||
2709 | return spear_pinctrl_remove(pdev); | ||
2710 | } | ||
2711 | |||
2712 | static struct platform_driver spear1310_pinctrl_driver = { | 2707 | static struct platform_driver spear1310_pinctrl_driver = { |
2713 | .driver = { | 2708 | .driver = { |
2714 | .name = DRIVER_NAME, | 2709 | .name = DRIVER_NAME, |
2715 | .of_match_table = spear1310_pinctrl_of_match, | 2710 | .of_match_table = spear1310_pinctrl_of_match, |
2716 | }, | 2711 | }, |
2717 | .probe = spear1310_pinctrl_probe, | 2712 | .probe = spear1310_pinctrl_probe, |
2718 | .remove = spear1310_pinctrl_remove, | ||
2719 | }; | 2713 | }; |
2720 | 2714 | ||
2721 | static int __init spear1310_pinctrl_init(void) | 2715 | static int __init spear1310_pinctrl_init(void) |
diff --git a/drivers/pinctrl/spear/pinctrl-spear1340.c b/drivers/pinctrl/spear/pinctrl-spear1340.c index f842e9dc40d0..c01fb23ee636 100644 --- a/drivers/pinctrl/spear/pinctrl-spear1340.c +++ b/drivers/pinctrl/spear/pinctrl-spear1340.c | |||
@@ -2020,18 +2020,12 @@ static int spear1340_pinctrl_probe(struct platform_device *pdev) | |||
2020 | return spear_pinctrl_probe(pdev, &spear1340_machdata); | 2020 | return spear_pinctrl_probe(pdev, &spear1340_machdata); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | static int spear1340_pinctrl_remove(struct platform_device *pdev) | ||
2024 | { | ||
2025 | return spear_pinctrl_remove(pdev); | ||
2026 | } | ||
2027 | |||
2028 | static struct platform_driver spear1340_pinctrl_driver = { | 2023 | static struct platform_driver spear1340_pinctrl_driver = { |
2029 | .driver = { | 2024 | .driver = { |
2030 | .name = DRIVER_NAME, | 2025 | .name = DRIVER_NAME, |
2031 | .of_match_table = spear1340_pinctrl_of_match, | 2026 | .of_match_table = spear1340_pinctrl_of_match, |
2032 | }, | 2027 | }, |
2033 | .probe = spear1340_pinctrl_probe, | 2028 | .probe = spear1340_pinctrl_probe, |
2034 | .remove = spear1340_pinctrl_remove, | ||
2035 | }; | 2029 | }; |
2036 | 2030 | ||
2037 | static int __init spear1340_pinctrl_init(void) | 2031 | static int __init spear1340_pinctrl_init(void) |
diff --git a/drivers/pinctrl/spear/pinctrl-spear300.c b/drivers/pinctrl/spear/pinctrl-spear300.c index d998a2ccff48..111148daa3f1 100644 --- a/drivers/pinctrl/spear/pinctrl-spear300.c +++ b/drivers/pinctrl/spear/pinctrl-spear300.c | |||
@@ -677,18 +677,12 @@ static int spear300_pinctrl_probe(struct platform_device *pdev) | |||
677 | return 0; | 677 | return 0; |
678 | } | 678 | } |
679 | 679 | ||
680 | static int spear300_pinctrl_remove(struct platform_device *pdev) | ||
681 | { | ||
682 | return spear_pinctrl_remove(pdev); | ||
683 | } | ||
684 | |||
685 | static struct platform_driver spear300_pinctrl_driver = { | 680 | static struct platform_driver spear300_pinctrl_driver = { |
686 | .driver = { | 681 | .driver = { |
687 | .name = DRIVER_NAME, | 682 | .name = DRIVER_NAME, |
688 | .of_match_table = spear300_pinctrl_of_match, | 683 | .of_match_table = spear300_pinctrl_of_match, |
689 | }, | 684 | }, |
690 | .probe = spear300_pinctrl_probe, | 685 | .probe = spear300_pinctrl_probe, |
691 | .remove = spear300_pinctrl_remove, | ||
692 | }; | 686 | }; |
693 | 687 | ||
694 | static int __init spear300_pinctrl_init(void) | 688 | static int __init spear300_pinctrl_init(void) |
diff --git a/drivers/pinctrl/spear/pinctrl-spear310.c b/drivers/pinctrl/spear/pinctrl-spear310.c index 609b18aceb16..a7b000062985 100644 --- a/drivers/pinctrl/spear/pinctrl-spear310.c +++ b/drivers/pinctrl/spear/pinctrl-spear310.c | |||
@@ -400,18 +400,12 @@ static int spear310_pinctrl_probe(struct platform_device *pdev) | |||
400 | return 0; | 400 | return 0; |
401 | } | 401 | } |
402 | 402 | ||
403 | static int spear310_pinctrl_remove(struct platform_device *pdev) | ||
404 | { | ||
405 | return spear_pinctrl_remove(pdev); | ||
406 | } | ||
407 | |||
408 | static struct platform_driver spear310_pinctrl_driver = { | 403 | static struct platform_driver spear310_pinctrl_driver = { |
409 | .driver = { | 404 | .driver = { |
410 | .name = DRIVER_NAME, | 405 | .name = DRIVER_NAME, |
411 | .of_match_table = spear310_pinctrl_of_match, | 406 | .of_match_table = spear310_pinctrl_of_match, |
412 | }, | 407 | }, |
413 | .probe = spear310_pinctrl_probe, | 408 | .probe = spear310_pinctrl_probe, |
414 | .remove = spear310_pinctrl_remove, | ||
415 | }; | 409 | }; |
416 | 410 | ||
417 | static int __init spear310_pinctrl_init(void) | 411 | static int __init spear310_pinctrl_init(void) |
diff --git a/drivers/pinctrl/spear/pinctrl-spear320.c b/drivers/pinctrl/spear/pinctrl-spear320.c index c07114431bd4..e2b3817701dc 100644 --- a/drivers/pinctrl/spear/pinctrl-spear320.c +++ b/drivers/pinctrl/spear/pinctrl-spear320.c | |||
@@ -3441,18 +3441,12 @@ static int spear320_pinctrl_probe(struct platform_device *pdev) | |||
3441 | return 0; | 3441 | return 0; |
3442 | } | 3442 | } |
3443 | 3443 | ||
3444 | static int spear320_pinctrl_remove(struct platform_device *pdev) | ||
3445 | { | ||
3446 | return spear_pinctrl_remove(pdev); | ||
3447 | } | ||
3448 | |||
3449 | static struct platform_driver spear320_pinctrl_driver = { | 3444 | static struct platform_driver spear320_pinctrl_driver = { |
3450 | .driver = { | 3445 | .driver = { |
3451 | .name = DRIVER_NAME, | 3446 | .name = DRIVER_NAME, |
3452 | .of_match_table = spear320_pinctrl_of_match, | 3447 | .of_match_table = spear320_pinctrl_of_match, |
3453 | }, | 3448 | }, |
3454 | .probe = spear320_pinctrl_probe, | 3449 | .probe = spear320_pinctrl_probe, |
3455 | .remove = spear320_pinctrl_remove, | ||
3456 | }; | 3450 | }; |
3457 | 3451 | ||
3458 | static int __init spear320_pinctrl_init(void) | 3452 | static int __init spear320_pinctrl_init(void) |
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index 8deb566ed4cd..ae9fab82a1b9 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c | |||
@@ -358,7 +358,7 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
358 | ret = stm32_pctrl_dt_subnode_to_map(pctldev, np, map, | 358 | ret = stm32_pctrl_dt_subnode_to_map(pctldev, np, map, |
359 | &reserved_maps, num_maps); | 359 | &reserved_maps, num_maps); |
360 | if (ret < 0) { | 360 | if (ret < 0) { |
361 | pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); | 361 | pinctrl_utils_free_map(pctldev, *map, *num_maps); |
362 | return ret; | 362 | return ret; |
363 | } | 363 | } |
364 | } | 364 | } |
@@ -396,7 +396,7 @@ static int stm32_pctrl_get_group_pins(struct pinctrl_dev *pctldev, | |||
396 | 396 | ||
397 | static const struct pinctrl_ops stm32_pctrl_ops = { | 397 | static const struct pinctrl_ops stm32_pctrl_ops = { |
398 | .dt_node_to_map = stm32_pctrl_dt_node_to_map, | 398 | .dt_node_to_map = stm32_pctrl_dt_node_to_map, |
399 | .dt_free_map = pinctrl_utils_dt_free_map, | 399 | .dt_free_map = pinctrl_utils_free_map, |
400 | .get_groups_count = stm32_pctrl_get_groups_count, | 400 | .get_groups_count = stm32_pctrl_get_groups_count, |
401 | .get_group_name = stm32_pctrl_get_group_name, | 401 | .get_group_name = stm32_pctrl_get_group_name, |
402 | .get_group_pins = stm32_pctrl_get_group_pins, | 402 | .get_group_pins = stm32_pctrl_get_group_pins, |
@@ -454,6 +454,29 @@ static void stm32_pmx_set_mode(struct stm32_gpio_bank *bank, | |||
454 | clk_disable(bank->clk); | 454 | clk_disable(bank->clk); |
455 | } | 455 | } |
456 | 456 | ||
457 | static void stm32_pmx_get_mode(struct stm32_gpio_bank *bank, | ||
458 | int pin, u32 *mode, u32 *alt) | ||
459 | { | ||
460 | u32 val; | ||
461 | int alt_shift = (pin % 8) * 4; | ||
462 | int alt_offset = STM32_GPIO_AFRL + (pin / 8) * 4; | ||
463 | unsigned long flags; | ||
464 | |||
465 | clk_enable(bank->clk); | ||
466 | spin_lock_irqsave(&bank->lock, flags); | ||
467 | |||
468 | val = readl_relaxed(bank->base + alt_offset); | ||
469 | val &= GENMASK(alt_shift + 3, alt_shift); | ||
470 | *alt = val >> alt_shift; | ||
471 | |||
472 | val = readl_relaxed(bank->base + STM32_GPIO_MODER); | ||
473 | val &= GENMASK(pin * 2 + 1, pin * 2); | ||
474 | *mode = val >> (pin * 2); | ||
475 | |||
476 | spin_unlock_irqrestore(&bank->lock, flags); | ||
477 | clk_disable(bank->clk); | ||
478 | } | ||
479 | |||
457 | static int stm32_pmx_set_mux(struct pinctrl_dev *pctldev, | 480 | static int stm32_pmx_set_mux(struct pinctrl_dev *pctldev, |
458 | unsigned function, | 481 | unsigned function, |
459 | unsigned group) | 482 | unsigned group) |
@@ -525,6 +548,24 @@ static void stm32_pconf_set_driving(struct stm32_gpio_bank *bank, | |||
525 | clk_disable(bank->clk); | 548 | clk_disable(bank->clk); |
526 | } | 549 | } |
527 | 550 | ||
551 | static u32 stm32_pconf_get_driving(struct stm32_gpio_bank *bank, | ||
552 | unsigned int offset) | ||
553 | { | ||
554 | unsigned long flags; | ||
555 | u32 val; | ||
556 | |||
557 | clk_enable(bank->clk); | ||
558 | spin_lock_irqsave(&bank->lock, flags); | ||
559 | |||
560 | val = readl_relaxed(bank->base + STM32_GPIO_TYPER); | ||
561 | val &= BIT(offset); | ||
562 | |||
563 | spin_unlock_irqrestore(&bank->lock, flags); | ||
564 | clk_disable(bank->clk); | ||
565 | |||
566 | return (val >> offset); | ||
567 | } | ||
568 | |||
528 | static void stm32_pconf_set_speed(struct stm32_gpio_bank *bank, | 569 | static void stm32_pconf_set_speed(struct stm32_gpio_bank *bank, |
529 | unsigned offset, u32 speed) | 570 | unsigned offset, u32 speed) |
530 | { | 571 | { |
@@ -543,6 +584,24 @@ static void stm32_pconf_set_speed(struct stm32_gpio_bank *bank, | |||
543 | clk_disable(bank->clk); | 584 | clk_disable(bank->clk); |
544 | } | 585 | } |
545 | 586 | ||
587 | static u32 stm32_pconf_get_speed(struct stm32_gpio_bank *bank, | ||
588 | unsigned int offset) | ||
589 | { | ||
590 | unsigned long flags; | ||
591 | u32 val; | ||
592 | |||
593 | clk_enable(bank->clk); | ||
594 | spin_lock_irqsave(&bank->lock, flags); | ||
595 | |||
596 | val = readl_relaxed(bank->base + STM32_GPIO_SPEEDR); | ||
597 | val &= GENMASK(offset * 2 + 1, offset * 2); | ||
598 | |||
599 | spin_unlock_irqrestore(&bank->lock, flags); | ||
600 | clk_disable(bank->clk); | ||
601 | |||
602 | return (val >> (offset * 2)); | ||
603 | } | ||
604 | |||
546 | static void stm32_pconf_set_bias(struct stm32_gpio_bank *bank, | 605 | static void stm32_pconf_set_bias(struct stm32_gpio_bank *bank, |
547 | unsigned offset, u32 bias) | 606 | unsigned offset, u32 bias) |
548 | { | 607 | { |
@@ -561,6 +620,57 @@ static void stm32_pconf_set_bias(struct stm32_gpio_bank *bank, | |||
561 | clk_disable(bank->clk); | 620 | clk_disable(bank->clk); |
562 | } | 621 | } |
563 | 622 | ||
623 | static u32 stm32_pconf_get_bias(struct stm32_gpio_bank *bank, | ||
624 | unsigned int offset) | ||
625 | { | ||
626 | unsigned long flags; | ||
627 | u32 val; | ||
628 | |||
629 | clk_enable(bank->clk); | ||
630 | spin_lock_irqsave(&bank->lock, flags); | ||
631 | |||
632 | val = readl_relaxed(bank->base + STM32_GPIO_PUPDR); | ||
633 | val &= GENMASK(offset * 2 + 1, offset * 2); | ||
634 | |||
635 | spin_unlock_irqrestore(&bank->lock, flags); | ||
636 | clk_disable(bank->clk); | ||
637 | |||
638 | return (val >> (offset * 2)); | ||
639 | } | ||
640 | |||
641 | static bool stm32_pconf_input_get(struct stm32_gpio_bank *bank, | ||
642 | unsigned int offset) | ||
643 | { | ||
644 | unsigned long flags; | ||
645 | u32 val; | ||
646 | |||
647 | clk_enable(bank->clk); | ||
648 | spin_lock_irqsave(&bank->lock, flags); | ||
649 | |||
650 | val = !!(readl_relaxed(bank->base + STM32_GPIO_IDR) & BIT(offset)); | ||
651 | |||
652 | spin_unlock_irqrestore(&bank->lock, flags); | ||
653 | clk_disable(bank->clk); | ||
654 | |||
655 | return val; | ||
656 | } | ||
657 | |||
658 | static bool stm32_pconf_output_get(struct stm32_gpio_bank *bank, | ||
659 | unsigned int offset) | ||
660 | { | ||
661 | unsigned long flags; | ||
662 | u32 val; | ||
663 | |||
664 | clk_enable(bank->clk); | ||
665 | spin_lock_irqsave(&bank->lock, flags); | ||
666 | val = !!(readl_relaxed(bank->base + STM32_GPIO_ODR) & BIT(offset)); | ||
667 | |||
668 | spin_unlock_irqrestore(&bank->lock, flags); | ||
669 | clk_disable(bank->clk); | ||
670 | |||
671 | return val; | ||
672 | } | ||
673 | |||
564 | static int stm32_pconf_parse_conf(struct pinctrl_dev *pctldev, | 674 | static int stm32_pconf_parse_conf(struct pinctrl_dev *pctldev, |
565 | unsigned int pin, enum pin_config_param param, | 675 | unsigned int pin, enum pin_config_param param, |
566 | enum pin_config_param arg) | 676 | enum pin_config_param arg) |
@@ -634,9 +744,73 @@ static int stm32_pconf_group_set(struct pinctrl_dev *pctldev, unsigned group, | |||
634 | return 0; | 744 | return 0; |
635 | } | 745 | } |
636 | 746 | ||
747 | static void stm32_pconf_dbg_show(struct pinctrl_dev *pctldev, | ||
748 | struct seq_file *s, | ||
749 | unsigned int pin) | ||
750 | { | ||
751 | struct pinctrl_gpio_range *range; | ||
752 | struct stm32_gpio_bank *bank; | ||
753 | int offset; | ||
754 | u32 mode, alt, drive, speed, bias; | ||
755 | static const char * const modes[] = { | ||
756 | "input", "output", "alternate", "analog" }; | ||
757 | static const char * const speeds[] = { | ||
758 | "low", "medium", "high", "very high" }; | ||
759 | static const char * const biasing[] = { | ||
760 | "floating", "pull up", "pull down", "" }; | ||
761 | bool val; | ||
762 | |||
763 | range = pinctrl_find_gpio_range_from_pin_nolock(pctldev, pin); | ||
764 | bank = gpio_range_to_bank(range); | ||
765 | offset = stm32_gpio_pin(pin); | ||
766 | |||
767 | stm32_pmx_get_mode(bank, offset, &mode, &alt); | ||
768 | bias = stm32_pconf_get_bias(bank, offset); | ||
769 | |||
770 | seq_printf(s, "%s ", modes[mode]); | ||
771 | |||
772 | switch (mode) { | ||
773 | /* input */ | ||
774 | case 0: | ||
775 | val = stm32_pconf_input_get(bank, offset); | ||
776 | seq_printf(s, "- %s - %s", | ||
777 | val ? "high" : "low", | ||
778 | biasing[bias]); | ||
779 | break; | ||
780 | |||
781 | /* output */ | ||
782 | case 1: | ||
783 | drive = stm32_pconf_get_driving(bank, offset); | ||
784 | speed = stm32_pconf_get_speed(bank, offset); | ||
785 | val = stm32_pconf_output_get(bank, offset); | ||
786 | seq_printf(s, "- %s - %s - %s - %s %s", | ||
787 | val ? "high" : "low", | ||
788 | drive ? "open drain" : "push pull", | ||
789 | biasing[bias], | ||
790 | speeds[speed], "speed"); | ||
791 | break; | ||
792 | |||
793 | /* alternate */ | ||
794 | case 2: | ||
795 | drive = stm32_pconf_get_driving(bank, offset); | ||
796 | speed = stm32_pconf_get_speed(bank, offset); | ||
797 | seq_printf(s, "%d - %s - %s - %s %s", alt, | ||
798 | drive ? "open drain" : "push pull", | ||
799 | biasing[bias], | ||
800 | speeds[speed], "speed"); | ||
801 | break; | ||
802 | |||
803 | /* analog */ | ||
804 | case 3: | ||
805 | break; | ||
806 | } | ||
807 | } | ||
808 | |||
809 | |||
637 | static const struct pinconf_ops stm32_pconf_ops = { | 810 | static const struct pinconf_ops stm32_pconf_ops = { |
638 | .pin_config_group_get = stm32_pconf_group_get, | 811 | .pin_config_group_get = stm32_pconf_group_get, |
639 | .pin_config_group_set = stm32_pconf_group_set, | 812 | .pin_config_group_set = stm32_pconf_group_set, |
813 | .pin_config_dbg_show = stm32_pconf_dbg_show, | ||
640 | }; | 814 | }; |
641 | 815 | ||
642 | static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, | 816 | static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, |
@@ -813,10 +987,11 @@ int stm32_pctl_probe(struct platform_device *pdev) | |||
813 | pctl->pctl_desc.pmxops = &stm32_pmx_ops; | 987 | pctl->pctl_desc.pmxops = &stm32_pmx_ops; |
814 | pctl->dev = &pdev->dev; | 988 | pctl->dev = &pdev->dev; |
815 | 989 | ||
816 | pctl->pctl_dev = pinctrl_register(&pctl->pctl_desc, &pdev->dev, pctl); | 990 | pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->pctl_desc, |
817 | if (!pctl->pctl_dev) { | 991 | pctl); |
992 | if (IS_ERR(pctl->pctl_dev)) { | ||
818 | dev_err(&pdev->dev, "Failed pinctrl registration\n"); | 993 | dev_err(&pdev->dev, "Failed pinctrl registration\n"); |
819 | return -EINVAL; | 994 | return PTR_ERR(pctl->pctl_dev); |
820 | } | 995 | } |
821 | 996 | ||
822 | for (i = 0; i < pctl->nbanks; i++) | 997 | for (i = 0; i < pctl->nbanks; i++) |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 3b017dbd289c..54455af566ec 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c | |||
@@ -933,18 +933,15 @@ int sunxi_pinctrl_init(struct platform_device *pdev, | |||
933 | pctrl_desc->pctlops = &sunxi_pctrl_ops; | 933 | pctrl_desc->pctlops = &sunxi_pctrl_ops; |
934 | pctrl_desc->pmxops = &sunxi_pmx_ops; | 934 | pctrl_desc->pmxops = &sunxi_pmx_ops; |
935 | 935 | ||
936 | pctl->pctl_dev = pinctrl_register(pctrl_desc, | 936 | pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl); |
937 | &pdev->dev, pctl); | ||
938 | if (IS_ERR(pctl->pctl_dev)) { | 937 | if (IS_ERR(pctl->pctl_dev)) { |
939 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); | 938 | dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); |
940 | return PTR_ERR(pctl->pctl_dev); | 939 | return PTR_ERR(pctl->pctl_dev); |
941 | } | 940 | } |
942 | 941 | ||
943 | pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL); | 942 | pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL); |
944 | if (!pctl->chip) { | 943 | if (!pctl->chip) |
945 | ret = -ENOMEM; | 944 | return -ENOMEM; |
946 | goto pinctrl_error; | ||
947 | } | ||
948 | 945 | ||
949 | last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number; | 946 | last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number; |
950 | pctl->chip->owner = THIS_MODULE; | 947 | pctl->chip->owner = THIS_MODULE; |
@@ -966,7 +963,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, | |||
966 | 963 | ||
967 | ret = gpiochip_add_data(pctl->chip, pctl); | 964 | ret = gpiochip_add_data(pctl->chip, pctl); |
968 | if (ret) | 965 | if (ret) |
969 | goto pinctrl_error; | 966 | return ret; |
970 | 967 | ||
971 | for (i = 0; i < pctl->desc->npins; i++) { | 968 | for (i = 0; i < pctl->desc->npins; i++) { |
972 | const struct sunxi_desc_pin *pin = pctl->desc->pins + i; | 969 | const struct sunxi_desc_pin *pin = pctl->desc->pins + i; |
@@ -1044,7 +1041,5 @@ clk_error: | |||
1044 | clk_disable_unprepare(clk); | 1041 | clk_disable_unprepare(clk); |
1045 | gpiochip_error: | 1042 | gpiochip_error: |
1046 | gpiochip_remove(pctl->chip); | 1043 | gpiochip_remove(pctl->chip); |
1047 | pinctrl_error: | ||
1048 | pinctrl_unregister(pctl->pctl_dev); | ||
1049 | return ret; | 1044 | return ret; |
1050 | } | 1045 | } |
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c index 946cda3fee35..6f68a9eebc58 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | |||
@@ -267,7 +267,7 @@ static const struct pinctrl_ops tegra_xusb_padctl_pinctrl_ops = { | |||
267 | .get_group_name = tegra_xusb_padctl_get_group_name, | 267 | .get_group_name = tegra_xusb_padctl_get_group_name, |
268 | .get_group_pins = tegra_xusb_padctl_get_group_pins, | 268 | .get_group_pins = tegra_xusb_padctl_get_group_pins, |
269 | .dt_node_to_map = tegra_xusb_padctl_dt_node_to_map, | 269 | .dt_node_to_map = tegra_xusb_padctl_dt_node_to_map, |
270 | .dt_free_map = pinctrl_utils_dt_free_map, | 270 | .dt_free_map = pinctrl_utils_free_map, |
271 | }; | 271 | }; |
272 | 272 | ||
273 | static int tegra_xusb_padctl_get_functions_count(struct pinctrl_dev *pinctrl) | 273 | static int tegra_xusb_padctl_get_functions_count(struct pinctrl_dev *pinctrl) |
@@ -914,7 +914,8 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev) | |||
914 | padctl->desc.confops = &tegra_xusb_padctl_pinconf_ops; | 914 | padctl->desc.confops = &tegra_xusb_padctl_pinconf_ops; |
915 | padctl->desc.owner = THIS_MODULE; | 915 | padctl->desc.owner = THIS_MODULE; |
916 | 916 | ||
917 | padctl->pinctrl = pinctrl_register(&padctl->desc, &pdev->dev, padctl); | 917 | padctl->pinctrl = devm_pinctrl_register(&pdev->dev, &padctl->desc, |
918 | padctl); | ||
918 | if (IS_ERR(padctl->pinctrl)) { | 919 | if (IS_ERR(padctl->pinctrl)) { |
919 | dev_err(&pdev->dev, "failed to register pincontrol\n"); | 920 | dev_err(&pdev->dev, "failed to register pincontrol\n"); |
920 | err = PTR_ERR(padctl->pinctrl); | 921 | err = PTR_ERR(padctl->pinctrl); |
@@ -924,7 +925,7 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev) | |||
924 | phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops); | 925 | phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops); |
925 | if (IS_ERR(phy)) { | 926 | if (IS_ERR(phy)) { |
926 | err = PTR_ERR(phy); | 927 | err = PTR_ERR(phy); |
927 | goto unregister; | 928 | goto reset; |
928 | } | 929 | } |
929 | 930 | ||
930 | padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy; | 931 | padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy; |
@@ -933,7 +934,7 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev) | |||
933 | phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops); | 934 | phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops); |
934 | if (IS_ERR(phy)) { | 935 | if (IS_ERR(phy)) { |
935 | err = PTR_ERR(phy); | 936 | err = PTR_ERR(phy); |
936 | goto unregister; | 937 | goto reset; |
937 | } | 938 | } |
938 | 939 | ||
939 | padctl->phys[TEGRA_XUSB_PADCTL_SATA] = phy; | 940 | padctl->phys[TEGRA_XUSB_PADCTL_SATA] = phy; |
@@ -944,13 +945,11 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev) | |||
944 | if (IS_ERR(padctl->provider)) { | 945 | if (IS_ERR(padctl->provider)) { |
945 | err = PTR_ERR(padctl->provider); | 946 | err = PTR_ERR(padctl->provider); |
946 | dev_err(&pdev->dev, "failed to register PHYs: %d\n", err); | 947 | dev_err(&pdev->dev, "failed to register PHYs: %d\n", err); |
947 | goto unregister; | 948 | goto reset; |
948 | } | 949 | } |
949 | 950 | ||
950 | return 0; | 951 | return 0; |
951 | 952 | ||
952 | unregister: | ||
953 | pinctrl_unregister(padctl->pinctrl); | ||
954 | reset: | 953 | reset: |
955 | reset_control_assert(padctl->rst); | 954 | reset_control_assert(padctl->rst); |
956 | return err; | 955 | return err; |
@@ -962,8 +961,6 @@ int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev) | |||
962 | struct tegra_xusb_padctl *padctl = platform_get_drvdata(pdev); | 961 | struct tegra_xusb_padctl *padctl = platform_get_drvdata(pdev); |
963 | int err; | 962 | int err; |
964 | 963 | ||
965 | pinctrl_unregister(padctl->pinctrl); | ||
966 | |||
967 | err = reset_control_assert(padctl->rst); | 964 | err = reset_control_assert(padctl->rst); |
968 | if (err < 0) | 965 | if (err < 0) |
969 | dev_err(&pdev->dev, "failed to assert reset: %d\n", err); | 966 | dev_err(&pdev->dev, "failed to assert reset: %d\n", err); |
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c index 49388822c0e9..6e82b290cb4f 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra.c | |||
@@ -215,7 +215,7 @@ static int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
215 | ret = tegra_pinctrl_dt_subnode_to_map(pctldev, np, map, | 215 | ret = tegra_pinctrl_dt_subnode_to_map(pctldev, np, map, |
216 | &reserved_maps, num_maps); | 216 | &reserved_maps, num_maps); |
217 | if (ret < 0) { | 217 | if (ret < 0) { |
218 | pinctrl_utils_dt_free_map(pctldev, *map, | 218 | pinctrl_utils_free_map(pctldev, *map, |
219 | *num_maps); | 219 | *num_maps); |
220 | of_node_put(np); | 220 | of_node_put(np); |
221 | return ret; | 221 | return ret; |
@@ -233,7 +233,7 @@ static const struct pinctrl_ops tegra_pinctrl_ops = { | |||
233 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, | 233 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, |
234 | #endif | 234 | #endif |
235 | .dt_node_to_map = tegra_pinctrl_dt_node_to_map, | 235 | .dt_node_to_map = tegra_pinctrl_dt_node_to_map, |
236 | .dt_free_map = pinctrl_utils_dt_free_map, | 236 | .dt_free_map = pinctrl_utils_free_map, |
237 | }; | 237 | }; |
238 | 238 | ||
239 | static int tegra_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) | 239 | static int tegra_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) |
@@ -417,7 +417,7 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx, | |||
417 | return -ENOTSUPP; | 417 | return -ENOTSUPP; |
418 | } | 418 | } |
419 | 419 | ||
420 | if (*reg < 0 || *bit > 31) { | 420 | if (*reg < 0 || *bit < 0) { |
421 | if (report_err) { | 421 | if (report_err) { |
422 | const char *prop = "unknown"; | 422 | const char *prop = "unknown"; |
423 | int i; | 423 | int i; |
@@ -625,6 +625,22 @@ static struct pinctrl_desc tegra_pinctrl_desc = { | |||
625 | .owner = THIS_MODULE, | 625 | .owner = THIS_MODULE, |
626 | }; | 626 | }; |
627 | 627 | ||
628 | static void tegra_pinctrl_clear_parked_bits(struct tegra_pmx *pmx) | ||
629 | { | ||
630 | int i = 0; | ||
631 | const struct tegra_pingroup *g; | ||
632 | u32 val; | ||
633 | |||
634 | for (i = 0; i < pmx->soc->ngroups; ++i) { | ||
635 | if (pmx->soc->groups[i].parked_reg >= 0) { | ||
636 | g = &pmx->soc->groups[i]; | ||
637 | val = pmx_readl(pmx, g->parked_bank, g->parked_reg); | ||
638 | val &= ~(1 << g->parked_bit); | ||
639 | pmx_writel(pmx, val, g->parked_bank, g->parked_reg); | ||
640 | } | ||
641 | } | ||
642 | } | ||
643 | |||
628 | static bool gpio_node_has_range(void) | 644 | static bool gpio_node_has_range(void) |
629 | { | 645 | { |
630 | struct device_node *np; | 646 | struct device_node *np; |
@@ -719,12 +735,14 @@ int tegra_pinctrl_probe(struct platform_device *pdev, | |||
719 | return PTR_ERR(pmx->regs[i]); | 735 | return PTR_ERR(pmx->regs[i]); |
720 | } | 736 | } |
721 | 737 | ||
722 | pmx->pctl = pinctrl_register(&tegra_pinctrl_desc, &pdev->dev, pmx); | 738 | pmx->pctl = devm_pinctrl_register(&pdev->dev, &tegra_pinctrl_desc, pmx); |
723 | if (IS_ERR(pmx->pctl)) { | 739 | if (IS_ERR(pmx->pctl)) { |
724 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); | 740 | dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); |
725 | return PTR_ERR(pmx->pctl); | 741 | return PTR_ERR(pmx->pctl); |
726 | } | 742 | } |
727 | 743 | ||
744 | tegra_pinctrl_clear_parked_bits(pmx); | ||
745 | |||
728 | if (!gpio_node_has_range()) | 746 | if (!gpio_node_has_range()) |
729 | pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range); | 747 | pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range); |
730 | 748 | ||
@@ -735,13 +753,3 @@ int tegra_pinctrl_probe(struct platform_device *pdev, | |||
735 | return 0; | 753 | return 0; |
736 | } | 754 | } |
737 | EXPORT_SYMBOL_GPL(tegra_pinctrl_probe); | 755 | EXPORT_SYMBOL_GPL(tegra_pinctrl_probe); |
738 | |||
739 | int tegra_pinctrl_remove(struct platform_device *pdev) | ||
740 | { | ||
741 | struct tegra_pmx *pmx = platform_get_drvdata(pdev); | ||
742 | |||
743 | pinctrl_unregister(pmx->pctl); | ||
744 | |||
745 | return 0; | ||
746 | } | ||
747 | EXPORT_SYMBOL_GPL(tegra_pinctrl_remove); | ||
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.h b/drivers/pinctrl/tegra/pinctrl-tegra.h index 1615db7e3a4b..d2ced17382b5 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra.h +++ b/drivers/pinctrl/tegra/pinctrl-tegra.h | |||
@@ -93,6 +93,9 @@ struct tegra_function { | |||
93 | * @tri_reg: Tri-state register offset. | 93 | * @tri_reg: Tri-state register offset. |
94 | * @tri_bank: Tri-state register bank. | 94 | * @tri_bank: Tri-state register bank. |
95 | * @tri_bit: Tri-state register bit. | 95 | * @tri_bit: Tri-state register bit. |
96 | * @parked_reg: Parked register offset. -1 if unsupported. | ||
97 | * @parked_bank: Parked register bank. 0 if unsupported. | ||
98 | * @parked_bit: Parked register bit. 0 if unsupported. | ||
96 | * @einput_bit: Enable-input register bit. | 99 | * @einput_bit: Enable-input register bit. |
97 | * @odrain_bit: Open-drain register bit. | 100 | * @odrain_bit: Open-drain register bit. |
98 | * @lock_bit: Lock register bit. | 101 | * @lock_bit: Lock register bit. |
@@ -135,13 +138,16 @@ struct tegra_pingroup { | |||
135 | s16 pupd_reg; | 138 | s16 pupd_reg; |
136 | s16 tri_reg; | 139 | s16 tri_reg; |
137 | s16 drv_reg; | 140 | s16 drv_reg; |
141 | s16 parked_reg; | ||
138 | u32 mux_bank:2; | 142 | u32 mux_bank:2; |
139 | u32 pupd_bank:2; | 143 | u32 pupd_bank:2; |
140 | u32 tri_bank:2; | 144 | u32 tri_bank:2; |
141 | u32 drv_bank:2; | 145 | u32 drv_bank:2; |
146 | u32 parked_bank:2; | ||
142 | s32 mux_bit:6; | 147 | s32 mux_bit:6; |
143 | s32 pupd_bit:6; | 148 | s32 pupd_bit:6; |
144 | s32 tri_bit:6; | 149 | s32 tri_bit:6; |
150 | s32 parked_bit:6; | ||
145 | s32 einput_bit:6; | 151 | s32 einput_bit:6; |
146 | s32 odrain_bit:6; | 152 | s32 odrain_bit:6; |
147 | s32 lock_bit:6; | 153 | s32 lock_bit:6; |
@@ -189,6 +195,4 @@ struct tegra_pinctrl_soc_data { | |||
189 | 195 | ||
190 | int tegra_pinctrl_probe(struct platform_device *pdev, | 196 | int tegra_pinctrl_probe(struct platform_device *pdev, |
191 | const struct tegra_pinctrl_soc_data *soc_data); | 197 | const struct tegra_pinctrl_soc_data *soc_data); |
192 | int tegra_pinctrl_remove(struct platform_device *pdev); | ||
193 | |||
194 | #endif | 198 | #endif |
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra114.c b/drivers/pinctrl/tegra/pinctrl-tegra114.c index 05e49d5137ab..4851d169f4c7 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra114.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra114.c | |||
@@ -1578,6 +1578,7 @@ static struct tegra_function tegra114_functions[] = { | |||
1578 | .lock_bit = 7, \ | 1578 | .lock_bit = 7, \ |
1579 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ | 1579 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ |
1580 | .rcv_sel_bit = PINGROUP_BIT_##rcv_sel(9), \ | 1580 | .rcv_sel_bit = PINGROUP_BIT_##rcv_sel(9), \ |
1581 | .parked_reg = -1, \ | ||
1581 | .drv_reg = -1, \ | 1582 | .drv_reg = -1, \ |
1582 | } | 1583 | } |
1583 | 1584 | ||
@@ -1598,6 +1599,7 @@ static struct tegra_function tegra114_functions[] = { | |||
1598 | .rcv_sel_bit = -1, \ | 1599 | .rcv_sel_bit = -1, \ |
1599 | .drv_reg = DRV_PINGROUP_REG(r), \ | 1600 | .drv_reg = DRV_PINGROUP_REG(r), \ |
1600 | .drv_bank = 0, \ | 1601 | .drv_bank = 0, \ |
1602 | .parked_reg = -1, \ | ||
1601 | .hsm_bit = hsm_b, \ | 1603 | .hsm_bit = hsm_b, \ |
1602 | .schmitt_bit = schmitt_b, \ | 1604 | .schmitt_bit = schmitt_b, \ |
1603 | .lpmd_bit = lpmd_b, \ | 1605 | .lpmd_bit = lpmd_b, \ |
@@ -1863,7 +1865,6 @@ static struct platform_driver tegra114_pinctrl_driver = { | |||
1863 | .of_match_table = tegra114_pinctrl_of_match, | 1865 | .of_match_table = tegra114_pinctrl_of_match, |
1864 | }, | 1866 | }, |
1865 | .probe = tegra114_pinctrl_probe, | 1867 | .probe = tegra114_pinctrl_probe, |
1866 | .remove = tegra_pinctrl_remove, | ||
1867 | }; | 1868 | }; |
1868 | module_platform_driver(tegra114_pinctrl_driver); | 1869 | module_platform_driver(tegra114_pinctrl_driver); |
1869 | 1870 | ||
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra124.c b/drivers/pinctrl/tegra/pinctrl-tegra124.c index 7cd44c7c296d..a0ce723a9482 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra124.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra124.c | |||
@@ -1747,6 +1747,7 @@ static struct tegra_function tegra124_functions[] = { | |||
1747 | .lock_bit = 7, \ | 1747 | .lock_bit = 7, \ |
1748 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ | 1748 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ |
1749 | .rcv_sel_bit = PINGROUP_BIT_##rcv_sel(9), \ | 1749 | .rcv_sel_bit = PINGROUP_BIT_##rcv_sel(9), \ |
1750 | .parked_reg = -1, \ | ||
1750 | .drv_reg = -1, \ | 1751 | .drv_reg = -1, \ |
1751 | } | 1752 | } |
1752 | 1753 | ||
@@ -1767,6 +1768,7 @@ static struct tegra_function tegra124_functions[] = { | |||
1767 | .rcv_sel_bit = -1, \ | 1768 | .rcv_sel_bit = -1, \ |
1768 | .drv_reg = DRV_PINGROUP_REG(r), \ | 1769 | .drv_reg = DRV_PINGROUP_REG(r), \ |
1769 | .drv_bank = 0, \ | 1770 | .drv_bank = 0, \ |
1771 | .parked_reg = -1, \ | ||
1770 | .hsm_bit = hsm_b, \ | 1772 | .hsm_bit = hsm_b, \ |
1771 | .schmitt_bit = schmitt_b, \ | 1773 | .schmitt_bit = schmitt_b, \ |
1772 | .lpmd_bit = lpmd_b, \ | 1774 | .lpmd_bit = lpmd_b, \ |
@@ -2075,7 +2077,6 @@ static struct platform_driver tegra124_pinctrl_driver = { | |||
2075 | .of_match_table = tegra124_pinctrl_of_match, | 2077 | .of_match_table = tegra124_pinctrl_of_match, |
2076 | }, | 2078 | }, |
2077 | .probe = tegra124_pinctrl_probe, | 2079 | .probe = tegra124_pinctrl_probe, |
2078 | .remove = tegra_pinctrl_remove, | ||
2079 | }; | 2080 | }; |
2080 | module_platform_driver(tegra124_pinctrl_driver); | 2081 | module_platform_driver(tegra124_pinctrl_driver); |
2081 | 2082 | ||
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra20.c b/drivers/pinctrl/tegra/pinctrl-tegra20.c index 4833db4433d9..09bad6980ad1 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra20.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra20.c | |||
@@ -1994,6 +1994,7 @@ static struct tegra_function tegra20_functions[] = { | |||
1994 | .tri_reg = ((tri_r) - TRISTATE_REG_A), \ | 1994 | .tri_reg = ((tri_r) - TRISTATE_REG_A), \ |
1995 | .tri_bank = 0, \ | 1995 | .tri_bank = 0, \ |
1996 | .tri_bit = tri_b, \ | 1996 | .tri_bit = tri_b, \ |
1997 | .parked_reg = -1, \ | ||
1997 | .einput_bit = -1, \ | 1998 | .einput_bit = -1, \ |
1998 | .odrain_bit = -1, \ | 1999 | .odrain_bit = -1, \ |
1999 | .lock_bit = -1, \ | 2000 | .lock_bit = -1, \ |
@@ -2013,6 +2014,7 @@ static struct tegra_function tegra20_functions[] = { | |||
2013 | .pupd_bank = 2, \ | 2014 | .pupd_bank = 2, \ |
2014 | .pupd_bit = pupd_b, \ | 2015 | .pupd_bit = pupd_b, \ |
2015 | .drv_reg = -1, \ | 2016 | .drv_reg = -1, \ |
2017 | .parked_reg = -1, \ | ||
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | /* Pin groups for drive strength registers (configurable version) */ | 2020 | /* Pin groups for drive strength registers (configurable version) */ |
@@ -2028,6 +2030,7 @@ static struct tegra_function tegra20_functions[] = { | |||
2028 | .tri_reg = -1, \ | 2030 | .tri_reg = -1, \ |
2029 | .drv_reg = ((r) - PINGROUP_REG_A), \ | 2031 | .drv_reg = ((r) - PINGROUP_REG_A), \ |
2030 | .drv_bank = 3, \ | 2032 | .drv_bank = 3, \ |
2033 | .parked_reg = -1, \ | ||
2031 | .hsm_bit = hsm_b, \ | 2034 | .hsm_bit = hsm_b, \ |
2032 | .schmitt_bit = schmitt_b, \ | 2035 | .schmitt_bit = schmitt_b, \ |
2033 | .lpmd_bit = lpmd_b, \ | 2036 | .lpmd_bit = lpmd_b, \ |
@@ -2242,7 +2245,6 @@ static struct platform_driver tegra20_pinctrl_driver = { | |||
2242 | .of_match_table = tegra20_pinctrl_of_match, | 2245 | .of_match_table = tegra20_pinctrl_of_match, |
2243 | }, | 2246 | }, |
2244 | .probe = tegra20_pinctrl_probe, | 2247 | .probe = tegra20_pinctrl_probe, |
2245 | .remove = tegra_pinctrl_remove, | ||
2246 | }; | 2248 | }; |
2247 | module_platform_driver(tegra20_pinctrl_driver); | 2249 | module_platform_driver(tegra20_pinctrl_driver); |
2248 | 2250 | ||
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra210.c b/drivers/pinctrl/tegra/pinctrl-tegra210.c index 252b464901c0..2d856af389ef 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra210.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra210.c | |||
@@ -1310,6 +1310,9 @@ static struct tegra_function tegra210_functions[] = { | |||
1310 | .lock_bit = 7, \ | 1310 | .lock_bit = 7, \ |
1311 | .ioreset_bit = -1, \ | 1311 | .ioreset_bit = -1, \ |
1312 | .rcv_sel_bit = PINGROUP_BIT_##e_io_hv(10), \ | 1312 | .rcv_sel_bit = PINGROUP_BIT_##e_io_hv(10), \ |
1313 | .parked_reg = PINGROUP_REG(r), \ | ||
1314 | .parked_bank = 1, \ | ||
1315 | .parked_bit = 5, \ | ||
1313 | .hsm_bit = PINGROUP_BIT_##hsm(9), \ | 1316 | .hsm_bit = PINGROUP_BIT_##hsm(9), \ |
1314 | .schmitt_bit = 12, \ | 1317 | .schmitt_bit = 12, \ |
1315 | .drvtype_bit = PINGROUP_BIT_##drvtype(13), \ | 1318 | .drvtype_bit = PINGROUP_BIT_##drvtype(13), \ |
@@ -1342,6 +1345,7 @@ static struct tegra_function tegra210_functions[] = { | |||
1342 | .rcv_sel_bit = -1, \ | 1345 | .rcv_sel_bit = -1, \ |
1343 | .drv_reg = DRV_PINGROUP_REG(r), \ | 1346 | .drv_reg = DRV_PINGROUP_REG(r), \ |
1344 | .drv_bank = 0, \ | 1347 | .drv_bank = 0, \ |
1348 | .parked_reg = -1, \ | ||
1345 | .hsm_bit = -1, \ | 1349 | .hsm_bit = -1, \ |
1346 | .schmitt_bit = -1, \ | 1350 | .schmitt_bit = -1, \ |
1347 | .lpmd_bit = -1, \ | 1351 | .lpmd_bit = -1, \ |
@@ -1579,7 +1583,6 @@ static struct platform_driver tegra210_pinctrl_driver = { | |||
1579 | .of_match_table = tegra210_pinctrl_of_match, | 1583 | .of_match_table = tegra210_pinctrl_of_match, |
1580 | }, | 1584 | }, |
1581 | .probe = tegra210_pinctrl_probe, | 1585 | .probe = tegra210_pinctrl_probe, |
1582 | .remove = tegra_pinctrl_remove, | ||
1583 | }; | 1586 | }; |
1584 | module_platform_driver(tegra210_pinctrl_driver); | 1587 | module_platform_driver(tegra210_pinctrl_driver); |
1585 | 1588 | ||
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra30.c b/drivers/pinctrl/tegra/pinctrl-tegra30.c index 47b2fd8bb2e9..fb7817fea2d9 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra30.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra30.c | |||
@@ -2139,6 +2139,7 @@ static struct tegra_function tegra30_functions[] = { | |||
2139 | .lock_bit = 7, \ | 2139 | .lock_bit = 7, \ |
2140 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ | 2140 | .ioreset_bit = PINGROUP_BIT_##ior(8), \ |
2141 | .rcv_sel_bit = -1, \ | 2141 | .rcv_sel_bit = -1, \ |
2142 | .parked_reg = -1, \ | ||
2142 | .drv_reg = -1, \ | 2143 | .drv_reg = -1, \ |
2143 | } | 2144 | } |
2144 | 2145 | ||
@@ -2159,6 +2160,7 @@ static struct tegra_function tegra30_functions[] = { | |||
2159 | .rcv_sel_bit = -1, \ | 2160 | .rcv_sel_bit = -1, \ |
2160 | .drv_reg = DRV_PINGROUP_REG(r), \ | 2161 | .drv_reg = DRV_PINGROUP_REG(r), \ |
2161 | .drv_bank = 0, \ | 2162 | .drv_bank = 0, \ |
2163 | .parked_reg = -1, \ | ||
2162 | .hsm_bit = hsm_b, \ | 2164 | .hsm_bit = hsm_b, \ |
2163 | .schmitt_bit = schmitt_b, \ | 2165 | .schmitt_bit = schmitt_b, \ |
2164 | .lpmd_bit = lpmd_b, \ | 2166 | .lpmd_bit = lpmd_b, \ |
@@ -2498,7 +2500,6 @@ static struct platform_driver tegra30_pinctrl_driver = { | |||
2498 | .of_match_table = tegra30_pinctrl_of_match, | 2500 | .of_match_table = tegra30_pinctrl_of_match, |
2499 | }, | 2501 | }, |
2500 | .probe = tegra30_pinctrl_probe, | 2502 | .probe = tegra30_pinctrl_probe, |
2501 | .remove = tegra_pinctrl_remove, | ||
2502 | }; | 2503 | }; |
2503 | module_platform_driver(tegra30_pinctrl_driver); | 2504 | module_platform_driver(tegra30_pinctrl_driver); |
2504 | 2505 | ||
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c index 589872cc8adb..967400971d45 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | |||
@@ -115,7 +115,7 @@ static const struct pinctrl_ops uniphier_pctlops = { | |||
115 | .pin_dbg_show = uniphier_pctl_pin_dbg_show, | 115 | .pin_dbg_show = uniphier_pctl_pin_dbg_show, |
116 | #endif | 116 | #endif |
117 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, | 117 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, |
118 | .dt_free_map = pinctrl_utils_dt_free_map, | 118 | .dt_free_map = pinctrl_utils_free_map, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev, | 121 | static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev, |
@@ -665,7 +665,7 @@ int uniphier_pinctrl_probe(struct platform_device *pdev, | |||
665 | desc->pmxops = &uniphier_pmxops; | 665 | desc->pmxops = &uniphier_pmxops; |
666 | desc->confops = &uniphier_confops; | 666 | desc->confops = &uniphier_confops; |
667 | 667 | ||
668 | priv->pctldev = pinctrl_register(desc, dev, priv); | 668 | priv->pctldev = devm_pinctrl_register(dev, desc, priv); |
669 | if (IS_ERR(priv->pctldev)) { | 669 | if (IS_ERR(priv->pctldev)) { |
670 | dev_err(dev, "failed to register UniPhier pinctrl driver\n"); | 670 | dev_err(dev, "failed to register UniPhier pinctrl driver\n"); |
671 | return PTR_ERR(priv->pctldev); | 671 | return PTR_ERR(priv->pctldev); |
@@ -676,13 +676,3 @@ int uniphier_pinctrl_probe(struct platform_device *pdev, | |||
676 | return 0; | 676 | return 0; |
677 | } | 677 | } |
678 | EXPORT_SYMBOL_GPL(uniphier_pinctrl_probe); | 678 | EXPORT_SYMBOL_GPL(uniphier_pinctrl_probe); |
679 | |||
680 | int uniphier_pinctrl_remove(struct platform_device *pdev) | ||
681 | { | ||
682 | struct uniphier_pinctrl_priv *priv = platform_get_drvdata(pdev); | ||
683 | |||
684 | pinctrl_unregister(priv->pctldev); | ||
685 | |||
686 | return 0; | ||
687 | } | ||
688 | EXPORT_SYMBOL_GPL(uniphier_pinctrl_remove); | ||
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c index a7056dccfa53..4a0439c80aa0 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c | |||
@@ -878,7 +878,6 @@ MODULE_DEVICE_TABLE(of, ph1_ld4_pinctrl_match); | |||
878 | 878 | ||
879 | static struct platform_driver ph1_ld4_pinctrl_driver = { | 879 | static struct platform_driver ph1_ld4_pinctrl_driver = { |
880 | .probe = ph1_ld4_pinctrl_probe, | 880 | .probe = ph1_ld4_pinctrl_probe, |
881 | .remove = uniphier_pinctrl_remove, | ||
882 | .driver = { | 881 | .driver = { |
883 | .name = DRIVER_NAME, | 882 | .name = DRIVER_NAME, |
884 | .of_match_table = ph1_ld4_pinctrl_match, | 883 | .of_match_table = ph1_ld4_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c index 1824831bb4da..150d33928df2 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c | |||
@@ -1266,7 +1266,6 @@ MODULE_DEVICE_TABLE(of, ph1_ld6b_pinctrl_match); | |||
1266 | 1266 | ||
1267 | static struct platform_driver ph1_ld6b_pinctrl_driver = { | 1267 | static struct platform_driver ph1_ld6b_pinctrl_driver = { |
1268 | .probe = ph1_ld6b_pinctrl_probe, | 1268 | .probe = ph1_ld6b_pinctrl_probe, |
1269 | .remove = uniphier_pinctrl_remove, | ||
1270 | .driver = { | 1269 | .driver = { |
1271 | .name = DRIVER_NAME, | 1270 | .name = DRIVER_NAME, |
1272 | .of_match_table = ph1_ld6b_pinctrl_match, | 1271 | .of_match_table = ph1_ld6b_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c index ec8e92dfaf8c..b1f09e68f90e 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c | |||
@@ -1552,7 +1552,6 @@ MODULE_DEVICE_TABLE(of, ph1_pro4_pinctrl_match); | |||
1552 | 1552 | ||
1553 | static struct platform_driver ph1_pro4_pinctrl_driver = { | 1553 | static struct platform_driver ph1_pro4_pinctrl_driver = { |
1554 | .probe = ph1_pro4_pinctrl_probe, | 1554 | .probe = ph1_pro4_pinctrl_probe, |
1555 | .remove = uniphier_pinctrl_remove, | ||
1556 | .driver = { | 1555 | .driver = { |
1557 | .name = DRIVER_NAME, | 1556 | .name = DRIVER_NAME, |
1558 | .of_match_table = ph1_pro4_pinctrl_match, | 1557 | .of_match_table = ph1_pro4_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c index e3d648eae85a..3087f76752a6 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c | |||
@@ -1343,7 +1343,6 @@ MODULE_DEVICE_TABLE(of, ph1_pro5_pinctrl_match); | |||
1343 | 1343 | ||
1344 | static struct platform_driver ph1_pro5_pinctrl_driver = { | 1344 | static struct platform_driver ph1_pro5_pinctrl_driver = { |
1345 | .probe = ph1_pro5_pinctrl_probe, | 1345 | .probe = ph1_pro5_pinctrl_probe, |
1346 | .remove = uniphier_pinctrl_remove, | ||
1347 | .driver = { | 1346 | .driver = { |
1348 | .name = DRIVER_NAME, | 1347 | .name = DRIVER_NAME, |
1349 | .of_match_table = ph1_pro5_pinctrl_match, | 1348 | .of_match_table = ph1_pro5_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c index bc00d7591c59..e868030ff31c 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c | |||
@@ -1261,7 +1261,6 @@ MODULE_DEVICE_TABLE(of, proxstream2_pinctrl_match); | |||
1261 | 1261 | ||
1262 | static struct platform_driver proxstream2_pinctrl_driver = { | 1262 | static struct platform_driver proxstream2_pinctrl_driver = { |
1263 | .probe = proxstream2_pinctrl_probe, | 1263 | .probe = proxstream2_pinctrl_probe, |
1264 | .remove = uniphier_pinctrl_remove, | ||
1265 | .driver = { | 1264 | .driver = { |
1266 | .name = DRIVER_NAME, | 1265 | .name = DRIVER_NAME, |
1267 | .of_match_table = proxstream2_pinctrl_match, | 1266 | .of_match_table = proxstream2_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c index c3700a33a5da..ceb7a9899bde 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c | |||
@@ -786,7 +786,6 @@ MODULE_DEVICE_TABLE(of, ph1_sld8_pinctrl_match); | |||
786 | 786 | ||
787 | static struct platform_driver ph1_sld8_pinctrl_driver = { | 787 | static struct platform_driver ph1_sld8_pinctrl_driver = { |
788 | .probe = ph1_sld8_pinctrl_probe, | 788 | .probe = ph1_sld8_pinctrl_probe, |
789 | .remove = uniphier_pinctrl_remove, | ||
790 | .driver = { | 789 | .driver = { |
791 | .name = DRIVER_NAME, | 790 | .name = DRIVER_NAME, |
792 | .of_match_table = ph1_sld8_pinctrl_match, | 791 | .of_match_table = ph1_sld8_pinctrl_match, |
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h b/drivers/pinctrl/uniphier/pinctrl-uniphier.h index e1e98b868be5..a21154f4b453 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h | |||
@@ -212,6 +212,4 @@ int uniphier_pinctrl_probe(struct platform_device *pdev, | |||
212 | struct pinctrl_desc *desc, | 212 | struct pinctrl_desc *desc, |
213 | struct uniphier_pinctrl_socdata *socdata); | 213 | struct uniphier_pinctrl_socdata *socdata); |
214 | 214 | ||
215 | int uniphier_pinctrl_remove(struct platform_device *pdev); | ||
216 | |||
217 | #endif /* __PINCTRL_UNIPHIER_H__ */ | 215 | #endif /* __PINCTRL_UNIPHIER_H__ */ |
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index 5c261bf5542f..cbc638631678 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c | |||
@@ -583,7 +583,7 @@ int wmt_pinctrl_probe(struct platform_device *pdev, | |||
583 | 583 | ||
584 | data->dev = &pdev->dev; | 584 | data->dev = &pdev->dev; |
585 | 585 | ||
586 | data->pctl_dev = pinctrl_register(&wmt_desc, &pdev->dev, data); | 586 | data->pctl_dev = devm_pinctrl_register(&pdev->dev, &wmt_desc, data); |
587 | if (IS_ERR(data->pctl_dev)) { | 587 | if (IS_ERR(data->pctl_dev)) { |
588 | dev_err(&pdev->dev, "Failed to register pinctrl\n"); | 588 | dev_err(&pdev->dev, "Failed to register pinctrl\n"); |
589 | return PTR_ERR(data->pctl_dev); | 589 | return PTR_ERR(data->pctl_dev); |
@@ -592,7 +592,7 @@ int wmt_pinctrl_probe(struct platform_device *pdev, | |||
592 | err = gpiochip_add_data(&data->gpio_chip, data); | 592 | err = gpiochip_add_data(&data->gpio_chip, data); |
593 | if (err) { | 593 | if (err) { |
594 | dev_err(&pdev->dev, "could not add GPIO chip\n"); | 594 | dev_err(&pdev->dev, "could not add GPIO chip\n"); |
595 | goto fail_gpio; | 595 | return err; |
596 | } | 596 | } |
597 | 597 | ||
598 | err = gpiochip_add_pin_range(&data->gpio_chip, dev_name(data->dev), | 598 | err = gpiochip_add_pin_range(&data->gpio_chip, dev_name(data->dev), |
@@ -606,8 +606,6 @@ int wmt_pinctrl_probe(struct platform_device *pdev, | |||
606 | 606 | ||
607 | fail_range: | 607 | fail_range: |
608 | gpiochip_remove(&data->gpio_chip); | 608 | gpiochip_remove(&data->gpio_chip); |
609 | fail_gpio: | ||
610 | pinctrl_unregister(data->pctl_dev); | ||
611 | return err; | 609 | return err; |
612 | } | 610 | } |
613 | 611 | ||
@@ -616,7 +614,6 @@ int wmt_pinctrl_remove(struct platform_device *pdev) | |||
616 | struct wmt_pinctrl_data *data = platform_get_drvdata(pdev); | 614 | struct wmt_pinctrl_data *data = platform_get_drvdata(pdev); |
617 | 615 | ||
618 | gpiochip_remove(&data->gpio_chip); | 616 | gpiochip_remove(&data->gpio_chip); |
619 | pinctrl_unregister(data->pctl_dev); | ||
620 | 617 | ||
621 | return 0; | 618 | return 0; |
622 | } | 619 | } |
diff --git a/include/dt-bindings/gpio/meson-gxbb-gpio.h b/include/dt-bindings/gpio/meson-gxbb-gpio.h new file mode 100644 index 000000000000..58654fd7aa1e --- /dev/null +++ b/include/dt-bindings/gpio/meson-gxbb-gpio.h | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * GPIO definitions for Amlogic Meson GXBB SoCs | ||
3 | * | ||
4 | * Copyright (C) 2016 Endless Mobile, Inc. | ||
5 | * Author: Carlo Caione <carlo@endlessm.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
13 | */ | ||
14 | |||
15 | #ifndef _DT_BINDINGS_MESON_GXBB_GPIO_H | ||
16 | #define _DT_BINDINGS_MESON_GXBB_GPIO_H | ||
17 | |||
18 | #define GPIOAO_0 0 | ||
19 | #define GPIOAO_1 1 | ||
20 | #define GPIOAO_2 2 | ||
21 | #define GPIOAO_3 3 | ||
22 | #define GPIOAO_4 4 | ||
23 | #define GPIOAO_5 5 | ||
24 | #define GPIOAO_6 6 | ||
25 | #define GPIOAO_7 7 | ||
26 | #define GPIOAO_8 8 | ||
27 | #define GPIOAO_9 9 | ||
28 | #define GPIOAO_10 10 | ||
29 | #define GPIOAO_11 11 | ||
30 | #define GPIOAO_12 12 | ||
31 | #define GPIOAO_13 13 | ||
32 | |||
33 | #define GPIOZ_0 0 | ||
34 | #define GPIOZ_1 1 | ||
35 | #define GPIOZ_2 2 | ||
36 | #define GPIOZ_3 3 | ||
37 | #define GPIOZ_4 4 | ||
38 | #define GPIOZ_5 5 | ||
39 | #define GPIOZ_6 6 | ||
40 | #define GPIOZ_7 7 | ||
41 | #define GPIOZ_8 8 | ||
42 | #define GPIOZ_9 9 | ||
43 | #define GPIOZ_10 10 | ||
44 | #define GPIOZ_11 11 | ||
45 | #define GPIOZ_12 12 | ||
46 | #define GPIOZ_13 13 | ||
47 | #define GPIOZ_14 14 | ||
48 | #define GPIOZ_15 15 | ||
49 | #define GPIOH_0 16 | ||
50 | #define GPIOH_1 17 | ||
51 | #define GPIOH_2 18 | ||
52 | #define GPIOH_3 19 | ||
53 | #define BOOT_0 20 | ||
54 | #define BOOT_1 21 | ||
55 | #define BOOT_2 22 | ||
56 | #define BOOT_3 23 | ||
57 | #define BOOT_4 24 | ||
58 | #define BOOT_5 25 | ||
59 | #define BOOT_6 26 | ||
60 | #define BOOT_7 27 | ||
61 | #define BOOT_8 28 | ||
62 | #define BOOT_9 29 | ||
63 | #define BOOT_10 30 | ||
64 | #define BOOT_11 31 | ||
65 | #define BOOT_12 32 | ||
66 | #define BOOT_13 33 | ||
67 | #define BOOT_14 34 | ||
68 | #define BOOT_15 35 | ||
69 | #define BOOT_16 36 | ||
70 | #define BOOT_17 37 | ||
71 | #define CARD_0 38 | ||
72 | #define CARD_1 39 | ||
73 | #define CARD_2 40 | ||
74 | #define CARD_3 41 | ||
75 | #define CARD_4 42 | ||
76 | #define CARD_5 43 | ||
77 | #define CARD_6 44 | ||
78 | #define GPIODV_0 45 | ||
79 | #define GPIODV_1 46 | ||
80 | #define GPIODV_2 47 | ||
81 | #define GPIODV_3 48 | ||
82 | #define GPIODV_4 49 | ||
83 | #define GPIODV_5 50 | ||
84 | #define GPIODV_6 51 | ||
85 | #define GPIODV_7 52 | ||
86 | #define GPIODV_8 53 | ||
87 | #define GPIODV_9 54 | ||
88 | #define GPIODV_10 55 | ||
89 | #define GPIODV_11 56 | ||
90 | #define GPIODV_12 57 | ||
91 | #define GPIODV_13 58 | ||
92 | #define GPIODV_14 59 | ||
93 | #define GPIODV_15 60 | ||
94 | #define GPIODV_16 61 | ||
95 | #define GPIODV_17 62 | ||
96 | #define GPIODV_18 63 | ||
97 | #define GPIODV_19 64 | ||
98 | #define GPIODV_20 65 | ||
99 | #define GPIODV_21 66 | ||
100 | #define GPIODV_22 67 | ||
101 | #define GPIODV_23 68 | ||
102 | #define GPIODV_24 69 | ||
103 | #define GPIODV_25 70 | ||
104 | #define GPIODV_26 71 | ||
105 | #define GPIODV_27 72 | ||
106 | #define GPIODV_28 73 | ||
107 | #define GPIODV_29 74 | ||
108 | #define GPIOY_0 75 | ||
109 | #define GPIOY_1 76 | ||
110 | #define GPIOY_2 77 | ||
111 | #define GPIOY_3 78 | ||
112 | #define GPIOY_4 79 | ||
113 | #define GPIOY_5 80 | ||
114 | #define GPIOY_6 81 | ||
115 | #define GPIOY_7 82 | ||
116 | #define GPIOY_8 83 | ||
117 | #define GPIOY_9 84 | ||
118 | #define GPIOY_10 85 | ||
119 | #define GPIOY_11 86 | ||
120 | #define GPIOY_12 87 | ||
121 | #define GPIOY_13 88 | ||
122 | #define GPIOY_14 89 | ||
123 | #define GPIOY_15 90 | ||
124 | #define GPIOY_16 91 | ||
125 | #define GPIOX_0 92 | ||
126 | #define GPIOX_1 93 | ||
127 | #define GPIOX_2 94 | ||
128 | #define GPIOX_3 95 | ||
129 | #define GPIOX_4 96 | ||
130 | #define GPIOX_5 97 | ||
131 | #define GPIOX_6 98 | ||
132 | #define GPIOX_7 99 | ||
133 | #define GPIOX_8 100 | ||
134 | #define GPIOX_9 101 | ||
135 | #define GPIOX_10 102 | ||
136 | #define GPIOX_11 103 | ||
137 | #define GPIOX_12 104 | ||
138 | #define GPIOX_13 105 | ||
139 | #define GPIOX_14 106 | ||
140 | #define GPIOX_15 107 | ||
141 | #define GPIOX_16 108 | ||
142 | #define GPIOX_17 109 | ||
143 | #define GPIOX_18 110 | ||
144 | #define GPIOX_19 111 | ||
145 | #define GPIOX_20 112 | ||
146 | #define GPIOX_21 113 | ||
147 | #define GPIOX_22 114 | ||
148 | #define GPIOCLK_0 115 | ||
149 | #define GPIOCLK_1 116 | ||
150 | #define GPIOCLK_2 117 | ||
151 | #define GPIOCLK_3 118 | ||
152 | #define GPIO_TEST_N 119 | ||
153 | |||
154 | #endif | ||
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index 9ba59fcba549..a42e57da270d 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h | |||
@@ -144,6 +144,12 @@ struct pinctrl_desc { | |||
144 | extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | 144 | extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, |
145 | struct device *dev, void *driver_data); | 145 | struct device *dev, void *driver_data); |
146 | extern void pinctrl_unregister(struct pinctrl_dev *pctldev); | 146 | extern void pinctrl_unregister(struct pinctrl_dev *pctldev); |
147 | extern struct pinctrl_dev *devm_pinctrl_register(struct device *dev, | ||
148 | struct pinctrl_desc *pctldesc, | ||
149 | void *driver_data); | ||
150 | extern void devm_pinctrl_unregister(struct device *dev, | ||
151 | struct pinctrl_dev *pctldev); | ||
152 | |||
147 | extern bool pin_is_valid(struct pinctrl_dev *pctldev, int pin); | 153 | extern bool pin_is_valid(struct pinctrl_dev *pctldev, int pin); |
148 | extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev, | 154 | extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev, |
149 | struct pinctrl_gpio_range *range); | 155 | struct pinctrl_gpio_range *range); |