Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp1071289pxt; Fri, 6 Aug 2021 23:33:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4ZwMsmCjmwQUGD8usPCsoq8aR/SDli4ZV148cZ0j2bxCgjZv9NGUpuZZNJ+rZB/4J+yuY X-Received: by 2002:a92:d1cf:: with SMTP id u15mr139523ilg.81.1628318003933; Fri, 06 Aug 2021 23:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628318003; cv=none; d=google.com; s=arc-20160816; b=iyQcXOXQfgGtv5Ax7YU0cafszxARcX4Mg17afAZEnlwPquv6LHGO8exiBskyBbEpcO DBolTk9sxy8NMP2aZK7oQn7jQ2w83JHbhlJTO0ctgxz44CJDRyzSSuqenAOwxfhw91iF HZTy0bp/kcAg8cYuzZO0Ij4GIzhZfWlwJ65W5pYHcJ+S59BTBIF64NyQF+B6WdVSPQcj +jkJlloovMx8MEquyU83IE0yTrPVoNg/2dQ07HDDP6lGHZfQqf+YatkljOSthAKDp6fg R7Kcwd51uQoLNwEHcB/a8Jg9SQzu5o0P9v7rbpzWl9ScxBn/QumUI4VVq1wMye63sjMb +Amg== 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; bh=P54ctfbGoBh5ux4NClP63TH2NnntZ9ZYQhBBtF0Cc7U=; b=DSrKJBdhvmcwYZhG6ZnsY1SJqHXPzwuE4jKbf2K3nk2kMLnrBMdaa4JYk5pQAaghn+ MZY0hkS1H7waL3zO/Fo2VvcLAGpDgbuqrHy1B+SbQ9NPXHGzuqWASyav94zxG/kp+Coy OrmuoWSsCY4i/Ds8NzNleNqMQAgzy+VEPpyf5yNIUvTK2oA846QuAS+qC680AaUABLkX 8HMTOaJXL/oFeHMt9js4yaupUXZnUJlNXTsWkuyx6MGjbR/Wwf1V6Btj3ks1OvxluIRj g77F90xAzIK/H1aerJzKoGXkQ9gJEBatnquTTGka97h78BaJEXYwREnuC4NZGxFpxTLl wX0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si3750296jao.99.2021.08.06.23.33.12; Fri, 06 Aug 2021 23:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhHGGdO (ORCPT + 99 others); Sat, 7 Aug 2021 02:33:14 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:13293 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbhHGGdO (ORCPT ); Sat, 7 Aug 2021 02:33:14 -0400 Received: from dggeme768-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GhXTX6Rhvz7ydp; Sat, 7 Aug 2021 14:28:00 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggeme768-chm.china.huawei.com (10.3.19.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sat, 7 Aug 2021 14:32:54 +0800 From: Weili Qian To: , CC: , , , , Weili Qian Subject: [PATCH 1/3] crypto: hisilicon - enable zip device clock gating Date: Sat, 7 Aug 2021 14:29:09 +0800 Message-ID: <1628317751-3396-2-git-send-email-qianweili@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1628317751-3396-1-git-send-email-qianweili@huawei.com> References: <1628317751-3396-1-git-send-email-qianweili@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme768-chm.china.huawei.com (10.3.19.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Kunpeng930 zip device supports dynamic clock gating. When executing tasks, the algorithm core is opened, and when idle, the algorithm core is closed. This patch enables zip dynamic clock gating by writing hardware registers. Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/zip/zip_main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index f8482ce..d1ca474 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -107,6 +107,14 @@ #define HZIP_DELAY_1_US 1 #define HZIP_POLL_TIMEOUT_US 1000 +/* clock gating */ +#define HZIP_PEH_CFG_AUTO_GATE 0x3011A8 +#define HZIP_PEH_CFG_AUTO_GATE_EN BIT(0) +#define HZIP_CORE_GATED_EN GENMASK(15, 8) +#define HZIP_CORE_GATED_OOO_EN BIT(29) +#define HZIP_CLOCK_GATED_EN (HZIP_CORE_GATED_EN | \ + HZIP_CORE_GATED_OOO_EN) + static const char hisi_zip_name[] = "hisi_zip"; static struct dentry *hzip_debugfs_root; @@ -312,6 +320,22 @@ static void hisi_zip_close_sva_prefetch(struct hisi_qm *qm) pci_err(qm->pdev, "failed to close sva prefetch\n"); } +static void hisi_zip_enable_clock_gate(struct hisi_qm *qm) +{ + u32 val; + + if (qm->ver < QM_HW_V3) + return; + + val = readl(qm->io_base + HZIP_CLOCK_GATE_CTRL); + val |= HZIP_CLOCK_GATED_EN; + writel(val, qm->io_base + HZIP_CLOCK_GATE_CTRL); + + val = readl(qm->io_base + HZIP_PEH_CFG_AUTO_GATE); + val |= HZIP_PEH_CFG_AUTO_GATE_EN; + writel(val, qm->io_base + HZIP_PEH_CFG_AUTO_GATE); +} + static int hisi_zip_set_user_domain_and_cache(struct hisi_qm *qm) { void __iomem *base = qm->io_base; @@ -359,6 +383,8 @@ static int hisi_zip_set_user_domain_and_cache(struct hisi_qm *qm) CQC_CACHE_WB_ENABLE | FIELD_PREP(SQC_CACHE_WB_THRD, 1) | FIELD_PREP(CQC_CACHE_WB_THRD, 1), base + QM_CACHE_CTL); + hisi_zip_enable_clock_gate(qm); + return 0; } -- 2.8.1