qcom-pdc.c (4dc70713dc24dceeea7f106828674744a6294860) qcom-pdc.c (d494d088ac44b9cf561362a7856fa20b656be64f)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
4 */
5
6#include <linux/err.h>
7#include <linux/init.h>
8#include <linux/interrupt.h>

--- 184 unchanged lines hidden (view full) ---

193 if (pin >= pdc_region[i].pin_base &&
194 pin < pdc_region[i].pin_base + pdc_region[i].cnt)
195 return &pdc_region[i];
196 }
197
198 return NULL;
199}
200
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
4 */
5
6#include <linux/err.h>
7#include <linux/init.h>
8#include <linux/interrupt.h>

--- 184 unchanged lines hidden (view full) ---

193 if (pin >= pdc_region[i].pin_base &&
194 pin < pdc_region[i].pin_base + pdc_region[i].cnt)
195 return &pdc_region[i];
196 }
197
198 return NULL;
199}
200
201static int qcom_pdc_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
202 unsigned long *hwirq, unsigned int *type)
203{
204 if (is_of_node(fwspec->fwnode)) {
205 if (fwspec->param_count != 2)
206 return -EINVAL;
207
208 *hwirq = fwspec->param[0];
209 *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
210 return 0;
211 }
212
213 return -EINVAL;
214}
215
216static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
217 unsigned int nr_irqs, void *data)
218{
219 struct irq_fwspec *fwspec = data;
220 struct irq_fwspec parent_fwspec;
221 struct pdc_pin_region *region;
222 irq_hw_number_t hwirq;
223 unsigned int type;
224 int ret;
225
201static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
202 unsigned int nr_irqs, void *data)
203{
204 struct irq_fwspec *fwspec = data;
205 struct irq_fwspec parent_fwspec;
206 struct pdc_pin_region *region;
207 irq_hw_number_t hwirq;
208 unsigned int type;
209 int ret;
210
226 ret = qcom_pdc_translate(domain, fwspec, &hwirq, &type);
211 ret = irq_domain_translate_twocell(domain, fwspec, &hwirq, &type);
227 if (ret)
228 return ret;
229
230 if (hwirq == GPIO_NO_WAKE_IRQ)
231 return irq_domain_disconnect_hierarchy(domain, virq);
232
233 ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
234 &qcom_pdc_gic_chip, NULL);

--- 16 unchanged lines hidden (view full) ---

251 parent_fwspec.param[1] = pin_to_hwirq(region, hwirq);
252 parent_fwspec.param[2] = type;
253
254 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
255 &parent_fwspec);
256}
257
258static const struct irq_domain_ops qcom_pdc_ops = {
212 if (ret)
213 return ret;
214
215 if (hwirq == GPIO_NO_WAKE_IRQ)
216 return irq_domain_disconnect_hierarchy(domain, virq);
217
218 ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
219 &qcom_pdc_gic_chip, NULL);

--- 16 unchanged lines hidden (view full) ---

236 parent_fwspec.param[1] = pin_to_hwirq(region, hwirq);
237 parent_fwspec.param[2] = type;
238
239 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
240 &parent_fwspec);
241}
242
243static const struct irq_domain_ops qcom_pdc_ops = {
259 .translate = qcom_pdc_translate,
244 .translate = irq_domain_translate_twocell,
260 .alloc = qcom_pdc_alloc,
261 .free = irq_domain_free_irqs_common,
262};
263
264static int pdc_setup_pin_mapping(struct device_node *np)
265{
266 int ret, n, i;
267 u32 irq_index, reg_index, val;

--- 91 unchanged lines hidden ---
245 .alloc = qcom_pdc_alloc,
246 .free = irq_domain_free_irqs_common,
247};
248
249static int pdc_setup_pin_mapping(struct device_node *np)
250{
251 int ret, n, i;
252 u32 irq_index, reg_index, val;

--- 91 unchanged lines hidden ---