Skip to contentSkip to conversation

soc: amlogic: add support for Meson GX VPU Domains

PATCH RESEND In review Neil Armstrong 2 participants 4 messages Oct 28, 2017 – Oct 29, 2017

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

v2 cover soc: amlogic: add support for Meson GX VPU Domains

[Resent with *correct* linux-pm in CC]

On the Amlogic Gx SoCs (GXBB, GXL & GXM), the VPU power domain is initialized by the vendor U-Boot code, but running mainline U-boot has been possible on these SoCs. But lacking such init made the system lock at kernel boot.

This patchset adds the Video Processing Unit power domain driver to enable the same power-on and power-down sequences and was designed to allow booting with the power domain already initialized or not.

This driver has been tested on :
- Odroid-C2 (GXBB) with Vendor and Mainline U-Boot
- P212 (GXL) with Vendor and Mainline U-Boot
- Khadas Vim (GXL) with Vendor U-Boot
- Khadas Vim2 with (GXM) Vendor U-Boot

Changes since v1:
- fixed bindings compatible string

Neil Armstrong (2):
soc: amlogic: add Meson GX VPU Domains driver
dt-bindings: power: add amlogic meson power domain bindings

 .../bindings/power/amlogic,meson-gx-pwrc.txt       |  61 ++++++
 drivers/soc/amlogic/Kconfig                        |  10 +
 drivers/soc/amlogic/Makefile                       |   1 +
 drivers/soc/amlogic/meson-gx-pwrc-vpu.c            | 234 +++++++++++++++++++++
 4 files changed, 306 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/amlogic,meson-gx-pwrc.txt
 create mode 100644 drivers/soc/amlogic/meson-gx-pwrc-vpu.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH RESEND v2 1/2 soc: amlogic: add Meson GX VPU Domains driver

The Video Processing Unit needs a specific Power Domain powering scheme this driver handles this as a PM Power Domain driver.

---
 drivers/soc/amlogic/Kconfig             |  10 ++
 drivers/soc/amlogic/Makefile            |   1 +
 drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 234 ++++++++++++++++++++++++++++++++
 3 files changed, 245 insertions(+)
 create mode 100644 drivers/soc/amlogic/meson-gx-pwrc-vpu.c
drivers/soc/amlogic/Kconfig +10 -0
index ef0b8f6..1621bb2 100644
@@ -9,6 +9,16 @@ config MESON_GX_SOCINFO
 	  Say yes to support decoding of Amlogic Meson GX SoC family
 	  information about the type, package and version.
 
+config MESON_GX_PM_DOMAINS
+	bool "Amlogic Meson GX Power Domains driver"
+	depends on ARCH_MESON || COMPILE_TEST
+	default ARCH_MESON
+	select PM_GENERIC_DOMAINS
+	select PM_GENERIC_DOMAINS_OF
+	help
+	  Say yes to expose Amlogic Meson GX Power Domains as
+	  Generic Power Domains.
+
 config MESON_MX_SOCINFO
 	bool "Amlogic Meson MX SoC Information driver"
 	depends on ARCH_MESON || COMPILE_TEST
drivers/soc/amlogic/Makefile +1 -0
index 1f5df50..8fa3218 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MESON_GX_SOCINFO) += meson-gx-socinfo.o
+obj-$(CONFIG_MESON_GX_PM_DOMAINS) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_MESON_MX_SOCINFO) += meson-mx-socinfo.o
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +234 -0

234 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH RESEND v2 2/2 dt-bindings: power: add amlogic meson power domain bindings

In reply to Neil Armstrong
---
 .../bindings/power/amlogic,meson-gx-pwrc.txt       | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/amlogic,meson-gx-pwrc.txt
