Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp549537rwl; Fri, 4 Nov 2022 03:41:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nnajJVBs5C5op1UPIdp6syqDzNhryBYTTWfxjYvDmcvkgF5hPgxa3EimZycEl0wmVy6jq X-Received: by 2002:a17:90b:1a81:b0:213:f71d:4895 with SMTP id ng1-20020a17090b1a8100b00213f71d4895mr23454467pjb.213.1667558471194; Fri, 04 Nov 2022 03:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667558471; cv=none; d=google.com; s=arc-20160816; b=koHUK4Ia81J8pUtnjadU0ls2q+nmeu/jTbTEBTvr/DPbQSh1WSeJaog2w1iidi0Sti hkJX/5blVgzyypYJ0lKT5Ks9daHaZNJxBdScKIfr5oytaPPPUqJNpoWUmqrsyD9F86u8 XN/tkKqHWEmFujfy5Yug2sd2HC/tjdFJCDYdMIuSfBeHSMdrOGm1gZE/rbf+YwZ8CBJ8 +eDLbj/HA9Hg5sg+e1qsD+R676GkscdAXrGqrEF+Oet3QRHxZUs8GYi9e2wFXdhTqHRL z9WEtU0cqsx+/4cmhISW8Cap3f2jjrZXwOiaPitNogsRzjee/b2RFuxhOlRVhAu3coOa pq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dz2mheJDfObycJwcc1Bk8TmgsLqq6x+ImrkrFILsGBU=; b=YauDYyMnWPECIszbzaYUX92Mmy82B5N4RqoEizeR6F2CVlM2drLBmcWABO9Z6Vz6Cc VODs7dwoXTShUzFfOpWN/fdQOtZl/QPBijOg4MZ9LbPEyvCYGusO9g13WVnm0n87Nok/ lIG71nf6J/uFdUdks5T2pBfg8/8f+JqI3+Zyc6+3lvXiojyvcwMiccvrhZ9o26fCxAbk XykgKQaPswpwSeHm2FLdDifqyp8oyiaCFuLAZTwnNtMLgN9jImiJpa/a3Rh6flOxrZw7 4FLdU+0f4MdGqFLPvqoWdfyOGkD/xfjitbozO+GE3PINLdxcOicVJOIUSNzACtf9ojDe j0BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=AHytPh7q; 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 s142-20020a632c94000000b0046afed15623si3940515pgs.372.2022.11.04.03.40.58; Fri, 04 Nov 2022 03:41:11 -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=AHytPh7q; 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 S231208AbiKDJwQ (ORCPT + 97 others); Fri, 4 Nov 2022 05:52:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbiKDJwK (ORCPT ); Fri, 4 Nov 2022 05:52:10 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A47FA2A94F; Fri, 4 Nov 2022 02:52:08 -0700 (PDT) X-UUID: 6f2bf9b93c7444cbae37ef907697346a-20221104 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=dz2mheJDfObycJwcc1Bk8TmgsLqq6x+ImrkrFILsGBU=; b=AHytPh7qCdRrYOyxIW+NiPo+YLlIXAW+is7DYFWgkuq8D//f3TNFYf4pqpntIkOQF4RCzLOBrFn7pTfjWzv8aRGxO+U0WAY0wmMzcp5TUCMZQHxsJOZj0TYBProAMWm3euvLK61yogvkom7qeUUkus1zuvGh4ZZ+5MngvgrKmSc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:36d67164-c8b0-4591-b30c-971df89928f7,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:62cd327,CLOUDID:2dd372eb-84ac-4628-a416-bc50d5503da6,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 6f2bf9b93c7444cbae37ef907697346a-20221104 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1242091507; Fri, 04 Nov 2022 17:52:02 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) 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.792.15; Fri, 4 Nov 2022 17:52:01 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 4 Nov 2022 17:52:00 +0800 From: Mengqi Zhang To: , , , , , CC: , , , , , , Mengqi Zhang Subject: [PATCH v2 1/2] mmc: mtk-sd: add Inline Crypto Engine clock control Date: Fri, 4 Nov 2022 17:51:13 +0800 Message-ID: <20221104095112.27348-2-mengqi.zhang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104095112.27348-1-mengqi.zhang@mediatek.com> References: <20221104095112.27348-1-mengqi.zhang@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY 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 Add crypto clock control and ungate it before CQHCI init. Signed-off-by: Mengqi Zhang Reviewed-by: AngeloGioacchino Del Regno --- drivers/mmc/host/mtk-sd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 3f7f3a1e0df8..652a67f9b054 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -452,6 +452,7 @@ struct msdc_host { struct clk *bus_clk; /* bus clock which used to access register */ struct clk *src_clk_cg; /* msdc source clock control gate */ struct clk *sys_clk_cg; /* msdc subsys clock control gate */ + struct clk *crypto_clk; /* msdc crypto clock control gate */ struct clk_bulk_data bulk_clks[MSDC_NR_CLOCKS]; u32 mclk; /* mmc subsystem clock frequency */ u32 src_clk_freq; /* source clock frequency */ @@ -840,6 +841,7 @@ static void msdc_set_busy_timeout(struct msdc_host *host, u64 ns, u64 clks) static void msdc_gate_clock(struct msdc_host *host) { clk_bulk_disable_unprepare(MSDC_NR_CLOCKS, host->bulk_clks); + clk_disable_unprepare(host->crypto_clk); clk_disable_unprepare(host->src_clk_cg); clk_disable_unprepare(host->src_clk); clk_disable_unprepare(host->bus_clk); @@ -855,6 +857,7 @@ static int msdc_ungate_clock(struct msdc_host *host) clk_prepare_enable(host->bus_clk); clk_prepare_enable(host->src_clk); clk_prepare_enable(host->src_clk_cg); + clk_prepare_enable(host->crypto_clk); ret = clk_bulk_prepare_enable(MSDC_NR_CLOCKS, host->bulk_clks); if (ret) { dev_err(host->dev, "Cannot enable pclk/axi/ahb clock gates\n"); @@ -2672,6 +2675,15 @@ static int msdc_drv_probe(struct platform_device *pdev) goto host_free; } + /* only eMMC has crypto property */ + if (!(mmc->caps2 & MMC_CAP2_NO_MMC)) { + host->crypto_clk = devm_clk_get_optional(&pdev->dev, "crypto"); + if (IS_ERR(host->crypto_clk)) + host->crypto_clk = NULL; + else + mmc->caps2 |= MMC_CAP2_CRYPTO; + } + host->irq = platform_get_irq(pdev, 0); if (host->irq < 0) { ret = -EINVAL; -- 2.25.1