Skip to contentSkip to conversation

soc: ti: wkup_m3_ipc: support vtt toggle, io isolation & voltage scaling

PATCH In review Drew Fustini 2 participants 14 messages Feb 19, 2022 – Feb 21, 2022

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

cover soc: ti: wkup_m3_ipc: support vtt toggle, io isolation & voltage scaling

Improve the wkup_m3_ipc driver to better support the TI Wakeup Cortex M3 device found on TI AM33xx and AM43xx SoCs.

This series derives from these commits in the ti-linux-5.10.y branch of the TI Linux repo [1]:

6ab4eff1034b ("remoteproc: move rproc_da_to_va declaration to remoteproc.h") 2a9be39a26f7 ("dt-bindings: wkup_m3_ipc: Add vtt toggling bindings") c65263f9e12c ("wkup_m3_ipc: Add support for toggling VTT regulator") 5c6c821803e1 ("dt-bindings: wkup_m3_ipc: Add ti,io-isolation property") 196c46f7577d ("wkup_m3_ipc: Add support for IO Isolation") c28acc847e5d ("soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling") a4f9ef4ab5ca ("ARM: dts: am437x-gp-evm: Enable wkup_m3 control of IO isolation") 94de756f1771 ("ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node") b7ae4b063793 ("ARM: dts: am43xx: Add scale data fw to wkup_m3_ipc node") 451ec7871ae7 ("soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend")

Minor changes have been made to some patches to resolve conflicts and to split i2c voltage scaling dt-bindings into separate patch.

[1] git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git

Dave Gerlach (10):
dt-bindings: wkup_m3_ipc: Add vtt toggling bindings
soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator
dt-bindings: wkup_m3_ipc: Add ti,io-isolation property
soc: ti: wkup_m3_ipc: Add support for IO Isolation
ARM: dts: am437x-gp-evm: Enable wkup_m3 control of IO isolation
dt-bindings: wkup_m3_ipc: Add scale-data-fw property
soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling
ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node
ARM: dts: am43xx: Add scale data fw to wkup_m3_ipc node
soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend

Suman Anna (1):
remoteproc: move rproc_da_to_va declaration to remoteproc.h

 .../bindings/soc/ti/wkup_m3_ipc.txt           |  91 ++++++++
 arch/arm/boot/dts/am335x-bone-common.dtsi     |   4 +
 arch/arm/boot/dts/am335x-evm.dts              |   4 +
 arch/arm/boot/dts/am335x-evmsk.dts            |   4 +
 arch/arm/boot/dts/am437x-gp-evm.dts           |   5 +
 arch/arm/boot/dts/am437x-sk-evm.dts           |   4 +
 arch/arm/boot/dts/am43x-epos-evm.dts          |   4 +
 drivers/remoteproc/remoteproc_internal.h      |   1 -
 drivers/soc/ti/wkup_m3_ipc.c                  | 208 +++++++++++++++++-
 include/linux/remoteproc.h                    |   1 +
 include/linux/wkup_m3_ipc.h                   |  13 ++
 11 files changed, 334 insertions(+), 5 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/11 remoteproc: move rproc_da_to_va declaration to remoteproc.h

From: Suman Anna <[email protected]>

The rproc_da_to_va() API is an exported function, so move its declaration from the remoteproc local remoteproc_internal.h to the public remoteproc.h file.

This will allow drivers outside of the remoteproc folder to be able to use this API.

[dfustini: fix line number conflict]
---
 drivers/remoteproc/remoteproc_internal.h | 1 -
 include/linux/remoteproc.h               | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_internal.h +0 -1
index a328e634b1de..72d4d3d7d94d 100644
@@ -84,7 +84,6 @@ static inline void  rproc_char_device_remove(struct rproc *rproc)
 void rproc_free_vring(struct rproc_vring *rvring);
 int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
 
-void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem);
 phys_addr_t rproc_va_to_pa(void *cpu_addr);
 int rproc_trigger_recovery(struct rproc *rproc);
 
include/linux/remoteproc.h +1 -0
index e0600e1e5c17..cc9dc9aef0c0 100644
@@ -673,6 +673,7 @@ void rproc_shutdown(struct rproc *rproc);
 int rproc_detach(struct rproc *rproc);
 int rproc_set_firmware(struct rproc *rproc, const char *fw_name);
 void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
+void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem);
 void rproc_coredump_using_sections(struct rproc *rproc);
 int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size);
 int rproc_coredump_add_custom_segment(struct rproc *rproc,
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/11 dt-bindings: wkup_m3_ipc: Add vtt toggling bindings

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add description of the wkup_m3_ipc DT properties that can be used to toggle VTT regulator during low power mode transitions.

---
 .../bindings/soc/ti/wkup_m3_ipc.txt           | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt +34 -0
index 401550487ed6..4cdbb60fd0d0 100644
@@ -55,3 +55,37 @@ Example:
 			...
 		};
 	};
