aboutsummaryrefslogtreecommitdiffstats
path: root/net/rfkill
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2014-10-27 06:15:14 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-04 15:58:24 -0500
commit72daceb9a10af4614d4aee304f07904191962f07 (patch)
tree56369fd293bddb3602a30d68d123da9c68927c30 /net/rfkill
parentf028d5242d7ecb0a1bfc80e7bd292201c8612641 (diff)
net: rfkill: gpio: Add default GPIO driver mappings for ACPI
The driver uses devm_gpiod_get_index(..., index) so that the index refers directly to the GpioIo resource under the ACPI device. The problem with this is that if the ordering changes we get wrong GPIOs. With ACPI 5.1 _DSD we can now use names instead to reference GPIOs analogous to Device Tree. However, we still have systems out there that do not provide _DSD at all. These systems must be supported as well. Luckily we now have acpi_dev_add_driver_gpios() that can be used to provide mappings for systems where _DSD is not provided and still take advantage of _DSD if it exists. This patch changes the driver to create default GPIO mappings if we are running on ACPI system. While there we can drop the indices completely and use devm_gpiod_get() with name instead. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: John W. Linville <linville@tuxdriver.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r--net/rfkill/rfkill-gpio.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 0f62326c0f5e..2a4717967502 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -63,6 +63,15 @@ static const struct rfkill_ops rfkill_gpio_ops = {
63 .set_block = rfkill_gpio_set_power, 63 .set_block = rfkill_gpio_set_power,
64}; 64};
65 65
66static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
67static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
68
69static const struct acpi_gpio_mapping acpi_rfkill_default_gpios[] = {
70 { "reset-gpios", &reset_gpios, 1 },
71 { "shutdown-gpios", &shutdown_gpios, 1 },
72 { },
73};
74
66static int rfkill_gpio_acpi_probe(struct device *dev, 75static int rfkill_gpio_acpi_probe(struct device *dev,
67 struct rfkill_gpio_data *rfkill) 76 struct rfkill_gpio_data *rfkill)
68{ 77{
@@ -75,7 +84,8 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
75 rfkill->name = dev_name(dev); 84 rfkill->name = dev_name(dev);
76 rfkill->type = (unsigned)id->driver_data; 85 rfkill->type = (unsigned)id->driver_data;
77 86
78 return 0; 87 return acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
88 acpi_rfkill_default_gpios);
79} 89}
80 90
81static int rfkill_gpio_probe(struct platform_device *pdev) 91static int rfkill_gpio_probe(struct platform_device *pdev)
@@ -102,7 +112,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
102 112
103 rfkill->clk = devm_clk_get(&pdev->dev, NULL); 113 rfkill->clk = devm_clk_get(&pdev->dev, NULL);
104 114
105 gpio = devm_gpiod_get_index(&pdev->dev, "reset", 0); 115 gpio = devm_gpiod_get(&pdev->dev, "reset");
106 if (!IS_ERR(gpio)) { 116 if (!IS_ERR(gpio)) {
107 ret = gpiod_direction_output(gpio, 0); 117 ret = gpiod_direction_output(gpio, 0);
108 if (ret) 118 if (ret)
@@ -110,7 +120,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
110 rfkill->reset_gpio = gpio; 120 rfkill->reset_gpio = gpio;
111 } 121 }
112 122
113 gpio = devm_gpiod_get_index(&pdev->dev, "shutdown", 1); 123 gpio = devm_gpiod_get(&pdev->dev, "shutdown");
114 if (!IS_ERR(gpio)) { 124 if (!IS_ERR(gpio)) {
115 ret = gpiod_direction_output(gpio, 0); 125 ret = gpiod_direction_output(gpio, 0);
116 if (ret) 126 if (ret)
@@ -150,6 +160,8 @@ static int rfkill_gpio_remove(struct platform_device *pdev)
150 rfkill_unregister(rfkill->rfkill_dev); 160 rfkill_unregister(rfkill->rfkill_dev);
151 rfkill_destroy(rfkill->rfkill_dev); 161 rfkill_destroy(rfkill->rfkill_dev);
152 162
163 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
164
153 return 0; 165 return 0;
154} 166}
155 167