From patchwork Fri Jan 8 08:17:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 12006027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78B36C433DB for ; Fri, 8 Jan 2021 08:18:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 113E323447 for ; Fri, 8 Jan 2021 08:18:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 113E323447 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Bwdanhse7AjJyJJaM2KjAmntrnNssmQZOw8oxyj7Wbg=; b=0GZ8PfEWWWnY1HfJD2ik81uGS u6VGTSDMB4hpH2JKyrIzGCCGbxM+XDPlJZeTJkIbQKChhixRUbO0K8qeAZ5vW8nbIMCuScsKftT30 3TwZoYHY1Mix/1U3WiorxdEyigq8EuTP69KC8Yg1dbU1qaQILtRqVgbMu7HzKigH1YRLIkWTbKBX4 Qrw66ShWubyusCJihzo3HyEQkdEpWp3FtmEoWSGWvdxory64X6z2iXsfub88DGKAQF5gfn4HHyBjo g058Aypnx9uASo6wyDFRJR38goAGbk3ko+lBILfmxqVGbpPqE7etKy5ZF32or7OD0abAErKOBTUk6 uc0X4iEAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyE-000396-Sq; Fri, 08 Jan 2021 08:18:06 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyD-00037g-49 for linux-mediatek@lists.infradead.org; Fri, 08 Jan 2021 08:18:05 +0000 Received: by mail-pf1-x449.google.com with SMTP id l17so6144951pff.17 for ; Fri, 08 Jan 2021 00:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=MTRtl2UAGlXiRiGOyc8AHNRImXjzXH68pAaaOwyulHE=; b=V6EL31lTkHVGs10R8sodrz5276YWozWSBOItTi9gN8gncQV8Tjwe6RSj+PgZcVAoGV 2U4TObb11sP/ILFF6IJYsHlKQHVF9DLwTvs992qHpCfPSMJlEOK0IFYVcCzdtidpHgtB pdC8DD4JR8/zqKrxfbQzsQS7svGn58Q41yz+4uJvKy00+iZmxFqtTm91OjE5PnYNC1ww +5fy/LHvystcDU6LK+0YhIXnj+p/aViMZY+LnxkjoZ9Je32qgLDuEUmsdtX9e6BT6IyO VGTl2hv/ITPcj+ME8pOhoY4kLJQIDiDqzzrjFOYxAjHfvcvpq1YRRIBRJWlZOlBOEw66 jIHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MTRtl2UAGlXiRiGOyc8AHNRImXjzXH68pAaaOwyulHE=; b=bfP8Czrg0Xo/x7juKuYoNan0Xf21oFJdE/PHot5zRdoRNkUUZva6TDvb+AkllbNGrx u0Zr9+22KaXmxl0m8P8g0/2FlbUqyT6lOzUMf4NyAFkVZHbRLrQMRRmgxf2QfDUoee5p kItcp0KHwQEAREC5k2xpG9jlGK4adLlpzbKH0dph5dF+rNRJnTuIvTqyo+A08OPSHWiE h4yVLDdMGQbIlZ80KyYca+wzfvObJfMel9GhV0t3cMAvf07C4z8UKhVsxRCCHuGbibar xDN/4TdeIvFkhK3j3DdHUcj96l0FeLfZjUYtoBotMqU2Lsyuio78EsgvxUR/NI289Tn7 4cgA== X-Gm-Message-State: AOAM531JmR+abR8PPaLwZrThc8TJCbRO+f3ADgJ/UirjjzfGAlTO+3eM zRZtPpGJewMsM3mAikP/G7uqIYev4wxy X-Google-Smtp-Source: ABdhPJxmyHvyUBXGANKNPo0GB8zfz2o/IJkoe30Xr6ThffKBgLQZuYb5UHeFQfE76Cz/didQG1YaHoJjCMFy X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:725a:fff:fe41:c6a5]) (user=tzungbi job=sendgmr) by 2002:a17:90a:1706:: with SMTP id z6mr1765727pjd.0.1610093876865; Fri, 08 Jan 2021 00:17:56 -0800 (PST) Date: Fri, 8 Jan 2021 16:17:35 +0800 In-Reply-To: <20210108081738.2175224-1-tzungbi@google.com> Message-Id: <20210108081738.2175224-2-tzungbi@google.com> Mime-Version: 1.0 References: <20210108081738.2175224-1-tzungbi@google.com> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH v2 1/4] remoteproc/mediatek: use devm_platform_ioremap_resource_byname From: Tzung-Bi Shih To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_031805_180188_714B0FB5 X-CRM114-Status: GOOD ( 10.91 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, mathieu.poirier@linaro.org, linux-remoteproc@vger.kernel.org, tzungbi@google.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Replaces platform_get_resource_byname() and devm_ioremap_resource() pairs to devm_platform_ioremap_resource_byname(). Note that, not every pairs are applicable to replace. Especially when it needs to access the resource struct from platform_get_resource_byname(). For example: scp->sram_size = resource_size(res); Signed-off-by: Tzung-Bi Shih --- drivers/remoteproc/mtk_scp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index e0c235690361..1f0ed2974d5c 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -719,8 +719,7 @@ static int scp_probe(struct platform_device *pdev) for (i = 0; i < SCP_IPI_MAX; i++) mutex_init(&scp->ipi_desc[i].lock); - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); - scp->reg_base = devm_ioremap_resource(dev, res); + scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); if (IS_ERR((__force void *)scp->reg_base)) { dev_err(dev, "Failed to parse and map cfg memory\n"); ret = PTR_ERR((__force void *)scp->reg_base); From patchwork Fri Jan 8 08:17:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 12006031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D77FC433DB for ; Fri, 8 Jan 2021 08:18:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 082F323447 for ; Fri, 8 Jan 2021 08:18:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 082F323447 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HZp9wyPrdK32IchpX964rOYMzsXnurW1adUZnRGrv10=; b=US1m6BKwZ7i5PMuKzBLwDyk1S cqEwHmnP47XwpNcBDINiAes/LvIRoOFskLE3Ce8Ph/85tZM2b+cuwE1klfGv6j6UJKW1WR1bTjwjx Bv4CtchHIyZ2UguqI36W6P51Xbz/bkDEEO33G+NIA2Er3h8mVQZ0wL+D/hnc467dLFVgy9InZ551B ryVM7WFZ4TGxV5jDpwMP/8UjHpnn2QoTJGm9mTfGG1PGSpnAnE2uSq7oFeFICL2awFdiJGLiRa7ta Qr4YW2UEAL+bQKueu6UXC6sTHeNycDfCskrGZmkBnUYbjLNO9G0/1sDSNvDztGxne804bYvpdzvr3 0cSuCMkqg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyJ-0003Af-WB; Fri, 08 Jan 2021 08:18:12 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyH-00038F-Id for linux-mediatek@lists.infradead.org; Fri, 08 Jan 2021 08:18:10 +0000 Received: by mail-qk1-x749.google.com with SMTP id u9so8708562qkk.5 for ; Fri, 08 Jan 2021 00:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=R57CcAcJp5uD5dq5EWgT5pOw4gxHlrQ3Su0vEVAHoVA=; b=BwTJuMFDGoSghD5LbsH5Cw7LX0/rKMZncBvaYZmRRftCpPS9ikO90ooY3zKsdBHh0R CWQ4iBzzkqTJ39D0Yw4W6CAF5nepOQ+ExE7x9ZiXEDenNPmY3P9HZigEYXbkFkkHNsSU SJXVByg5dPtfQXULAO04yhngGjj2YUq7Sv4aqVoQlhd4ahZQia3YHUOrbgHirzEep4Qi bUbwkQyT5tM/KCUUj4xsczk/IsYJ/zjKkdFcukHKGbmz5KoJMoWo/nTusrS7wY71Zg4T c5adwvygIR9zH2k8XCT4ixdFebAy+5sDWfL7DoGk0iuA1ly9FHeF++vt2ORArBYSCTlW L9/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=R57CcAcJp5uD5dq5EWgT5pOw4gxHlrQ3Su0vEVAHoVA=; b=EGClpvR9qQ8UDGN6zJW2yYL1wHytddnz2NIfDgUSGjB5oTJacE0P2CmA8bfnQnSjiz SgFrInl49ir+IeKrEEG/3UdysIJNIQi9abiCLu1uejho/cLrtfApPgCMAHtujQA7IkXZ MC/IOAWwUyuSClTGAeg//XYKYewKu2Ew664iAFIHkGpZXPRbyvXKWojDL3RXhKW6M7Wq htMsca22wcjCWBSwWawWqBNcdfODzPzxPsNYk+zbqNYuNgLvGYzvKtgAgfMXnr90J6HU NvidBTTBIloqhxqUrtYzzJh3qwfuhowhtumfqjJ6y8p55VxX8fyjenbIvB/nU5P2FDpS UwIQ== X-Gm-Message-State: AOAM531MafNEoyJSu9AwjFj9fqHt0JciKx7DbIIeOCZJKNkI7lMNI0rC wobn3GvJ9ZA0pyW3NDHZ9jWrhzuiIaQc X-Google-Smtp-Source: ABdhPJwHhuxkzvvD6e9WI7V4kGI7pAXOpvrQPy2rirJ5V9r+aLhmL4ro1CwshF/ltrcIA1JYp9UCtMgshgTP X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:725a:fff:fe41:c6a5]) (user=tzungbi job=sendgmr) by 2002:a0c:f185:: with SMTP id m5mr5692827qvl.19.1610093880727; Fri, 08 Jan 2021 00:18:00 -0800 (PST) Date: Fri, 8 Jan 2021 16:17:36 +0800 In-Reply-To: <20210108081738.2175224-1-tzungbi@google.com> Message-Id: <20210108081738.2175224-3-tzungbi@google.com> Mime-Version: 1.0 References: <20210108081738.2175224-1-tzungbi@google.com> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH v2 2/4] remoteproc/mediatek: enable MPU for all memory regions in MT8192 SCP From: Tzung-Bi Shih To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_031809_674735_FAC540C6 X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, mathieu.poirier@linaro.org, linux-remoteproc@vger.kernel.org, stable@vger.kernel.org, tzungbi@google.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The register MT8192_CORE0_MEM_ATT_PREDEF contains attributes for each memory region. It defines whether a memory region can be managed by MPU or not. In the past, due to the default settings in the register, MT8192 SCP works luckily. After enabling L1TCM, SCP starts to access memory region that is not included in the default settings. As a result, SCP hangs. Enables MPU for all memory regions in MT8192 SCP. Note that the register is read only once when SCP resets. Thus, it must be set from kernel side. Fixes: fd0b6c1ff85a ("remoteproc/mediatek: Add support for mt8192 SCP") Cc: # v5.10+ Signed-off-by: Tzung-Bi Shih --- Changes from previous version[1]: - Adds Fixes and Cc tags. [1]: https://patchwork.kernel.org/project/linux-remoteproc/list/?series=410291 drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 988edb4977c3..661c998288d7 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -47,6 +47,7 @@ #define MT8192_CORE0_SW_RSTN_CLR 0x10000 #define MT8192_CORE0_SW_RSTN_SET 0x10004 +#define MT8192_CORE0_MEM_ATT_PREDEF 0x10008 #define MT8192_CORE0_WDT_CFG 0x10034 #define SCP_FW_VER_LEN 32 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 1f0ed2974d5c..c33c41fe54cd 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -369,6 +369,9 @@ static int mt8192_scp_before_load(struct mtk_scp *scp) mt8192_power_on_sram(scp->reg_base + MT8192_L1TCM_SRAM_PDN); mt8192_power_on_sram(scp->reg_base + MT8192_CPU0_SRAM_PD); + /* enable MPU for all memory regions */ + writel(0xff, scp->reg_base + MT8192_CORE0_MEM_ATT_PREDEF); + return 0; } From patchwork Fri Jan 8 08:17:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 12006035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24181C433E6 for ; Fri, 8 Jan 2021 08:18:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D59D4235DD for ; Fri, 8 Jan 2021 08:18:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D59D4235DD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ECeFZVXKekroGc/W2D62EcL2BXiGfju+X5B31suEoY0=; b=Id3DqGrFAMTi5vAsxreMc4zWe JSfpSWaGAkCo5aubiqwmIyVju8PYG9lhXYOyPN5Vbq3Iarq1hXapIxpI6pp5OsmvFE2uGy33bFaw9 34yKwAV/0Tcq0EsqM6FbDbHoGHRDKQ9NdWirgtxYQQ8GYn7sh8PwbxGxOtAy8Kr+keiZGRZ1w+wGE PoHLOj4Xj47IXH2CHu5QOeD5l6mW9yYDUah6VMvCmsV7/jiqb6/Ya4rcVL2hdBzTbjIbtJhlc/Lgx pkyTej4n12nl3KEesKy9QUYqcQOLY9NsCW+iTWgd9WdEjICXY3nauzUWWQKcE+vJswogpWw+TM7YS EhzQaP8KA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyI-0003A6-8d; Fri, 08 Jan 2021 08:18:10 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyG-00038f-5o for linux-mediatek@lists.infradead.org; Fri, 08 Jan 2021 08:18:08 +0000 Received: by mail-yb1-xb49.google.com with SMTP id l126so14973639ybl.10 for ; Fri, 08 Jan 2021 00:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bI+0dIEYVTi9BtzYNPAvr6WiFZISRySVGENe/QVVeXw=; b=Iyscw6HOMElHAJAqxy6xFyo6nkn4oDAvWAg+pUIizUYF/vLoLvVh+XHIA75PrE2M69 dduZxqboECIIG01/0rGLNzDPeZxb7bnQYF9lFkxuOCXGQDyMFbfa8FA1+v3qDAybmn2H I6huQgDIThU7nbf8A+IZtNO1r5Qtjz+jdLWVOzBryoFrJKTutnQDSGRZ+iEP04Rv9khF MnWRbYRgHNgBGsrbDMS4jWu3pCeo+uVvmWLHwQUN1IXXrRgRsK0ibfUj2qwDTo78idJI kmTOVtuIr9Y2cgngOalOyhzyfsTBaFGLWlOcwutTD0spWf9sBmblvs92aZ03PRch+atu Yy+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bI+0dIEYVTi9BtzYNPAvr6WiFZISRySVGENe/QVVeXw=; b=qVcMFNnk8hZbP4/rDt9jnrE2dM6S2Rliwp78aIBAR622FgZoY+reQNp6GcLaZXTH7v lTgw9TF5vxw74hyapDuPAVvUsgIGfh+8kx9iVHJKdcjdcw7K2ipq08RuMiD3GVVRU07p q5y75zk2UsRGL95hEZNdMtqeujIswCZcTJtJmVugcdPFOdC8pxBPXwaXKoASH14sE+RC Cx05Rj5XB4u5fQEblNhtTX7K88OGLtkF6RTqKmiutd8I8oKvBMhrgX65RTmtgNwU/1MJ MFtestXtqedQoIG8QDMTpdKIXHjgvNAEa0CT2cH9PMYx+uR4PbnESUyWlwlP8JLzlLmH ON2A== X-Gm-Message-State: AOAM533Oj86znVd+1iwTN8/w8qKqpTO/5sdE5uvoU5ryhNRrLwyedTfM A671Q9gjYgu5MbwTl25MwUlzUXD98rg6 X-Google-Smtp-Source: ABdhPJygnrtyISlSlZ02dPQVOsCdCcsdrrSWjhpY98JkLLd5qOr7KV+rZKsNbB9nbQf38IzFNJeKIP5MZsSZ X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:725a:fff:fe41:c6a5]) (user=tzungbi job=sendgmr) by 2002:a25:c5c1:: with SMTP id v184mr4291137ybe.449.1610093884486; Fri, 08 Jan 2021 00:18:04 -0800 (PST) Date: Fri, 8 Jan 2021 16:17:37 +0800 In-Reply-To: <20210108081738.2175224-1-tzungbi@google.com> Message-Id: <20210108081738.2175224-4-tzungbi@google.com> Mime-Version: 1.0 References: <20210108081738.2175224-1-tzungbi@google.com> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH v2 3/4] dt-bindings: remoteproc: mediatek: add L1TCM memory region From: Tzung-Bi Shih To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_031808_233331_0E88F078 X-CRM114-Status: UNSURE ( 9.39 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, mathieu.poirier@linaro.org, Rob Herring , linux-remoteproc@vger.kernel.org, tzungbi@google.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Adds L1TCM memory region. The reg-name is "l1tcm". Acked-by: Rob Herring Signed-off-by: Tzung-Bi Shih --- Documentation/devicetree/bindings/remoteproc/mtk,scp.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt b/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt index 3ba668bab14b..3f5f78764b60 100644 --- a/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt +++ b/Documentation/devicetree/bindings/remoteproc/mtk,scp.txt @@ -6,10 +6,10 @@ Mediatek SoCs. Required properties: - compatible Should be "mediatek,mt8183-scp" -- reg Should contain the address ranges for the two memory - regions, SRAM and CFG. -- reg-names Contains the corresponding names for the two memory - regions. These should be named "sram" & "cfg". +- reg Should contain the address ranges for memory regions: + SRAM, CFG, and L1TCM. +- reg-names Contains the corresponding names for the memory regions: + "sram", "cfg", and "l1tcm". - clocks Clock for co-processor (See: ../clock/clock-bindings.txt) - clock-names Contains the corresponding name for the clock. This should be named "main". From patchwork Fri Jan 8 08:17:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 12006033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E345AC433E0 for ; Fri, 8 Jan 2021 08:18:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8533123447 for ; Fri, 8 Jan 2021 08:18:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8533123447 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LEbf1dB/+kdwDiXZl6dG0H6opaQlQGv8645QeeLMTl0=; b=FEOnJSaDQluIpCW8mlKMDdaNd nYKnXVu3Br4bXoaZUz8PrUA4uprfjgtt5mdDWZxwOUlUCIMbrFytwMTPJItWsE3BcYhksdGWUqPWE FuP0EI4czsZpxletk+k/eVq48b8NdJMLTQH3M1u6oPlH6irNz5iKVe2NKLkNk56seuE/PW8uQmjW3 65HtqlVb2X7Uzmb3nBg/Huhd5HAvX91BumJJkN899vU0qt6qDRfup6X133mTKnGGv51bSv31LIsfh DPCwJCnDOk+H1G9VRdQRoRa15zajw44aQrhX1WZ6JAieJwYBYi62UTO+TO7Cfepy33IMoWlL7NgTj R3Phpe/gw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyQ-0003By-LU; Fri, 08 Jan 2021 08:18:18 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxmyO-00039d-BQ for linux-mediatek@lists.infradead.org; Fri, 08 Jan 2021 08:18:17 +0000 Received: by mail-qt1-x849.google.com with SMTP id c14so7759240qtn.5 for ; Fri, 08 Jan 2021 00:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=LPy4kNss0vjaYMzm9yB8ZiYIGPp2YbxLPVEf6yAWf0E=; b=svCkAik61y2tqlI8QaAncQGfiqLGdx5ZK5/6jZwHf12GHTZ4tQSTP+82FWBOi0RfRY kHHnn5asv2m5TUtnsm/WXAjaf7y6sC8QUobHAXRKLBePbWoFeANyfK4fSDYosMcDQN3q fHABjoi4xqsrNzSpz61bjhugyeGHkYg+gxbvjouet+cJsMxu/clNaKRgSaUWSv4Au7nW Netk0E+Vw8siXB+M+rQ5K6CWnhaHYi3tdI/64hm9ShUzdauoHMijY/7rtEDf3wBk8yCj HyEHrnn1umGjn4zYtKv/ZRXHBTPy7eLsLbsIO/8pfpR4fR/aKzvwk/G7qH49x5i+slcM 3F0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LPy4kNss0vjaYMzm9yB8ZiYIGPp2YbxLPVEf6yAWf0E=; b=aQ+Bk90UCkYNyrtFz3MKe1A/YC25xd3wDQr69OvgvXmSPc3SBO5oFqLAQIgOeybVgD jaHcaRMJsqkRSPA26bk2YrgJPUgxzQlU5U5A3TeJ5kI19T6QGl+zRxVarOsPsJMzNyYr OGGmCJGku8wgz1g7I43GmyCf5Q976lTndub8yUI1w2Bt8qSFDQmMZmlLz0P8wc7J+Eai nCcAcpn22Z/3vuHTenCVJ6DhdJw86ZYrS09TqCYICrvhCDRyzkFVISCDGus6VU+oG8M9 EP98pKDW9zhq9wZDf1hYpmdqe5+28WikTTbLOx9X1a/d3Rx/+Cc4Sl6mAD5sxU4VtmMa 6hug== X-Gm-Message-State: AOAM530vEjPgrzFoGFj0izU2LcHUpF5EsfsgQ3VoaEWCo7SZtvZjuvDD Dyy5kZPKzs3lkYYX2vl+AIb5iizaBx71 X-Google-Smtp-Source: ABdhPJwCuBbyszBJxL/WGIggEGfWdYN2ks6dq347se1rJMLcshWX3ZB6Svohs/cFLFVUi1NxZfF6HQDb5DBm X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:725a:fff:fe41:c6a5]) (user=tzungbi job=sendgmr) by 2002:a0c:8445:: with SMTP id l63mr2381601qva.60.1610093887875; Fri, 08 Jan 2021 00:18:07 -0800 (PST) Date: Fri, 8 Jan 2021 16:17:38 +0800 In-Reply-To: <20210108081738.2175224-1-tzungbi@google.com> Message-Id: <20210108081738.2175224-5-tzungbi@google.com> Mime-Version: 1.0 References: <20210108081738.2175224-1-tzungbi@google.com> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH v2 4/4] remoteproc/mediatek: support L1TCM From: Tzung-Bi Shih To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_031816_424659_CEC68E53 X-CRM114-Status: GOOD ( 17.66 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, mathieu.poirier@linaro.org, linux-remoteproc@vger.kernel.org, tzungbi@google.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org L1TCM is a high performance memory region in MT8192 SCP. Reads L1TCM memory region from DTS to determine if the machine supports. Loads L1TCM memory region to SCP sys if the firmware provides. Starts from MT8192 SCP, the firmware contains physical addresses for each memory region, for instance: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0xXXXXXX 0xXXXXXXXX 0x10500000 0xXXXXX 0xXXXXX XXX 0xXXXX LOAD 0xXXXXXX 0xXXXXXXXX 0x10700000 0xXXXXX 0xXXXXX XXX 0xXXXX LOAD 0xXXXXXX 0xXXXXXXXX 0x50000000 0xXXXXX 0xXXXXX XXX 0xXXXX Kernel driver can use the "PhysAddr" (i.e. da in the da_to_va callbacks) to know the ELF segment belongs to which region. To backward compatible to MT8183 SCP, separates the da_to_va callbacks for new and legacy version. Signed-off-by: Tzung-Bi Shih --- Changes from v1[1]: - Uses -EINVAL to determine the memory region isn't specified to make the intent more clear. [1]: https://patchwork.kernel.org/project/linux-remoteproc/patch/20201214050521.845396-3-tzungbi@google.com/ drivers/remoteproc/mtk_common.h | 5 +++ drivers/remoteproc/mtk_scp.c | 56 +++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 661c998288d7..5f7cd2336cef 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -76,6 +76,7 @@ struct mtk_scp_of_data { void (*scp_reset_assert)(struct mtk_scp *scp); void (*scp_reset_deassert)(struct mtk_scp *scp); void (*scp_stop)(struct mtk_scp *scp); + void *(*scp_da_to_va)(struct mtk_scp *scp, u64 da, size_t len); u32 host_to_scp_reg; u32 host_to_scp_int_bit; @@ -90,6 +91,10 @@ struct mtk_scp { void __iomem *reg_base; void __iomem *sram_base; size_t sram_size; + phys_addr_t sram_phys; + void __iomem *l1tcm_base; + size_t l1tcm_size; + phys_addr_t l1tcm_phys; const struct mtk_scp_of_data *data; diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index c33c41fe54cd..96ee61bf9245 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -461,9 +461,8 @@ static int scp_start(struct rproc *rproc) return ret; } -static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len) +static void *mt8183_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) { - struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; int offset; if (da < scp->sram_size) { @@ -479,6 +478,42 @@ static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len) return NULL; } +static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) +{ + int offset; + + if (da >= scp->sram_phys && + (da + len) <= scp->sram_phys + scp->sram_size) { + offset = da - scp->sram_phys; + return (void __force *)scp->sram_base + offset; + } + + /* optional memory region */ + if (scp->l1tcm_size && + da >= scp->l1tcm_phys && + (da + len) <= scp->l1tcm_phys + scp->l1tcm_size) { + offset = da - scp->l1tcm_phys; + return (void __force *)scp->l1tcm_base + offset; + } + + /* optional memory region */ + if (scp->dram_size && + da >= scp->dma_addr && + (da + len) <= scp->dma_addr + scp->dram_size) { + offset = da - scp->dma_addr; + return scp->cpu_addr + offset; + } + + return NULL; +} + +static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len) +{ + struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; + + return scp->data->scp_da_to_va(scp, da, len); +} + static void mt8183_scp_stop(struct mtk_scp *scp) { /* Disable SCP watchdog */ @@ -717,6 +752,21 @@ static int scp_probe(struct platform_device *pdev) goto free_rproc; } scp->sram_size = resource_size(res); + scp->sram_phys = res->start; + + /* l1tcm is an optional memory region */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm"); + scp->l1tcm_base = devm_ioremap_resource(dev, res); + if (IS_ERR((__force void *)scp->l1tcm_base)) { + ret = PTR_ERR((__force void *)scp->l1tcm_base); + if (ret != -EINVAL) { + dev_err(dev, "Failed to map l1tcm memory\n"); + goto free_rproc; + } + } else { + scp->l1tcm_size = resource_size(res); + scp->l1tcm_phys = res->start; + } mutex_init(&scp->send_lock); for (i = 0; i < SCP_IPI_MAX; i++) @@ -805,6 +855,7 @@ static const struct mtk_scp_of_data mt8183_of_data = { .scp_reset_assert = mt8183_scp_reset_assert, .scp_reset_deassert = mt8183_scp_reset_deassert, .scp_stop = mt8183_scp_stop, + .scp_da_to_va = mt8183_scp_da_to_va, .host_to_scp_reg = MT8183_HOST_TO_SCP, .host_to_scp_int_bit = MT8183_HOST_IPC_INT_BIT, .ipi_buf_offset = 0x7bdb0, @@ -816,6 +867,7 @@ static const struct mtk_scp_of_data mt8192_of_data = { .scp_reset_assert = mt8192_scp_reset_assert, .scp_reset_deassert = mt8192_scp_reset_deassert, .scp_stop = mt8192_scp_stop, + .scp_da_to_va = mt8192_scp_da_to_va, .host_to_scp_reg = MT8192_GIPC_IN_SET, .host_to_scp_int_bit = MT8192_HOST_IPC_INT_BIT, };