From patchwork Wed Jan 27 08:31:33 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: 12049487 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.1 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 77E25C433E0 for ; Wed, 27 Jan 2021 09:34:35 +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 E536320770 for ; Wed, 27 Jan 2021 09:34:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E536320770 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=pEb1G1rjIap5okzN7DNVLvTyqNjCiLKbN8VAubBj+7s=; b=ONozLPpurdvMrSL46X7L1oxR4 12OSTX/5j6oO7x9+LhBhmR/d7TJ9QmU48Pq8kIgvScLgy3SU0elD1LXlsHBmMO3oBp1da+od1weyl WEiqmImFwhTT5+Je0M1qaya0p76rSW8Er07pVDXqvOWpwNOC7khEKjk89DV2CUq0NP6VHWHSkOFXj FfWjTFsT9TlwCe6o35WTdwxR+vuSvie0FZSdG5pa45SfQopfGzW6EtLbDP4d/i3ZCsVn/fPVworT5 LgZfFbOUagqdL0Y7GiJInqB1N1exxEjIio1oIwBBGQZDwhTWJ2E9MpwaWJDnAUtu7GBiS7wbUm+Iq 5m8r/6bdg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFe-0005o3-1F; Wed, 27 Jan 2021 08:32:34 +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 1l4gFc-0005mv-Gb for linux-mediatek@lists.infradead.org; Wed, 27 Jan 2021 08:32:33 +0000 Received: by mail-yb1-xb49.google.com with SMTP id y1so1651940ybe.11 for ; Wed, 27 Jan 2021 00:32:30 -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=+a0m3LuKmOdctmWgOFSSQsFlabVB3Kaf/W6pr4iH3tg=; b=awsbucR+8poF69HXjAAN3EvY1WueYbQJgcbdWYLBHw5zJmrUYVPK2tfp5SucTtrahc Cwz9dSeBoa+/nQBuQ7r2Ehxi3f9HFsU7eeGrKIIMjIXHg+48KUfQsOQw1eDn2+bVWJbF z05CejH8BXUin/1Rq/zyCIdFlNu2Fu7O18Q4Ggw3fsGc936oUlMCUW04HFQqfexVWNez KOXE1VI9b9GBLMgl64S0AnRKhFb8bfN4DmoQdgNfTX84ltRkVoVOnF8xRr49qqohahU/ e2Ro5EtxmegUdrjz00giu/FNnGh3uYlLJQlp+Wgir+Jbv4pCuO4bdn5EHak/ZIDwTHB5 dkPQ== 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=+a0m3LuKmOdctmWgOFSSQsFlabVB3Kaf/W6pr4iH3tg=; b=L7OI7ie2VZNA9RbJpxUnCfoV2sU6t7q8vBvTnjR9k7DiXuLxoL1x4KX4op2CxwwPYB aM6CQDBgmlBeNI9w6OsL5gTo3jrMgXVaXd56jRzTcFSMSxnTDK6pm/Xyzgx4GqQ0N81B O4cZ33lBtvFrqyqy4NcFou7WeBOqCI+aifflbSWKM9uHQXC6pP53O6+50c5Q4vC6YXNA UZWFRTwCPKOCx1Ey8dUYOzAUN/vJwyrJoG+PNpPTAawO4s8G0Scjl5NPAb7vemFOKW7m iUN9cDg81TEGSGGmckfJT45Fe0FHPZU25z5ARqNCrZOJPt6Kfv4Ey6PlKQn4Af8QgRef SScA== X-Gm-Message-State: AOAM532zLT7xQokeXmXB/mS610PQZZDkDLqfJNgmDKHjauk58fIqQigF zB25niJMVFPUXT6mrKStMrWnOdbOCwgn X-Google-Smtp-Source: ABdhPJya2SzL3qr8wMjzd6kk7QFftN0tLzBSfhW5Tsa1Ft4O70vVR3PxMz0LDDgj3J5gTNnGfIVoeWnhokM1 X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:d17d:c7bb:69a2:7e2f]) (user=tzungbi job=sendgmr) by 2002:a25:ce08:: with SMTP id x8mr14658300ybe.164.1611736348965; Wed, 27 Jan 2021 00:32:28 -0800 (PST) Date: Wed, 27 Jan 2021 16:31:33 +0800 In-Reply-To: <20210127083136.3745652-1-tzungbi@google.com> Message-Id: <20210127083136.3745652-2-tzungbi@google.com> Mime-Version: 1.0 References: <20210127083136.3745652-1-tzungbi@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v3 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-20210127_033232_634616_706813A4 X-CRM114-Status: GOOD ( 11.01 ) 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); Reviewed-by: Mathieu Poirier 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 eba825b46696..d83e1164f02f 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -721,8 +721,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 Wed Jan 27 08:31:34 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: 12049397 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.1 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 A43ABC433DB for ; Wed, 27 Jan 2021 08:57: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 10F0A20754 for ; Wed, 27 Jan 2021 08:57:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10F0A20754 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=TTc2JfR8f0Wd51nXV9aptz/tWe0xgKIY9yMkqR1Nf2w=; b=WjtxALhwWVRpWg5NF3u20rBjD Ru97WK//LnK7ZFr4mG1KACt2H6JtV7GiAt1Dnpg1ov85DRGrkMN62sYz3tLQ1qkKM2pmU/CMETk3r dvAP/IC501a7mRb+PeqQ+B+KxwLEYkn0CusqO5FcKvsV9Lg4n94/XKovSJl+AkfpdJ8FQfUfGIzyY ZnN/XQHF3IvQd3BcYfzdjWH5U1DoVcCFiWVnCIhfyWaXEuTzGnL+Ocf4uPvwXWwxtpHN+uldZ+0FX LwXE+mApq8xM/5J3Mpd8oLrpcJShKnA4NVhCiXN0PGcVhLlHrN/eT70fpKmXrzt+OtRDYo1+QCFe5 1zg/PwbeA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFh-0005p4-Vv; Wed, 27 Jan 2021 08:32:38 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFg-0005nw-De for linux-mediatek@lists.infradead.org; Wed, 27 Jan 2021 08:32:37 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id k7so1638335ybm.13 for ; Wed, 27 Jan 2021 00:32:34 -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=SmiMh0LR1+qpBQs71pN3MQ5z1dtkmQlW7LOu3fdZxYc=; b=rrXwZ9bm2rsHie+KDd9fWKXYVFbzbfhsHlMQSz9gFMUP3reWooj6uuA2HmrOYrLwiq kYs86koHVLx0gEw+UWH7PoHcVPLY4AOA0dZnCcgev+X/R/bdnfebMQb7DrovteE/wM1T jV98B5EgPoINEulnzdhCIshFSA/EunLfsVSn21Vn6/RACRPvQmFiNU7hJGXsC8BW8/xP rwRXE5q7jG1MgI3J21y5/kpGDvzlBGYhNnaTGKDG5mTNlrX2TJFMJaAtv3/Z1mLrWeMO 6sizgSXNlb/+n/M64KGj3ZPUQ2gJb1DRhbgiYHDPnVciKsjOG3cfs+X2peN5j9PX+X+L g9jQ== 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=SmiMh0LR1+qpBQs71pN3MQ5z1dtkmQlW7LOu3fdZxYc=; b=XXL2wflGCmZUNad/Dl+fSKKK3AJMIWTnqB5gWip7s7nalOo0xbheVwbzA18WwgbXTh YWfIzx7pGv1b/3+EROo5tp0qm6RweiERgP7Zof1rJG4hSf2vX2B38lyZ+gEtBWM86tHM gmUwK5oniUap1wi+kZ1LjBQUHdnZcTkORnsDo24ulN/lx0ptX5gARaFmDu0QsnVN4nk0 Z32Gh1lMC8AVGc44z1rICWImsieQPHwDvNacRx1suYVyswFspKm2bDdvqwQhKkoLgb3t 3Qf6Uii71K3OmaiDj4MkD4OsM3tTAhg18jZRe66FziJDWqBJL5xShss/HYs3UGeZDBwR jWqQ== X-Gm-Message-State: AOAM532Uxf+QYwJKBgJ6BnWDQCShJDwWNxDW4bl66vzWN+I55CXl5W3B hGXuJpW3Z9+b1Yi8txM4YQmRQQtHxIou X-Google-Smtp-Source: ABdhPJyoBFYN8c1zqNrS1+bqbnoMM0Q2Xo7B1whfoExZWSybm5Lh61Rr2MDPRz8tvDy5a2u+4L+Gn8Y+NvHI X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:d17d:c7bb:69a2:7e2f]) (user=tzungbi job=sendgmr) by 2002:a25:b813:: with SMTP id v19mr14700220ybj.178.1611736352922; Wed, 27 Jan 2021 00:32:32 -0800 (PST) Date: Wed, 27 Jan 2021 16:31:34 +0800 In-Reply-To: <20210127083136.3745652-1-tzungbi@google.com> Message-Id: <20210127083136.3745652-3-tzungbi@google.com> Mime-Version: 1.0 References: <20210127083136.3745652-1-tzungbi@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v3 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-20210127_033236_492947_0FFD3962 X-CRM114-Status: GOOD ( 11.96 ) 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 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. Reviewed-by: Mathieu Poirier Signed-off-by: Tzung-Bi Shih --- 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 bcab38511bf3..204691138677 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_IRQ 0x10030 #define MT8192_CORE0_WDT_CFG 0x10034 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index d83e1164f02f..05b157689121 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -371,6 +371,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 Wed Jan 27 08:31: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: 12049325 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.1 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 D1555C433DB for ; Wed, 27 Jan 2021 08:33:03 +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 79FBE20644 for ; Wed, 27 Jan 2021 08:33:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79FBE20644 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=z9ij5mBGeTjLXJ74Sn4z1WYhF1/qoQuOyEYFEIg+zOo=; b=khlsiSYSj4twlkhh0x4k2VfWB iFKhE5/v29dQ/v30XJOmTftIvhE4yjFulv2w0QNCDelKbrIS8x8WepjRrE+JQK6GgQhgrquw1Hv6h vwc4zhSVr42eEO5sL91jkaRTeowZVthk4Fr+x8sP94Gmz1sbvuVO9k7fQU+itltYRqOiqcPL2JmOh kgA2wK2JjACIC//umnTCcXhObjfNNIxTKTHEUe8tpSkMMtFi9xs+wn6e+MghEUYuoo5SNm3QRyNwU GmP+dtuAWGZBpr/KGyHbGmCJ1usyD82gwBZmbRMd0+PHTRrAwmAO/kSDYwI8GCaEuVIt0sfZuQAnt 4lc5iFmzA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFn-0005qJ-Gq; Wed, 27 Jan 2021 08:32:43 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFk-0005oz-Mr for linux-mediatek@lists.infradead.org; Wed, 27 Jan 2021 08:32:41 +0000 Received: by mail-pg1-x549.google.com with SMTP id 18so1053891pgp.22 for ; Wed, 27 Jan 2021 00:32:38 -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=LGZTxpAXqFWtECT4mU7eGwfUfjYEwbaGaOmL3s+WPHY=; b=Mk8UO9d9k5Z55wJIilDYOJbDVrADuEvo1RU1iq6uOFWQ2fpZhKzOBeUq40bTXbRUhW H9Nd9XfdYWaApv8HgACBsOSQIMZ9Q/3vTbecNY/Qps4GTc5lhFlAGQWsX9ovK/wsGDh5 0UWExHtK6vDsOFjf/kVISrSdNxBzzWdmNJmnZmUd5HnK+Ek75aatKN7s4buu1pQ/uCKo TdxneGiJN2fv9e7ZRAi9kYTlCnRSyFrrcjcJNtBR7kUjRwvWFO3mHbo/bMHOMRnk86tx oMIO8+9hrYWPcva2sgwg+r4M/1tpmOF1ANT3UzZ0ZwtgXaNrcJQ1mn2bTF3FO74hBpHO dGmQ== 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=LGZTxpAXqFWtECT4mU7eGwfUfjYEwbaGaOmL3s+WPHY=; b=fWcOYmfk28S9yCpmvdcTLhVpFwqii48x7Kt5V+GDjCgfgzRrIwul2SOP7VVUe3T6pr 0Mj2/jILmrndiwJIKhHtxwEVOyQtCyi1GHq9pVOvrbj+Dz53lj4hAXydJo7A33zt+wHO uCfRE1A31rWqjpRQdxbRjEvP3ZiHOTWdlzqav0OWjPA5ldYBhoafCRwFCYO9FsnjMYsc ZdrP5aC7bR9sisNdMAok6RUzd7ccd4myno+PEKz1yK3FxQ41ATptbMVlDSSXmDEqiwh1 WcvEAvS9CcRGHJRm0iXAKBTVfq/A/twjIXZS31PExyScorh3vPFC7yMw1Sqx552/Z+Xv LR5w== X-Gm-Message-State: AOAM531uywCUAQMI8hNU2YHDMsfQvNyXAPFBW/bfGdyKa9lJCfjNFLBT oGXW766rc1loDLOz2/+Yk213IjtS8wTz X-Google-Smtp-Source: ABdhPJy8uOr6FzvmT069kx+Pz1AfQycAO6RoKVfv9FAjkZesiSjZw9ppOmVHAroDlr7jOix3x2+itbb2+XU4 X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:d17d:c7bb:69a2:7e2f]) (user=tzungbi job=sendgmr) by 2002:a62:ce8b:0:b029:1bc:39bd:13ad with SMTP id y133-20020a62ce8b0000b02901bc39bd13admr9563175pfg.24.1611736356753; Wed, 27 Jan 2021 00:32:36 -0800 (PST) Date: Wed, 27 Jan 2021 16:31:35 +0800 In-Reply-To: <20210127083136.3745652-1-tzungbi@google.com> Message-Id: <20210127083136.3745652-4-tzungbi@google.com> Mime-Version: 1.0 References: <20210127083136.3745652-1-tzungbi@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v3 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-20210127_033240_759921_F67586D3 X-CRM114-Status: UNSURE ( 9.48 ) 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 Reviewed-by: Mathieu Poirier 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 Wed Jan 27 08:31: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: 12049323 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.1 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 AF80FC433DB for ; Wed, 27 Jan 2021 08:32:58 +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 501292073C for ; Wed, 27 Jan 2021 08:32:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 501292073C 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=6/h2QBqzNZjRII9BkKTZIyWSxXOr6bvOkN6wCk5IE1A=; b=1TEuKwRegwHSKzfMKM6z92RJr x6mVr+ydlSuKkbKCQ6IXoBRgJeXdTM5VMp0UEDqwXBgAqBsWXZ1K36NEFlipsxqqNvROpVL/a0iwS KpS2MkGDYuueNFxbUbSEZJpouIY0Dvs1Q7eePCpDJ75XffSfqlTypwSreEZV2GYrp6uuYAhl5mNhs 8U3joYqHtTonc6akVswWr1q7dwgDapkb8reCgUgB8UXx3xdxi9bZOvLqW3R96PV8GYCuV9xNxgM92 5NeHATwWLcZ4j4uenF7O3qnP3Hd5yjmPhgyGYRP1TsE66qe6aK7NnV1FYqodCWPMsPY+kgqeQPjCS V2JUNna5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4gFp-0005r4-Sl; Wed, 27 Jan 2021 08:32:45 +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 1l4gFo-0005ps-C5 for linux-mediatek@lists.infradead.org; Wed, 27 Jan 2021 08:32:45 +0000 Received: by mail-qk1-x749.google.com with SMTP id d194so941760qke.3 for ; Wed, 27 Jan 2021 00:32:41 -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=RaHwNMHy6Q38UiSowCFhrFgySXI51I5XcIPwGHCFzHA=; b=gt9CAJsB4pywidn35l9GS7kegoCleTTUcDZQcAThNVCvSLsL96zDlM02lHQsGfKQ4c nsHoKonjbw5h9LIEPq4EboL2a1/SsfYSAUu/BUE/cwZnBWXda+GTE9VNTxAl1MQ9ztOQ 6gc8/U7UN3d21+aj9xiGZGioe1yftTZmpYLKQN9YWg+z/TRqfPjgCc+2macCjkKVx28A qHAjRc8Qs0f8MmcSNqAu9+fZnYQ5UW0EQT8ibFMEem5CnFSMe5v62wxmy9417Kk0613z 8zigCiHr9ge6GEe+D6moVsmhYHXFMeVM4b0IJnK/ECA6/6A/j6higCoRvB91xZxYNpkB lwgg== 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=RaHwNMHy6Q38UiSowCFhrFgySXI51I5XcIPwGHCFzHA=; b=b7Rr4ZPkAoLApihJiRbloQX9mzNbeeFzxb7qHUjKouUY52xJ9AF89NUG8zrrGIftoB ZAiLfJ7RI9Ik6r3d6nlPkCGXP0stF1eRdDMLNYyZ5e2kB2Cidexg7knjZ2usIFrAuG6L x0Rdey4tBguJnG0axHh9+pJVq77CXaqEUV6xpTwLs1IsbO0ggJdhvL781vYSjOWqBAPa dtD4xgJoWSGeUnmqp3GPVTtzznMyjUVYcZY8nAXYK0vUqTQbcAh2+0pXekaGJx9iTbPp 7ECQn9xna2npDJBUIykst4A6WitrzB0F2zaRgyUmAorEPbgvsQKcpizIxhrKKdv621o+ y6/A== X-Gm-Message-State: AOAM531yYblls1+YH6n1xOscHTKMxXE5At3u9U5L02RrtxNftUuvGgIx N9LSWKPN/eS745EiJnNGNl1jacyFQhMs X-Google-Smtp-Source: ABdhPJxPwHBmIFY24IEnCMNSrpm1zBwNilXq7JcimT+k2/ombKudG+h8PD0tqcATpEqofEfIQ5a7TWoIaljj X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:d17d:c7bb:69a2:7e2f]) (user=tzungbi job=sendgmr) by 2002:ad4:4cd0:: with SMTP id i16mr2727580qvz.49.1611736360511; Wed, 27 Jan 2021 00:32:40 -0800 (PST) Date: Wed, 27 Jan 2021 16:31:36 +0800 In-Reply-To: <20210127083136.3745652-1-tzungbi@google.com> Message-Id: <20210127083136.3745652-5-tzungbi@google.com> Mime-Version: 1.0 References: <20210127083136.3745652-1-tzungbi@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v3 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-20210127_033244_417871_2DB0840E X-CRM114-Status: GOOD ( 17.50 ) 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. Reviewed-by: Mathieu Poirier Signed-off-by: Tzung-Bi Shih --- 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 204691138677..61901f5efa05 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -77,6 +77,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; @@ -91,6 +92,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 05b157689121..ce727598c41c 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -463,9 +463,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) { @@ -481,6 +480,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 */ @@ -719,6 +754,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++) @@ -807,6 +857,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, @@ -818,6 +869,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, };