Lines Matching +full:irqs +full:- +full:reserved
1 // SPDX-License-Identifier: GPL-2.0-only
3 * PRU-ICSS INTC IRQChip driver for various TI SoCs
5 * Copyright (C) 2016-2020 Texas Instruments Incorporated - http://www.ti.com/
9 * Suman Anna <s-anna@ti.com>
24 * Number of host interrupts reaching the main MPU sub-system. Note that this
57 /* CMR register bit-field macros */
62 /* HMR register bit-field macros */
67 /* HIPIR register bit-fields */
74 * struct pruss_intc_map_record - keeps track of actual mapping state
84 * struct pruss_intc_match_data - match data to handle SoC variations
95 * struct pruss_intc - PRUSS interrupt controller structure
98 * @irqs: kernel irq numbers corresponding to PRUSS host interrupts
108 unsigned int irqs[MAX_NUM_HOST_IRQS]; member
117 * struct pruss_host_irq_data - PRUSS host irq data structure
128 return readl_relaxed(intc->base + reg); in pruss_intc_read_reg()
134 writel_relaxed(val, intc->base + reg); in pruss_intc_write_reg()
150 dev_dbg(intc->dev, "SYSEV%u -> CH%d (CMR%d 0x%08x)\n", evt, ch, in pruss_intc_update_cmr()
166 dev_dbg(intc->dev, "CH%d -> HOST%d (HMR%d 0x%08x)\n", ch, host, idx, in pruss_intc_update_hmr()
171 * pruss_intc_map() - configure the PRUSS INTC
180 struct device *dev = intc->dev; in pruss_intc_map()
184 mutex_lock(&intc->lock); in pruss_intc_map()
186 intc->event_channel[hwirq].ref_count++; in pruss_intc_map()
188 ch = intc->event_channel[hwirq].value; in pruss_intc_map()
189 host = intc->channel_host[ch].value; in pruss_intc_map()
200 if (++intc->channel_host[ch].ref_count == 1) { in pruss_intc_map()
210 mutex_unlock(&intc->lock); in pruss_intc_map()
214 * pruss_intc_unmap() - unconfigure the PRUSS INTC
227 mutex_lock(&intc->lock); in pruss_intc_unmap()
229 ch = intc->event_channel[hwirq].value; in pruss_intc_unmap()
230 host = intc->channel_host[ch].value; in pruss_intc_unmap()
232 if (--intc->channel_host[ch].ref_count == 0) { in pruss_intc_unmap()
240 intc->event_channel[hwirq].ref_count--; in pruss_intc_unmap()
252 dev_dbg(intc->dev, "unmapped system_event = %lu channel = %d host = %d\n", in pruss_intc_unmap()
255 mutex_unlock(&intc->lock); in pruss_intc_unmap()
260 const struct pruss_intc_match_data *soc_config = intc->soc_config; in pruss_intc_init()
263 num_chnl_map_regs = DIV_ROUND_UP(soc_config->num_system_events, in pruss_intc_init()
265 num_host_intr_regs = DIV_ROUND_UP(soc_config->num_host_events, in pruss_intc_init()
267 num_event_type_regs = DIV_ROUND_UP(soc_config->num_system_events, 32); in pruss_intc_init()
293 unsigned int hwirq = data->hwirq; in pruss_intc_irq_ack()
301 unsigned int hwirq = data->hwirq; in pruss_intc_irq_mask()
309 unsigned int hwirq = data->hwirq; in pruss_intc_irq_unmask()
317 return -ENODEV; in pruss_intc_irq_reqres()
335 return -EINVAL; in pruss_intc_irq_get_irqchip_state()
337 reg = PRU_INTC_SRSR(data->hwirq / 32); in pruss_intc_irq_get_irqchip_state()
338 mask = BIT(data->hwirq % 32); in pruss_intc_irq_get_irqchip_state()
354 return -EINVAL; in pruss_intc_irq_set_irqchip_state()
357 pruss_intc_write_reg(intc, PRU_INTC_SISR, data->hwirq); in pruss_intc_irq_set_irqchip_state()
359 pruss_intc_write_reg(intc, PRU_INTC_SICR, data->hwirq); in pruss_intc_irq_set_irqchip_state()
365 .name = "pruss-intc",
378 struct device *dev = intc->dev; in pruss_intc_validate_mapping()
381 mutex_lock(&intc->lock); in pruss_intc_validate_mapping()
384 if (intc->event_channel[event].ref_count > 0 && in pruss_intc_validate_mapping()
385 intc->event_channel[event].value != channel) { in pruss_intc_validate_mapping()
387 event, channel, intc->event_channel[event].value); in pruss_intc_validate_mapping()
388 ret = -EBUSY; in pruss_intc_validate_mapping()
393 if (intc->channel_host[channel].ref_count > 0 && in pruss_intc_validate_mapping()
394 intc->channel_host[channel].value != host) { in pruss_intc_validate_mapping()
396 channel, host, intc->channel_host[channel].value); in pruss_intc_validate_mapping()
397 ret = -EBUSY; in pruss_intc_validate_mapping()
401 intc->event_channel[event].value = channel; in pruss_intc_validate_mapping()
402 intc->channel_host[channel].value = host; in pruss_intc_validate_mapping()
405 mutex_unlock(&intc->lock); in pruss_intc_validate_mapping()
414 struct pruss_intc *intc = d->host_data; in pruss_intc_irq_domain_xlate()
415 struct device *dev = intc->dev; in pruss_intc_irq_domain_xlate()
419 return -EINVAL; in pruss_intc_irq_domain_xlate()
422 if (sys_event < 0 || sys_event >= intc->soc_config->num_system_events) { in pruss_intc_irq_domain_xlate()
424 return -EINVAL; in pruss_intc_irq_domain_xlate()
428 if (channel < 0 || channel >= intc->soc_config->num_host_events) { in pruss_intc_irq_domain_xlate()
430 return -EINVAL; in pruss_intc_irq_domain_xlate()
434 if (host < 0 || host >= intc->soc_config->num_host_events) { in pruss_intc_irq_domain_xlate()
436 return -EINVAL; in pruss_intc_irq_domain_xlate()
453 struct pruss_intc *intc = d->host_data; in pruss_intc_irq_domain_map()
465 struct pruss_intc *intc = d->host_data; in pruss_intc_irq_domain_unmap()
484 struct pruss_intc *intc = host_irq_data->intc; in pruss_intc_irq_handler()
485 u8 host_irq = host_irq_data->host_irq + FIRST_PRU_HOST_INT; in pruss_intc_irq_handler()
499 err = generic_handle_domain_irq(intc->domain, hwirq); in pruss_intc_irq_handler()
520 struct device *dev = &pdev->dev; in pruss_intc_probe()
528 return -ENODEV; in pruss_intc_probe()
530 max_system_events = data->num_system_events; in pruss_intc_probe()
534 return -ENOMEM; in pruss_intc_probe()
536 intc->soc_config = data; in pruss_intc_probe()
537 intc->dev = dev; in pruss_intc_probe()
540 intc->base = devm_platform_ioremap_resource(pdev, 0); in pruss_intc_probe()
541 if (IS_ERR(intc->base)) in pruss_intc_probe()
542 return PTR_ERR(intc->base); in pruss_intc_probe()
544 ret = of_property_read_u8(dev->of_node, "ti,irqs-reserved", in pruss_intc_probe()
548 * The irqs-reserved is used only for some SoC's therefore not having in pruss_intc_probe()
551 if (ret < 0 && ret != -EINVAL) in pruss_intc_probe()
556 mutex_init(&intc->lock); in pruss_intc_probe()
558 intc->domain = irq_domain_add_linear(dev->of_node, max_system_events, in pruss_intc_probe()
560 if (!intc->domain) in pruss_intc_probe()
561 return -ENOMEM; in pruss_intc_probe()
573 intc->irqs[i] = irq; in pruss_intc_probe()
577 ret = -ENOMEM; in pruss_intc_probe()
581 host_data->intc = intc; in pruss_intc_probe()
582 host_data->host_irq = i; in pruss_intc_probe()
591 while (--i >= 0) { in pruss_intc_probe()
592 if (intc->irqs[i]) in pruss_intc_probe()
593 irq_set_chained_handler_and_data(intc->irqs[i], NULL, in pruss_intc_probe()
597 irq_domain_remove(intc->domain); in pruss_intc_probe()
605 u8 max_system_events = intc->soc_config->num_system_events; in pruss_intc_remove()
610 if (intc->irqs[i]) in pruss_intc_remove()
611 irq_set_chained_handler_and_data(intc->irqs[i], NULL, in pruss_intc_remove()
616 irq_dispose_mapping(irq_find_mapping(intc->domain, hwirq)); in pruss_intc_remove()
618 irq_domain_remove(intc->domain); in pruss_intc_remove()
633 .compatible = "ti,pruss-intc",
637 .compatible = "ti,icssg-intc",
646 .name = "pruss-intc",
656 MODULE_AUTHOR("Suman Anna <s-anna@ti.com>");
658 MODULE_DESCRIPTION("TI PRU-ICSS INTC Driver");