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

soc: fsl: qe: convert QE interrupt controller to platform_device

Since 5.13 QE's ucc nodes can't get interrupts from devicetree:

ucc@2000 {
cell-index = <1>;
reg = <0x2000 0x200>;
interrupts = <32>;
interrupt-parent = <&qeic>;
};

Now fw_devlink expects driver to create and probe a struct device
for interrupt controller.

So lets convert this driver to simple platform_device with probe().
Also use platform_get_ and devm_ family function to get/allocate
resources and drop unused .compatible = "qeic".

[1] - https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com
Fixes: e590474768f1 ("driver core: Set fw_devlink=on by default")
Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by default""")
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>

authored by

Maxim Kochetkov and committed by
Li Yang
be7ecbd2 e73f0f0e

+46 -33
+46 -33
drivers/soc/fsl/qe/qe_ic.c
··· 23 23 #include <linux/signal.h> 24 24 #include <linux/device.h> 25 25 #include <linux/spinlock.h> 26 + #include <linux/platform_device.h> 26 27 #include <asm/irq.h> 27 28 #include <asm/io.h> 28 29 #include <soc/fsl/qe/qe.h> ··· 405 404 chip->irq_eoi(&desc->irq_data); 406 405 } 407 406 408 - static void __init qe_ic_init(struct device_node *node) 407 + static int qe_ic_init(struct platform_device *pdev) 409 408 { 409 + struct device *dev = &pdev->dev; 410 410 void (*low_handler)(struct irq_desc *desc); 411 411 void (*high_handler)(struct irq_desc *desc); 412 412 struct qe_ic *qe_ic; 413 - struct resource res; 414 - u32 ret; 413 + struct resource *res; 414 + struct device_node *node = pdev->dev.of_node; 415 415 416 - ret = of_address_to_resource(node, 0, &res); 417 - if (ret) 418 - return; 419 - 420 - qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL); 421 - if (qe_ic == NULL) 422 - return; 423 - 424 - qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS, 425 - &qe_ic_host_ops, qe_ic); 426 - if (qe_ic->irqhost == NULL) { 427 - kfree(qe_ic); 428 - return; 416 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 417 + if (res == NULL) { 418 + dev_err(dev, "no memory resource defined\n"); 419 + return -ENODEV; 429 420 } 430 421 431 - qe_ic->regs = ioremap(res.start, resource_size(&res)); 422 + qe_ic = devm_kzalloc(dev, sizeof(*qe_ic), GFP_KERNEL); 423 + if (qe_ic == NULL) 424 + return -ENOMEM; 425 + 426 + qe_ic->regs = devm_ioremap(dev, res->start, resource_size(res)); 427 + if (qe_ic->regs == NULL) { 428 + dev_err(dev, "failed to ioremap() registers\n"); 429 + return -ENODEV; 430 + } 432 431 433 432 qe_ic->hc_irq = qe_ic_irq_chip; 434 433 435 - qe_ic->virq_high = irq_of_parse_and_map(node, 0); 436 - qe_ic->virq_low = irq_of_parse_and_map(node, 1); 434 + qe_ic->virq_high = platform_get_irq(pdev, 0); 435 + qe_ic->virq_low = platform_get_irq(pdev, 1); 437 436 438 - if (!qe_ic->virq_low) { 439 - printk(KERN_ERR "Failed to map QE_IC low IRQ\n"); 440 - kfree(qe_ic); 441 - return; 437 + if (qe_ic->virq_low < 0) { 438 + return -ENODEV; 442 439 } 440 + 443 441 if (qe_ic->virq_high != qe_ic->virq_low) { 444 442 low_handler = qe_ic_cascade_low; 445 443 high_handler = qe_ic_cascade_high; 446 444 } else { 447 445 low_handler = qe_ic_cascade_muxed_mpic; 448 446 high_handler = NULL; 447 + } 448 + 449 + qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS, 450 + &qe_ic_host_ops, qe_ic); 451 + if (qe_ic->irqhost == NULL) { 452 + dev_err(dev, "failed to add irq domain\n"); 453 + return -ENODEV; 449 454 } 450 455 451 456 qe_ic_write(qe_ic->regs, QEIC_CICR, 0); ··· 463 456 irq_set_handler_data(qe_ic->virq_high, qe_ic); 464 457 irq_set_chained_handler(qe_ic->virq_high, high_handler); 465 458 } 459 + return 0; 466 460 } 461 + static const struct of_device_id qe_ic_ids[] = { 462 + { .compatible = "fsl,qe-ic"}, 463 + { .type = "qeic"}, 464 + {}, 465 + }; 466 + 467 + static struct platform_driver qe_ic_driver = 468 + { 469 + .driver = { 470 + .name = "qe-ic", 471 + .of_match_table = qe_ic_ids, 472 + }, 473 + .probe = qe_ic_init, 474 + }; 467 475 468 476 static int __init qe_ic_of_init(void) 469 477 { 470 - struct device_node *np; 471 - 472 - np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic"); 473 - if (!np) { 474 - np = of_find_node_by_type(NULL, "qeic"); 475 - if (!np) 476 - return -ENODEV; 477 - } 478 - qe_ic_init(np); 479 - of_node_put(np); 478 + platform_driver_register(&qe_ic_driver); 480 479 return 0; 481 480 } 482 481 subsys_initcall(qe_ic_of_init);