Lines Matching +full:int +full:- +full:map +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0
3 #define pr_fmt(fmt) "irq-ls-extirq: " fmt
12 #include <dt-bindings/interrupt-controller/arm-gic.h>
23 struct irq_fwspec map[MAXIRQ]; member
26 static void ls_extirq_intpcr_rmw(struct ls_extirq_data *priv, u32 mask, in ls_extirq_intpcr_rmw() argument
33 * IRQ descriptors, making sure the read-modify-write is atomic. in ls_extirq_intpcr_rmw()
35 raw_spin_lock(&priv->lock); in ls_extirq_intpcr_rmw()
37 if (priv->big_endian) in ls_extirq_intpcr_rmw()
38 intpcr = ioread32be(priv->intpcr); in ls_extirq_intpcr_rmw()
40 intpcr = ioread32(priv->intpcr); in ls_extirq_intpcr_rmw()
42 intpcr &= ~mask; in ls_extirq_intpcr_rmw()
45 if (priv->big_endian) in ls_extirq_intpcr_rmw()
46 iowrite32be(intpcr, priv->intpcr); in ls_extirq_intpcr_rmw()
48 iowrite32(intpcr, priv->intpcr); in ls_extirq_intpcr_rmw()
50 raw_spin_unlock(&priv->lock); in ls_extirq_intpcr_rmw()
53 static int
54 ls_extirq_set_type(struct irq_data *data, unsigned int type) in ls_extirq_set_type()
56 struct ls_extirq_data *priv = data->chip_data; in ls_extirq_set_type()
57 irq_hw_number_t hwirq = data->hwirq; in ls_extirq_set_type()
58 u32 value, mask; in ls_extirq_set_type() local
60 if (priv->is_ls1021a_or_ls1043a) in ls_extirq_set_type()
61 mask = 1U << (31 - hwirq); in ls_extirq_set_type()
63 mask = 1U << hwirq; in ls_extirq_set_type()
68 value = mask; in ls_extirq_set_type()
72 value = mask; in ls_extirq_set_type()
79 return -EINVAL; in ls_extirq_set_type()
82 ls_extirq_intpcr_rmw(priv, mask, value); in ls_extirq_set_type()
88 .name = "ls-extirq",
98 static int
99 ls_extirq_domain_alloc(struct irq_domain *domain, unsigned int virq, in ls_extirq_domain_alloc()
100 unsigned int nr_irqs, void *arg) in ls_extirq_domain_alloc()
102 struct ls_extirq_data *priv = domain->host_data; in ls_extirq_domain_alloc()
106 if (fwspec->param_count != 2) in ls_extirq_domain_alloc()
107 return -EINVAL; in ls_extirq_domain_alloc()
109 hwirq = fwspec->param[0]; in ls_extirq_domain_alloc()
110 if (hwirq >= priv->nirq) in ls_extirq_domain_alloc()
111 return -EINVAL; in ls_extirq_domain_alloc()
116 return irq_domain_alloc_irqs_parent(domain, virq, 1, &priv->map[hwirq]); in ls_extirq_domain_alloc()
125 static int
128 const __be32 *map; in ls_extirq_parse_map() local
130 int ret; in ls_extirq_parse_map()
132 map = of_get_property(node, "interrupt-map", &mapsize); in ls_extirq_parse_map()
133 if (!map) in ls_extirq_parse_map()
134 return -ENOENT; in ls_extirq_parse_map()
135 if (mapsize % sizeof(*map)) in ls_extirq_parse_map()
136 return -EINVAL; in ls_extirq_parse_map()
137 mapsize /= sizeof(*map); in ls_extirq_parse_map()
144 return -EINVAL; in ls_extirq_parse_map()
145 hwirq = be32_to_cpup(map); in ls_extirq_parse_map()
147 return -EINVAL; in ls_extirq_parse_map()
148 priv->nirq = max(priv->nirq, hwirq + 1); in ls_extirq_parse_map()
150 ipar = of_find_node_by_phandle(be32_to_cpup(map + 2)); in ls_extirq_parse_map()
151 map += 3; in ls_extirq_parse_map()
152 mapsize -= 3; in ls_extirq_parse_map()
154 return -EINVAL; in ls_extirq_parse_map()
155 priv->map[hwirq].fwnode = &ipar->fwnode; in ls_extirq_parse_map()
156 ret = of_property_read_u32(ipar, "#interrupt-cells", &intsize); in ls_extirq_parse_map()
161 return -EINVAL; in ls_extirq_parse_map()
163 priv->map[hwirq].param_count = intsize; in ls_extirq_parse_map()
165 priv->map[hwirq].param[j] = be32_to_cpup(map++); in ls_extirq_parse_map()
166 mapsize -= intsize; in ls_extirq_parse_map()
171 static int __init
176 int ret; in ls_extirq_of_init()
181 ret = -ENODEV; in ls_extirq_of_init()
187 ret = -ENOMEM; in ls_extirq_of_init()
195 priv->intpcr = of_iomap(node, 0); in ls_extirq_of_init()
196 if (!priv->intpcr) { in ls_extirq_of_init()
198 ret = -ENOMEM; in ls_extirq_of_init()
206 priv->big_endian = of_device_is_big_endian(node->parent); in ls_extirq_of_init()
207 priv->is_ls1021a_or_ls1043a = of_device_is_compatible(node, "fsl,ls1021a-extirq") || in ls_extirq_of_init()
208 of_device_is_compatible(node, "fsl,ls1043a-extirq"); in ls_extirq_of_init()
209 raw_spin_lock_init(&priv->lock); in ls_extirq_of_init()
211 domain = irq_domain_add_hierarchy(parent_domain, 0, priv->nirq, node, in ls_extirq_of_init()
214 ret = -ENOMEM; in ls_extirq_of_init()
222 iounmap(priv->intpcr); in ls_extirq_of_init()
230 IRQCHIP_DECLARE(ls1021a_extirq, "fsl,ls1021a-extirq", ls_extirq_of_init);
231 IRQCHIP_DECLARE(ls1043a_extirq, "fsl,ls1043a-extirq", ls_extirq_of_init);
232 IRQCHIP_DECLARE(ls1088a_extirq, "fsl,ls1088a-extirq", ls_extirq_of_init);