History

Merge tag 'gpio-v5.2-updates-for-linus-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel

gpio: updates for v5.2 (part 1) - batch of improvements for the vf610 driver which shrink the code and make use of resource managed helpers - support for a new variant of pca953x - make gpio-mockup buildable on systems without IOMEM - make gpio-74x164 more flexible by using generic device properties plus minor improvements - new driver for Mellanox BlueField - fixes for wakeup GPIOs in gpio-omap - use devm_platform_ioremap_resource() in gpio-mxc - a couple improvements of kernel docs for ACPI code - don't WARN() in gpiod_put() on optional GPIOs

Linus Walleij committed 7 years ago

Commit 4779a062 parents 12f2639 b0d256910 files · +279 −125Browse files

Unified · Split

10 files
  1. Documentation/devicetree/bindings/gpio/gpio-pca953x.txt +1 −0
  2. drivers/gpio/Kconfig +19 −14
  3. drivers/gpio/Makefile +1 −0
  4. drivers/gpio/gpio-74x164.c +9 −13
  5. drivers/gpio/gpio-mlxbf.c +152 −0
  6. drivers/gpio/gpio-omap.c +33 −28
  7. drivers/gpio/gpio-pca953x.c +1 −0
  8. drivers/gpio/gpio-vf610.c +36 −49
  9. drivers/gpio/gpiolib-acpi.c +25 −20
  10. drivers/gpio/gpiolib.c +2 −1
