All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2]  soc: ti: wkup_m3_ipc: support i2c voltage scaling
@ 2022-04-25  5:28 ` Drew Fustini
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini

Allow loading of a binary file containing i2c scaling sequences to be
provided to the Cortex-M3 firmware in order to properly scale voltage
rails on the PMIC during low power modes like DeepSleep0.

The new 'ti,scale-data-fw' property contains the name of a binary file.
    
A prerequisite for this series is:
[PATCH v3 0/2] soc: ti: wkup_m3_ipc: Add support for IO Isolation
https://lore.kernel.org/linux-devicetree/20220414192722.2978837-1-dfustini@baylibre.com/

Dave Gerlach (2):
  dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
  soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling

 .../bindings/soc/ti/wkup-m3-ipc.yaml          | 11 +++
 drivers/soc/ti/wkup_m3_ipc.c                  | 93 ++++++++++++++++++-
 include/linux/wkup_m3_ipc.h                   |  9 ++
 3 files changed, 112 insertions(+), 1 deletion(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/2]  soc: ti: wkup_m3_ipc: support i2c voltage scaling
@ 2022-04-25  5:28 ` Drew Fustini
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini

Allow loading of a binary file containing i2c scaling sequences to be
provided to the Cortex-M3 firmware in order to properly scale voltage
rails on the PMIC during low power modes like DeepSleep0.

The new 'ti,scale-data-fw' property contains the name of a binary file.
    
A prerequisite for this series is:
[PATCH v3 0/2] soc: ti: wkup_m3_ipc: Add support for IO Isolation
https://lore.kernel.org/linux-devicetree/20220414192722.2978837-1-dfustini@baylibre.com/

Dave Gerlach (2):
  dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
  soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling

 .../bindings/soc/ti/wkup-m3-ipc.yaml          | 11 +++
 drivers/soc/ti/wkup_m3_ipc.c                  | 93 ++++++++++++++++++-
 include/linux/wkup_m3_ipc.h                   |  9 ++
 3 files changed, 112 insertions(+), 1 deletion(-)

-- 
2.32.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
  2022-04-25  5:28 ` Drew Fustini
@ 2022-04-25  5:28   ` Drew Fustini
  -1 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini, Keerthy

From: Dave Gerlach <d-gerlach@ti.com>

Add documentation for ti,scale-data-fw property to enable I2C PMIC
voltage scaling during deep sleep. The property contains the name of a
binary file for the CM3 firmware to load.

Based on previous work by Russ Dill.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
[dfustini: split from driver patch and convert to json-schema]
Signed-off-by: Drew Fustini <dfustini@baylibre.com>
---
 .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
index 88d690de050c..d2c248d82384 100644
--- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
+++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
@@ -40,6 +40,12 @@ description: |+
   override the pin's existing bias (pull-up/pull-down) and value (high/low) when
   IO isolation is active.
 
+  Support for I2C PMIC Voltage Scaling
+  ====================================
+  It is possible to pass the name of a binary file to load into the CM3 memory.
+  The binary data is the I2C sequences for the CM3 to send out to the PMIC
+  during low power mode entry.
+
 properties:
   compatible:
     enum:
@@ -67,6 +73,11 @@ properties:
       mbox_wkupm3 child node.
     maxItems: 1
 
+  ti,scale-data-fw:
+    $ref: /schemas/types.yaml#/definitions/string
+    description:
+      Name of the firmware binary in /lib/firmware to copy to CM3 aux data
+
   ti,vtt-gpio-pin:
     $ref: /schemas/types.yaml#/definitions/uint32
     description: GPIO pin connected to enable pin on VTT regulator
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
@ 2022-04-25  5:28   ` Drew Fustini
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini, Keerthy

From: Dave Gerlach <d-gerlach@ti.com>

Add documentation for ti,scale-data-fw property to enable I2C PMIC
voltage scaling during deep sleep. The property contains the name of a
binary file for the CM3 firmware to load.

Based on previous work by Russ Dill.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
[dfustini: split from driver patch and convert to json-schema]
Signed-off-by: Drew Fustini <dfustini@baylibre.com>
---
 .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
index 88d690de050c..d2c248d82384 100644
--- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
+++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
@@ -40,6 +40,12 @@ description: |+
   override the pin's existing bias (pull-up/pull-down) and value (high/low) when
   IO isolation is active.
 
+  Support for I2C PMIC Voltage Scaling
+  ====================================
+  It is possible to pass the name of a binary file to load into the CM3 memory.
+  The binary data is the I2C sequences for the CM3 to send out to the PMIC
+  during low power mode entry.
+
 properties:
   compatible:
     enum:
@@ -67,6 +73,11 @@ properties:
       mbox_wkupm3 child node.
     maxItems: 1
 
+  ti,scale-data-fw:
+    $ref: /schemas/types.yaml#/definitions/string
+    description:
+      Name of the firmware binary in /lib/firmware to copy to CM3 aux data
+
   ti,vtt-gpio-pin:
     $ref: /schemas/types.yaml#/definitions/uint32
     description: GPIO pin connected to enable pin on VTT regulator
-- 
2.32.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling
  2022-04-25  5:28 ` Drew Fustini
