fpi-bus.c 2.2 KB

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