+
+Support for VTT Toggle
+==================================
+In order to enable the support for VTT toggle during Suspend/Resume
+sequence needed by some boards (like AM335x EVM-SK & AM437x GP EVM),
+the below DT properties are required. It is possible to toggle VTT
+using one of two methods depending on the SoC being used, either
+GPIO0 toggle (AM335x and AM437x), or any GPIO with DS_PAD_CONFIG
+bits in the control module (AM437x only).
+
+VTT Toggle using GPIO0
+----------------------------------
+Supported by: AM335x and AM437x
+Used on: AM335x EVM-SK
+
+Optional properties:
+- ti,needs-vtt-toggle:	Indicates that the boards requires VTT toggling
+			during suspend/resume.
+- ti,vtt-gpio-pin:	Specifies the GPIO0 pin used for VTT toggle.
+
+Important Note:
+- Here it is assumed that VTT Toggle will be done using a pin on GPIO-0 Instance.
+  It will not work on any other GPIO using the above properties, regardless of
+  which part is being used.
+
+Example:
+	wkup_m3_ipc: wkup_m3_ipc@1324 {
+		compatible = "ti,am3352-wkup-m3-ipc";
+		...
+		...
+		ti,needs-vtt-toggle;
+		ti,vtt-gpio-pin = <7>;
+		...
+	};
Signature · 1 line
2.32.0
maintainer
#3 lore raw

Re: [PATCH 02/11] dt-bindings: wkup_m3_ipc: Add vtt toggling bindings

Quoted 9 lines · Drew Fustini

From: Dave Gerlach <[email protected]>

Add description of the wkup_m3_ipc DT properties that can be used to toggle VTT regulator during low power mode transitions.

---
 .../bindings/soc/ti/wkup_m3_ipc.txt           | 34 +++++++++++++++++++

NAK. no more txt files please. convert to yaml prior to adding features.

Quoted 47 lines
 1 file changed, 34 insertions(+)
Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt +34 -0
index 401550487ed6..4cdbb60fd0d0 100644
@@ -55,3 +55,37 @@ Example:
...
 		};
 	};
+
+Support for VTT Toggle
+==================================
+In order to enable the support for VTT toggle during Suspend/Resume
+sequence needed by some boards (like AM335x EVM-SK & AM437x GP EVM),
+the below DT properties are required. It is possible to toggle VTT
+using one of two methods depending on the SoC being used, either
+GPIO0 toggle (AM335x and AM437x), or any GPIO with DS_PAD_CONFIG
+bits in the control module (AM437x only).
+
+VTT Toggle using GPIO0
+----------------------------------
+Supported by: AM335x and AM437x
+Used on: AM335x EVM-SK
+
+Optional properties:
+- ti,needs-vtt-toggle:	Indicates that the boards requires VTT toggling
+			during suspend/resume.
+- ti,vtt-gpio-pin:	Specifies the GPIO0 pin used for VTT toggle.
+
+Important Note:
+- Here it is assumed that VTT Toggle will be done using a pin on GPIO-0 Instance.
+  It will not work on any other GPIO using the above properties, regardless of
+  which part is being used.
+
+Example:
+	wkup_m3_ipc: wkup_m3_ipc@1324 {
+		compatible = "ti,am3352-wkup-m3-ipc";
+		...
+		...
+		ti,needs-vtt-toggle;
+		ti,vtt-gpio-pin = <7>;
+		...
+	};
Signature · 1 line
2.32.0
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#4 lore raw

PATCH 3/11 soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Some boards (currently AM335x EVM-SK) provides s/w control via GPIO to toggle VTT regulator to reduce power consumption in low power state.

The VTT regulator should be disabled after enabling self-refresh on suspend, and should be enabled before disabling self-refresh on resume. This is to allow proper self-refresh entry/exit commands to be transmitted to the memory.

Add support for toggling VTT regulator using DT properties. Actual toggling happens in CM3 Firmware. The enable option & the GPIO pin used is collected in A8 Core and then sent to CM3 using IPC registers.

Note:
Here it is assumed that VTT Toggle will be done using a pin on GPIO-0 Instance. The reason is GPIO-0 is in wakeup domain.

---
 drivers/soc/ti/wkup_m3_ipc.c | 27 +++++++++++++++++++++++++--
 include/linux/wkup_m3_ipc.h  |  1 +
 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/soc/ti/wkup_m3_ipc.c +25 -2
index 72386bd393fe..974b4118a893 100644
@@ -40,6 +40,13 @@
 #define M3_FW_VERSION_MASK		0xffff
 #define M3_WAKE_SRC_MASK		0xff
 
+#define IPC_MEM_TYPE_SHIFT		(0x0)
+#define IPC_MEM_TYPE_MASK		(0x7 << 0)
+#define IPC_VTT_STAT_SHIFT		(0x3)
+#define IPC_VTT_STAT_MASK		(0x1 << 3)
+#define IPC_VTT_GPIO_PIN_SHIFT		(0x4)
+#define IPC_VTT_GPIO_PIN_MASK		(0x3f << 4)
+
 #define M3_STATE_UNKNOWN		0
 #define M3_STATE_RESET			1
 #define M3_STATE_INITED			2
