diff options
author | MaJun <majun258@huawei.com> | 2016-03-17 04:34:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-03-21 06:24:11 -0400 |
commit | ed2a1002d25ccdb6606c8ccb608524118bd30614 (patch) | |
tree | 8318b3d998df026d3425cfd4c9718d56d7ba5f2e /drivers/irqchip | |
parent | d0e286415dc1f4fea2971d6186b0775c7062575b (diff) |
irqchip/mbigen: Handle multiple device nodes in a mbigen module
Each mbigen device is represented as a independent platform device. If the
devices belong to the same mbigen hardware module, then the register space for
these devices is the same. That leads to a resource conflict.
The solution for this is to represent the mbigen module as a platform device
and make the mbigen devices subdevices of that. The register space is
associated to the mbigen module and therefor the resource conflict is avoided.
[ tglx: Massaged changelog, cleaned up the code and removed the silly printk ]
Signed-off-by: Ma Jun <majun258@huawei.com>
Cc: mark.rutland@arm.com
Cc: jason@lakedaemon.net
Cc: marc.zyngier@arm.com
Cc: Catalin.Marinas@arm.com
Cc: guohanjun@huawei.com
Cc: Will.Deacon@arm.com
Cc: huxinwei@huawei.com
Cc: lizefan@huawei.com
Cc: dingtianhong@huawei.com
Cc: zhaojunhua@hisilicon.com
Cc: liguozhu@hisilicon.com
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1458203641-17172-3-git-send-email-majun258@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/irqchip')
-rw-r--r-- | drivers/irqchip/irq-mbigen.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index 4dd3eb8a40b3..d67baa231c13 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c | |||
@@ -239,8 +239,11 @@ static struct irq_domain_ops mbigen_domain_ops = { | |||
239 | static int mbigen_device_probe(struct platform_device *pdev) | 239 | static int mbigen_device_probe(struct platform_device *pdev) |
240 | { | 240 | { |
241 | struct mbigen_device *mgn_chip; | 241 | struct mbigen_device *mgn_chip; |
242 | struct resource *res; | 242 | struct platform_device *child; |
243 | struct irq_domain *domain; | 243 | struct irq_domain *domain; |
244 | struct device_node *np; | ||
245 | struct device *parent; | ||
246 | struct resource *res; | ||
244 | u32 num_pins; | 247 | u32 num_pins; |
245 | 248 | ||
246 | mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL); | 249 | mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL); |
@@ -254,23 +257,30 @@ static int mbigen_device_probe(struct platform_device *pdev) | |||
254 | if (IS_ERR(mgn_chip->base)) | 257 | if (IS_ERR(mgn_chip->base)) |
255 | return PTR_ERR(mgn_chip->base); | 258 | return PTR_ERR(mgn_chip->base); |
256 | 259 | ||
257 | if (of_property_read_u32(pdev->dev.of_node, "num-pins", &num_pins) < 0) { | 260 | for_each_child_of_node(pdev->dev.of_node, np) { |
258 | dev_err(&pdev->dev, "No num-pins property\n"); | 261 | if (!of_property_read_bool(np, "interrupt-controller")) |
259 | return -EINVAL; | 262 | continue; |
260 | } | ||
261 | 263 | ||
262 | domain = platform_msi_create_device_domain(&pdev->dev, num_pins, | 264 | parent = platform_bus_type.dev_root; |
263 | mbigen_write_msg, | 265 | child = of_platform_device_create(np, NULL, parent); |
264 | &mbigen_domain_ops, | 266 | if (IS_ERR(child)) |
265 | mgn_chip); | 267 | return PTR_ERR(child); |
266 | 268 | ||
267 | if (!domain) | 269 | if (of_property_read_u32(child->dev.of_node, "num-pins", |
268 | return -ENOMEM; | 270 | &num_pins) < 0) { |
271 | dev_err(&pdev->dev, "No num-pins property\n"); | ||
272 | return -EINVAL; | ||
273 | } | ||
274 | |||
275 | domain = platform_msi_create_device_domain(&child->dev, num_pins, | ||
276 | mbigen_write_msg, | ||
277 | &mbigen_domain_ops, | ||
278 | mgn_chip); | ||
279 | if (!domain) | ||
280 | return -ENOMEM; | ||
281 | } | ||
269 | 282 | ||
270 | platform_set_drvdata(pdev, mgn_chip); | 283 | platform_set_drvdata(pdev, mgn_chip); |
271 | |||
272 | dev_info(&pdev->dev, "Allocated %d MSIs\n", num_pins); | ||
273 | |||
274 | return 0; | 284 | return 0; |
275 | } | 285 | } |
276 | 286 | ||