From patchwork Sat Feb 19 21:53:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544106 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 5A6C0C433EF for ; Sat, 19 Feb 2022 21:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235688AbiBSV4B (ORCPT ); Sat, 19 Feb 2022 16:56:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbiBSV4B (ORCPT ); Sat, 19 Feb 2022 16:56:01 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 152D7541A7 for ; Sat, 19 Feb 2022 13:55:41 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id m13-20020a17090aab0d00b001bbe267d4d1so2631500pjq.0 for ; Sat, 19 Feb 2022 13:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xFv8pYP/ZU+UReQceN+3cdKUVINAH0lfYR5sSaL4wpY=; b=XPsUi7jSiA5kjSrk5AzxuhDHnSy45szyngwKqcCazfH7MoUZob4Lm3qB/pUi+xGH1w tM2FTl2egymaCOspqlEYDrzD7iXa5xVrTZ5GeLKxYZzbH4R7UehkDivjq5OPJiotItOs fKrT6Etz8W7S5vIN7qCH3x04vVBdMLLHfjy+uoDjlbBK4EnnJyLJtPTURv+kLWXXhi39 +3ekYDxTkPkpAjFkPprNKmRbSUMpOa2XWRWcwRVdE/LKBcDKQ5qLIBZX0JoZDg9/gH4r ydgqdMa7gdqIe+e3fy3oMstvVM4dBgTXBGUGgEshGlHfPMQ8ULFmRInkq6jCb39i2CS+ LmsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xFv8pYP/ZU+UReQceN+3cdKUVINAH0lfYR5sSaL4wpY=; b=alarW8l+2pyIdAPsS1RkyE34t2LS9i0NFRPPTvNn+wq6ov+W5aLureLO9zRghxlHGk vvnZYz3szPuqd+bX2D1w4ZQGVe3vItOKywJ56hrNqaxerclAcTuOzwSVFsEGcNLQW5sk Y/sl3iD/aolVULMfAg+yUCM0cbS94wbWvNlY8OAPJbDIhZz/ERbtdsFe5TRIyhEkz1PE NxhCCDU7zg++s9fKJcGFIoc7xOe1/lNj3qZAP5vTM8YS7N2aXZVnafH30ODDrw6VCRNb 2u3KPNjAqcuw/EGrCrtV6Z2sAIXt81TMEdA2GgGA/VPX+ici0pMlHlFbG1JJI13HKtjI dzcg== X-Gm-Message-State: AOAM532Yi25qgVox6gzgVbUl4m7R/xODsN7DzO9EErxeKSYcxCaaUisG xQaBS9F2NdAiYwvTYAsgjW6bIQ== X-Google-Smtp-Source: ABdhPJyS54Vh+H8WNTs+GkpNEVkoLaIFTLqYsD/C0UVOD/Oa+ZbdqlFNf5Y7Edc06y/9TO+gZLiBSA== X-Received: by 2002:a17:90b:f88:b0:1b8:ad41:e200 with SMTP id ft8-20020a17090b0f8800b001b8ad41e200mr18633706pjb.1.1645307740514; Sat, 19 Feb 2022 13:55:40 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:39 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Subject: [PATCH 01/11] remoteproc: move rproc_da_to_va declaration to remoteproc.h Date: Sat, 19 Feb 2022 13:53:18 -0800 Message-Id: <20220219215328.485660-2-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Suman Anna 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. Signed-off-by: Suman Anna Signed-off-by: Dave Gerlach [dfustini: fix line number conflict] Signed-off-by: Drew Fustini --- drivers/remoteproc/remoteproc_internal.h | 1 - include/linux/remoteproc.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index a328e634b1de..72d4d3d7d94d 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -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); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e0600e1e5c17..cc9dc9aef0c0 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -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, From patchwork Sat Feb 19 21:53:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544105 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 346FAC433EF for ; Sat, 19 Feb 2022 21:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231797AbiBSV4J (ORCPT ); Sat, 19 Feb 2022 16:56:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243160AbiBSV4G (ORCPT ); Sat, 19 Feb 2022 16:56:06 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CB954188 for ; Sat, 19 Feb 2022 13:55:44 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id h7-20020a17090a648700b001b927560c2bso11684446pjj.1 for ; Sat, 19 Feb 2022 13:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DPqC7sk0jXG3KL4pgR3flZBRy+4blHrbIS6/yBS27Mg=; b=RCOdYH6WIaW2xVqRGFA32u3oOOKisUBbxh2bQZ6OLEuubkB37e/DLlUPUI/qS7ZsPp K9vvLxcUrbv9BMjXSg9sciDkhvYNEdsasmZcb9Ita6e1im3+L2SufG4wk2DJXmvo5pK+ Wx2IcMPhbQ1baTb9PqWZsTEBmfmjFo8u1nF5FRQu3fsbnEslXRYQAawKzZ/FeLpMmYU+ P3YLroiH1jtnPz8t/uPk7nZkuRosB1f+3Lu82Nd6FqbNMUN3ETXpC3qUUkI2D6KutTCV MvLoFxsc1KMYD2sK6O4571yQv32Zu02CNtmn8AKwLrNsFHFGSBRAnJHyhvH6+ZTianzC Gd9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DPqC7sk0jXG3KL4pgR3flZBRy+4blHrbIS6/yBS27Mg=; b=6yYG7vGWAL0wcNxdiu2RnIRgqhfrni9VPyiXBv5St24pX+kMGJsvTNxrPPqaKyy5bM UKm+C6SMBCbOOADa6WujmtBqeulcA71HS3LYbXHzup4Z6ONZqbAEBNeTa3AmnSEsrLyr Dx4mGuSWbonrjZoCIdP3EVbFIcwn1FUvolxZRCAi3vZAmeEef1MumsNXmZoGV9Ngta8U PMvnsQnsZznCS6MYkUQ9lsnF2mgzb1mRIiUXo4UqNvPUMlkDZzCN5GHaroj1r5OXkieI Nso9XkxTyp6uEjd/B2OxC/7xNpCd1y11qWuZYilDHxMT80R4nuW03cv+2Msbtbkdzpxs 8VOg== X-Gm-Message-State: AOAM530iVT8gtLmnX4WQ61G6ysIejgko7igNfHYouK4gni2l7IOJ5eJr b4z6jBw0Ltx97ivwnWBAlIqLaA== X-Google-Smtp-Source: ABdhPJyrjgGWD8uK2oJsFpdirNDfgtzWoV5CCSu0s9ORmrFOQ1CeFPo+nYa0r4tS45fI/XS//g8JLQ== X-Received: by 2002:a17:90a:9309:b0:1bc:1bf1:dad4 with SMTP id p9-20020a17090a930900b001bc1bf1dad4mr1336912pjo.169.1645307744093; Sat, 19 Feb 2022 13:55:44 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:43 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Subject: [PATCH 03/11] soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator Date: Sat, 19 Feb 2022 13:53:20 -0800 Message-Id: <20220219215328.485660-4-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Dave Gerlach 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. Signed-off-by: Dave Gerlach Signed-off-by: Keerthy Signed-off-by: Drew Fustini --- drivers/soc/ti/wkup_m3_ipc.c | 27 +++++++++++++++++++++++++-- include/linux/wkup_m3_ipc.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c index 72386bd393fe..974b4118a893 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -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 diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h index 3f496967b538..2bc52c6381d5 100644 --- a/include/linux/wkup_m3_ipc.h +++ b/include/linux/wkup_m3_ipc.h @@ -33,6 +33,7 @@ struct wkup_m3_ipc { int mem_type; unsigned long resume_addr; + int vtt_conf; int state; struct completion sync_complete; From patchwork Sat Feb 19 21:53:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544101 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 06EA7C4321E for ; Sat, 19 Feb 2022 21:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240181AbiBSV42 (ORCPT ); Sat, 19 Feb 2022 16:56:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243188AbiBSV4N (ORCPT ); Sat, 19 Feb 2022 16:56:13 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F07D4541B4 for ; Sat, 19 Feb 2022 13:55:46 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id om7so11523614pjb.5 for ; Sat, 19 Feb 2022 13:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9DbHqa7/PuuNUMOB7llAk+nGQ8XUCY82hlr70rx3hVw=; b=lMjdjwfj/yDZTTN1HHuqEqPG/1HemUUV8Zai5f4adJ5QtFzGfu892IQ+bv5mTvsCdC hKeH346azPEzDp7/Qee0oz31oraJBCRHEJBp+3bc0zfjWKaIC/2DErWJW/PlQiSEp796 +pDt3kN28gf1Bgr0wZ8xOlhxKf6CBK7MQleRRBLx3tdSPuDwDfxkjCdpPfluTJXCWWke fLVHPkKFGUsMUAwLRWalE3t5L6NumiQ64GU6D0CahKtRD5D562bkHFyaSM+XyjtTwnL5 cxTLxN6H3KPXLOyCgUmogh5pOcF1ugmkJvBage57cVzRK9F2p5b1aDgP+nRfPkWEfAj8 HA2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9DbHqa7/PuuNUMOB7llAk+nGQ8XUCY82hlr70rx3hVw=; b=L3JIx2HLPzN6606uuRsILw0GYXWcTl5toKghfFII4Ul4ExcB9R9zKeAJA+c/udBMim HDORfjug9ZBRyOhDLT0CDaRqmLiPeJRCdKDZ1yME2Qh9nLAZpU24np968kF0K6cqDbAd qBf12xKo0tBfTCIsvfLLkD7bG7fGobq/aGJ1+mGZgWcQcxyHUHloDNaxXJPB3ZhFJ0Kc 02Y2tQOzajwSPMoLcQGXkzd+iVN6q7HrkCdqlmq0m0kDk5BSybobGqKpCUqw2/fJZl+y /A4vnDrLK4flS2QoiB4uFmN8AYR/PHRWs7TfP6c3lx6jhlschgttPTC9YBbniwIR9Zof /feg== X-Gm-Message-State: AOAM533PH9pC7W+712ocIZlsJoTTHF5dRsxY0m5GIPXl3DeBmeHaEeB1 +rWEKmt2QiXk1ZxeuGkNWWzmnQ== X-Google-Smtp-Source: ABdhPJwn7h7JYGRUMVhMEzpjLHw+5/dBjRfY4qeN6ev9JfTP0JOjdKzAk7hp+6ntGi56C2g+1y40Vg== X-Received: by 2002:a17:90b:358d:b0:1bb:74a3:7088 with SMTP id mm13-20020a17090b358d00b001bb74a37088mr14369662pjb.141.1645307746444; Sat, 19 Feb 2022 13:55:46 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:46 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Subject: [PATCH 05/11] soc: ti: wkup_m3_ipc: Add support for IO Isolation Date: Sat, 19 Feb 2022 13:53:22 -0800 Message-Id: <20220219215328.485660-6-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Dave Gerlach 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. Signed-off-by: Dave Gerlach Signed-off-by: Keerthy Signed-off-by: Drew Fustini --- drivers/soc/ti/wkup_m3_ipc.c | 14 ++++++++++++-- include/linux/wkup_m3_ipc.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c index 974b4118a893..e7ae942b7014 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -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 diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h index 2bc52c6381d5..b706eac58f92 100644 --- a/include/linux/wkup_m3_ipc.h +++ b/include/linux/wkup_m3_ipc.h @@ -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; From patchwork Sat Feb 19 21:53:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544102 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 1CD86C433F5 for ; Sat, 19 Feb 2022 21:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243275AbiBSV41 (ORCPT ); Sat, 19 Feb 2022 16:56:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243219AbiBSV4O (ORCPT ); Sat, 19 Feb 2022 16:56:14 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B30BF54689 for ; Sat, 19 Feb 2022 13:55:50 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso15469288pjg.0 for ; Sat, 19 Feb 2022 13:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=t+5B6LvYZGVsC3RYEHxmGkbftMOyxJbez7YJNLu0KHE=; b=aMZG0ids+uNPndh1cyCwh2vSTCkuG5aqqdJ/jVm8LjYLl/PohNxzF+Bogj1X01eGgA VUJkkonUSbHfr78kn1xUS+s/pWBSiBVxPpIUCQKQN3lktHeCcjIGCSI8wYw8aWvmH8AB SVj409alfkBwXv2gn0m0yrGFYcM2xyRYoroSjQJOvzEW5hzFN/2h9saJml6kiCUwnq8H saVqhc9PrFgce7gwLWT1mep+GWykmEEX+60Yqx9xFIN9PVguKVamO+mtptv9N46/4sDk b2721BTjA60KOxw53Y5NgZHXIJd+18O9FDcUdGVeth/54OsX022OQbfSxqFFHJkwcVC7 whqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t+5B6LvYZGVsC3RYEHxmGkbftMOyxJbez7YJNLu0KHE=; b=ZjgFv4Pc6BzTjLV2d3w3yX3ecPZ4FdwVQPdEj83i4CnOo53/oyhl1Gll92FWkHp4o/ fiv46uCNFY5skfb/Uq+73mr9+uphmt4ylXZK286+47Wa6GBdCKn71/hgcy9O8h9qU2lE /nXeHZ4xyv7eVU5B8pZhZgRGoV4OL3lHD7mxzgzNW0dLbv6wWOaJuJG4O7VfiIY2tQTw +YC9nZcxC7nro70x8IW53ZyO6EF4zWXtwwGRz+UCPtd9rIT1FwgssAIcQT4vpsgKaATf ZNSdaQXIqBPs9nI52usMMxMDQ0CcClREpmDQL/l7/YFgZm9Op93xgBb7Q6mRS8ofUnAq jWdA== X-Gm-Message-State: AOAM533p0iA+txqPrRuUK8Zt9dJ7waJwRug3m53RiXtn8+IKFBttHu7W z+ZHP7PZdRH3EgorsKPK4VA0VQ== X-Google-Smtp-Source: ABdhPJwyfHS3ghnsjIwEF90RzGT1P8dhDe8Avt9cgZIMwrN4JBt5Xp8oD5kaPGBxoAenuP43h80mhQ== X-Received: by 2002:a17:902:7892:b0:14e:c520:e47d with SMTP id q18-20020a170902789200b0014ec520e47dmr12728416pll.105.1645307750121; Sat, 19 Feb 2022 13:55:50 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:49 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Subject: [PATCH 08/11] soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling Date: Sat, 19 Feb 2022 13:53:25 -0800 Message-Id: <20220219215328.485660-9-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- 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 e7ae942b7014..5a1722c3bf1a 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -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 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); From patchwork Sat Feb 19 21:53:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544104 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 78E2FC433FE for ; Sat, 19 Feb 2022 21:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243228AbiBSV4R (ORCPT ); Sat, 19 Feb 2022 16:56:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243184AbiBSV4O (ORCPT ); Sat, 19 Feb 2022 16:56:14 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58FD15468E for ; Sat, 19 Feb 2022 13:55:52 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id q11so70546pln.11 for ; Sat, 19 Feb 2022 13:55:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OQDRi6ED3yUR5t/CfNm3XcVMLYaE2vx+NvYgZhn41jM=; b=6GHSa5GF8BjEaY7vMtmInKxOt8TmNQ1d0610AcajUoKsN4RkwwGGvXzpTXU+LlFdTf xvzpqg2g6Cwcsj81sxu/k3JXw9k4tLb7CjnQY+ugOdUniG1g6cHXCOkRzbBIHxuJS+VG aZSjxlhb52B5hQJBE0qy9W0tEO9+qg6Zx/jSgP5UafDVAZpQL03Uo3aZWHy73i37mDfc Ahq8VTCdE6ansytJJY97wCGy1MD8Zq3xZUJ2EhXAqk1QMBrDHaMLQrTnCNamc9j1J1wo VfsjsWpsUE3MbTgya/9DLmrY7FkksAM8otYWCck9N/R6tBazGrqTef1YWyAqT74E82qL OuCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OQDRi6ED3yUR5t/CfNm3XcVMLYaE2vx+NvYgZhn41jM=; b=axrgmhJ33dPE4eB0RwOt8HSsi+RkiQ05z/Cabyiw+IdxpN2k9xBzAVOp+V37DuxrYT EDxW8YNOFdZl7JqrqBbxu4bS6I6YCopSQHrW+ZwVfVCd8mNweP8yjnBVPODkV/GYuaH5 5x77P7ZXb3l1MXxq8f823FSIIQntPBNm28/mKwOOr0x4D3tpOav3f0DOpt9AnpIoUeft 1vr/YLFMqLDx+eyl7d/WxYZkOleYAbXGC8Ia+MEMnb0Vt9gCfn2JEVtBLDc1oBEyhUrf Ks0Mg5P/xvDfVOpzhhhrLhlHqbcQKow0etVU/zfgNYrkitaywRd8Q4SSpNtiMonrgDpG 8q7w== X-Gm-Message-State: AOAM531cfsuN4LFm/qTjhLNOcJ+KdbpMU8oFsgNxMDpDApAllqCn2iTK y9IHtYgVadbp65Nzb3v0lr5vVDLH8e9aTlNh X-Google-Smtp-Source: ABdhPJw0tEzcnvcnUL9jKO7VcMyldkWgIl50hqtyptCPIDfgsNjwWfxsyHfUYSMRG9qVpiLLUmxLoQ== X-Received: by 2002:a17:90b:2516:b0:1bb:f8e6:f568 with SMTP id ns22-20020a17090b251600b001bbf8e6f568mr4198555pjb.118.1645307751504; Sat, 19 Feb 2022 13:55:51 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:50 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Subject: [PATCH 09/11] ARM: dts: am33xx: Add scale data fw to wkup_m3_ipc node Date: Sat, 19 Feb 2022 13:53:26 -0800 Message-Id: <20220219215328.485660-10-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Dave Gerlach Add appropriate scale-data-fw names for all am33xx platforms. Signed-off-by: Dave Gerlach [dfustini: modified line numbers to resolve conflict] Signed-off-by: Drew Fustini --- 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(+) diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi index 56ae5095a5b8..31b051651e4f 100644 --- a/arch/arm/boot/dts/am335x-bone-common.dtsi +++ b/arch/arm/boot/dts/am335x-bone-common.dtsi @@ -405,3 +405,7 @@ &rtc { &pruss_tm { status = "okay"; }; + +&wkup_m3_ipc { + ti,scale-data-fw = "am335x-bone-scale-data.bin"; +}; diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index 659e99eabe66..92941a3b1add 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -782,3 +782,7 @@ &rtc { &pruss_tm { status = "okay"; }; + +&wkup_m3_ipc { + ti,scale-data-fw = "am335x-evm-scale-data.bin"; +}; diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index a2db65538e51..3986ed2a12d5 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts @@ -719,3 +719,7 @@ &rtc { &pruss_tm { status = "okay"; }; + +&wkup_m3_ipc { + ti,scale-data-fw = "am335x-evm-scale-data.bin"; +}; From patchwork Sat Feb 19 21:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 544103 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 47BF4C433FE for ; Sat, 19 Feb 2022 21:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243184AbiBSV4U (ORCPT ); Sat, 19 Feb 2022 16:56:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243235AbiBSV4P (ORCPT ); Sat, 19 Feb 2022 16:56:15 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943055469E for ; Sat, 19 Feb 2022 13:55:54 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id om7so11523776pjb.5 for ; Sat, 19 Feb 2022 13:55:54 -0800 (PST) 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=ALItf1cmaYde5anKiXpaOkvR8+mXdj6IXy5l9T74CXY=; b=Fn3Ru8rk2m6UM8OQLbL67IIZ8/ISkk5RdEHaoDTmx+kgG1d3LaSWDLlgU5hpIz1l7O J7wJiWswQe2eiNiH9NK+KlcuyYwX5V/xk9AHURcL6gvv2KVTbN0ZXmOqjFP+Ymae+m6A XsyBw4215bt3cTNo+f3XJ9PD+lGYKgdRNXJuv4eDuVCSb1Kd3aWbB/DRxrG1zuO6qOK6 bmbXgCSMop4xAHAEGWRHJpJPJUIw19GqTB9pqV/e0IkSqhlP2Oz0sYn9UK88VS0LbwQK NDpXPd0nK3sJsBc29nP85v40SbCnUAjXVZumbtGJ7Ffb2doMS7kbn7u00qZ8C4AP5K39 rWYg== 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=ALItf1cmaYde5anKiXpaOkvR8+mXdj6IXy5l9T74CXY=; b=40g6PKLcLBYXaBO9GwtmDhUFp1K//RarPyt7lfFFl7CgeZQuBSOxBi6Tp8jQzNwaur ygm6FPeZONx/U7BPTYH9k+LZaCNYSnxUP2MmlBgcCeWz93OtxC5KfGUWuzzEejXtfBov wVoyD4+Xcj/E4eZOAXnKgv6LF4vEDgJlB+KQ4O8i41LGol0wgFIThIP0wLACGrdHbzk7 awOsgzvNC4wen6ZSfl6rcgCfuq5QsfSOB5CQGSp2ny1FVw+5eCwM3IomK2oFer1v6bEp AnbWjRw1+u0W+x+bPAp7hWRVw2uiCZh6qDUrwD4JDU5fdsW8kBIRkaLiPp8Hj3x8nfW2 W2mA== X-Gm-Message-State: AOAM530I0zeRSoPmrFSY6lGsx+cCU3AEWUfZ+zBcdN6VFrEz5AHE4GdA Fl/x2Vbo2njF/s6HdUigs44F7g== X-Google-Smtp-Source: ABdhPJxMLUiSjR9mcVV1iK9+hG/lKSlGmCHqWar1s22AM6LNq/uC41pK9n3kfEId/9Rjt1hG8v3Asg== X-Received: by 2002:a17:902:ba96:b0:14c:8407:8e4b with SMTP id k22-20020a170902ba9600b0014c84078e4bmr12646881pls.135.1645307754101; Sat, 19 Feb 2022 13:55:54 -0800 (PST) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:31ab:1e81:9550:f30a]) by smtp.gmail.com with ESMTPSA id i17sm13447337pgn.82.2022.02.19.13.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 13:55:53 -0800 (PST) From: Drew Fustini To: =?utf-8?q?Beno=C3=AEt_Cousson?= , Bjorn Andersson , Dave Gerlach , devicetree@vger.kernel.org, Drew Fustini , Keerthy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org, Mathieu Poirier , Nishanth Menon , Rob Herring , Santosh Shilimkar , Tony Lindgren , s-anna@ti.com, khilman@baylibre.com Cc: Brad Griffis Subject: [PATCH 11/11] soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend Date: Sat, 19 Feb 2022 13:53:28 -0800 Message-Id: <20220219215328.485660-12-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219215328.485660-1-dfustini@baylibre.com> References: <20220219215328.485660-1-dfustini@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Dave Gerlach 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. Suggested-by: Brad Griffis Signed-off-by: Dave Gerlach [dfustini: resolve trivial line conflicts] Signed-off-by: Drew Fustini --- drivers/soc/ti/wkup_m3_ipc.c | 78 +++++++++++++++++++++++++++++++++++- include/linux/wkup_m3_ipc.h | 2 + 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c index 5a1722c3bf1a..244bce3f52e8 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -7,6 +7,7 @@ * Dave Gerlach */ +#include #include #include #include @@ -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); diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h index fef0fac60f8c..26d1eb058fa3 100644 --- a/include/linux/wkup_m3_ipc.h +++ b/include/linux/wkup_m3_ipc.h @@ -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 {