Documentation/devicetree/bindings/gpio/gpio-pca953x.txt+1−0
@@ -30,6 +30,7 @@ Required properties: · 29 unmodified lines
3030 ti,tca6424
3131 ti,tca9539
3232 ti,tca9554
33+ onnn,cat9554
3334 onnn,pca9654
3435 exar,xra1202
3536 - gpio-controller: if used as gpio expander.
drivers/gpio/Kconfig+19−14
@@ -330,20 +330,6 @@ config GPIO_MM_LANTIQ · 329 unmodified lines
330330 (EBU) found on Lantiq SoCs. The gpios are output only as they are
331331 created by attaching a 16bit latch to the bus.
332332
333−config GPIO_MOCKUP
334− tristate "GPIO Testing Driver"
335− depends on GPIOLIB && SYSFS
336− select GPIO_SYSFS
337− select GPIOLIB_IRQCHIP
338− select IRQ_SIM
339− help
340− This enables GPIO Testing driver, which provides a way to test GPIO
341− subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS
342− must be selected for this test.
343− User could use it through the script in
344− tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in
345− it.
346−
347333 config GPIO_MPC5200
348334 def_bool y
349335 depends on PPC_MPC52xx
@@ -1316,6 +1302,13 @@ config GPIO_MERRIFIELD · 966 unmodified lines
13161302 help
13171303 Say Y here to support Intel Merrifield GPIO.
13181304
1305+config GPIO_MLXBF
1306+ tristate "Mellanox BlueField SoC GPIO"
1307+ depends on (MELLANOX_PLATFORM && ARM64 && ACPI) || (64BIT && COMPILE_TEST)
1308+ select GPIO_GENERIC
1309+ help
1310+ Say Y here if you want GPIO support on Mellanox BlueField SoC.
1311+
13191312 config GPIO_ML_IOH
13201313 tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support"
13211314 depends on X86 || COMPILE_TEST
@@ -1442,4 +1435,16 @@ config GPIO_VIPERBOARD · 120 unmodified lines
14421435
14431436 endmenu
14441437
1438+config GPIO_MOCKUP
1439+ tristate "GPIO Testing Driver"
1440+ depends on GPIOLIB
1441+ select IRQ_SIM
1442+ help
1443+ This enables GPIO Testing driver, which provides a way to test GPIO
1444+ subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS
1445+ must be selected for this test.
1446+ User could use it through the script in
1447+ tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in
1448+ it.
1449+
14451450 endif
drivers/gpio/Makefile+1−0
@@ -85,6 +85,7 @@ obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o · 84 unmodified lines
8585 obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o
8686 obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o
8787 obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o
88+obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o
8889 obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o
8990 obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o
9091 obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o
drivers/gpio/gpio-74x164.c+9−13
@@ -1,21 +1,18 @@
1+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * 74Hx164 - Generic serial-in/parallel-out 8-bits shift register GPIO driver
34 *
45 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
56 * Copyright (C) 2010 Miguel Gaio <miguel.gaio@efixo.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License version 2 as
9− * published by the Free Software Foundation.
107 */
118
12−#include <linux/init.h>
13−#include <linux/mutex.h>
14−#include <linux/spi/spi.h>
15−#include <linux/gpio/driver.h>
169 #include <linux/gpio/consumer.h>
17−#include <linux/slab.h>
10+#include <linux/gpio/driver.h>
1811 #include <linux/module.h>
12+#include <linux/mutex.h>
13+#include <linux/property.h>
14+#include <linux/slab.h>
15+#include <linux/spi/spi.h>
1916
2017 #define GEN_74X164_NUMBER_GPIOS 8
2118
@@ -116,10 +113,9 @@ static int gen_74x164_probe(struct spi_device *spi) · 94 unmodified lines
116113 if (ret < 0)
117114 return ret;
118115
119− if (of_property_read_u32(spi->dev.of_node, "registers-number",
120− &nregs)) {
121− dev_err(&spi->dev,
122− "Missing registers-number property in the DT.\n");
116+ ret = device_property_read_u32(&spi->dev, "registers-number", &nregs);
117+ if (ret) {
118+ dev_err(&spi->dev, "Missing 'registers-number' property.\n");
123119 return -EINVAL;
124120 }
125121
drivers/gpio/gpio-mlxbf.c+152−0
@@ -0,0 +1,152 @@
1+// SPDX-License-Identifier: GPL-2.0
2+
3+#include <linux/acpi.h>
4+#include <linux/bitops.h>
5+#include <linux/device.h>
6+#include <linux/gpio/driver.h>
7+#include <linux/io.h>
8+#include <linux/kernel.h>
9+#include <linux/module.h>
10+#include <linux/platform_device.h>
11+#include <linux/pm.h>
12+#include <linux/resource.h>
13+#include <linux/types.h>
14+
15+/* Number of pins on BlueField */
16+#define MLXBF_GPIO_NR 54
17+
18+/* Pad Electrical Controls. */
19+#define MLXBF_GPIO_PAD_CONTROL_FIRST_WORD 0x0700
20+#define MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD 0x0708
21+#define MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD 0x0710
22+#define MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD 0x0718
23+
24+#define MLXBF_GPIO_PIN_DIR_I 0x1040
25+#define MLXBF_GPIO_PIN_DIR_O 0x1048
26+#define MLXBF_GPIO_PIN_STATE 0x1000
27+#define MLXBF_GPIO_SCRATCHPAD 0x20
28+
29+#ifdef CONFIG_PM
30+struct mlxbf_gpio_context_save_regs {
31+ u64 scratchpad;
32+ u64 pad_control[MLXBF_GPIO_NR];
33+ u64 pin_dir_i;
34+ u64 pin_dir_o;
35+};
36+#endif
37+
38+/* Device state structure. */
39+struct mlxbf_gpio_state {
40+ struct gpio_chip gc;
41+
42+ /* Memory Address */
43+ void __iomem *base;
44+
45+#ifdef CONFIG_PM
46+ struct mlxbf_gpio_context_save_regs csave_regs;
47+#endif
48+};
49+
50+static int mlxbf_gpio_probe(struct platform_device *pdev)
51+{
52+ struct mlxbf_gpio_state *gs;
53+ struct device *dev = &pdev->dev;
54+ struct gpio_chip *gc;
55+ int ret;
56+
57+ gs = devm_kzalloc(&pdev->dev, sizeof(*gs), GFP_KERNEL);
58+ if (!gs)
59+ return -ENOMEM;
60+
61+ gs->base = devm_platform_ioremap_resource(pdev, 0);
62+ if (IS_ERR(gs->base))
63+ return PTR_ERR(gs->base);
64+
65+ gc = &gs->gc;
66+ ret = bgpio_init(gc, dev, 8,
67+ gs->base + MLXBF_GPIO_PIN_STATE,
68+ NULL,
69+ NULL,
70+ gs->base + MLXBF_GPIO_PIN_DIR_O,
71+ gs->base + MLXBF_GPIO_PIN_DIR_I,
72+ 0);
73+ if (ret)
74+ return -ENODEV;
75+
76+ gc->owner = THIS_MODULE;
77+ gc->ngpio = MLXBF_GPIO_NR;
78+
79+ ret = devm_gpiochip_add_data(dev, &gs->gc, gs);
80+ if (ret) {
81+ dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n");
82+ return ret;
83+ }
84+
85+ platform_set_drvdata(pdev, gs);
86+ dev_info(&pdev->dev, "registered Mellanox BlueField GPIO");
87+ return 0;
88+}
89+
90+#ifdef CONFIG_PM
91+static int mlxbf_gpio_suspend(struct platform_device *pdev, pm_message_t state)
92+{
93+ struct mlxbf_gpio_state *gs = platform_get_drvdata(pdev);
94+
95+ gs->csave_regs.scratchpad = readq(gs->base + MLXBF_GPIO_SCRATCHPAD);
96+ gs->csave_regs.pad_control[0] =
97+ readq(gs->base + MLXBF_GPIO_PAD_CONTROL_FIRST_WORD);
98+ gs->csave_regs.pad_control[1] =
99+ readq(gs->base + MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD);
100+ gs->csave_regs.pad_control[2] =
101+ readq(gs->base + MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD);
102+ gs->csave_regs.pad_control[3] =
103+ readq(gs->base + MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD);
104+ gs->csave_regs.pin_dir_i = readq(gs->base + MLXBF_GPIO_PIN_DIR_I);
105+ gs->csave_regs.pin_dir_o = readq(gs->base + MLXBF_GPIO_PIN_DIR_O);
106+
107+ return 0;
108+}
109+
110+static int mlxbf_gpio_resume(struct platform_device *pdev)
111+{
112+ struct mlxbf_gpio_state *gs = platform_get_drvdata(pdev);
113+
114+ writeq(gs->csave_regs.scratchpad, gs->base + MLXBF_GPIO_SCRATCHPAD);
115+ writeq(gs->csave_regs.pad_control[0],
116+ gs->base + MLXBF_GPIO_PAD_CONTROL_FIRST_WORD);
117+ writeq(gs->csave_regs.pad_control[1],
118+ gs->base + MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD);
119+ writeq(gs->csave_regs.pad_control[2],
120+ gs->base + MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD);
121+ writeq(gs->csave_regs.pad_control[3],
122+ gs->base + MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD);
123+ writeq(gs->csave_regs.pin_dir_i, gs->base + MLXBF_GPIO_PIN_DIR_I);
124+ writeq(gs->csave_regs.pin_dir_o, gs->base + MLXBF_GPIO_PIN_DIR_O);
125+
126+ return 0;
127+}
128+#endif
129+
130+static const struct acpi_device_id mlxbf_gpio_acpi_match[] = {
131+ { "MLNXBF02", 0 },
132+ {}
133+};
134+MODULE_DEVICE_TABLE(acpi, mlxbf_gpio_acpi_match);
135+
136+static struct platform_driver mlxbf_gpio_driver = {
137+ .driver = {
138+ .name = "mlxbf_gpio",
139+ .acpi_match_table = ACPI_PTR(mlxbf_gpio_acpi_match),
140+ },
141+ .probe = mlxbf_gpio_probe,
142+#ifdef CONFIG_PM
143+ .suspend = mlxbf_gpio_suspend,
144+ .resume = mlxbf_gpio_resume,
145+#endif
146+};
147+
148+module_platform_driver(mlxbf_gpio_driver);
149+
150+MODULE_DESCRIPTION("Mellanox BlueField GPIO Driver");
151+MODULE_AUTHOR("Mellanox Technologies");
152+MODULE_LICENSE("GPL");
drivers/gpio/gpio-omap.c+33−28
@@ -83,7 +83,6 @@ struct gpio_bank { · 82 unmodified lines
8383 int stride;
8484 u32 width;
8585 int context_loss_count;
86− bool workaround_enabled;
8786 u32 quirks;
8887
8988 void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable);
@@ -353,6 +352,22 @@ static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset) · 263 unmodified lines
353352 }
354353 }
355354
355+/*
356+ * Off mode wake-up capable GPIOs in bank(s) that are in the wakeup domain.
357+ * See TRM section for GPIO for "Wake-Up Generation" for the list of GPIOs
358+ * in wakeup domain. If bank->non_wakeup_gpios is not configured, assume none
359+ * are capable waking up the system from off mode.
360+ */
361+static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask)
362+{
363+ u32 no_wake = bank->non_wakeup_gpios;
364+
365+ if (no_wake)
366+ return !!(~no_wake & gpio_mask);
367+
368+ return false;
369+}
370+
356371 static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
357372 unsigned trigger)
358373 {
@@ -384,13 +399,7 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, · 25 unmodified lines
384399 }
385400
386401 /* This part needs to be executed always for OMAP{34xx, 44xx} */
387− if (!bank->regs->irqctrl) {
388− /* On omap24xx proceed only when valid GPIO bit is set */
389− if (bank->non_wakeup_gpios) {
390− if (!(bank->non_wakeup_gpios & gpio_bit))
391− goto exit;
392− }
393−
402+ if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) {
394403 /*
395404 * Log the edge gpio and manually trigger the IRQ
396405 * after resume if the input level changes
@@ -403,7 +412,6 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, · 6 unmodified lines
403412 bank->enabled_non_wakeup_gpios &= ~gpio_bit;
404413 }
405414
406−exit:
407415 bank->level_mask =
408416 readl_relaxed(bank->base + bank->regs->leveldetect0) |
409417 readl_relaxed(bank->base + bank->regs->leveldetect1);
@@ -1311,7 +1319,10 @@ static void omap_gpio_restore_context(struct gpio_bank *bank) · 901 unmodified lines
13111319 static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context)
13121320 {
13131321 struct device *dev = bank->chip.parent;
1314− u32 l1 = 0, l2 = 0;
1322+ void __iomem *base = bank->base;
1323+ u32 nowake;
1324+
1325+ bank->saved_datain = readl_relaxed(base + bank->regs->datain);
13151326
13161327 if (bank->funcs.idle_enable_level_quirk)
13171328 bank->funcs.idle_enable_level_quirk(bank);
@@ -1323,22 +1334,15 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) · 5 unmodified lines
13231334 goto update_gpio_context_count;
13241335
13251336 /*
1326− * If going to OFF, remove triggering for all
1337+ * If going to OFF, remove triggering for all wkup domain
13271338 * non-wakeup GPIOs. Otherwise spurious IRQs will be
13281339 * generated. See OMAP2420 Errata item 1.101.
13291340 */
1330− bank->saved_datain = readl_relaxed(bank->base +
1331− bank->regs->datain);
1332− l1 = bank->context.fallingdetect;
1333− l2 = bank->context.risingdetect;
1334−
1335− l1 &= ~bank->enabled_non_wakeup_gpios;
1336− l2 &= ~bank->enabled_non_wakeup_gpios;
1337−
1338− writel_relaxed(l1, bank->base + bank->regs->fallingdetect);
1339− writel_relaxed(l2, bank->base + bank->regs->risingdetect);
1340−
1341− bank->workaround_enabled = true;
1341+ if (!bank->loses_context && bank->enabled_non_wakeup_gpios) {
1342+ nowake = bank->enabled_non_wakeup_gpios;
1343+ omap_gpio_rmw(base, bank->regs->fallingdetect, nowake, ~nowake);
1344+ omap_gpio_rmw(base, bank->regs->risingdetect, nowake, ~nowake);
1345+ }
13421346
13431347 update_gpio_context_count:
13441348 if (bank->get_context_loss_count)
@@ -1383,11 +1387,14 @@ static void omap_gpio_unidle(struct gpio_bank *bank) · 38 unmodified lines
13831387 return;
13841388 }
13851389 }
1390+ } else {
1391+ /* Restore changes done for OMAP2420 errata 1.101 */
1392+ writel_relaxed(bank->context.fallingdetect,
1393+ bank->base + bank->regs->fallingdetect);
1394+ writel_relaxed(bank->context.risingdetect,
1395+ bank->base + bank->regs->risingdetect);
13861396 }
13871397
1388− if (!bank->workaround_enabled)
1389− return;
1390−
13911398 l = readl_relaxed(bank->base + bank->regs->datain);
13921399
13931400 /*
@@ -1437,8 +1444,6 @@ static void omap_gpio_unidle(struct gpio_bank *bank) · 43 unmodified lines
14371444 writel_relaxed(old0, bank->base + bank->regs->leveldetect0);
14381445 writel_relaxed(old1, bank->base + bank->regs->leveldetect1);
14391446 }
1440−
1441− bank->workaround_enabled = false;
14421447 }
14431448
14441449 static int gpio_omap_cpu_notifier(struct notifier_block *nb,
drivers/gpio/gpio-pca953x.c+1−0
@@ -1178,6 +1178,7 @@ static const struct of_device_id pca953x_dt_ids[] = { · 1177 unmodified lines
11781178 { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },
11791179 { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), },
11801180
1181+ { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), },
11811182 { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), },
11821183
11831184 { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), },
drivers/gpio/gpio-vf610.c+36−49
@@ -29,6 +29,7 @@ struct fsl_gpio_soc_data { · 28 unmodified lines
2929
3030 struct vf610_gpio_port {
3131 struct gpio_chip gc;
32+ struct irq_chip ic;
3233 void __iomem *base;
3334 void __iomem *gpio_base;
3435 const struct fsl_gpio_soc_data *sdata;
@@ -60,8 +61,6 @@ struct vf610_gpio_port { · 25 unmodified lines
6061 #define PORT_INT_EITHER_EDGE 0xb
6162 #define PORT_INT_LOGIC_ONE 0xc
6263
63−static struct irq_chip vf610_gpio_irq_chip;
64−
6564 static const struct fsl_gpio_soc_data imx_data = {
6665 .have_paddr = true,
6766 };
@@ -86,28 +85,24 @@ static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) · 18 unmodified lines
8685 {
8786 struct vf610_gpio_port *port = gpiochip_get_data(gc);
8887 unsigned long mask = BIT(gpio);
89− void __iomem *addr;
88+ unsigned long offset = GPIO_PDIR;
9089
9190 if (port->sdata && port->sdata->have_paddr) {
9291 mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR);
93− addr = mask ? port->gpio_base + GPIO_PDOR :
94− port->gpio_base + GPIO_PDIR;
95− return !!(vf610_gpio_readl(addr) & BIT(gpio));
96− } else {
97− return !!(vf610_gpio_readl(port->gpio_base + GPIO_PDIR)
98− & BIT(gpio));
92+ if (mask)
93+ offset = GPIO_PDOR;
9994 }
95+
96+ return !!(vf610_gpio_readl(port->gpio_base + offset) & BIT(gpio));
10097 }
10198
10299 static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
103100 {
104101 struct vf610_gpio_port *port = gpiochip_get_data(gc);
105102 unsigned long mask = BIT(gpio);
103+ unsigned long offset = val ? GPIO_PSOR : GPIO_PCOR;
106104
107− if (val)
108− vf610_gpio_writel(mask, port->gpio_base + GPIO_PSOR);
109− else
110− vf610_gpio_writel(mask, port->gpio_base + GPIO_PCOR);
105+ vf610_gpio_writel(mask, port->gpio_base + offset);
111106 }
112107
113108 static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
@@ -237,14 +232,10 @@ static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable) · 123 unmodified lines
237232 return 0;
238233 }
239234
240−static struct irq_chip vf610_gpio_irq_chip = {
241− .name = "gpio-vf610",
242− .irq_ack = vf610_gpio_irq_ack,
243− .irq_mask = vf610_gpio_irq_mask,
244− .irq_unmask = vf610_gpio_irq_unmask,
245− .irq_set_type = vf610_gpio_irq_set_type,
246− .irq_set_wake = vf610_gpio_irq_set_wake,
247−};
235+static void vf610_gpio_disable_clk(void *data)
236+{
237+ clk_disable_unprepare(data);
238+}
248239
249240 static int vf610_gpio_probe(struct platform_device *pdev)
250241 {
@@ -252,10 +243,11 @@ static int vf610_gpio_probe(struct platform_device *pdev) · 1 unmodified line
252243 struct device_node *np = dev->of_node;
253244 struct vf610_gpio_port *port;
254245 struct gpio_chip *gc;
246+ struct irq_chip *ic;
255247 int i;
256248 int ret;
257249
258− port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
250+ port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
259251 if (!port)
260252 return -ENOMEM;
261253
@@ -272,11 +264,15 @@ static int vf610_gpio_probe(struct platform_device *pdev) · 10 unmodified lines
272264 if (port->irq < 0)
273265 return port->irq;
274266
275− port->clk_port = devm_clk_get(&pdev->dev, "port");
267+ port->clk_port = devm_clk_get(dev, "port");
276268 if (!IS_ERR(port->clk_port)) {
277269 ret = clk_prepare_enable(port->clk_port);
278270 if (ret)
279271 return ret;
272+ ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk,
273+ port->clk_port);
274+ if (ret)
275+ return ret;
280276 } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) {
281277 /*
282278 * Percolate deferrals, for anything else,
@@ -285,20 +281,19 @@ static int vf610_gpio_probe(struct platform_device *pdev) · 2 unmodified lines
285281 return PTR_ERR(port->clk_port);
286282 }
287283
288− port->clk_gpio = devm_clk_get(&pdev->dev, "gpio");
284+ port->clk_gpio = devm_clk_get(dev, "gpio");
289285 if (!IS_ERR(port->clk_gpio)) {
290286 ret = clk_prepare_enable(port->clk_gpio);
291− if (ret) {
292− clk_disable_unprepare(port->clk_port);
287+ if (ret)
288+ return ret;
289+ ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk,
290+ port->clk_gpio);
291+ if (ret)
293292 return ret;
294− }
295293 } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) {
296− clk_disable_unprepare(port->clk_port);
297294 return PTR_ERR(port->clk_gpio);
298295 }
299296
300− platform_set_drvdata(pdev, port);
301−
302297 gc = &port->gc;
303298 gc->of_node = np;
304299 gc->parent = dev;
@@ -313,7 +308,15 @@ static int vf610_gpio_probe(struct platform_device *pdev) · 8 unmodified lines
313308 gc->direction_output = vf610_gpio_direction_output;
314309 gc->set = vf610_gpio_set;
315310
316− ret = gpiochip_add_data(gc, port);
311+ ic = &port->ic;
312+ ic->name = "gpio-vf610";
313+ ic->irq_ack = vf610_gpio_irq_ack;
314+ ic->irq_mask = vf610_gpio_irq_mask;
315+ ic->irq_unmask = vf610_gpio_irq_unmask;
316+ ic->irq_set_type = vf610_gpio_irq_set_type;
317+ ic->irq_set_wake = vf610_gpio_irq_set_wake;
318+
319+ ret = devm_gpiochip_add_data(dev, gc, port);
317320 if (ret < 0)
318321 return ret;
319322
@@ -324,39 +327,23 @@ static int vf610_gpio_probe(struct platform_device *pdev) · 4 unmodified lines
324327 /* Clear the interrupt status register for all GPIO's */
325328 vf610_gpio_writel(~0, port->base + PORT_ISFR);
326329
327− ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0,
328− handle_edge_irq, IRQ_TYPE_NONE);
330+ ret = gpiochip_irqchip_add(gc, ic, 0, handle_edge_irq, IRQ_TYPE_NONE);
329331 if (ret) {
330332 dev_err(dev, "failed to add irqchip\n");
331− gpiochip_remove(gc);
332333 return ret;
333334 }
334− gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, port->irq,
335+ gpiochip_set_chained_irqchip(gc, ic, port->irq,
335336 vf610_gpio_irq_handler);
336337
337338 return 0;
338339 }
339340
340−static int vf610_gpio_remove(struct platform_device *pdev)
341−{
342− struct vf610_gpio_port *port = platform_get_drvdata(pdev);
343−
344− gpiochip_remove(&port->gc);
345− if (!IS_ERR(port->clk_port))
346− clk_disable_unprepare(port->clk_port);
347− if (!IS_ERR(port->clk_gpio))
348− clk_disable_unprepare(port->clk_gpio);
349−
350− return 0;
351−}
352−
353341 static struct platform_driver vf610_gpio_driver = {
354342 .driver = {
355343 .name = "gpio-vf610",
356344 .of_match_table = vf610_gpio_dt_ids,
357345 },
358346 .probe = vf610_gpio_probe,
359− .remove = vf610_gpio_remove,
360347 };
361348
362349 builtin_platform_driver(vf610_gpio_driver);
drivers/gpio/gpiolib-acpi.c+25−20
@@ -24,13 +24,13 @@ · 23 unmodified lines
2424 *
2525 * @node: list-entry of the events list of the struct acpi_gpio_chip
2626 * @handle: handle of ACPI method to execute when the IRQ triggers
27− * @handler: irq_handler to pass to request_irq when requesting the IRQ
28− * @pin: GPIO pin number on the gpio_chip
29− * @irq: Linux IRQ number for the event, for request_ / free_irq
30− * @irqflags: flags to pass to request_irq when requesting the IRQ
27+ * @handler: handler function to pass to request_irq() when requesting the IRQ
28+ * @pin: GPIO pin number on the struct gpio_chip
29+ * @irq: Linux IRQ number for the event, for request_irq() / free_irq()
30+ * @irqflags: flags to pass to request_irq() when requesting the IRQ
3131 * @irq_is_wake: If the ACPI flags indicate the IRQ is a wakeup source
32− * @irq_requested:True if request_irq has been done
33− * @desc: gpio_desc for the GPIO pin for this event
32+ * @irq_requested:True if request_irq() has been done
33+ * @desc: struct gpio_desc for the GPIO pin for this event
3434 */
3535 struct acpi_gpio_event {
3636 struct list_head node;
@@ -65,10 +65,10 @@ struct acpi_gpio_chip { · 28 unmodified lines
6565 };
6666
6767 /*
68− * For gpiochips which call acpi_gpiochip_request_interrupts() before late_init
68+ * For GPIO chips which call acpi_gpiochip_request_interrupts() before late_init
6969 * (so builtin drivers) we register the ACPI GpioInt IRQ handlers from a
70− * late_initcall_sync handler, so that other builtin drivers can register their
71− * OpRegions before the event handlers can run. This list contains gpiochips
70+ * late_initcall_sync() handler, so that other builtin drivers can register their
71+ * OpRegions before the event handlers can run. This list contains GPIO chips
7272 * for which the acpi_gpiochip_request_irqs() call has been deferred.
7373 */
7474 static DEFINE_MUTEX(acpi_gpio_deferred_req_irqs_lock);
@@ -90,7 +90,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) · 15 unmodified lines
9090 *
9191 * Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR
9292 * error value. Specifically returns %-EPROBE_DEFER if the referenced GPIO
93− * controller does not have gpiochip registered at the moment. This is to
93+ * controller does not have GPIO chip registered at the moment. This is to
9494 * support probe deferral.
9595 */
9696 static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
@@ -287,9 +287,9 @@ fail_free_desc: · 190 unmodified lines
287287 *
288288 * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are
289289 * handled by ACPI event methods which need to be called from the GPIO
290− * chip's interrupt handler. acpi_gpiochip_request_interrupts finds out which
291− * gpio pins have acpi event methods and assigns interrupt handlers that calls
292− * the acpi event methods for those pins.
290+ * chip's interrupt handler. acpi_gpiochip_request_interrupts() finds out which
291+ * GPIO pins have ACPI event methods and assigns interrupt handlers that calls
292+ * the ACPI event methods for those pins.
293293 */
294294 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
295295 {
@@ -653,7 +653,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, · 357 unmodified lines
653653 * that case @index is used to select the GPIO entry in the property value
654654 * (in case of multiple).
655655 *
656− * If the GPIO cannot be translated or there is an error an ERR_PTR is
656+ * If the GPIO cannot be translated or there is an error, an ERR_PTR is
657657 * returned.
658658 *
659659 * Note: if the GPIO resource has multiple entries in the pin list, this
@@ -751,10 +751,13 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, · 91 unmodified lines
751751 * @index: index of GpioIo/GpioInt resource (starting from %0)
752752 * @info: info pointer to fill in (optional)
753753 *
754− * If @fwnode is an ACPI device object, call %acpi_get_gpiod_by_index() for it.
755− * Otherwise (ie. it is a data-only non-device object), use the property-based
754+ * If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it.
755+ * Otherwise (i.e. it is a data-only non-device object), use the property-based
756756 * GPIO lookup to get to the GPIO resource with the relevant information and use
757757 * that to obtain the GPIO descriptor to return.
758+ *
759+ * If the GPIO cannot be translated or there is an error an ERR_PTR is
760+ * returned.
758761 */
759762 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
760763 const char *propname, int index,
@@ -1158,11 +1161,13 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data) · 397 unmodified lines
11581161 }
11591162
11601163 /**
1161− * acpi_gpio_count - return the number of GPIOs associated with a
1162− * device / function or -ENOENT if no GPIO has been
1163− * assigned to the requested function.
1164− * @dev: GPIO consumer, can be NULL for system-global GPIOs
1164+ * acpi_gpio_count - count the GPIOs associated with a device / function
1165+ * @dev: GPIO consumer, can be %NULL for system-global GPIOs
11651166 * @con_id: function within the GPIO consumer
1167+ *
1168+ * Return:
1169+ * The number of GPIOs associated with a device / function or %-ENOENT,
1170+ * if no GPIO has been assigned to the requested function.
11661171 */
11671172 int acpi_gpio_count(struct device *dev, const char *con_id)
11681173 {
drivers/gpio/gpiolib.c+2−1
@@ -4626,7 +4626,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_optional); · 4625 unmodified lines
46264626 */
46274627 void gpiod_put(struct gpio_desc *desc)
46284628 {
4629− gpiod_free(desc);
4629+ if (desc)
4630+ gpiod_free(desc);
46304631 }
46314632 EXPORT_SYMBOL_GPL(gpiod_put);
46324633

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t