@ 2022-04-25  5:28   ` Drew Fustini
  -1 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini, Keerthy

From: Dave Gerlach <d-gerlach@ti.com>

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.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
[dfustini: add NULL argument to rproc_da_to_va() call]
[dfustini: replace FW_ACTION_HOTPLUG with FW_ACTION_UEVENT]
Signed-off-by: Drew Fustini <dfustini@baylibre.com>
---
 drivers/soc/ti/wkup_m3_ipc.c | 93 +++++++++++++++++++++++++++++++++++-
 include/linux/wkup_m3_ipc.h  |  9 ++++
 2 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
index 988162dd153a..007daf9af8b5 100644
--- a/drivers/soc/ti/wkup_m3_ipc.c
+++ b/drivers/soc/ti/wkup_m3_ipc.c
@@ -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);
 
@@ -528,6 +613,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
diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h
index b706eac58f92..fef0fac60f8c 100644
--- a/include/linux/wkup_m3_ipc.h
+++ b/include/linux/wkup_m3_ipc.h
@@ -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);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling
@ 2022-04-25  5:28   ` Drew Fustini
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-25  5:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Nishanth Menon,
	Santosh Shilimkar, Dave Gerlach, Tony Lindgren
  Cc: devicetree, linux-arm-kernel, linux-kernel, Drew Fustini, Keerthy

From: Dave Gerlach <d-gerlach@ti.com>

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.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
[dfustini: add NULL argument to rproc_da_to_va() call]
[dfustini: replace FW_ACTION_HOTPLUG with FW_ACTION_UEVENT]
Signed-off-by: Drew Fustini <dfustini@baylibre.com>
---
 drivers/soc/ti/wkup_m3_ipc.c | 93 +++++++++++++++++++++++++++++++++++-
 include/linux/wkup_m3_ipc.h  |  9 ++++
 2 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
index 988162dd153a..007daf9af8b5 100644
--- a/drivers/soc/ti/wkup_m3_ipc.c
+++ b/drivers/soc/ti/wkup_m3_ipc.c
@@ -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);
 
@@ -528,6 +613,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
diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h
index b706eac58f92..fef0fac60f8c 100644
--- a/include/linux/wkup_m3_ipc.h
+++ b/include/linux/wkup_m3_ipc.h
@@ -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);
-- 
2.32.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
  2022-04-25  5:28   ` Drew Fustini
@ 2022-04-25 16:22     ` Rob Herring
  -1 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2022-04-25 16:22 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Krzysztof Kozlowski, Nishanth Menon, Santosh Shilimkar,
	Dave Gerlach, Tony Lindgren, devicetree, linux-arm-kernel,
	linux-kernel, Keerthy

On Sun, Apr 24, 2022 at 10:28:05PM -0700, Drew Fustini wrote:
> From: Dave Gerlach <d-gerlach@ti.com>
> 
> Add documentation for ti,scale-data-fw property to enable I2C PMIC
> voltage scaling during deep sleep. The property contains the name of a
> binary file for the CM3 firmware to load.
> 
> Based on previous work by Russ Dill.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> [dfustini: split from driver patch and convert to json-schema]
> Signed-off-by: Drew Fustini <dfustini@baylibre.com>
> ---
>  .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> index 88d690de050c..d2c248d82384 100644
> --- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> +++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> @@ -40,6 +40,12 @@ description: |+
>    override the pin's existing bias (pull-up/pull-down) and value (high/low) when
>    IO isolation is active.
>  
> +  Support for I2C PMIC Voltage Scaling
> +  ====================================
> +  It is possible to pass the name of a binary file to load into the CM3 memory.
> +  The binary data is the I2C sequences for the CM3 to send out to the PMIC
> +  during low power mode entry.
> +
>  properties:
>    compatible:
>      enum:
> @@ -67,6 +73,11 @@ properties:
>        mbox_wkupm3 child node.
>      maxItems: 1
>  
> +  ti,scale-data-fw:
> +    $ref: /schemas/types.yaml#/definitions/string
> +    description:
> +      Name of the firmware binary in /lib/firmware to copy to CM3 aux data

