Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp353834rwd; Wed, 7 Jun 2023 00:26:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NYM8eY705qpA+cbBtHt74VWMpsMkBVv0sDcIesBve62QaJ+xHUVF4DDoW+fgOwBqvrCtM X-Received: by 2002:a05:6a00:178b:b0:650:1a64:d8d3 with SMTP id s11-20020a056a00178b00b006501a64d8d3mr5752020pfg.14.1686122809432; Wed, 07 Jun 2023 00:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686122809; cv=none; d=google.com; s=arc-20160816; b=CaT7k1DYSrJKdoY+TxqAGJ7FYTQyhOVPVgg4X3oOxhwfUDB2jY+ZU+plJ2y3f6LZRb 0I7TD2jPrFYlHazZTXktgKoaRDYD8QZposTY35H4ATRsGZV6zt/C57qGF2XHdtYcjkSY olrG+jahQjbIj+k01RrgVWNspzfh6kK+Cu7axMzidKm/njXcj/Saqmy6u9jQ72DlOz9t wLJ6kILQTe07umKEVo75pgY9zvhCsKCGaooXPN5NKXueoq9/4IO0insyIQR381DHs5RH A/l333Gc6JkvTFFkWoUX4ADSPnR+nyYxEnsRfL8n1fiXSkuWYS5279FS7YojLkmigA85 qEYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QXn8SvH2/w9lO1bbMXJFemS5MdtvWe7KC3lTPxKRpm0=; b=SU3Qox9OYMrU4po1dM/yLREiv80o/t1GSfRoTNr+3uF5J3pUNAqvQUWlkuMsMhfnjP Y8wjE/hCqgA+dlSLtyHkSEbSejb7U8/bug7ABv6nIbXrEHibGLjTzDAl1l4uUYhxjy2H 5zgOfAAajbvZwqwZLAX3XkOB2sTFxne4uQosGwNtM4WI4+t9poZPtDE/gIaQPggiqPb8 pi0TVhVnokobvX3zCTHw/VyJ7a/vIf8/ZfM7/0tn8NqlJGQK0OlK7+zfpPn/JH+awyRw YIEOL1zdipGFrkSmjkdUqdHLngv2xzOiLNuyn1Y59QGBdw1lKJjK+9PBzo5Kr8ahPp0j cU/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=k5ZFjO1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u76-20020a62794f000000b0066106e1980esi1802043pfc.63.2023.06.07.00.26.36; Wed, 07 Jun 2023 00:26:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=k5ZFjO1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238971AbjFGHXB (ORCPT + 99 others); Wed, 7 Jun 2023 03:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238972AbjFGHWg (ORCPT ); Wed, 7 Jun 2023 03:22:36 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 571F11994; Wed, 7 Jun 2023 00:22:34 -0700 (PDT) X-UUID: 0ce70efa050411eeb20a276fd37b9834-20230607 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=QXn8SvH2/w9lO1bbMXJFemS5MdtvWe7KC3lTPxKRpm0=; b=k5ZFjO1AslVffJQhDmVjvt9TLpMQnypjFb++FCf2Pou1jZWWg96oX6tcMrrPBkJdxHu7NYJyRQqFD6vdVhkm4B/YivKG7s4exBX+kR9f7Ed+6fHe1fG8BtiepUywL/2tHraAH/4hL2xmuCRteJQHIZQ1eE9o1xJkSpYyVHzHy6E=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.25,REQID:31e2080e-74b8-47b4-948d-529146f9a1a2,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.25,REQID:31e2080e-74b8-47b4-948d-529146f9a1a2,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:d5b0ae3,CLOUDID:c1544a6e-2f20-4998-991c-3b78627e4938,B ulkID:230607152226UX4GEF1X,BulkQuantity:0,Recheck:0,SF:17|19|48|38|29|28,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 0ce70efa050411eeb20a276fd37b9834-20230607 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1560284541; Wed, 07 Jun 2023 15:22:24 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 7 Jun 2023 15:22:24 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 7 Jun 2023 15:22:24 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v13 08/11] remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset Date: Wed, 7 Jun 2023 15:22:19 +0800 Message-ID: <20230607072222.8628-9-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230607072222.8628-1-tinghan.shen@mediatek.com> References: <20230607072222.8628-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because MT8195 SCP core 0 and core 1 both boot from head of SRAM and have the same viewpoint of SRAM, SCP has a "core 1 SRAM offset" configuration to control the access destination of SCP core 1 to boot core 1 from different SRAM location. The "core 1 SRAM offset" configuration is composed by a range and an offset. It works like a simple memory mapped mechanism. When SCP core 1 accesses a SRAM address located in the range, the SCP bus adds the configured offset to the address to shift the physical destination address on SCP SRAM. This shifting is transparent to the software running on SCP core 1. Signed-off-by: Tinghan Shen Reviewed-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_common.h | 7 +++++++ drivers/remoteproc/mtk_scp.c | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 0bfd242c41cc..2806bd71ef94 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -65,6 +65,13 @@ #define MT8195_CORE1_MEM_ATT_PREDEF 0x20008 #define MT8195_CORE1_WDT_CFG 0x20034 +#define MT8195_SEC_CTRL 0x85000 +#define MT8195_CORE_OFFSET_ENABLE_D BIT(13) +#define MT8195_CORE_OFFSET_ENABLE_I BIT(12) +#define MT8195_L2TCM_OFFSET_RANGE_0_LOW 0x850b0 +#define MT8195_L2TCM_OFFSET_RANGE_0_HIGH 0x850b4 +#define MT8195_L2TCM_OFFSET 0x850d0 + #define SCP_FW_VER_LEN 32 #define SCP_SHARE_BUFFER_SIZE 288 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index edbf71f4c21e..82bba6146d23 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -498,6 +498,9 @@ static int mt8195_scp_before_load(struct mtk_scp *scp) static int mt8195_scp_c1_before_load(struct mtk_scp *scp) { + u32 sec_ctrl; + struct mtk_scp *scp_c0; + scp_sram_power_on(scp->reg_base + MT8195_CPU1_SRAM_PD, 0); /* hold SCP in reset while loading FW. */ @@ -506,6 +509,30 @@ static int mt8195_scp_c1_before_load(struct mtk_scp *scp) /* enable MPU for all memory regions */ writel(0xff, scp->reg_base + MT8195_CORE1_MEM_ATT_PREDEF); + /* + * The L2TCM_OFFSET_RANGE and L2TCM_OFFSET shift the destination address + * on SRAM when SCP core 1 accesses SRAM. + * + * This configuration solves booting the SCP core 0 and core 1 from + * different SRAM address because core 0 and core 1 both boot from + * the head of SRAM by default. this must be configured before boot SCP core 1. + * + * The value of L2TCM_OFFSET_RANGE is from the viewpoint of SCP core 1. + * When SCP core 1 issues address within the range (L2TCM_OFFSET_RANGE), + * the address will be added with a fixed offset (L2TCM_OFFSET) on the bus. + * The shift action is tranparent to software. + */ + writel(0, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_LOW); + writel(scp->sram_size, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_HIGH); + + scp_c0 = list_first_entry(scp->cluster, struct mtk_scp, elem); + writel(scp->sram_phys - scp_c0->sram_phys, scp->reg_base + MT8195_L2TCM_OFFSET); + + /* enable SRAM offset when fetching instruction and data */ + sec_ctrl = readl(scp->reg_base + MT8195_SEC_CTRL); + sec_ctrl |= MT8195_CORE_OFFSET_ENABLE_I | MT8195_CORE_OFFSET_ENABLE_D; + writel(sec_ctrl, scp->reg_base + MT8195_SEC_CTRL); + return 0; } -- 2.18.0