From patchwork Mon May 2 03:32:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 12833811 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F079EC433EF for ; Mon, 2 May 2022 03:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jVfkQSGWK/dhTqfTeexdZomnGztVNpkjOZUPX4h1Bck=; b=hLUWW0WxYkjtar gAcpjNQZ0jSR+NUGW6+dlZny9hx/H5HGkco2gq3SaYr8sY5uiirdRESVuJA0jkVb0/3vVsuGaz7B7 zc6ef7jkDwJdlfRvGnmL2+Xuuo498wSz0x21f7w0nPSzL0cJyShqpeC1Yt9TILfeWtYqZKgXVdt8o A5HM7+xpsTsKoeAyEY8M7TVsjwy/O5qe8Ba8EJq8EMAYU7/105XBoqjcvGX+b5zZOgoEAxnT7HdLf Py83WClmKRVrRUtxB6wSSsqFjpkv763Top9IuoRnm7zHnHLvRPNFVJLedi7uYutIM/4k6dG1VnyJc GiP/3ui+erbkEn3TLDKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlMwo-00HRoB-Gd; Mon, 02 May 2022 03:42:06 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlMwk-00HRn6-5G for linux-arm-kernel@lists.infradead.org; Mon, 02 May 2022 03:42:05 +0000 Received: by mail-pj1-x1029.google.com with SMTP id r9so11667507pjo.5 for ; Sun, 01 May 2022 20:42:00 -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:mime-version :content-transfer-encoding; bh=VhMy0JI7nNqcQppVA0JnYf0znLff5xYbmdVFPc+7KFQ=; b=ChL4RwRqNvbXjaSPkV0XOY0AhGcyDG9VMONy6kHgvW0Up2Ct3NrlwsQ8JPPPgxhxzx MyHet0Q8sDBWDLzfsKwdb8kC1fZQUjdhMTKmd6bqo5Bn98pct4S58/gI1ScGiCsjtyy0 HULbiWyczH59s7EOEMjnL4nOFAOWSn5JsqIdVpmOCR6flpN/Z/O/kMvAnuRbFNFjLuVW SCzFmWTI4Q3K8EQE5jFn3mqh53rdRAMCtj8ZUKUbTKx/6U6ueg/QAc3OQ8CLl+GiRpgk s9Gxm4imDmYRi0Qsc5um+i4MzvnuLQT0p9xlBpSC7Z9spKmy+dP96bvyOVsywCYkFJGi GMyg== 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:mime-version :content-transfer-encoding; bh=VhMy0JI7nNqcQppVA0JnYf0znLff5xYbmdVFPc+7KFQ=; b=rAOMx2gR6RbYiAZQsIgtzWcD4KqZU6XARDJlSkWM3q/xKTcoJj+Amsz9fE9nCzOc2u wUHwZnOrEVFNezdgg/YFhxnd93+/D/fQd8b5c4WLRWWCkQE059Hl7p21vGBVPZwsz88P yteKJAskV/Q76D8Wb9d/vzVFNjHHxpUpm+LU7+HYO7rUX4XzLJUtOM58XtqC6pcBEafH fzx7uRIJOt2hsC1wziaoV5mKGEzNe7gysrgyUT9RvD3j9fBpDuFK8hPpSkthKGQ5reAH P/RGEvY2/ETac8p2zmU42IRr8zQ9gaGM8v/i2oHjQVQzFuURAzUyR5hLjYck83VBBrsl 60Jg== X-Gm-Message-State: AOAM533Oyihscvtfh06ZRezk5QVi7lU/48NA/QD56new3igWjVqZJmt3 zr5xOcYWyYzs4laSJ157oGP/Pg== X-Google-Smtp-Source: ABdhPJxQ9L5CeBdFW4cwMPIBeK3305HYCgwmo/7c5uyUgh63G1/L1nCkVvbO8lV2mxdW6FmybkuIGw== X-Received: by 2002:a17:902:b948:b0:153:9994:b587 with SMTP id h8-20020a170902b94800b001539994b587mr10048888pls.68.1651462920135; Sun, 01 May 2022 20:42:00 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1001:7090:c18e:6070:88f2:a04d]) by smtp.gmail.com with ESMTPSA id h25-20020aa786d9000000b0050dc7628131sm3677842pfo.11.2022.05.01.20.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 May 2022 20:41:59 -0700 (PDT) From: Drew Fustini To: Nishanth Menon , Santosh Shilimkar Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Drew Fustini , Brad Griffis , Dave Gerlach Subject: [PATCH] soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend Date: Sun, 1 May 2022 20:32:12 -0700 Message-Id: <20220502033211.1383158-1-dfustini@baylibre.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220501_204202_455989_EF8E68E5 X-CRM114-Status: GOOD ( 19.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 [1]. 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. [1] https://git.ti.com/cgit/processor-firmware/ti-amx3-cm3-pm-firmware/tree/src/pm_services/pm_handlers.c?h=08.02.00.006#n141 Suggested-by: Brad Griffis Signed-off-by: Dave Gerlach [dfustini: add link for a8_lp_ds0_handler() in ti-amx3-cm3-pm-firmware] Signed-off-by: Drew Fustini --- drivers/soc/ti/wkup_m3_ipc.c | 79 +++++++++++++++++++++++++++++++++++- include/linux/wkup_m3_ipc.h | 2 + 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c index c35eaecf4ab4..19bed465ad94 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 @@ -157,6 +161,73 @@ static int wkup_m3_init_scale_data(struct wkup_m3_ipc *m3_ipc, return ret; } +#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 void am33xx_txev_eoi(struct wkup_m3_ipc *m3_ipc) { writel(AM33XX_M3_TXEV_ACK, @@ -402,7 +473,9 @@ 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); @@ -633,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: @@ -644,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 {