Skip to contentSkip to conversation

drivers: soc: sunxi: Introduce SoC driver to map SRAMs

PATCH Superseded Maxime Ripard 2 participants 3 messages Jun 1, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 drivers: soc: sunxi: Introduce SoC driver to map SRAMs

The Allwinner SoCs have a handful of SRAM that can be either mapped to be accessible by devices or the CPU.

That mapping is controlled by an SRAM controller, and that mapping might not be set by the bootloader, for example if the device wasn't used at all, or if we're using solutions like the U-Boot's Falcon Boot.

We could also imagine changing this at runtime for example to change the mapping of these SRAMs to use them for suspend/resume or runtime memory rate change, if that ever happens.

These use cases require some API in the kernel to control that mapping, exported through a drivers/soc driver.

This driver also implement a debugfs file that shows the SRAM found in the system, the current mapping and the SRAM that have been claimed by some drivers in the kernel.

---

Hi Arnd, Kevin, Olof,

Could you please apply directly this patch to your tree?

It's the only driver related patch that should come in for this release cycle.

Thanks!
Maxime

Changes from v3:
- Fixed the width of A3-A4 section
- Added Hans' and Arnd's Acked-by

 .../devicetree/bindings/soc/sunxi/sram.txt         |  72 ++++++
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/sunxi/Kconfig                          |  10 +
 drivers/soc/sunxi/Makefile                         |   1 +
 drivers/soc/sunxi/sunxi_sram.c                     | 284 +++++++++++++++++++++
 include/linux/soc/sunxi/sunxi_sram.h               |  19 ++
 7 files changed, 388 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/sunxi/sram.txt
 create mode 100644 drivers/soc/sunxi/Kconfig
 create mode 100644 drivers/soc/sunxi/Makefile
 create mode 100644 drivers/soc/sunxi/sunxi_sram.c
 create mode 100644 include/linux/soc/sunxi/sunxi_sram.h
Documentation/devicetree/bindings/soc/sunxi/sram.txt new file +72 -0
new file mode 100644
index 000000000000..067698112f5f
@@ -0,0 +1,72 @@
+Allwinnner SoC SRAM controllers
+-----------------------------------------------------
+
+The SRAM controller found on most Allwinner devices is represented by
+a regular node for the SRAM controller itself, with sub-nodes
+reprensenting the SRAM handled by the SRAM controller.
+
+Controller Node
+---------------
+
+Required properties:
+- compatible : "allwinner,sun4i-a10-sram-controller"
+- reg : sram controller register offset + length
+
+SRAM nodes
+----------
+
+Each SRAM is described using the mmio-sram bindings documented in
+Documentation/devicetree/bindings/misc/sram.txt
+
+Each SRAM will have SRAM sections that are going to be handled by the
+SRAM controller as subnodes. These sections are represented following
+once again the representation described in the mmio-sram binding.
+
+The valid sections compatible are:
+    - allwinner,sun4i-a10-sram-a3-a4
+    - allwinner,sun4i-a10-sram-d
+
+Devices using SRAM sections
+---------------------------
+
+Some devices need to request to the SRAM controller to map an SRAM for
+their exclusive use.
+
+The relationship between such a device and an SRAM section is
+expressed through the allwinner,sram property, that will take a
+phandle and an argument.
+
+This valid values for this argument are:
+  - 0: CPU
+  - 1: Device
+
+Example
+-------
+sram-controller at 01c00000 {
+	compatible = "allwinner,sun4i-a10-sram-controller";
+	reg = <0x01c00000 0x30>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+	ranges;
+
+	sram_a: sram at 00000000 {
+		compatible = "mmio-sram";
+		reg = <0x00000000 0xc000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0x00000000 0xc000>;
+
+		emac_sram: sram-section at 8000 {
+			compatible = "allwinner,sun4i-a10-sram-a3-a4";
+			reg = <0x8000 0x4000>;
+			status = "disabled";
+		};
+	};
+};
+
+emac: ethernet at 01c0b000 {
+	compatible = "allwinner,sun4i-a10-emac";
+	...
+
+	allwinner,sram = <&emac_sram 1>;
+};
drivers/soc/Kconfig +1 -0
index d8bde82f0370..96ddecb92254 100644
@@ -2,6 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/sunxi/Kconfig"
 source "drivers/soc/ti/Kconfig"
 source "drivers/soc/versatile/Kconfig"
 
