hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpio/gpio-intel-mid.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Intel MID GPIO driver
34 *
45 * Copyright (c) 2008-2014,2016 Intel Corporation.
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 version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 /* Supports:
....@@ -20,12 +12,11 @@
2012 */
2113
2214 #include <linux/delay.h>
15
+#include <linux/gpio/driver.h>
2316 #include <linux/init.h>
2417 #include <linux/interrupt.h>
2518 #include <linux/io.h>
26
-#include <linux/gpio/driver.h>
2719 #include <linux/kernel.h>
28
-#include <linux/module.h>
2920 #include <linux/pci.h>
3021 #include <linux/platform_device.h>
3122 #include <linux/pm_runtime.h>
....@@ -273,9 +264,8 @@
273264 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x08f7),
274265 .driver_data = (kernel_ulong_t)&gpio_cloverview_core,
275266 },
276
- { 0 }
267
+ { }
277268 };
278
-MODULE_DEVICE_TABLE(pci, intel_gpio_ids);
279269
280270 static void intel_mid_irq_handler(struct irq_desc *desc)
281271 {
....@@ -303,8 +293,9 @@
303293 chip->irq_eoi(data);
304294 }
305295
306
-static void intel_mid_irq_init_hw(struct intel_mid_gpio *priv)
296
+static int intel_mid_irq_init_hw(struct gpio_chip *chip)
307297 {
298
+ struct intel_mid_gpio *priv = gpiochip_get_data(chip);
308299 void __iomem *reg;
309300 unsigned base;
310301
....@@ -319,6 +310,8 @@
319310 reg = gpio_reg(&priv->chip, base, GEDR);
320311 writel(~0, reg);
321312 }
313
+
314
+ return 0;
322315 }
323316
324317 static int __maybe_unused intel_gpio_runtime_idle(struct device *dev)
....@@ -339,6 +332,7 @@
339332 u32 gpio_base;
340333 u32 irq_base;
341334 int retval;
335
+ struct gpio_irq_chip *girq;
342336 struct intel_mid_gpio_ddata *ddata =
343337 (struct intel_mid_gpio_ddata *)id->driver_data;
344338
....@@ -379,30 +373,28 @@
379373
380374 spin_lock_init(&priv->lock);
381375
376
+ girq = &priv->chip.irq;
377
+ girq->chip = &intel_mid_irqchip;
378
+ girq->init_hw = intel_mid_irq_init_hw;
379
+ girq->parent_handler = intel_mid_irq_handler;
380
+ girq->num_parents = 1;
381
+ girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents,
382
+ sizeof(*girq->parents),
383
+ GFP_KERNEL);
384
+ if (!girq->parents)
385
+ return -ENOMEM;
386
+ girq->parents[0] = pdev->irq;
387
+ girq->first = irq_base;
388
+ girq->default_type = IRQ_TYPE_NONE;
389
+ girq->handler = handle_simple_irq;
390
+
382391 pci_set_drvdata(pdev, priv);
392
+
383393 retval = devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv);
384394 if (retval) {
385395 dev_err(&pdev->dev, "gpiochip_add error %d\n", retval);
386396 return retval;
387397 }
388
-
389
- retval = gpiochip_irqchip_add(&priv->chip,
390
- &intel_mid_irqchip,
391
- irq_base,
392
- handle_simple_irq,
393
- IRQ_TYPE_NONE);
394
- if (retval) {
395
- dev_err(&pdev->dev,
396
- "could not connect irqchip to gpiochip\n");
397
- return retval;
398
- }
399
-
400
- intel_mid_irq_init_hw(priv);
401
-
402
- gpiochip_set_chained_irqchip(&priv->chip,
403
- &intel_mid_irqchip,
404
- pdev->irq,
405
- intel_mid_irq_handler);
406398
407399 pm_runtime_put_noidle(&pdev->dev);
408400 pm_runtime_allow(&pdev->dev);