fpi-bus.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2011-2015 John Crispin <blogic@phrozen.org>
  7. * Copyright (C) 2015 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  8. * Copyright (C) 2017 Hauke Mehrtens <hauke@hauke-m.de>
  9. */
  10. #include <linux/device.h>
  11. #include <linux/err.h>
  12. #include <linux/mfd/syscon.h>
  13. #include <linux/module.h>
  14. #include <linux/of.h>
  15. #include <linux/of_platform.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/property.h>
  18. #include <linux/regmap.h>
  19. #include <lantiq_soc.h>
  20. #define XBAR_ALWAYS_LAST 0x430
  21. #define XBAR_FPI_BURST_EN BIT(1)
  22. #define XBAR_AHB_BURST_EN BIT(2)
  23. #define RCU_VR9_BE_AHB1S 0x00000008
  24. static int ltq_fpi_probe(struct platform_device *pdev)
  25. {
  26. struct device *dev = &pdev->dev;
  27. struct device_node *np = dev->of_node;
  28. struct resource *res_xbar;
  29. struct regmap *rcu_regmap;
  30. void __iomem *xbar_membase;
  31. u32 rcu_ahb_endianness_reg_offset;
  32. int ret;
  33. res_xbar = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  34. xbar_membase = devm_ioremap_resource(dev, res_xbar);
  35. if (IS_ERR(xbar_membase))
  36. return PTR_ERR(xbar_membase);
  37. /* RCU configuration is optional */
  38. rcu_regmap = syscon_regmap_lookup_by_phandle(np, "lantiq,rcu");
  39. if (IS_ERR(rcu_regmap))
  40. return PTR_ERR(rcu_regmap);
  41. ret = device_property_read_u32(dev, "lantiq,offset-endianness",
  42. &rcu_ahb_endianness_reg_offset);
  43. if (ret) {
  44. dev_err(&pdev->dev, "Failed to get RCU reg offset\n");
  45. return ret;
  46. }
  47. ret = regmap_update_bits(rcu_regmap, rcu_ahb_endianness_reg_offset,
  48. RCU_VR9_BE_AHB1S, RCU_VR9_BE_AHB1S);
  49. if (ret) {
  50. dev_warn(&pdev->dev,
  51. "Failed to configure RCU AHB endianness\n");
  52. return ret;
  53. }
  54. /* disable fpi burst */
  55. ltq_w32_mask(XBAR_FPI_BURST_EN, 0, xbar_membase + XBAR_ALWAYS_LAST);
  56. return of_platform_populate(dev->of_node, NULL, NULL, dev);
  57. }
  58. static const struct of_device_id ltq_fpi_match[] = {
  59. { .compatible = "lantiq,xrx200-fpi" },
  60. {},
  61. };
  62. MODULE_DEVICE_TABLE(of, ltq_fpi_match);
  63. static struct platform_driver ltq_fpi_driver = {
  64. .probe = ltq_fpi_probe,
  65. .driver = {
  66. .name = "fpi-xway",
  67. .of_match_table = ltq_fpi_match,
  68. },
  69. };
  70. module_platform_driver(ltq_fpi_driver);
  71. MODULE_DESCRIPTION("Lantiq FPI bus driver");
  72. MODULE_LICENSE("GPL");