@@ -215,6 +222,12 @@ static int wkup_m3_is_available(struct wkup_m3_ipc *m3_ipc)
 		(m3_ipc->state != M3_STATE_UNKNOWN));
 }
 
+static void wkup_m3_set_vtt_gpio(struct wkup_m3_ipc *m3_ipc, int gpio)
+{
+	m3_ipc->vtt_conf = (1 << IPC_VTT_STAT_SHIFT) |
+			    (gpio << IPC_VTT_GPIO_PIN_SHIFT);
+}
+
 /* Public functions */
 /**
  * wkup_m3_set_mem_type - Pass wkup_m3 which type of memory is in use
@@ -294,7 +307,8 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
 	/* Program each required IPC register then write defaults to others */
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->resume_addr, 0);
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
-	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type, 4);
+	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type |
+			       m3_ipc->vtt_conf, 4);
 
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
@@ -433,12 +447,13 @@ static int wkup_m3_rproc_boot_thread(void *arg)
 static int wkup_m3_ipc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	int irq, ret;
+	int irq, ret, temp;
 	phandle rproc_phandle;
 	struct rproc *m3_rproc;
 	struct resource *res;
 	struct task_struct *task;
 	struct wkup_m3_ipc *m3_ipc;
+	struct device_node *np = dev->of_node;
 
 	m3_ipc = devm_kzalloc(dev, sizeof(*m3_ipc), GFP_KERNEL);
 	if (!m3_ipc)
@@ -496,6 +511,14 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 
 	m3_ipc->ops = &ipc_ops;
 
