|
16 | 16 | #include <linux/hdlc.h> |
17 | 17 | #include <linux/io.h> |
18 | 18 | #include <linux/kernel.h> |
| 19 | +#include <linux/mfd/syscon.h> |
19 | 20 | #include <linux/platform_device.h> |
20 | 21 | #include <linux/poll.h> |
| 22 | +#include <linux/regmap.h> |
21 | 23 | #include <linux/slab.h> |
22 | 24 | #include <linux/gpio/consumer.h> |
23 | 25 | #include <linux/of.h> |
@@ -1389,9 +1391,28 @@ static int ixp4xx_hss_probe(struct platform_device *pdev) |
1389 | 1391 | struct device *dev = &pdev->dev; |
1390 | 1392 | struct net_device *ndev; |
1391 | 1393 | struct device_node *np; |
| 1394 | + struct regmap *rmap; |
1392 | 1395 | struct port *port; |
1393 | 1396 | hdlc_device *hdlc; |
1394 | 1397 | 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 | + } |
1395 | 1416 |
|
1396 | 1417 | np = dev->of_node; |
1397 | 1418 |
|
@@ -1516,25 +1537,9 @@ static struct platform_driver ixp4xx_hss_driver = { |
1516 | 1537 | .probe = ixp4xx_hss_probe, |
1517 | 1538 | .remove = ixp4xx_hss_remove, |
1518 | 1539 | }; |
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); |
1534 | 1541 |
|
1535 | 1542 | MODULE_AUTHOR("Krzysztof Halasa"); |
1536 | 1543 | MODULE_DESCRIPTION("Intel IXP4xx HSS driver"); |
1537 | 1544 | MODULE_LICENSE("GPL v2"); |
1538 | 1545 | MODULE_ALIAS("platform:ixp4xx_hss"); |
1539 | | -module_init(hss_init_module); |
1540 | | -module_exit(hss_cleanup_module); |
|
0 commit comments