0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/device.h>
0010 #include <linux/err.h>
0011 #include <linux/mfd/syscon.h>
0012 #include <linux/module.h>
0013 #include <linux/of.h>
0014 #include <linux/of_platform.h>
0015 #include <linux/platform_device.h>
0016 #include <linux/property.h>
0017 #include <linux/regmap.h>
0018
0019 #include <lantiq_soc.h>
0020
0021 #define XBAR_ALWAYS_LAST 0x430
0022 #define XBAR_FPI_BURST_EN BIT(1)
0023 #define XBAR_AHB_BURST_EN BIT(2)
0024
0025 #define RCU_VR9_BE_AHB1S 0x00000008
0026
0027 static int ltq_fpi_probe(struct platform_device *pdev)
0028 {
0029 struct device *dev = &pdev->dev;
0030 struct device_node *np = dev->of_node;
0031 struct regmap *rcu_regmap;
0032 void __iomem *xbar_membase;
0033 u32 rcu_ahb_endianness_reg_offset;
0034 int ret;
0035
0036 xbar_membase = devm_platform_ioremap_resource(pdev, 0);
0037 if (IS_ERR(xbar_membase))
0038 return PTR_ERR(xbar_membase);
0039
0040
0041 rcu_regmap = syscon_regmap_lookup_by_phandle(np, "lantiq,rcu");
0042 if (IS_ERR(rcu_regmap))
0043 return PTR_ERR(rcu_regmap);
0044
0045 ret = device_property_read_u32(dev, "lantiq,offset-endianness",
0046 &rcu_ahb_endianness_reg_offset);
0047 if (ret) {
0048 dev_err(&pdev->dev, "Failed to get RCU reg offset\n");
0049 return ret;
0050 }
0051
0052 ret = regmap_update_bits(rcu_regmap, rcu_ahb_endianness_reg_offset,
0053 RCU_VR9_BE_AHB1S, RCU_VR9_BE_AHB1S);
0054 if (ret) {
0055 dev_warn(&pdev->dev,
0056 "Failed to configure RCU AHB endianness\n");
0057 return ret;
0058 }
0059
0060
0061 ltq_w32_mask(XBAR_FPI_BURST_EN, 0, xbar_membase + XBAR_ALWAYS_LAST);
0062
0063 return of_platform_populate(dev->of_node, NULL, NULL, dev);
0064 }
0065
0066 static const struct of_device_id ltq_fpi_match[] = {
0067 { .compatible = "lantiq,xrx200-fpi" },
0068 {},
0069 };
0070 MODULE_DEVICE_TABLE(of, ltq_fpi_match);
0071
0072 static struct platform_driver ltq_fpi_driver = {
0073 .probe = ltq_fpi_probe,
0074 .driver = {
0075 .name = "fpi-xway",
0076 .of_match_table = ltq_fpi_match,
0077 },
0078 };
0079
0080 module_platform_driver(ltq_fpi_driver);
0081
0082 MODULE_DESCRIPTION("Lantiq FPI bus driver");
0083 MODULE_LICENSE("GPL");