aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2019-02-10 11:05:29 -0500
committerLinus Walleij <linus.walleij@linaro.org>2019-04-23 10:02:15 -0400
commitbc4d7eafb7ad590f546b58c40cd7856990fbb303 (patch)
tree2538b36b5190f5ac7def7e62da0c004a24c99664
parent4af20dc583b364fad45df6fb81873606af8b70fb (diff)
ARM: ixp4xx: Turn the NPE into a platform device
Instead of registering everything related to the NPE unconditionally in the module_init() call (which will never work with multiplatform) create a platform device and probe the NPE like any other device. Put the device first in the list of devices added for the platform so it is there when the dependent network and crypto drivers probe later on. This probe() path will not be taken unconditionally on device tree boots, so remove the DT guard. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--arch/arm/mach-ixp4xx/common.c6
-rw-r--r--drivers/soc/ixp4xx/ixp4xx-npe.c23
2 files changed, 19 insertions, 10 deletions
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index fc4c9b21ca96..e7789d06c39b 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -150,7 +150,13 @@ static struct platform_device ixp4xx_udc_device = {
150 }, 150 },
151}; 151};
152 152
153static struct platform_device ixp4xx_npe_device = {
154 .name = "ixp4xx-npe",
155 .id = -1,
156};
157
153static struct platform_device *ixp4xx_devices[] __initdata = { 158static struct platform_device *ixp4xx_devices[] __initdata = {
159 &ixp4xx_npe_device,
154 &ixp4xx_gpio_device, 160 &ixp4xx_gpio_device,
155 &ixp4xx_udc_device, 161 &ixp4xx_udc_device,
156}; 162};
diff --git a/drivers/soc/ixp4xx/ixp4xx-npe.c b/drivers/soc/ixp4xx/ixp4xx-npe.c
index 1f6e01369d54..e3294457b5de 100644
--- a/drivers/soc/ixp4xx/ixp4xx-npe.c
+++ b/drivers/soc/ixp4xx/ixp4xx-npe.c
@@ -21,6 +21,7 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/platform_device.h>
24#include <linux/soc/ixp4xx/npe.h> 25#include <linux/soc/ixp4xx/npe.h>
25 26
26#define DEBUG_MSG 0 27#define DEBUG_MSG 0
@@ -683,16 +684,10 @@ void npe_release(struct npe *npe)
683 module_put(THIS_MODULE); 684 module_put(THIS_MODULE);
684} 685}
685 686
686 687static int ixp4xx_npe_probe(struct platform_device *pdev)
687static int __init npe_init_module(void)
688{ 688{
689
690 int i, found = 0; 689 int i, found = 0;
691 690
692 /* This driver does not work with device tree */
693 if (of_have_populated_dt())
694 return -ENODEV;
695
696 for (i = 0; i < NPE_COUNT; i++) { 691 for (i = 0; i < NPE_COUNT; i++) {
697 struct npe *npe = &npe_tab[i]; 692 struct npe *npe = &npe_tab[i];
698 if (!(ixp4xx_read_feature_bits() & 693 if (!(ixp4xx_read_feature_bits() &
@@ -717,7 +712,7 @@ static int __init npe_init_module(void)
717 return 0; 712 return 0;
718} 713}
719 714
720static void __exit npe_cleanup_module(void) 715static int ixp4xx_npe_remove(struct platform_device *pdev)
721{ 716{
722 int i; 717 int i;
723 718
@@ -726,10 +721,18 @@ static void __exit npe_cleanup_module(void)
726 npe_reset(&npe_tab[i]); 721 npe_reset(&npe_tab[i]);
727 release_resource(npe_tab[i].mem_res); 722 release_resource(npe_tab[i].mem_res);
728 } 723 }
724
725 return 0;
729} 726}
730 727
731module_init(npe_init_module); 728static struct platform_driver ixp4xx_npe_driver = {
732module_exit(npe_cleanup_module); 729 .driver = {
730 .name = "ixp4xx-npe",
731 },
732 .probe = ixp4xx_npe_probe,
733 .remove = ixp4xx_npe_remove,
734};
735module_platform_driver(ixp4xx_npe_driver);
733 736
734MODULE_AUTHOR("Krzysztof Halasa"); 737MODULE_AUTHOR("Krzysztof Halasa");
735MODULE_LICENSE("GPL v2"); 738MODULE_LICENSE("GPL v2");