Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * IRQ domain support for SH INTC subsystem
0003  *
0004  * Copyright (C) 2012  Paul Mundt
0005  *
0006  * This file is subject to the terms and conditions of the GNU General Public
0007  * License.  See the file "COPYING" in the main directory of this archive
0008  * for more details.
0009  */
0010 #define pr_fmt(fmt) "intc: " fmt
0011 
0012 #include <linux/irqdomain.h>
0013 #include <linux/sh_intc.h>
0014 #include <linux/export.h>
0015 #include "internals.h"
0016 
0017 /**
0018  * intc_irq_domain_evt_xlate() - Generic xlate for vectored IRQs.
0019  *
0020  * This takes care of exception vector to hwirq translation through
0021  * by way of evt2irq() translation.
0022  *
0023  * Note: For platforms that use a flat vector space without INTEVT this
0024  * basically just mimics irq_domain_xlate_onecell() by way of a nopped
0025  * out evt2irq() implementation.
0026  */
0027 static int intc_evt_xlate(struct irq_domain *d, struct device_node *ctrlr,
0028               const u32 *intspec, unsigned int intsize,
0029               unsigned long *out_hwirq, unsigned int *out_type)
0030 {
0031     if (WARN_ON(intsize < 1))
0032         return -EINVAL;
0033 
0034     *out_hwirq = evt2irq(intspec[0]);
0035     *out_type = IRQ_TYPE_NONE;
0036 
0037     return 0;
0038 }
0039 
0040 static const struct irq_domain_ops intc_evt_ops = {
0041     .xlate      = intc_evt_xlate,
0042 };
0043 
0044 void __init intc_irq_domain_init(struct intc_desc_int *d,
0045                  struct intc_hw_desc *hw)
0046 {
0047     unsigned int irq_base, irq_end;
0048 
0049     /*
0050      * Quick linear revmap check
0051      */
0052     irq_base = evt2irq(hw->vectors[0].vect);
0053     irq_end = evt2irq(hw->vectors[hw->nr_vectors - 1].vect);
0054 
0055     /*
0056      * Linear domains have a hard-wired assertion that IRQs start at
0057      * 0 in order to make some performance optimizations. Lamely
0058      * restrict the linear case to these conditions here, taking the
0059      * tree penalty for linear cases with non-zero hwirq bases.
0060      */
0061     if (irq_base == 0 && irq_end == (irq_base + hw->nr_vectors - 1))
0062         d->domain = irq_domain_add_linear(NULL, hw->nr_vectors,
0063                           &intc_evt_ops, NULL);
0064     else
0065         d->domain = irq_domain_add_tree(NULL, &intc_evt_ops, NULL);
0066 
0067     BUG_ON(!d->domain);
0068 }