The location of firmware files is up to the OS.

Is there other firmware? If not, 'firmware-name' is the somewhat 
standard property for this.

What's the default name?

> +
>    ti,vtt-gpio-pin:
>      $ref: /schemas/types.yaml#/definitions/uint32
>      description: GPIO pin connected to enable pin on VTT regulator
> -- 
> 2.32.0
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
@ 2022-04-25 16:22     ` Rob Herring
  0 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2022-04-25 16:22 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Krzysztof Kozlowski, Nishanth Menon, Santosh Shilimkar,
	Dave Gerlach, Tony Lindgren, devicetree, linux-arm-kernel,
	linux-kernel, Keerthy

On Sun, Apr 24, 2022 at 10:28:05PM -0700, Drew Fustini wrote:
> From: Dave Gerlach <d-gerlach@ti.com>
> 
> Add documentation for ti,scale-data-fw property to enable I2C PMIC
> voltage scaling during deep sleep. The property contains the name of a
> binary file for the CM3 firmware to load.
> 
> Based on previous work by Russ Dill.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> [dfustini: split from driver patch and convert to json-schema]
> Signed-off-by: Drew Fustini <dfustini@baylibre.com>
> ---
>  .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> index 88d690de050c..d2c248d82384 100644
> --- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> +++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> @@ -40,6 +40,12 @@ description: |+
>    override the pin's existing bias (pull-up/pull-down) and value (high/low) when
>    IO isolation is active.
>  
> +  Support for I2C PMIC Voltage Scaling
> +  ====================================
> +  It is possible to pass the name of a binary file to load into the CM3 memory.
> +  The binary data is the I2C sequences for the CM3 to send out to the PMIC
> +  during low power mode entry.
> +
>  properties:
>    compatible:
>      enum:
> @@ -67,6 +73,11 @@ properties:
>        mbox_wkupm3 child node.
>      maxItems: 1
>  
> +  ti,scale-data-fw:
> +    $ref: /schemas/types.yaml#/definitions/string
> +    description:
> +      Name of the firmware binary in /lib/firmware to copy to CM3 aux data

The location of firmware files is up to the OS.

Is there other firmware? If not, 'firmware-name' is the somewhat 
standard property for this.

What's the default name?

> +
>    ti,vtt-gpio-pin:
>      $ref: /schemas/types.yaml#/definitions/uint32
>      description: GPIO pin connected to enable pin on VTT regulator
> -- 
> 2.32.0
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
  2022-04-25 16:22     ` Rob Herring
@ 2022-04-26 19:28       ` Drew Fustini
  -1 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-26 19:28 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Nishanth Menon, Santosh Shilimkar,
	Dave Gerlach, Tony Lindgren, devicetree, linux-arm-kernel,
	linux-kernel, Keerthy

On Mon, Apr 25, 2022 at 11:22:20AM -0500, Rob Herring wrote:
> On Sun, Apr 24, 2022 at 10:28:05PM -0700, Drew Fustini wrote:
> > From: Dave Gerlach <d-gerlach@ti.com>
> > 
> > Add documentation for ti,scale-data-fw property to enable I2C PMIC
> > voltage scaling during deep sleep. The property contains the name of a
> > binary file for the CM3 firmware to load.
> > 
> > Based on previous work by Russ Dill.
> > 
> > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> > Signed-off-by: Keerthy <j-keerthy@ti.com>
> > [dfustini: split from driver patch and convert to json-schema]
> > Signed-off-by: Drew Fustini <dfustini@baylibre.com>
> > ---
> >  .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > index 88d690de050c..d2c248d82384 100644
> > --- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > +++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > @@ -40,6 +40,12 @@ description: |+
> >    override the pin's existing bias (pull-up/pull-down) and value (high/low) when
> >    IO isolation is active.
> >  
> > +  Support for I2C PMIC Voltage Scaling
> > +  ====================================
> > +  It is possible to pass the name of a binary file to load into the CM3 memory.
> > +  The binary data is the I2C sequences for the CM3 to send out to the PMIC
> > +  during low power mode entry.
> > +
> >  properties:
> >    compatible:
> >      enum:
> > @@ -67,6 +73,11 @@ properties:
> >        mbox_wkupm3 child node.
> >      maxItems: 1
> >  
> > +  ti,scale-data-fw:
> > +    $ref: /schemas/types.yaml#/definitions/string
> > +    description:
> > +      Name of the firmware binary in /lib/firmware to copy to CM3 aux data
> 
> The location of firmware files is up to the OS.
> 
> Is there other firmware? If not, 'firmware-name' is the somewhat 
> standard property for this.
> 
> What's the default name?

Thank you for the suggestion.  I will change it to firmware-name as
this is the only type of firmware that this driver will need to load.

There is no default name for the firmware. The name depends on the board
being used. The current [1] possibilites are:

am43x-evm-scale-data.bin
am335x-bone-scale-data.bin
am335x-evm-scale-data.bin

Thank you,
Drew

[1] https://git.ti.com/cgit/processor-firmware/ti-amx3-cm3-pm-firmware/tree/bin?h=08.02.00.006

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property
@ 2022-04-26 19:28       ` Drew Fustini
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Fustini @ 2022-04-26 19:28 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Nishanth Menon, Santosh Shilimkar,
	Dave Gerlach, Tony Lindgren, devicetree, linux-arm-kernel,
	linux-kernel, Keerthy

