hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mfd/qcom-pm8xxx.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 and
6
- * only version 2 as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #define pr_fmt(fmt) "%s: " fmt, __func__
....@@ -70,20 +62,21 @@
7062 #define PM8XXX_NR_IRQS 256
7163 #define PM8821_NR_IRQS 112
7264
65
+struct pm_irq_data {
66
+ int num_irqs;
67
+ struct irq_chip *irq_chip;
68
+ void (*irq_handler)(struct irq_desc *desc);
69
+};
70
+
7371 struct pm_irq_chip {
7472 struct regmap *regmap;
7573 spinlock_t pm_irq_lock;
7674 struct irq_domain *irqdomain;
77
- unsigned int num_irqs;
7875 unsigned int num_blocks;
7976 unsigned int num_masters;
80
- u8 config[0];
81
-};
82
-
83
-struct pm_irq_data {
84
- int num_irqs;
85
- const struct irq_domain_ops *irq_domain_ops;
86
- void (*irq_handler)(struct irq_desc *desc);
77
+ const struct pm_irq_data *pm_irq_data;
78
+ /* MUST BE AT THE END OF THIS STRUCT */
79
+ u8 config[];
8780 };
8881
8982 static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, unsigned int bp,
....@@ -375,21 +368,38 @@
375368 .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE,
376369 };
377370
378
-static int pm8xxx_irq_domain_map(struct irq_domain *d, unsigned int irq,
379
- irq_hw_number_t hwirq)
371
+static void pm8xxx_irq_domain_map(struct pm_irq_chip *chip,
372
+ struct irq_domain *domain, unsigned int irq,
373
+ irq_hw_number_t hwirq, unsigned int type)
380374 {
381
- struct pm_irq_chip *chip = d->host_data;
382
-
383
- irq_set_chip_and_handler(irq, &pm8xxx_irq_chip, handle_level_irq);
384
- irq_set_chip_data(irq, chip);
375
+ irq_domain_set_info(domain, irq, hwirq, chip->pm_irq_data->irq_chip,
376
+ chip, handle_level_irq, NULL, NULL);
385377 irq_set_noprobe(irq);
378
+}
379
+
380
+static int pm8xxx_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
381
+ unsigned int nr_irqs, void *data)
382
+{
383
+ struct pm_irq_chip *chip = domain->host_data;
384
+ struct irq_fwspec *fwspec = data;
385
+ irq_hw_number_t hwirq;
386
+ unsigned int type;
387
+ int ret, i;
388
+
389
+ ret = irq_domain_translate_twocell(domain, fwspec, &hwirq, &type);
390
+ if (ret)
391
+ return ret;
392
+
393
+ for (i = 0; i < nr_irqs; i++)
394
+ pm8xxx_irq_domain_map(chip, domain, virq + i, hwirq + i, type);
386395
387396 return 0;
388397 }
389398
390399 static const struct irq_domain_ops pm8xxx_irq_domain_ops = {
391
- .xlate = irq_domain_xlate_twocell,
392
- .map = pm8xxx_irq_domain_map,
400
+ .alloc = pm8xxx_irq_domain_alloc,
401
+ .free = irq_domain_free_irqs_common,
402
+ .translate = irq_domain_translate_twocell,
393403 };
394404
395405 static void pm8821_irq_mask_ack(struct irq_data *d)
....@@ -473,23 +483,6 @@
473483 .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE,
474484 };
475485
476
-static int pm8821_irq_domain_map(struct irq_domain *d, unsigned int irq,
477
- irq_hw_number_t hwirq)
478
-{
479
- struct pm_irq_chip *chip = d->host_data;
480
-
481
- irq_set_chip_and_handler(irq, &pm8821_irq_chip, handle_level_irq);
482
- irq_set_chip_data(irq, chip);
483
- irq_set_noprobe(irq);
484
-
485
- return 0;
486
-}
487
-
488
-static const struct irq_domain_ops pm8821_irq_domain_ops = {
489
- .xlate = irq_domain_xlate_twocell,
490
- .map = pm8821_irq_domain_map,
491
-};
492
-
493486 static const struct regmap_config ssbi_regmap_config = {
494487 .reg_bits = 16,
495488 .val_bits = 8,
....@@ -501,13 +494,13 @@
501494
502495 static const struct pm_irq_data pm8xxx_data = {
503496 .num_irqs = PM8XXX_NR_IRQS,
504
- .irq_domain_ops = &pm8xxx_irq_domain_ops,
497
+ .irq_chip = &pm8xxx_irq_chip,
505498 .irq_handler = pm8xxx_irq_handler,
506499 };
507500
508501 static const struct pm_irq_data pm8821_data = {
509502 .num_irqs = PM8821_NR_IRQS,
510
- .irq_domain_ops = &pm8821_irq_domain_ops,
503
+ .irq_chip = &pm8821_irq_chip,
511504 .irq_handler = pm8821_irq_handler,
512505 };
513506
....@@ -571,14 +564,14 @@
571564
572565 platform_set_drvdata(pdev, chip);
573566 chip->regmap = regmap;
574
- chip->num_irqs = data->num_irqs;
575
- chip->num_blocks = DIV_ROUND_UP(chip->num_irqs, 8);
567
+ chip->num_blocks = DIV_ROUND_UP(data->num_irqs, 8);
576568 chip->num_masters = DIV_ROUND_UP(chip->num_blocks, 8);
569
+ chip->pm_irq_data = data;
577570 spin_lock_init(&chip->pm_irq_lock);
578571
579572 chip->irqdomain = irq_domain_add_linear(pdev->dev.of_node,
580573 data->num_irqs,
581
- data->irq_domain_ops,
574
+ &pm8xxx_irq_domain_ops,
582575 chip);
583576 if (!chip->irqdomain)
584577 return -ENODEV;