Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4af34b57 authored by Maxime Ripard's avatar Maxime Ripard Committed by Arnd Bergmann
Browse files

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.

Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
Tested-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 72275b4c
Loading
Loading
Loading
Loading
+72 −0
Original line number Diff line number Diff line
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@01c00000 {
	compatible = "allwinner,sun4i-a10-sram-controller";
	reg = <0x01c00000 0x30>;
	#address-cells = <1>;
	#size-cells = <1>;
	ranges;

	sram_a: sram@00000000 {
		compatible = "mmio-sram";
		reg = <0x00000000 0xc000>;
		#address-cells = <1>;
		#size-cells = <1>;
		ranges = <0 0x00000000 0xc000>;

		emac_sram: sram-section@8000 {
			compatible = "allwinner,sun4i-a10-sram-a3-a4";
			reg = <0x8000 0x4000>;
			status = "disabled";
		};
	};
};

emac: ethernet@01c0b000 {
	compatible = "allwinner,sun4i-a10-emac";
	...

	allwinner,sram = <&emac_sram 1>;
};
+1 −0
Original line number Diff line number Diff line
@@ -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"

+1 −0
Original line number Diff line number Diff line
@@ -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/
+10 −0
Original line number Diff line number Diff line
#
# 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.
+1 −0
Original line number Diff line number Diff line
obj-$(CONFIG_SUNXI_SRAM) +=	sunxi_sram.o
Loading