drivers/soc/Makefile +1 -0
index 70042b259744..7dc7c0d8a2c1 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_ARCH_MEDIATEK)	+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_SUNXI)	+= sunxi/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_SOC_TI)		+= ti/
 obj-$(CONFIG_PLAT_VERSATILE)	+= versatile/
drivers/soc/sunxi/Kconfig new file +10 -0
new file mode 100644
index 000000000000..353b07e40176
@@ -0,0 +1,10 @@
+#
+# Allwinner sunXi SoC drivers
+#
+config SUNXI_SRAM
+	bool
+	default ARCH_SUNXI
+	help
+	  Say y here to enable the SRAM controller support. This
+	  device is responsible on mapping the SRAM in the sunXi SoCs
+	  whether to the CPU/DMA, or to the devices.
drivers/soc/sunxi/Makefile new file +1 -0
new file mode 100644
index 000000000000..4cf9dbdf346e
@@ -0,0 +1 @@
+obj-$(CONFIG_SUNXI_SRAM) +=	sunxi_sram.o
drivers/soc/sunxi/sunxi_sram.c new file +284 -0

284 lines not on this page · raw message

include/linux/soc/sunxi/sunxi_sram.h new file +19 -0
new file mode 100644
index 000000000000..c5f663bba9c2
@@ -0,0 +1,19 @@
+/*
+ * Allwinner SoCs SRAM Controller Driver
+ *
+ * Copyright (C) 2015 Maxime Ripard
+ *
+ * Author: Maxime Ripard <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef _SUNXI_SRAM_H_
+#define _SUNXI_SRAM_H_
+
+int sunxi_sram_claim(struct device *dev);
+int sunxi_sram_release(struct device *dev);
+
+#endif /* _SUNXI_SRAM_H_ */
Signature · 1 line
2.4.1
#1 lore raw

PATCH v4 1/1 drivers: soc: sunxi: Introduce SoC driver to map SRAMs

Quoted 22 lines · On Monday 01 June 2015 11:04:26 Maxime Ripard wrote:

The Allwinner SoCs have a handful of SRAM that can be either mapped to be accessible by devices or the CPU.

That mapping is controlled by an SRAM controller, and that mapping might not be set by the bootloader, for example if the device wasn't used at all, or if we're using solutions like the U-Boot's Falcon Boot.

We could also imagine changing this at runtime for example to change the mapping of these SRAMs to use them for suspend/resume or runtime memory rate change, if that ever happens.

These use cases require some API in the kernel to control that mapping, exported through a drivers/soc driver.

This driver also implement a debugfs file that shows the SRAM found in the system, the current mapping and the SRAM that have been claimed by some drivers in the kernel.

Quoted 9 lines

---

Hi Arnd, Kevin, Olof,

Could you please apply directly this patch to your tree?

It's the only driver related patch that should come in for this release cycle.

Applied to next/drivers. Thanks for your hard work to get it adapted to all my wishes over your weekend, very much appreciated.

Arnd

#2 lore raw

PATCH v4 1/1 drivers: soc: sunxi: Introduce SoC driver to map SRAMs

Quoted 8 lines · Arnd Bergmann
Quoted 5 lines

Could you please apply directly this patch to your tree?

It's the only driver related patch that should come in for this release cycle.

Applied to next/drivers. Thanks for your hard work to get it adapted to all my wishes over your weekend, very much appreciated.

Great, thanks!

And don't mention it, I'm glad we came to an agreement on this :)

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150601/0e47fc33/attachment.sig>