+	if (of_find_property(np, "ti,needs-vtt-toggle", NULL) &&
+	    !(of_property_read_u32(np, "ti,vtt-gpio-pin", &temp))) {
+		if (temp >= 0 && temp <= 31)
+			wkup_m3_set_vtt_gpio(m3_ipc, temp);
+		else
+			dev_warn(dev, "Invalid VTT GPIO(%d) pin\n", temp);
+	}
+
 	/*
 	 * Wait for firmware loading completion in a thread so we
 	 * can boot the wkup_m3 as soon as it's ready without holding
include/linux/wkup_m3_ipc.h +1 -0
index 3f496967b538..2bc52c6381d5 100644
@@ -33,6 +33,7 @@ struct wkup_m3_ipc {
 
 	int mem_type;
 	unsigned long resume_addr;
+	int vtt_conf;
 	int state;
 
 	struct completion sync_complete;
Signature · 1 line
2.32.0
#5 lore raw

PATCH 4/11 dt-bindings: wkup_m3_ipc: Add ti,io-isolation property

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add documentation for the ti,io-isolation DT property on the wkup_m3_ipc node which tells the wkup_m3_ipc driver to use the wkup_m3 to enable IO Isolation during low power mode transitions on am43xx platforms.

---
 .../bindings/soc/ti/wkup_m3_ipc.txt           | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt +46 -0
index 4cdbb60fd0d0..df6b600abf4c 100644
@@ -89,3 +89,49 @@ Example:
 		ti,vtt-gpio-pin = <7>;
 		...
 	};
+
+
+IO Isolation
+============
+Supported by: AM43xx SoCs
+
+It is possible to configure any pin with a corresponding CTRL_CONF_*
+register in the control module to use the states defined in the DS_PAD_CONFIG
+bits by enabling IO isolation on the SoC. The 'ti,set-io-isolation' property
+tells the wkup_m3_ipc driver to enable IO isolation late in the suspend path
+after all drivers have been disabled.
+
+Optional properties:
+- ti,set-io-isolation:	Indicates that the IO's should be placed into
+			isolation and the DS_PAD_CONFIG values should be
+			used during suspend.
+
+Example (VTT Toggle using any GPIO on am437x-gp-evm):
+-----------------------------------------------------
+
+On the AM437x GP EVM, the VTT enable line must be held low to disable VTT
+regulator and held high to enable, so the following pinctrl entry is used.
+The DS pull is enabled which uses a pull down by default and DS off mode is
+used which outputs a low by default. For the normal state, a pull up is
+specified so that the VTT enable line gets pulled high immediately after
+the DS states are removed upon exit from DeepSleep0.
+
+	&am43xx_pinmux {
+		pinctrl-names = "default";
+		pinctrl-0 = <&ddr3_vtt_toggle_default>;
+
+		ddr3_vtt_toggle_default: ddr_vtt_toggle_default {
+		pinctrl-single,pins = <
+			0x25C (DS0_PULL_UP_DOWN_EN | PIN_OUTPUT_PULLUP |
+			       DS0_FORCE_OFF_MODE | MUX_MODE7)>;
+		};
+		...
+	};
+
+	wkup_m3_ipc: wkup_m3_ipc@1324 {
+		compatible = "ti,am4372-wkup-m3-ipc";
+		...
+		...
+		ti,set-io-isolation;
+		...
+	};
Signature · 1 line
2.32.0
#6 lore raw

PATCH 5/11 soc: ti: wkup_m3_ipc: Add support for IO Isolation

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

AM43xx support isolation of the IOs so that control is taken from the peripheral they are connected to and overridden by values present in the CTRL_CONF_* registers for the pad in the control module.

The actual toggling happens from the wkup_m3, so use a DT property from thea wkup_m3_ipc node to allow the PM code to communicate the necessity for placing the IOs into isolation to the firmware.

---
 drivers/soc/ti/wkup_m3_ipc.c | 14 ++++++++++++--
 include/linux/wkup_m3_ipc.h  |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/soc/ti/wkup_m3_ipc.c +12 -2
index 974b4118a893..e7ae942b7014 100644
@@ -46,6 +46,8 @@
 #define IPC_VTT_STAT_MASK		(0x1 << 3)
 #define IPC_VTT_GPIO_PIN_SHIFT		(0x4)
 #define IPC_VTT_GPIO_PIN_MASK		(0x3f << 4)
+#define IPC_IO_ISOLATION_STAT_SHIFT	(10)
+#define IPC_IO_ISOLATION_STAT_MASK	(0x1 << 10)
 
 #define M3_STATE_UNKNOWN		0
 #define M3_STATE_RESET			1
@@ -228,6 +230,11 @@ static void wkup_m3_set_vtt_gpio(struct wkup_m3_ipc *m3_ipc, int gpio)
 			    (gpio << IPC_VTT_GPIO_PIN_SHIFT);
 }
 
+static void wkup_m3_set_io_isolation(struct wkup_m3_ipc *m3_ipc)
+{
+	m3_ipc->isolation_conf = (1 << IPC_IO_ISOLATION_STAT_SHIFT);
+}
+
 /* Public functions */
 /**
  * wkup_m3_set_mem_type - Pass wkup_m3 which type of memory is in use
@@ -308,8 +315,8 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->resume_addr, 0);
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type |
-			       m3_ipc->vtt_conf, 4);
-
+			       m3_ipc->vtt_conf |
+			       m3_ipc->isolation_conf, 4);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 5);
@@ -519,6 +526,9 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 			dev_warn(dev, "Invalid VTT GPIO(%d) pin\n", temp);
 	}
 
+	if (of_find_property(np, "ti,set-io-isolation", NULL))
+		wkup_m3_set_io_isolation(m3_ipc);
+
 	/*
 	 * Wait for firmware loading completion in a thread so we
 	 * can boot the wkup_m3 as soon as it's ready without holding
include/linux/wkup_m3_ipc.h +1 -0
index 2bc52c6381d5..b706eac58f92 100644
@@ -34,6 +34,7 @@ struct wkup_m3_ipc {
 	int mem_type;
 	unsigned long resume_addr;
 	int vtt_conf;
+	int isolation_conf;
 	int state;
 
 	struct completion sync_complete;
Signature · 1 line
2.32.0
#7 lore raw

PATCH 6/11 ARM: dts: am437x-gp-evm: Enable wkup_m3 control of IO isolation

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

With this flag wkup_m3 is able to control IO isolation during suspend on the board.

---
 arch/arm/boot/dts/am437x-gp-evm.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/am437x-gp-evm.dts +4 -0
index 4416ddb559e4..91b67b428a06 100644
@@ -1127,6 +1127,10 @@ &cpu {
 	cpu0-supply = <&dcdc2>;
 };
 
+&wkup_m3_ipc {
+	ti,set-io-isolation;
+};
+
 &pruss1_mdio {
 	status = "disabled";
 };
Signature · 1 line
2.32.0
#8 lore raw

PATCH 7/11 dt-bindings: wkup_m3_ipc: Add scale-data-fw property

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add documentation for scale-data-fw property on the wkup_m3_ipc node to enable I2C PMIC voltage scaling. The property contains the name of a binary file for the CM3 firmware to load.

Based on previous work by Russ Dill.

[dfustini: split dt-binding change into separate patch]
---
 .../devicetree/bindings/soc/ti/wkup_m3_ipc.txt        | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/soc/ti/wkup_m3_ipc.txt +11 -0
index df6b600abf4c..01b78a9da943 100644
@@ -56,6 +56,17 @@ Example:
 		};
 	};
 
+Support for I2C PMIC Voltage Scaling
+--------------------
+It is possible to pass the name of a binary file to laod to the CM3 firmware
+in order to provide I2C sequences for the CM3 to send out to the PMIC during
+low power mode entry.
+
+Optional properties:
+--------------------
+- scale-data-fw:	Name of the firmware binary in /lib/firmware to copy to m3
+			aux data.
+
 Support for VTT Toggle
 ==================================
 In order to enable the support for VTT toggle during Suspend/Resume
Signature · 1 line
2.32.0
#9 lore raw

PATCH 8/11 soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Allow loading of a binary containing i2c scaling sequences to be provided to the wkup_m3 firmware in order to properly scale voltage rails on the PMIC during low power modes like DeepSleep0. Proper binary format is determined by the FW in use.

Code expects firmware to have 0x0C57 present as the first two bytes followed by one byte defining offset to sleep sequence followed by one byte defining offset to wake sequence and then lastly both sequences. Each sequence is a series of I2C transfers in the form:

u8 length | u8 chip address | u8 byte0/reg address | u8 byte1 | u8 byteN ..

The length indicates the number of bytes to transfer, including the register address. The length of each transfer is limited by the I2C buffer size of 32 bytes.

Based on previous work by Russ Dill.

[dfustini: add NULL argument to rproc_da_to_va() call]
[dfustini: replace FW_ACTION_HOTPLUG with FW_ACTION_UEVENT]
---
 drivers/soc/ti/wkup_m3_ipc.c | 93 +++++++++++++++++++++++++++++++++++-
 include/linux/wkup_m3_ipc.h  |  9 ++++
 2 files changed, 101 insertions(+), 1 deletion(-)
drivers/soc/ti/wkup_m3_ipc.c +92 -1
index e7ae942b7014..5a1722c3bf1a 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/firmware.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/interrupt.h>
@@ -55,6 +56,12 @@
 #define M3_STATE_MSG_FOR_LP		3
 #define M3_STATE_MSG_FOR_RESET		4
 
+#define WKUP_M3_SD_FW_MAGIC		0x570C
+
+#define WKUP_M3_DMEM_START		0x80000
+#define WKUP_M3_AUXDATA_OFFSET		0x1000
+#define WKUP_M3_AUXDATA_SIZE		0xFF
+
 static struct wkup_m3_ipc *m3_ipc_state;
 
 static const struct wkup_m3_wakeup_src wakeups[] = {
@@ -75,6 +82,81 @@ static const struct wkup_m3_wakeup_src wakeups[] = {
 	{.irq_nr = 0,	.src = "Unknown"},
 };
 
+/**
+ * wkup_m3_copy_aux_data - Copy auxiliary data to special region of m3 dmem
+ * @data - pointer to data
+ * @sz - size of data to copy (limit 256 bytes)
+ *
+ * Copies any additional blob of data to the wkup_m3 dmem to be used by the
+ * firmware
+ */
+static unsigned long wkup_m3_copy_aux_data(struct wkup_m3_ipc *m3_ipc,
+					   const void *data, int sz)
+{
+	unsigned long aux_data_dev_addr;
+	void *aux_data_addr;
+
+	aux_data_dev_addr = WKUP_M3_DMEM_START + WKUP_M3_AUXDATA_OFFSET;
+	aux_data_addr = rproc_da_to_va(m3_ipc->rproc,
+				       aux_data_dev_addr,
+				       WKUP_M3_AUXDATA_SIZE,
+				       NULL);
+	memcpy(aux_data_addr, data, sz);
+
+	return WKUP_M3_AUXDATA_OFFSET;
+}
+
+static void wkup_m3_scale_data_fw_cb(const struct firmware *fw, void *context)
+{
+	unsigned long val, aux_base;
+	struct wkup_m3_scale_data_header hdr;
+	struct wkup_m3_ipc *m3_ipc = context;
+	struct device *dev = m3_ipc->dev;
+
+	if (!fw) {
+		dev_err(dev, "Voltage scale fw name given but file missing.\n");
+		return;
+	}
+
+	memcpy(&hdr, fw->data, sizeof(hdr));
+
+	if (hdr.magic != WKUP_M3_SD_FW_MAGIC) {
+		dev_err(dev, "PM: Voltage Scale Data binary does not appear valid.\n");
+		goto release_sd_fw;
+	}
+
+	aux_base = wkup_m3_copy_aux_data(m3_ipc, fw->data + sizeof(hdr),
+					 fw->size - sizeof(hdr));
+
+	val = (aux_base + hdr.sleep_offset);
+	val |= ((aux_base + hdr.wake_offset) << 16);
+
+	m3_ipc->volt_scale_offsets = val;
+
+release_sd_fw:
+	release_firmware(fw);
+};
+
+static int wkup_m3_init_scale_data(struct wkup_m3_ipc *m3_ipc,
+				   struct device *dev)
+{
+	int ret = 0;
+
+	/*
+	 * If no name is provided, user has already been warned, pm will
+	 * still work so return 0
+	 */
+
+	if (!m3_ipc->sd_fw_name)
+		return ret;
+
+	ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
+				      m3_ipc->sd_fw_name, dev, GFP_ATOMIC,
+				      m3_ipc, wkup_m3_scale_data_fw_cb);
+
+	return ret;
+}
+
 static void am33xx_txev_eoi(struct wkup_m3_ipc *m3_ipc)
 {
 	writel(AM33XX_M3_TXEV_ACK,
@@ -139,6 +221,7 @@ static irqreturn_t wkup_m3_txev_handler(int irq, void *ipc_data)
 		}
 
 		m3_ipc->state = M3_STATE_INITED;
+		wkup_m3_init_scale_data(m3_ipc, dev);
 		complete(&m3_ipc->sync_complete);
 		break;
 	case M3_STATE_MSG_FOR_RESET:
@@ -300,12 +383,15 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
 	switch (state) {
 	case WKUP_M3_DEEPSLEEP:
 		m3_power_state = IPC_CMD_DS0;
+		wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->volt_scale_offsets, 5);
 		break;
 	case WKUP_M3_STANDBY:
 		m3_power_state = IPC_CMD_STANDBY;
+		wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 5);
 		break;
 	case WKUP_M3_IDLE:
 		m3_power_state = IPC_CMD_IDLE;
