bus: add bus driver for accessing Allwinner A64 DE2
authorIcenowy Zheng <icenowy@aosc.io>
Fri, 22 Jun 2018 12:45:36 +0000 (20:45 +0800)
committerMaxime Ripard <maxime.ripard@bootlin.com>
Thu, 28 Jun 2018 08:20:19 +0000 (10:20 +0200)
The "Display Engine 2.0" (usually called DE2) on the Allwinner A64 SoC
is different from the ones on other Allwinner SoCs. It requires a SRAM
region to be claimed, otherwise all DE2 subblocks won't be accessible.

Add a bus driver for the Allwinner A64 DE2 part which claims the SRAM
region when probing.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
drivers/bus/Kconfig
drivers/bus/Makefile
drivers/bus/sun50i-de2.c [new file with mode: 0644]

index d1c0b60..1851112 100644 (file)
@@ -103,6 +103,16 @@ config SIMPLE_PM_BUS
          Controller (BSC, sometimes called "LBSC within Bus Bridge", or
          "External Bus Interface") as found on several Renesas ARM SoCs.
 
+config SUN50I_DE2_BUS
+       bool "Allwinner A64 DE2 Bus Driver"
+         default ARM64
+         depends on ARCH_SUNXI
+         select SUNXI_SRAM
+         help
+         Say y here to enable support for Allwinner A64 DE2 bus driver. It's
+         mostly transparent, but a SRAM region needs to be claimed in the SRAM
+         controller to make the all blocks in the DE2 part accessible.
+
 config SUNXI_RSB
        tristate "Allwinner sunXi Reduced Serial Bus Driver"
          default MACH_SUN8I || MACH_SUN9I || ARM64
index b8f036c..ca300b1 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_OMAP_INTERCONNECT)       += omap_l3_smx.o omap_l3_noc.o
 
 obj-$(CONFIG_OMAP_OCP2SCP)     += omap-ocp2scp.o
 obj-$(CONFIG_QCOM_EBI2)                += qcom-ebi2.o
+obj-$(CONFIG_SUN50I_DE2_BUS)   += sun50i-de2.o
 obj-$(CONFIG_SUNXI_RSB)                += sunxi-rsb.o
 obj-$(CONFIG_SIMPLE_PM_BUS)    += simple-pm-bus.o
 obj-$(CONFIG_TEGRA_ACONNECT)   += tegra-aconnect.o
diff --git a/drivers/bus/sun50i-de2.c b/drivers/bus/sun50i-de2.c
new file mode 100644 (file)
index 0000000..6725187
--- /dev/null
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Allwinner A64 Display Engine 2.0 Bus Driver
+ *
+ * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io>
+ */
+
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/soc/sunxi/sunxi_sram.h>
+
+static int sun50i_de2_bus_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       int ret;
+
+       ret = sunxi_sram_claim(&pdev->dev);
+       if (ret) {
+               dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
+               return ret;
+       }
+
+       of_platform_populate(np, NULL, NULL, &pdev->dev);
+
+       return 0;
+}
+
+static int sun50i_de2_bus_remove(struct platform_device *pdev)
+{
+       sunxi_sram_release(&pdev->dev);
+       return 0;
+}
+
+static const struct of_device_id sun50i_de2_bus_of_match[] = {
+       { .compatible = "allwinner,sun50i-a64-de2", },
+       { /* sentinel */ }
+};
+
+static struct platform_driver sun50i_de2_bus_driver = {
+       .probe = sun50i_de2_bus_probe,
+       .remove = sun50i_de2_bus_remove,
+       .driver = {
+               .name = "sun50i-de2-bus",
+               .of_match_table = sun50i_de2_bus_of_match,
+       },
+};
+
+builtin_platform_driver(sun50i_de2_bus_driver);