Skip to content

Commit e172188

Browse files
author
Linus Walleij
committed
net: ixp4xx_hss: Check features using syscon
If we access the syscon (expansion bus config registers) using the syscon regmap instead of relying on direct accessor functions, we do not need to call this static code in the machine (arch/arm/mach-ixp4xx/common.c) which makes things less dependent on custom machine-dependent code. Look up the syscon regmap and handle the error: this will make deferred probe work with relation to the syscon. Select the syscon in Kconfig and depend on OF so we know that all we need will be available. Cc: David S. Miller <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: netdev@vger.kernel.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/r/20220211223238.648934-10-linus.walleij@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent c8200f4 commit e172188

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

drivers/net/wan/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ config SLIC_DS26522
293293
config IXP4XX_HSS
294294
tristate "Intel IXP4xx HSS (synchronous serial port) support"
295295
depends on HDLC && IXP4XX_NPE && IXP4XX_QMGR
296-
depends on ARCH_IXP4XX
296+
depends on ARCH_IXP4XX && OF
297+
select MFD_SYSCON
297298
help
298299
Say Y here if you want to use built-in HSS ports
299300
on IXP4xx processor.

drivers/net/wan/ixp4xx_hss.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
#include <linux/hdlc.h>
1717
#include <linux/io.h>
1818
#include <linux/kernel.h>
19+
#include <linux/mfd/syscon.h>
1920
#include <linux/platform_device.h>
2021
#include <linux/poll.h>
22+
#include <linux/regmap.h>
2123
#include <linux/slab.h>
2224
#include <linux/gpio/consumer.h>
2325
#include <linux/of.h>
@@ -1389,9 +1391,28 @@ static int ixp4xx_hss_probe(struct platform_device *pdev)
13891391
struct device *dev = &pdev->dev;
13901392
struct net_device *ndev;
13911393
struct device_node *np;
1394+
struct regmap *rmap;
13921395
struct port *port;
13931396
hdlc_device *hdlc;
13941397
int err;
1398+
u32 val;
1399+
1400+
/*
1401+
* Go into the syscon and check if we have the HSS and HDLC
1402+
* features available, else this will not work.
1403+
*/
1404+
rmap = syscon_regmap_lookup_by_compatible("syscon");
1405+
if (IS_ERR(rmap))
1406+
return dev_err_probe(dev, PTR_ERR(rmap),
1407+
"failed to look up syscon\n");
1408+
1409+
val = cpu_ixp4xx_features(rmap);
1410+
1411+
if ((val & (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
1412+
(IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) {
1413+
dev_err(dev, "HDLC and HSS feature unavailable in platform\n");
1414+
return -ENODEV;
1415+
}
13951416

13961417
np = dev->of_node;
13971418

@@ -1516,25 +1537,9 @@ static struct platform_driver ixp4xx_hss_driver = {
15161537
.probe = ixp4xx_hss_probe,
15171538
.remove = ixp4xx_hss_remove,
15181539
};
1519-
1520-
static int __init hss_init_module(void)
1521-
{
1522-
if ((ixp4xx_read_feature_bits() &
1523-
(IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
1524-
(IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS))
1525-
return -ENODEV;
1526-
1527-
return platform_driver_register(&ixp4xx_hss_driver);
1528-
}
1529-
1530-
static void __exit hss_cleanup_module(void)
1531-
{
1532-
platform_driver_unregister(&ixp4xx_hss_driver);
1533-
}
1540+
module_platform_driver(ixp4xx_hss_driver);
15341541

15351542
MODULE_AUTHOR("Krzysztof Halasa");
15361543
MODULE_DESCRIPTION("Intel IXP4xx HSS driver");
15371544
MODULE_LICENSE("GPL v2");
15381545
MODULE_ALIAS("platform:ixp4xx_hss");
1539-
module_init(hss_init_module);
1540-
module_exit(hss_cleanup_module);

0 commit comments

Comments
 (0)