Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip: mtk-sysirq: Get irq number from register resource size

Originally mtk-sysirq hardcoded supported irq number to 224. This
was fine since all SoCs before support the same number of irqs for
intpol.

However MT8173 intpol support 32 more irq pins, changes to get
irq number from register resource size to suppor MT8173 properly.

Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Signed-off-by: Eddie Huang <eddie.huang@mediatek.com>
Cc: <srv_heupstream@mediatek.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Robert Richter <rrichter@cavium.com>
Cc: Mark Brown <broonie@linaro.org>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: <marc.zyngier@arm.com>
Cc: <peter.maydell@linaro.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Jason Cooper <jason@lakedaemon.net>
Link: http://lkml.kernel.org/r/1421054073-43468-3-git-send-email-eddie.huang@mediatek.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Yingjoe Chen and committed by
Thomas Gleixner
cdb647a7 e03f9088

+11 -7
+11 -7
drivers/irqchip/irq-mtk-sysirq.c
··· 23 23 24 24 #include "irqchip.h" 25 25 26 - #define MT6577_SYS_INTPOL_NUM (224) 27 - 28 26 struct mtk_sysirq_chip_data { 29 27 spinlock_t lock; 30 28 void __iomem *intpol_base; ··· 122 124 { 123 125 struct irq_domain *domain, *domain_parent; 124 126 struct mtk_sysirq_chip_data *chip_data; 125 - int ret = 0; 127 + int ret, size, intpol_num; 128 + struct resource res; 126 129 127 130 domain_parent = irq_find_host(parent); 128 131 if (!domain_parent) { ··· 131 132 return -EINVAL; 132 133 } 133 134 135 + ret = of_address_to_resource(node, 0, &res); 136 + if (ret) 137 + return ret; 138 + 134 139 chip_data = kzalloc(sizeof(*chip_data), GFP_KERNEL); 135 140 if (!chip_data) 136 141 return -ENOMEM; 137 142 138 - chip_data->intpol_base = of_io_request_and_map(node, 0, "intpol"); 139 - if (IS_ERR(chip_data->intpol_base)) { 143 + size = resource_size(&res); 144 + intpol_num = size * 8; 145 + chip_data->intpol_base = ioremap(res.start, size); 146 + if (!chip_data->intpol_base) { 140 147 pr_err("mtk_sysirq: unable to map sysirq register\n"); 141 148 ret = PTR_ERR(chip_data->intpol_base); 142 149 goto out_free; 143 150 } 144 151 145 - domain = irq_domain_add_hierarchy(domain_parent, 0, 146 - MT6577_SYS_INTPOL_NUM, node, 152 + domain = irq_domain_add_hierarchy(domain_parent, 0, intpol_num, node, 147 153 &sysirq_domain_ops, chip_data); 148 154 if (!domain) { 149 155 ret = -ENOMEM;