Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1133731iog; Wed, 15 Jun 2022 22:40:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uerqJ8MLvFf/ZElVjqQ9thYmfIUw/1MW170NdRWxMfwu9Dp5G7GVh3TQ/8TcZBuFwrDjS6 X-Received: by 2002:a05:6402:1449:b0:42d:d250:e504 with SMTP id d9-20020a056402144900b0042dd250e504mr4197786edx.213.1655358027988; Wed, 15 Jun 2022 22:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655358027; cv=none; d=google.com; s=arc-20160816; b=Pi9SWi2s7obsYMIG23URF7SZaVZ7BY4olvD8+Bcg1wbpcPgMg3vYniDzCr/lKKVW79 RlTsUSdEtQeCYWAriPWUHDcP4+JgwJxMEGvjx8Ks3aBJ3Zg89F6N1VnvMLTCL7RR861O hfkf0ZYGxOduMQznawBgVNZD3M8JngXhKQJ1n2ReRSrapv3vXwe4NWWKnxb1IX2AMxE0 NRAi+I6qWa1Hy8SWHccBJjRQiH+rL3RPs4qF+4lqfLQNSVLCBFjVW8Q7aJQIic11iz/f pxes5Qw2bBbAR79IP22uXQPlBILaiY62u0UpIzGm3GM5V3KnEkw+2r1+maDNZ2FcmdCY WYGA== 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=5GXfKgVuNyhmjHMEfvKoaGdY0aR3sKb+D1widOPyp4E=; b=wiaWME9ScmXN7myDMqK3ZHYYjMWW+Q2jwZ4jPLf/AI/m4ZbC026Gd5fNWX02hFH0n5 W4VcQHItMRYDe4pkNgIKgUt9OPn4vUJb6yxis9/JwBnV9H3ArBLHg8dIlqw4pRxAf9a+ ElakynFRwp3lmEWFt0F1+otWpsuxjldlDtZuhkkq1FTQkO1PZ5zplB8m7ra7T89wrpQw t18AcGWSYzTlCC2961mALIqmUsok2zywyiV3f5zzmjfJ0RsHN5qF6fbPbSp1Jxy0H1di AoMpHyjmhhoUuew0pqVBSmNv0imnObKsWjA4unOTFAnJrqx7AQMAN4yl4BIT7nAl0Lvz Hhtg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 e12-20020a170906748c00b00711c8445670si800928ejl.277.2022.06.15.22.40.00; Wed, 15 Jun 2022 22:40:27 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358760AbiFPFht (ORCPT + 99 others); Thu, 16 Jun 2022 01:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358700AbiFPFhl (ORCPT ); Thu, 16 Jun 2022 01:37:41 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8CA205E3; Wed, 15 Jun 2022 22:37:37 -0700 (PDT) X-UUID: be1527b3f93c4ad897e44f80291c87b6-20220616 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:85a9e3c0-f0cc-4eac-affb-6ba2354a46fd,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:b14ad71,CLOUDID:c15b6ff6-e099-41ba-a32c-13b8bfe63214,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: be1527b3f93c4ad897e44f80291c87b6-20220616 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1953433498; Thu, 16 Jun 2022 13:37:29 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Thu, 16 Jun 2022 13:37:27 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Jun 2022 13:37:27 +0800 From: Stanley Chu To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v5 11/11] scsi: ufs-mediatek: Disable unused VCCQx power rails Date: Thu, 16 Jun 2022 13:37:25 +0800 Message-ID: <20220616053725.5681-12-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220616053725.5681-1-stanley.chu@mediatek.com> References: <20220616053725.5681-1-stanley.chu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 Some MediaTek UFS platforms support different VCCQx power rails, for example, both 1.2v and 1.8v VCCQx, in a single kernel image. To optimize the system power consumption, provide a way to disable and release the unused power rail during the device probing. Signed-off-by: Stanley Chu --- drivers/ufs/host/ufs-mediatek.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 34e51c094366..bfe04a4d1dce 100755 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -712,6 +712,29 @@ static int ufs_mtk_vreg_fix_vcc(struct ufs_hba *hba) return err; } +static void ufs_mtk_vreg_fix_vccqx(struct ufs_hba *hba) +{ + struct ufs_vreg_info *info = &hba->vreg_info; + struct ufs_vreg **vreg_on, **vreg_off; + + if (hba->dev_info.wspecversion >= 0x0300) { + vreg_on = &info->vccq; + vreg_off = &info->vccq2; + } else { + vreg_on = &info->vccq2; + vreg_off = &info->vccq; + } + + if (*vreg_on) + (*vreg_on)->always_on = true; + + if (*vreg_off) { + regulator_disable((*vreg_off)->reg); + devm_kfree(hba->dev, (*vreg_off)->name); + devm_kfree(hba->dev, *vreg_off); + } +} + /** * ufs_mtk_init - find other essential mmio bases * @hba: host controller instance @@ -1241,6 +1264,7 @@ static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *hba) } ufs_mtk_vreg_fix_vcc(hba); + ufs_mtk_vreg_fix_vccqx(hba); } static void ufs_mtk_event_notify(struct ufs_hba *hba, -- 2.18.0