Documentation/devicetree/bindings/power/amlogic,meson-gx-pwrc.txt new file +61 -0
new file mode 100644
index 0000000..95ec49a
@@ -0,0 +1,61 @@
+Amlogic Meson Power Controller
+==============================
+
+The Amlogic Meson SoCs embeds an internal Power domain controller.
+
+VPU Power Domain
+----------------
+
+The Video Processing Unit power domain is controlled by this power controller,
+but the domain requires some external resources to meet the correct power
+sequences.
+The bindings must respect the power domain bindings as described in the file
+power_domain.txt
+
+Device Tree Bindings:
+---------------------
+
+Required properties:
+- compatible: should be "amlogic,meson-gx-pwrc-vpu" for the Meson GX SoCs
+- #power-domain-cells: should be 0
+- amlogic,hhi-sysctrl: phandle to the HHI sysctrl node
+- resets: phandles to the reset lines needed for this power demain sequence
+	as described in ../reset/reset.txt
+- clocks: from common clock binding: handle to VPU and VAPB clocks
+- clock-names: from common clock binding: must contain "vpu", "vapb"
+	corresponding to entry in the clocks property.
+
+Parent node should have the following properties :
+- compatible: "amlogic,meson-gx-ao-sysctrl", "syscon", "simple-mfd"
+- reg: base address and size of the AO system control register space.
+
+Example:
+-------
+
+ao_sysctrl: sys-ctrl at 0 {
+	compatible = "amlogic,meson-gx-ao-sysctrl", "syscon", "simple-mfd";
+	reg =  <0x0 0x0 0x0 0x100>;
+
+	pwrc_vpu: power-controller-vpu {
+		compatible = "amlogic,meson-gx-pwrc-vpu";
+		#power-domain-cells = <0>;
+		amlogic,hhi-sysctrl = <&sysctrl>;
+		resets = <&reset RESET_VIU>,
+			 <&reset RESET_VENC>,
+			 <&reset RESET_VCBUS>,
+			 <&reset RESET_BT656>,
+			 <&reset RESET_DVIN_RESET>,
+			 <&reset RESET_RDMA>,
+			 <&reset RESET_VENCI>,
+			 <&reset RESET_VENCP>,
+		 	 <&reset RESET_VDAC>,
+		 	 <&reset RESET_VDI6>,
+		 	 <&reset RESET_VENCL>,
+			 <&reset RESET_VID_LOCK>;
+		clocks = <&clkc CLKID_VPU>,
+			 <&clkc CLKID_VAPB>;
+		clock-names = "vpu", "vapb";
+	};
+};
+
+
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [RESEND PATCH v2 1/2] soc: amlogic: add Meson GX VPU Domains driver

In reply to Neil Armstrong

Hi Neil,

Quoted 4 lines · Neil Armstrong

The Video Processing Unit needs a specific Power Domain powering scheme this driver handles this as a PM Power Domain driver.

[...]

Quoted 4 lines
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +4 -0
+static inline
+struct meson_gx_pwrc_vpu *genpd_to_pd(struct generic_pm_domain *d)
+{
+	return container_of(d, struct meson_gx_pwrc_vpu, genpd);

drivers/soc/amlogic/meson-gx-pwrc-vpu.c line 53

Quoted 10 lines
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +10 -0
+}
+
+static int meson_gx_pwrc_vpu_power_off(struct generic_pm_domain *genpd)
+{
+	struct meson_gx_pwrc_vpu *pd = genpd_to_pd(genpd);
+	int i;
+
+	regmap_update_bits(pd->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
+			   GEN_PWR_VPU_HDMI_ISO, GEN_PWR_VPU_HDMI_ISO);
+	udelay(20);

Some minor nits/questions. I know the vendor code does it this way, but...

drivers/soc/amlogic/meson-gx-pwrc-vpu.c line 60

Quoted 6 lines
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +6 -0
+	/* Power Down Memories */
+	for (i = 0; i < 32; i += 2) {
+		regmap_update_bits(pd->regmap_hhi, HHI_VPU_MEM_PD_REG0,
+				   0x2 << i, 0x3 << i);
+		udelay(5);
+	}

several of these bits are marked "reserved" in the datasheet. Have you tried without writing to the reserved bits?

drivers/soc/amlogic/meson-gx-pwrc-vpu.c line 65

Quoted 5 lines
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +5 -0
+	for (i = 0; i < 32; i += 2) {
+		regmap_update_bits(pd->regmap_hhi, HHI_VPU_MEM_PD_REG1,
+				   0x2 << i, 0x3 << i);
+		udelay(5);
+	}

ditto

drivers/soc/amlogic/meson-gx-pwrc-vpu.c line 70

Quoted 5 lines
drivers/soc/amlogic/meson-gx-pwrc-vpu.c new file +5 -0
+	for (i = 8; i < 16; i++) {
+		regmap_update_bits(pd->regmap_hhi, HHI_MEM_PD_REG0,
+				   BIT(i), BIT(i));
+		udelay(5);
+	}

Do these really have to be written one bit at a time?

I'm actually OK to merge things like this, since it also captures the sequences used by the vendor kernel, but I'm just curious if you did any of the other experiments.

If you can try those experiments, we can take them as follow-on patches.

Kevin