Lines Matching +full:sci +full:- +full:intr

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2018-2019 Texas Instruments Incorporated - https://www.ti.com/
21 * struct ti_sci_intr_irq_domain - Structure representing a TISCI based
23 * @sci: Pointer to TISCI handle
24 * @out_irqs: TISCI resource pointer representing INTR irqs.
26 * @ti_sci_id: TI-SCI device identifier
30 const struct ti_sci_handle *sci; member
38 .name = "INTR",
48 * ti_sci_intr_irq_domain_translate() - Retrieve hwirq and type from
62 struct ti_sci_intr_irq_domain *intr = domain->host_data; in ti_sci_intr_irq_domain_translate() local
64 if (fwspec->param_count != 1) in ti_sci_intr_irq_domain_translate()
65 return -EINVAL; in ti_sci_intr_irq_domain_translate()
67 *hwirq = fwspec->param[0]; in ti_sci_intr_irq_domain_translate()
68 *type = intr->type; in ti_sci_intr_irq_domain_translate()
74 * ti_sci_intr_xlate_irq() - Translate hwirq to parent's hwirq.
75 * @intr: IRQ domain corresponding to Interrupt Router
78 * Return parent irq number if translation is available else -ENOENT.
80 static int ti_sci_intr_xlate_irq(struct ti_sci_intr_irq_domain *intr, u32 irq) in ti_sci_intr_xlate_irq() argument
82 struct device_node *np = dev_of_node(intr->dev); in ti_sci_intr_xlate_irq()
86 range = of_get_property(np, "ti,interrupt-ranges", &len); in ti_sci_intr_xlate_irq()
90 for (len /= sizeof(*range); len >= 3; len -= 3) { in ti_sci_intr_xlate_irq()
96 return irq - base + pbase; in ti_sci_intr_xlate_irq()
99 return -ENOENT; in ti_sci_intr_xlate_irq()
103 * ti_sci_intr_irq_domain_free() - Free the specified IRQs from the domain.
111 struct ti_sci_intr_irq_domain *intr = domain->host_data; in ti_sci_intr_irq_domain_free() local
116 out_irq = (uintptr_t)data->chip_data; in ti_sci_intr_irq_domain_free()
118 intr->sci->ops.rm_irq_ops.free_irq(intr->sci, in ti_sci_intr_irq_domain_free()
119 intr->ti_sci_id, data->hwirq, in ti_sci_intr_irq_domain_free()
120 intr->ti_sci_id, out_irq); in ti_sci_intr_irq_domain_free()
121 ti_sci_release_resource(intr->out_irqs, out_irq); in ti_sci_intr_irq_domain_free()
127 * ti_sci_intr_alloc_parent_irq() - Allocate parent IRQ
132 * Returns intr output irq if all went well else appropriate error pointer.
137 struct ti_sci_intr_irq_domain *intr = domain->host_data; in ti_sci_intr_alloc_parent_irq() local
143 out_irq = ti_sci_get_free_resource(intr->out_irqs); in ti_sci_intr_alloc_parent_irq()
145 return -EINVAL; in ti_sci_intr_alloc_parent_irq()
147 p_hwirq = ti_sci_intr_xlate_irq(intr, out_irq); in ti_sci_intr_alloc_parent_irq()
151 parent_node = of_irq_find_parent(dev_of_node(intr->dev)); in ti_sci_intr_alloc_parent_irq()
154 if (of_device_is_compatible(parent_node, "arm,gic-v3")) { in ti_sci_intr_alloc_parent_irq()
158 fwspec.param[1] = p_hwirq - 32; /* SPI offset */ in ti_sci_intr_alloc_parent_irq()
159 fwspec.param[2] = intr->type; in ti_sci_intr_alloc_parent_irq()
170 err = intr->sci->ops.rm_irq_ops.set_irq(intr->sci, in ti_sci_intr_alloc_parent_irq()
171 intr->ti_sci_id, hwirq, in ti_sci_intr_alloc_parent_irq()
172 intr->ti_sci_id, out_irq); in ti_sci_intr_alloc_parent_irq()
181 ti_sci_release_resource(intr->out_irqs, out_irq); in ti_sci_intr_alloc_parent_irq()
186 * ti_sci_intr_irq_domain_alloc() - Allocate Interrupt router IRQs
227 struct ti_sci_intr_irq_domain *intr; in ti_sci_intr_irq_domain_probe() local
229 struct device *dev = &pdev->dev; in ti_sci_intr_irq_domain_probe()
235 return -ENODEV; in ti_sci_intr_irq_domain_probe()
242 return -ENODEV; in ti_sci_intr_irq_domain_probe()
245 intr = devm_kzalloc(dev, sizeof(*intr), GFP_KERNEL); in ti_sci_intr_irq_domain_probe()
246 if (!intr) in ti_sci_intr_irq_domain_probe()
247 return -ENOMEM; in ti_sci_intr_irq_domain_probe()
249 intr->dev = dev; in ti_sci_intr_irq_domain_probe()
250 ret = of_property_read_u32(dev_of_node(dev), "ti,intr-trigger-type", in ti_sci_intr_irq_domain_probe()
251 &intr->type); in ti_sci_intr_irq_domain_probe()
253 dev_err(dev, "missing ti,intr-trigger-type property\n"); in ti_sci_intr_irq_domain_probe()
254 return -EINVAL; in ti_sci_intr_irq_domain_probe()
257 intr->sci = devm_ti_sci_get_by_phandle(dev, "ti,sci"); in ti_sci_intr_irq_domain_probe()
258 if (IS_ERR(intr->sci)) in ti_sci_intr_irq_domain_probe()
259 return dev_err_probe(dev, PTR_ERR(intr->sci), in ti_sci_intr_irq_domain_probe()
260 "ti,sci read fail\n"); in ti_sci_intr_irq_domain_probe()
262 ret = of_property_read_u32(dev_of_node(dev), "ti,sci-dev-id", in ti_sci_intr_irq_domain_probe()
263 &intr->ti_sci_id); in ti_sci_intr_irq_domain_probe()
265 dev_err(dev, "missing 'ti,sci-dev-id' property\n"); in ti_sci_intr_irq_domain_probe()
266 return -EINVAL; in ti_sci_intr_irq_domain_probe()
269 intr->out_irqs = devm_ti_sci_get_resource(intr->sci, dev, in ti_sci_intr_irq_domain_probe()
270 intr->ti_sci_id, in ti_sci_intr_irq_domain_probe()
272 if (IS_ERR(intr->out_irqs)) { in ti_sci_intr_irq_domain_probe()
274 return PTR_ERR(intr->out_irqs); in ti_sci_intr_irq_domain_probe()
278 &ti_sci_intr_irq_domain_ops, intr); in ti_sci_intr_irq_domain_probe()
281 return -ENOMEM; in ti_sci_intr_irq_domain_probe()
284 dev_info(dev, "Interrupt Router %d domain created\n", intr->ti_sci_id); in ti_sci_intr_irq_domain_probe()
290 { .compatible = "ti,sci-intr", },
298 .name = "ti-sci-intr",
305 MODULE_DESCRIPTION("K3 Interrupt Router driver over TI SCI protocol");