From patchwork Thu Sep 15 01:51:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Chien Peter Lin X-Patchwork-Id: 1678100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HqGK3Ic8; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=XudV8FZq; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MSgFV5n8kz1yps for ; Thu, 15 Sep 2022 11:52:44 +1000 (AEST) 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:References:In-Reply-To: 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: List-Owner; bh=3z7PsRfaK8YID1n8EgqpJSwO6GnwLhmu1t7wbXbOuow=; b=HqGK3Ic8zBpF+b 9iw4qRM/SayLBqPEnnpt8vrQlN7dzfNSSM5xDRUhgqrdlwHoW8gY8E0E7S0tYsIjmJwNzQh/xwXr+ a//wacwzTvgBukEclfkaCpHQr/J6VKP6pyUbU2faVa3YgMh52l+wMBzf4hd32wYjiVkC0KS69Lgkk 0Gz4rRbpmYRenSGOFYyHB9FywRjFoWUGSld/FNaGyUwWT/1+57OYvMbvYes2vzbvygjhuHf8C8AnT hyoM2qKxTW66sg7IQCEuawp9bQyRIQoIUtXCW/2LqZcvZ/TcxABG3X7nm4hcvzpNOTiyS/0nmORNb eHDxxOhxPlqpzSaiOj4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYe3H-00Eb8i-B5; Thu, 15 Sep 2022 01:52:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYe3F-00Eb7N-7h for opensbi@bombadil.infradead.org; Thu, 15 Sep 2022 01:52:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=kqhWaaH1+8M7YUen7X3OpINxpU5irEjcAQg4FzfVPVc=; b=XudV8FZqh7fRYsb5a3fE9PwsYC AUHryYAhQiTRzFZV+/2YJxE5qMhkn4X/f/DXpDHuQMSc4eXJKD5D68wW1OHH9Ko9402sDV4F7lhoD TmIq1IjtYh4FnKfKtfOQoom+AqsIzyDMp+sd7CpT5PQk01GZQYopzHqAGwtmjMvE082INpwYmgfKl VIzXaqHOH2jW438C/CARv6YM2r4fEjUkJD9GHZLZEJApHR+v1iNolvZ5MHQ1jc5h7u/EYNvGZL1Rq m99NvC+aO128nYo66abTJ+jcgimppo7NWmaJy6qlRgjaCgZi7UIwno0m45DHHXeXj6tMaz99Wru6g 5UwRN0Xw==; Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYe39-000g8V-PY for opensbi@lists.infradead.org; Thu, 15 Sep 2022 01:52:25 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 28F1pr0V077114 for ; Thu, 15 Sep 2022 09:51:53 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from atcfdc88.andestech.com (10.0.15.120) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Thu, 15 Sep 2022 09:51:49 +0800 From: Yu Chien Peter Lin To: CC: , , , Yu Chien Peter Lin Subject: [PATCH 05/12] lib: utils/timer: Add PLMT mmio region to root domain Date: Thu, 15 Sep 2022 09:51:14 +0800 Message-ID: <20220915015121.27596-6-peterlin@andestech.com> X-Mailer: git-send-email 2.34.1.390.g2ae0a9cb82 In-Reply-To: <20220915015121.27596-1-peterlin@andestech.com> References: <20220915015121.27596-1-peterlin@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.120] X-DNSRBL: X-MAIL: Atcsqr.andestech.com 28F1pr0V077114 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220915_025222_148033_76A3A4EF X-CRM114-Status: GOOD ( 10.13 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.6 on casper.infradead.org summary: Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 TVD_RCVD_IP Message was received from an IP address 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add PLMT as mmio memregion in root domain at boot-time. Signed-off-by: Yu Chien Peter Lin Reviewed-by: Leo Yu-Chi Liang --- lib/utils/timer/fdt_timer_plmt.c | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/utils/timer/fdt_timer_plmt.c b/lib/utils/timer/fdt_timer_plmt.c index a509c05..46298bf 100644 --- a/lib/utils/timer/fdt_timer_plmt.c +++ b/lib/utils/timer/fdt_timer_plmt.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,36 @@ static int plmt_warm_timer_init(void) return 0; } +static int andes_plmt_add_regions(unsigned long addr, unsigned long size) +{ +#define PLMT_ADD_REGION_ALIGN 0x1000 + int rc; + unsigned long pos, end, region_size; + struct sbi_domain_memregion reg; + + pos = addr; + end = addr + size; + while (pos < end) { + if (pos & (PLMT_ADD_REGION_ALIGN - 1)) + region_size = 1UL << sbi_ffs(pos); + else + region_size = ((end - pos) < PLMT_ADD_REGION_ALIGN) + ? (end - pos) + : PLMT_ADD_REGION_ALIGN; + + sbi_domain_memregion_init(pos, region_size, + SBI_DOMAIN_MEMREGION_MMIO | + SBI_DOMAIN_MEMREGION_READABLE, + ®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + pos += region_size; + } + + return 0; +} + static int plmt_cold_timer_init(void *fdt, int nodeoff, const struct fdt_match *match) { @@ -53,6 +84,11 @@ static int plmt_cold_timer_init(void *fdt, int nodeoff, plmt_timer.timer_freq = freq; + /* Add PLMT region to the root domain */ + rc = andes_plmt_add_regions(plmt_base, plmt.size); + if (rc) + return rc; + sbi_timer_set_device(&plmt_timer); return 0;