From nobody Sun May 10 18:32:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FE24C433EF for ; Tue, 26 Apr 2022 19:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354115AbiDZTfr (ORCPT ); Tue, 26 Apr 2022 15:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354256AbiDZTfd (ORCPT ); Tue, 26 Apr 2022 15:35:33 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DB2FE5EB for ; Tue, 26 Apr 2022 12:31:56 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id j8so31137074pll.11 for ; Tue, 26 Apr 2022 12:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mgMaBzrqlCjRGRam/EOt4zCiGdz7YdwH1DVFMVDfBXs=; b=4iSQaIpcTJHXcBSlJlEWJJA6caO4iGkaz8udUxWuH377Fy/420RlqSFPr0zuzJTrlI ow/Wqnjm31vAQUMgUQy/45uq1nhGdG557XYH+zrIUSAsq6ZwKoy7+8Dg6Tr3fWpFBXQu d94vjw7vYnLz14cGh3Uw/0y0V3gM+5QgvwDNsa/auS4Kfb0f67hpPqa7hyiuff2s0SLY NZHyaGBtuTCZG0mp2xqJLqyiodo1pzG2i8Q+kabrdjUWz/lLEFng35FBelfQerqeggBC To48LL5vy2ZrIfj3vPhQLuZBNt9htOroZJUjkp2dRQb4tmfT1WgwiU+g00VCKRKAwgrH /N6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mgMaBzrqlCjRGRam/EOt4zCiGdz7YdwH1DVFMVDfBXs=; b=T5ommX0wdKTRus7TG1nNZ9zBBqRNMib0Tw8WSamgAHV1gdA0Vteg4ghF1FNRj/a10U U/XZAuiZ0TsKeqHl6KFW136I/re0TYzgVXuzZ2zKmHtfknDtJTfN/Bzh2We+wXjfgTID Rnv6xamnPfBqoJ9n9v6llKjAm97XNEVjY7O/w6v6hDJPf7b3bSWuc5AMQAUz1fhzu2xm c7zaxR8jPE/ugFwGDQMtel3YgJNkY3Duc3LtaEzFWp5rJxjU4LNaCqeMTmvTpcDTAQCL bYcoaWJJEfN+IyYEBIplctC7Q9JPRmYEy3cPVfNy7zvzT/2w23iv41oEBcDJAzozpnuG A8ww== X-Gm-Message-State: AOAM532XN4ATPntLbzLf/G8Waq3rjpZkIisVsxmmi79xKvX3D2E/uutO WuSLLbnELNu/4U0Y/QmS6EEBzg== X-Google-Smtp-Source: ABdhPJwWdeXDoRl1CnV+EVlepDxiTF9qYHgisD3NZHZGVmtsLKeF4TLs8wickLkRyt+RjPIQdF/iiA== X-Received: by 2002:a17:903:240f:b0:156:8e81:a0a3 with SMTP id e15-20020a170903240f00b001568e81a0a3mr24572132plo.13.1651001515895; Tue, 26 Apr 2022 12:31:55 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:9bcd:e060:b370:70d8]) by smtp.gmail.com with ESMTPSA id v16-20020a62a510000000b0050759c9a891sm15793410pfm.6.2022.04.26.12.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 12:31:55 -0700 (PDT) From: Drew Fustini To: Rob Herring , Krzysztof Kozlowski , Nishanth Menon , Santosh Shilimkar , Dave Gerlach , Tony Lindgren Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Drew Fustini , Keerthy Subject: [PATCH v2 1/2] dt-bindings: wkup-m3-ipc: Add ti,scale-data-fw property Date: Tue, 26 Apr 2022 12:32:52 -0700 Message-Id: <20220426193253.663582-2-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220426193253.663582-1-dfustini@baylibre.com> References: <20220426193253.663582-1-dfustini@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dave Gerlach 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 Signed-off-by: Keerthy [dfustini: split from driver patch and convert to json-schema] Signed-off-by: Drew Fustini --- Changes from v1: - change 'ti,scale-data-fw' to 'firmware-name' - add 'firmware-name' property to the examples .../devicetree/bindings/soc/ti/wkup-m3-ipc.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml b/Do= cumentation/devicetree/bindings/soc/ti/wkup-m3-ipc.yaml index 88d690de050c..fc8fa6ba8c43 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. =20 + Support for I2C PMIC Voltage Scaling + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + It is possible to pass the name of a binary file to load into the CM3 me= mory. + 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,10 @@ properties: mbox_wkupm3 child node. maxItems: 1 =20 + firmware-name: + description: + Name of binary file with I2C sequences for PMIC voltage scaling + ti,vtt-gpio-pin: $ref: /schemas/types.yaml#/definitions/uint32 description: GPIO pin connected to enable pin on VTT regulator @@ -117,6 +127,7 @@ examples: ti,rproc =3D <&wkup_m3>; mboxes =3D <&am335x_mailbox &mbox_wkupm3>; ti,vtt-gpio-pin =3D <7>; + firmware-name =3D "am335x-evm-scale-data.bin"; }; }; =20 @@ -157,6 +168,7 @@ examples: ti,rproc =3D <&wkup_m3>; mboxes =3D <&am437x_mailbox &mbox_wkupm3>; ti,set-io-isolation; + firmware-name =3D "am43x-evm-scale-data.bin"; }; }; =20 --=20 2.32.0 From nobody Sun May 10 18:32:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 763C1C433EF for ; Tue, 26 Apr 2022 19:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354167AbiDZTfv (ORCPT ); Tue, 26 Apr 2022 15:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354270AbiDZTfe (ORCPT ); Tue, 26 Apr 2022 15:35:34 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF61101761 for ; Tue, 26 Apr 2022 12:31:57 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id gj17-20020a17090b109100b001d8b390f77bso3054983pjb.1 for ; Tue, 26 Apr 2022 12:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mFkswMgpne+UcrkFhk762yyJlUSfm2r0QU+c4khVfyo=; b=W/nsavgFAZLbWFtHtX1hWcbBSa/v9kPWsQDeV29u0q2W/70Ry95HPXUGxz/dG4KYGZ 4BxyGMTU0QDjcC59+lrxQzyHq3l62blG9lOiVBjnH+nvdGGpj2+P0Gf6sgVZ4898Ggds zhaJkIHj+DTdEbed3njXfPSpTJsuywMscqm7btnhB055sqSG+dicTz7kZVItZVTM2Xq4 WeBJ5ZQCXL17YgtGhJcJbmCvT8hngwZ0SIJfAA2TNPr4uD+kNpMJE+5tQ6z2xvl9jv+X uQLibxfRzgXIsnRkoYMjQQtaqwZarpLBk69gyP/akdabEQs1gXBR3LcNh5kE5kghbG2d D5Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mFkswMgpne+UcrkFhk762yyJlUSfm2r0QU+c4khVfyo=; b=2QQU2pAU6/HbAlmIWodY9zp/flfzTp36RQd2wscAuqGYwsdkSSiWTiA9tqfjYCQNti ieBdB3/XKSB2/1+a1my80+oH0FyY6oqjxY50eZj3sHe2XLPGv1e/UfU0kOZTZpibnR39 0CkAwrISYsRgxHPUqCrx0LZ4bbe4ImrcAqszSVFq1cykZsVeNL1PRlAUWTkU+HJcHwZl NBtcZwAJ0cQ0Pg6p1mEpEelXhy3fdvBmDCc+1nq48enkebxD0bZpdJHUiR4nRGzWjUXK NajoDTFfSrh9cGo/RnyR2TpxSsBWmu2IcYif5xsHh+Hy0EpNttyZK6VEUyukQgYwoEmX qEaw== X-Gm-Message-State: AOAM532zpYB0UELZrcAnc92UFeVesnAS4DgyqLJiXse2PgoP4COm+GD/ 85cLyRI/k2Jt/I4UwEHhDphIYQ== X-Google-Smtp-Source: ABdhPJwpv7Jy4MbU9KYijX29TOmNV1w8YtFKr5tWpxisyZZR26TAMCX4qT6XXtW/sh0Z6PYI/wqLYw== X-Received: by 2002:a17:90b:4f45:b0:1d9:91df:ad2f with SMTP id pj5-20020a17090b4f4500b001d991dfad2fmr9885003pjb.4.1651001516857; Tue, 26 Apr 2022 12:31:56 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:9bcd:e060:b370:70d8]) by smtp.gmail.com with ESMTPSA id v16-20020a62a510000000b0050759c9a891sm15793410pfm.6.2022.04.26.12.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 12:31:56 -0700 (PDT) From: Drew Fustini To: Rob Herring , Krzysztof Kozlowski , Nishanth Menon , Santosh Shilimkar , Dave Gerlach , Tony Lindgren Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Drew Fustini , Keerthy Subject: [PATCH v2 2/2] soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling Date: Tue, 26 Apr 2022 12:32:53 -0700 Message-Id: <20220426193253.663582-3-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220426193253.663582-1-dfustini@baylibre.com> References: <20220426193253.663582-1-dfustini@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dave Gerlach 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 Signed-off-by: Keerthy [dfustini: add NULL argument to rproc_da_to_va() call] [dfustini: replace FW_ACTION_HOTPLUG with FW_ACTION_UEVENT] Signed-off-by: Drew Fustini --- Changes from v1: - change 'ti,scale-data-fw' to 'firmware-name' 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..c35eaecf4ab4 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -8,6 +8,7 @@ */ =20 #include +#include #include #include #include @@ -55,6 +56,12 @@ #define M3_STATE_MSG_FOR_LP 3 #define M3_STATE_MSG_FOR_RESET 4 =20 +#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; =20 static const struct wkup_m3_wakeup_src wakeups[] =3D { @@ -75,6 +82,81 @@ static const struct wkup_m3_wakeup_src wakeups[] =3D { {.irq_nr =3D 0, .src =3D "Unknown"}, }; =20 +/** + * 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 =3D WKUP_M3_DMEM_START + WKUP_M3_AUXDATA_OFFSET; + aux_data_addr =3D 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 *cont= ext) +{ + unsigned long val, aux_base; + struct wkup_m3_scale_data_header hdr; + struct wkup_m3_ipc *m3_ipc =3D context; + struct device *dev =3D 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 !=3D WKUP_M3_SD_FW_MAGIC) { + dev_err(dev, "PM: Voltage Scale Data binary does not appear valid.\n"); + goto release_sd_fw; + } + + aux_base =3D wkup_m3_copy_aux_data(m3_ipc, fw->data + sizeof(hdr), + fw->size - sizeof(hdr)); + + val =3D (aux_base + hdr.sleep_offset); + val |=3D ((aux_base + hdr.wake_offset) << 16); + + m3_ipc->volt_scale_offsets =3D 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 =3D 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 =3D 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) } =20 m3_ipc->state =3D 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_i= pc *m3_ipc, int state) switch (state) { case WKUP_M3_DEEPSLEEP: m3_power_state =3D IPC_CMD_DS0; + wkup_m3_ctrl_ipc_write(m3_ipc, m3_ipc->volt_scale_offsets, 5); break; case WKUP_M3_STANDBY: m3_power_state =3D IPC_CMD_STANDBY; + wkup_m3_ctrl_ipc_write(m3_ipc, DS_IPC_DEFAULT, 5); break; case WKUP_M3_IDLE: m3_power_state =3D 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); =20 @@ -528,6 +613,12 @@ static int wkup_m3_ipc_probe(struct platform_device *p= dev) if (of_find_property(np, "ti,set-io-isolation", NULL)) wkup_m3_set_io_isolation(m3_ipc); =20 + ret =3D of_property_read_string(np, "firmware-name", + &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; =20 + 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]; }; =20 +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); --=20 2.32.0