fpi-bus.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2011-2015 John Crispin <[email protected]>
  5. * Copyright (C) 2015 Martin Blumenstingl <[email protected]>
  6. * Copyright (C) 2017 Hauke Mehrtens <[email protected]>
  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 regmap *rcu_regmap;
  27. void __iomem *xbar_membase;
  28. u32 rcu_ahb_endianness_reg_offset;
  29. int ret;
  30. xbar_membase = devm_platform_ioremap_resource(pdev, 0);
  31. if (IS_ERR(xbar_membase))
  32. return PTR_ERR(xbar_membase);
  33. /* RCU configuration is optional */
  34. rcu_regmap = syscon_regmap_lookup_by_phandle(np, "lantiq,rcu");
  35. if (IS_ERR(rcu_regmap))
  36. return PTR_ERR(rcu_regmap);
  37. ret = device_property_read_u32(dev, "lantiq,offset-endianness",
  38. &rcu_ahb_endianness_reg_offset);
  39. if (ret) {
  40. dev_err(&pdev->dev, "Failed to get RCU reg offset\n");
  41. return ret;
  42. }
  43. ret = regmap_update_bits(rcu_regmap, rcu_ahb_endianness_reg_offset,
  44. RCU_VR9_BE_AHB1S, RCU_VR9_BE_AHB1S);
  45. if (ret) {
  46. dev_warn(&pdev->dev,
  47. "Failed to configure RCU AHB endianness\n");
  48. return ret;
  49. }
  50. /* disable fpi burst */
  51. ltq_w32_mask(XBAR_FPI_BURST_EN, 0, xbar_membase + XBAR_ALWAYS_LAST);
  52. return of_platform_populate(dev->of_node, NULL, NULL, dev);
  53. }
  54. static const struct of_device_id ltq_fpi_match[] = {
  55. { .compatible = "lantiq,xrx200-fpi" },
  56. {},
  57. };
  58. MODULE_DEVICE_TABLE(of, ltq_fpi_match);
  59. static struct platform_driver ltq_fpi_driver = {
  60. .probe = ltq_fpi_probe,
  61. .driver = {
  62. .name = "fpi-xway",
  63. .of_match_table = ltq_fpi_match,
  64. },
  65. };
  66. module_platform_driver(ltq_fpi_driver);
  67. MODULE_DESCRIPTION("Lantiq FPI bus driver");
  68. MODULE_LICENSE("GPL");