Lines Matching refs:intc
122 struct pruss_intc *intc; member
126 static inline u32 pruss_intc_read_reg(struct pruss_intc *intc, unsigned int reg) in pruss_intc_read_reg() argument
128 return readl_relaxed(intc->base + reg); in pruss_intc_read_reg()
131 static inline void pruss_intc_write_reg(struct pruss_intc *intc, in pruss_intc_write_reg() argument
134 writel_relaxed(val, intc->base + reg); in pruss_intc_write_reg()
137 static void pruss_intc_update_cmr(struct pruss_intc *intc, unsigned int evt, in pruss_intc_update_cmr() argument
145 val = pruss_intc_read_reg(intc, PRU_INTC_CMR(idx)); in pruss_intc_update_cmr()
148 pruss_intc_write_reg(intc, PRU_INTC_CMR(idx), val); in pruss_intc_update_cmr()
150 dev_dbg(intc->dev, "SYSEV%u -> CH%d (CMR%d 0x%08x)\n", evt, ch, in pruss_intc_update_cmr()
151 idx, pruss_intc_read_reg(intc, PRU_INTC_CMR(idx))); in pruss_intc_update_cmr()
154 static void pruss_intc_update_hmr(struct pruss_intc *intc, u8 ch, u8 host) in pruss_intc_update_hmr() argument
161 val = pruss_intc_read_reg(intc, PRU_INTC_HMR(idx)); in pruss_intc_update_hmr()
164 pruss_intc_write_reg(intc, PRU_INTC_HMR(idx), val); in pruss_intc_update_hmr()
166 dev_dbg(intc->dev, "CH%d -> HOST%d (HMR%d 0x%08x)\n", ch, host, idx, in pruss_intc_update_hmr()
167 pruss_intc_read_reg(intc, PRU_INTC_HMR(idx))); in pruss_intc_update_hmr()
178 static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq) in pruss_intc_map() argument
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()
191 pruss_intc_update_cmr(intc, hwirq, ch); in pruss_intc_map()
197 pruss_intc_write_reg(intc, PRU_INTC_ESR(reg_idx), val); in pruss_intc_map()
198 pruss_intc_write_reg(intc, PRU_INTC_SECR(reg_idx), val); in pruss_intc_map()
200 if (++intc->channel_host[ch].ref_count == 1) { in pruss_intc_map()
201 pruss_intc_update_hmr(intc, ch, host); in pruss_intc_map()
204 pruss_intc_write_reg(intc, PRU_INTC_HIEISR, host); in pruss_intc_map()
210 mutex_unlock(&intc->lock); in pruss_intc_map()
222 static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq) in pruss_intc_unmap() argument
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()
234 pruss_intc_write_reg(intc, PRU_INTC_HIDISR, host); in pruss_intc_unmap()
237 pruss_intc_update_hmr(intc, ch, 0); in pruss_intc_unmap()
240 intc->event_channel[hwirq].ref_count--; in pruss_intc_unmap()
245 pruss_intc_write_reg(intc, PRU_INTC_ECR(reg_idx), val); in pruss_intc_unmap()
247 pruss_intc_write_reg(intc, PRU_INTC_SECR(reg_idx), val); in pruss_intc_unmap()
250 pruss_intc_update_cmr(intc, hwirq, 0); 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()
258 static void pruss_intc_init(struct pruss_intc *intc) in pruss_intc_init() argument
260 const struct pruss_intc_match_data *soc_config = intc->soc_config; in pruss_intc_init()
274 pruss_intc_write_reg(intc, PRU_INTC_SIPR(i), 0xffffffff); in pruss_intc_init()
275 pruss_intc_write_reg(intc, PRU_INTC_SITR(i), 0); in pruss_intc_init()
280 pruss_intc_write_reg(intc, PRU_INTC_CMR(i), 0); in pruss_intc_init()
284 pruss_intc_write_reg(intc, PRU_INTC_HMR(i), 0); in pruss_intc_init()
287 pruss_intc_write_reg(intc, PRU_INTC_GER, 1); in pruss_intc_init()
292 struct pruss_intc *intc = irq_data_get_irq_chip_data(data); in pruss_intc_irq_ack() local
295 pruss_intc_write_reg(intc, PRU_INTC_SICR, hwirq); in pruss_intc_irq_ack()
300 struct pruss_intc *intc = irq_data_get_irq_chip_data(data); in pruss_intc_irq_mask() local
303 pruss_intc_write_reg(intc, PRU_INTC_EICR, hwirq); in pruss_intc_irq_mask()
308 struct pruss_intc *intc = irq_data_get_irq_chip_data(data); in pruss_intc_irq_unmask() local
311 pruss_intc_write_reg(intc, PRU_INTC_EISR, hwirq); in pruss_intc_irq_unmask()
331 struct pruss_intc *intc = irq_data_get_irq_chip_data(data); in pruss_intc_irq_get_irqchip_state() local
340 srsr = pruss_intc_read_reg(intc, reg); in pruss_intc_irq_get_irqchip_state()
351 struct pruss_intc *intc = irq_data_get_irq_chip_data(data); in pruss_intc_irq_set_irqchip_state() local
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()
375 static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, in pruss_intc_validate_mapping() argument
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()
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()
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() local
415 struct device *dev = intc->dev; 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()
428 if (channel < 0 || channel >= intc->soc_config->num_host_events) { in pruss_intc_irq_domain_xlate()
434 if (host < 0 || host >= intc->soc_config->num_host_events) { in pruss_intc_irq_domain_xlate()
440 ret = pruss_intc_validate_mapping(intc, sys_event, channel, host); in pruss_intc_irq_domain_xlate()
453 struct pruss_intc *intc = d->host_data; in pruss_intc_irq_domain_map() local
455 pruss_intc_map(intc, hw); in pruss_intc_irq_domain_map()
457 irq_set_chip_data(virq, intc); in pruss_intc_irq_domain_map()
465 struct pruss_intc *intc = d->host_data; in pruss_intc_irq_domain_unmap() local
470 pruss_intc_unmap(intc, hwirq); in pruss_intc_irq_domain_unmap()
484 struct pruss_intc *intc = host_irq_data->intc; in pruss_intc_irq_handler() local
494 hipir = pruss_intc_read_reg(intc, PRU_INTC_HIPIR(host_irq)); in pruss_intc_irq_handler()
499 err = generic_handle_domain_irq(intc->domain, hwirq); in pruss_intc_irq_handler()
506 pruss_intc_write_reg(intc, PRU_INTC_SICR, hwirq); in pruss_intc_irq_handler()
521 struct pruss_intc *intc; in pruss_intc_probe() local
532 intc = devm_kzalloc(dev, sizeof(*intc), GFP_KERNEL); in pruss_intc_probe()
533 if (!intc) in pruss_intc_probe()
536 intc->soc_config = data; in pruss_intc_probe()
537 intc->dev = dev; in pruss_intc_probe()
538 platform_set_drvdata(pdev, intc); 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()
554 pruss_intc_init(intc); 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()
559 &pruss_intc_irq_domain_ops, intc); in pruss_intc_probe()
560 if (!intc->domain) in pruss_intc_probe()
573 intc->irqs[i] = irq; in pruss_intc_probe()
581 host_data->intc = intc; 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()
604 struct pruss_intc *intc = platform_get_drvdata(pdev); in pruss_intc_remove() local
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()