On Mon, Apr 25, 2022 at 11:22:20AM -0500, Rob Herring wrote:
> On Sun, Apr 24, 2022 at 10:28:05PM -0700, Drew Fustini wrote:
> > From: Dave Gerlach <d-gerlach@ti.com>
> > 
> > Add documentation for ti,scale-data-fw property to enable I2C PMIC
> > voltage scaling during deep sleep. The property contains the name of a
> > binary file for the CM3 firmware to load.
> > 
> > Based on previous work by Russ Dill.
> > 
> > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> > Signed-off-by: Keerthy <j-keerthy@ti.com>
> > [dfustini: split from driver patch and convert to json-schema]
> > Signed-off-by: Drew Fustini <dfustini@baylibre.com>
> > ---
> >  .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml       | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > index 88d690de050c..d2c248d82384 100644
> > --- a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > +++ b/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml
> > @@ -40,6 +40,12 @@ description: |+
> >    override the pin's existing bias (pull-up/pull-down) and value (high/low) when
> >    IO isolation is active.
> >  
> > +  Support for I2C PMIC Voltage Scaling
> > +  ====================================
> > +  It is possible to pass the name of a binary file to load into the CM3 memory.
> > +  The binary data is the I2C sequences for the CM3 to send out to the PMIC
> > +  during low power mode entry.
> > +
> >  properties:
> >    compatible:
> >      enum:
> > @@ -67,6 +73,11 @@ properties:
> >        mbox_wkupm3 child node.
> >      maxItems: 1
> >  
> > +  ti,scale-data-fw:
> > +    $ref: /schemas/types.yaml#/definitions/string
> > +    description:
> > +      Name of the firmware binary in /lib/firmware to copy to CM3 aux data
> 
> The location of firmware files is up to the OS.
> 
> Is there other firmware? If not, 'firmware-name' is the somewhat 
> standard property for this.
> 
> What's the default name?

Thank you for the suggestion.  I will change it to firmware-name as
this is the only type of firmware that this driver will need to load.

There is no default name for the firmware. The name depends on the board
being used. The current [1] possibilites are:

am43x-evm-scale-data.bin
am335x-bone-scale-data.bin
am335x-evm-scale-data.bin

Thank you,
Drew

[1] https://git.ti.com/cgit/processor-firmware/ti-amx3-cm3-pm-firmware/tree/bin?h=08.02.00.006

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-26 19:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25  5:28 [PATCH 0/2] soc: ti: wkup_m3_ipc: support i2c voltage scaling Drew Fustini
2022-04-25  5:28 ` Drew Fustini
2022-04-25  5:28 ` [PATCH 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property Drew Fustini
2022-04-25  5:28   ` Drew Fustini
2022-04-25 16:22   ` Rob Herring
2022-04-25 16:22     ` Rob Herring
2022-04-26 19:28     ` Drew Fustini
2022-04-26 19:28       ` Drew Fustini
2022-04-25  5:28 ` [PATCH 2/2] soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling Drew Fustini
2022-04-25  5:28   ` Drew Fustini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.