+		wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 5);
 		break;
 	default:
 		return 1;
@@ -319,7 +405,6 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
 			       m3_ipc->isolation_conf, 4);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
-	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 5);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 6);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 7);
 
@@ -529,6 +614,12 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 	if (of_find_property(np, "ti,set-io-isolation", NULL))
 		wkup_m3_set_io_isolation(m3_ipc);
 
+	ret = of_property_read_string(np, "ti,scale-data-fw",
+				      &m3_ipc->sd_fw_name);
+	if (ret) {
+		dev_dbg(dev, "Voltage scaling data blob not provided from DT.\n");
+	};
+
 	/*
 	 * Wait for firmware loading completion in a thread so we
 	 * can boot the wkup_m3 as soon as it's ready without holding
include/linux/wkup_m3_ipc.h +9 -0
index b706eac58f92..fef0fac60f8c 100644
@@ -37,6 +37,9 @@ struct wkup_m3_ipc {
 	int isolation_conf;
 	int state;
 
+	unsigned long volt_scale_offsets;
+	const char *sd_fw_name;
+
 	struct completion sync_complete;
 	struct mbox_client mbox_client;
 	struct mbox_chan *mbox;
@@ -50,6 +53,12 @@ struct wkup_m3_wakeup_src {
 	char src[10];
 };
 
+struct wkup_m3_scale_data_header {
+	u16 magic;
+	u8 sleep_offset;
+	u8 wake_offset;
+} __packed;
+
 struct wkup_m3_ipc_ops {
 	void (*set_mem_type)(struct wkup_m3_ipc *m3_ipc, int mem_type);
 	void (*set_resume_address)(struct wkup_m3_ipc *m3_ipc, void *addr);
Signature · 1 line
2.32.0
#10 lore raw

PATCH 9/11 ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add appropriate scale-data-fw names for all am33xx platforms.

[dfustini: modified line numbers to resolve conflict]
---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 4 ++++
 arch/arm/boot/dts/am335x-evm.dts          | 4 ++++
 arch/arm/boot/dts/am335x-evmsk.dts        | 4 ++++
 3 files changed, 12 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +4 -0
index 56ae5095a5b8..31b051651e4f 100644
@@ -405,3 +405,7 @@ &rtc {
 &pruss_tm {
 	status = "okay";
 };
+
+&wkup_m3_ipc {
+	ti,scale-data-fw = "am335x-bone-scale-data.bin";
+};
arch/arm/boot/dts/am335x-evm.dts +4 -0
index 659e99eabe66..92941a3b1add 100644
@@ -782,3 +782,7 @@ &rtc {
 &pruss_tm {
 	status = "okay";
 };
+
+&wkup_m3_ipc {
+	ti,scale-data-fw = "am335x-evm-scale-data.bin";
+};
arch/arm/boot/dts/am335x-evmsk.dts +4 -0
index a2db65538e51..3986ed2a12d5 100644
@@ -719,3 +719,7 @@ &rtc {
 &pruss_tm {
 	status = "okay";
 };
+
+&wkup_m3_ipc {
+	ti,scale-data-fw = "am335x-evm-scale-data.bin";
+};
Signature · 1 line
2.32.0
#11 lore raw

PATCH 10/11 ARM: dts: am43xx: Add scale data fw to wkup_m3_ipc node

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add appropriate scale-data-fw names for all am43xx platforms.

---
 arch/arm/boot/dts/am437x-gp-evm.dts  | 1 +
 arch/arm/boot/dts/am437x-sk-evm.dts  | 4 ++++
 arch/arm/boot/dts/am43x-epos-evm.dts | 4 ++++
 3 files changed, 9 insertions(+)
arch/arm/boot/dts/am437x-gp-evm.dts +1 -0
index 91b67b428a06..ad561f81af3a 100644
@@ -1129,6 +1129,7 @@ &cpu {
 
 &wkup_m3_ipc {
 	ti,set-io-isolation;
+	ti,scale-data-fw = "am43x-evm-scale-data.bin";
 };
 
 &pruss1_mdio {
arch/arm/boot/dts/am437x-sk-evm.dts +4 -0
index 20a34d2d85df..7b518aff5f8f 100644
@@ -893,6 +893,10 @@ vpfe0_ep: endpoint {
 	};
 };
 
+&wkup_m3_ipc {
+	ti,scale-data-fw = "am43x-evm-scale-data.bin";
+};
+
 &pruss1_mdio {
 	status = "disabled";
 };
arch/arm/boot/dts/am43x-epos-evm.dts +4 -0
index 2f4d2e4e9b3e..a734bdc5e126 100644
@@ -1019,6 +1019,10 @@ &cpu {
 	cpu0-supply = <&dcdc2>;
 };
 
+&wkup_m3_ipc {
+	ti,scale-data-fw = "am43x-evm-scale-data.bin";
+};
+
 &pruss1_mdio {
 	status = "disabled";
 };
Signature · 1 line
2.32.0
#12 lore raw

PATCH 11/11 soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend

In reply to Drew Fustini

From: Dave Gerlach <[email protected]>

Add a debugfs option to allow configurable halting of the wkup_m3 during suspend at the last possible point before low power mode entry. This condition can only be resolved through JTAG and advancing beyond the while loop in a8_lp_ds0_handler. Although this hangs the system it forces the system to remain active once it has been entirely configured for low power mode entry, allowing for register inspection through JTAG to help in debugging transition errors.

Halt mode can be set using the enable_off_mode entry under wkup_m3_ipc in the debugfs.

[dfustini: resolve trivial line conflicts]
---
 drivers/soc/ti/wkup_m3_ipc.c | 78 +++++++++++++++++++++++++++++++++++-
 include/linux/wkup_m3_ipc.h  |  2 +
 2 files changed, 79 insertions(+), 1 deletion(-)
drivers/soc/ti/wkup_m3_ipc.c +77 -1
index 5a1722c3bf1a..244bce3f52e8 100644
@@ -7,6 +7,7 @@
  * Dave Gerlach <[email protected]>
  */
 
+#include <linux/debugfs.h>
 #include <linux/err.h>
 #include <linux/firmware.h>
 #include <linux/kernel.h>
@@ -50,6 +51,9 @@
 #define IPC_IO_ISOLATION_STAT_SHIFT	(10)
 #define IPC_IO_ISOLATION_STAT_MASK	(0x1 << 10)
 
+#define IPC_DBG_HALT_SHIFT		(11)
+#define IPC_DBG_HALT_MASK		(0x1 << 11)
+
 #define M3_STATE_UNKNOWN		0
 #define M3_STATE_RESET			1
 #define M3_STATE_INITED			2
@@ -137,6 +141,73 @@ static void wkup_m3_scale_data_fw_cb(const struct firmware *fw, void *context)
 	release_firmware(fw);
 };
 
+#ifdef CONFIG_DEBUG_FS
+static void wkup_m3_set_halt_late(bool enabled)
+{
+	if (enabled)
+		m3_ipc_state->halt = (1 << IPC_DBG_HALT_SHIFT);
+	else
+		m3_ipc_state->halt = 0;
+}
+
+static int option_get(void *data, u64 *val)
+{
+	u32 *option = data;
+
+	*val = *option;
+
+	return 0;
+}
+
+static int option_set(void *data, u64 val)
+{
+	u32 *option = data;
+
+	*option = val;
+
+	if (option == &m3_ipc_state->halt) {
+		if (val)
+			wkup_m3_set_halt_late(true);
+		else
+			wkup_m3_set_halt_late(false);
+	}
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(wkup_m3_ipc_option_fops, option_get, option_set,
+			"%llu\n");
+
+static int wkup_m3_ipc_dbg_init(struct wkup_m3_ipc *m3_ipc)
+{
+	m3_ipc->dbg_path = debugfs_create_dir("wkup_m3_ipc", NULL);
+
+	if (!m3_ipc->dbg_path)
+		return -EINVAL;
+
+	(void)debugfs_create_file("enable_late_halt", 0644,
+				  m3_ipc->dbg_path,
+				  &m3_ipc->halt,
+				  &wkup_m3_ipc_option_fops);
+
+	return 0;
+}
+
+static inline void wkup_m3_ipc_dbg_destroy(struct wkup_m3_ipc *m3_ipc)
+{
+	debugfs_remove_recursive(m3_ipc->dbg_path);
+}
+#else
+static inline int wkup_m3_ipc_dbg_init(struct wkup_m3_ipc *m3_ipc)
+{
+	return 0;
+}
+
+static inline void wkup_m3_ipc_dbg_destroy(struct wkup_m3_ipc *m3_ipc)
+{
+}
+#endif /* CONFIG_DEBUG_FS */
+
 static int wkup_m3_init_scale_data(struct wkup_m3_ipc *m3_ipc,
 				   struct device *dev)
 {
@@ -402,7 +473,8 @@ static int wkup_m3_prepare_low_power(struct wkup_m3_ipc *m3_ipc, int state)
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_power_state, 1);
 	wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->mem_type |
 			       m3_ipc->vtt_conf |
-			       m3_ipc->isolation_conf, 4);
+			       m3_ipc->isolation_conf |
+			       m3_ipc->halt, 4);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 2);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 3);
 	wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 6);
@@ -634,6 +706,8 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 		goto err_put_rproc;
 	}
 
+	wkup_m3_ipc_dbg_init(m3_ipc);
+
 	return 0;
 
 err_put_rproc:
@@ -645,6 +719,8 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
 
 static int wkup_m3_ipc_remove(struct platform_device *pdev)
 {
+	wkup_m3_ipc_dbg_destroy(m3_ipc_state);
+
 	mbox_free_channel(m3_ipc_state->mbox);
 
 	rproc_shutdown(m3_ipc_state->rproc);
include/linux/wkup_m3_ipc.h +2 -0
index fef0fac60f8c..26d1eb058fa3 100644
@@ -36,6 +36,7 @@ struct wkup_m3_ipc {
 	int vtt_conf;
 	int isolation_conf;
 	int state;
+	u32 halt;
 
 	unsigned long volt_scale_offsets;
 	const char *sd_fw_name;
@@ -46,6 +47,7 @@ struct wkup_m3_ipc {
 
 	struct wkup_m3_ipc_ops *ops;
 	int is_rtc_only;
+	struct dentry *dbg_path;
 };
 
 struct wkup_m3_wakeup_src {
Signature · 1 line
2.32.0
maintainer
#13 lore raw
In reply to Drew Fustini
Quoted 34 lines · Drew Fustini

Improve the wkup_m3_ipc driver to better support the TI Wakeup Cortex M3 device found on TI AM33xx and AM43xx SoCs.

This series derives from these commits in the ti-linux-5.10.y branch of the TI Linux repo [1]:

6ab4eff1034b ("remoteproc: move rproc_da_to_va declaration to remoteproc.h") 2a9be39a26f7 ("dt-bindings: wkup_m3_ipc: Add vtt toggling bindings") c65263f9e12c ("wkup_m3_ipc: Add support for toggling VTT regulator") 5c6c821803e1 ("dt-bindings: wkup_m3_ipc: Add ti,io-isolation property") 196c46f7577d ("wkup_m3_ipc: Add support for IO Isolation") c28acc847e5d ("soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling") a4f9ef4ab5ca ("ARM: dts: am437x-gp-evm: Enable wkup_m3 control of IO isolation") 94de756f1771 ("ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node") b7ae4b063793 ("ARM: dts: am43xx: Add scale data fw to wkup_m3_ipc node") 451ec7871ae7 ("soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend")

Minor changes have been made to some patches to resolve conflicts and to split i2c voltage scaling dt-bindings into separate patch.

[1] git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git

Dave Gerlach (10):
dt-bindings: wkup_m3_ipc: Add vtt toggling bindings
soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator
dt-bindings: wkup_m3_ipc: Add ti,io-isolation property
soc: ti: wkup_m3_ipc: Add support for IO Isolation
ARM: dts: am437x-gp-evm: Enable wkup_m3 control of IO isolation
dt-bindings: wkup_m3_ipc: Add scale-data-fw property
soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling
ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node
ARM: dts: am43xx: Add scale data fw to wkup_m3_ipc node
soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend

Quoted 2 lines

Suman Anna (1):
remoteproc: move rproc_da_to_va declaration to remoteproc.h

This series seems to needing to go to various maintainers here

Series should cleanup (example: txt files to yaml bindings), prior to creating patch series for each maintainer. I'd suggest bindings and drivers in 1 kernel rev and follow it up with dts updata for the next rev.

Quoted 17 lines
 .../bindings/soc/ti/wkup_m3_ipc.txt           |  91 ++++++++
 arch/arm/boot/dts/am335x-bone-common.dtsi     |   4 +
 arch/arm/boot/dts/am335x-evm.dts              |   4 +
 arch/arm/boot/dts/am335x-evmsk.dts            |   4 +
 arch/arm/boot/dts/am437x-gp-evm.dts           |   5 +
 arch/arm/boot/dts/am437x-sk-evm.dts           |   4 +
 arch/arm/boot/dts/am43x-epos-evm.dts          |   4 +
 drivers/remoteproc/remoteproc_internal.h      |   1 -
 drivers/soc/ti/wkup_m3_ipc.c                  | 208 +++++++++++++++++-
 include/linux/remoteproc.h                    |   1 +
 include/linux/wkup_m3_ipc.h                   |  13 ++
 11 files changed, 334 insertions(+), 5 deletions(-)
Signature · 1 line
2.32.0
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D