Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5025833pxv; Wed, 28 Jul 2021 01:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrdFjtufvJ4Vrl9jaE4dNC6+HfeTFUG/+lI8VOy0D3mFf7NtIjYJpyrAenXCxPeydF7uh7 X-Received: by 2002:a02:cf15:: with SMTP id q21mr25324881jar.119.1627459224299; Wed, 28 Jul 2021 01:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627459224; cv=none; d=google.com; s=arc-20160816; b=1D1wqq30f3CmoVLi7RZf9Ft/vwl9Tm6GA3Cf7ccBHrwY+uCWu5zS/Ua/psUg6ghYPW IjuwPqdSiXc4ttGfomQwi57wUhnyhMJ1fhkLG6G8/Y/KKB1xRmoPdHIT6syy5YUW/LI1 PefSlVhdN5DTswUY4xfJMLFsjvrb9AQo4VrPAerwveDL6lH/9841RfwCucbmtI9dKG5R Ve2le/92WulTdhrPnpqKK5hhA4OmugxpBmPvhwSo8RMMGqAR3ilLmsaR4lhl8SHKWYEQ se+zmifUCDlhe7yOBFwA9aCU/PANc4yipK3rSGpL7Tfw9q42t/KqwaMLM56YMgO3S6CN 422g== 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=+zs5zmsP/mAY6zhtek3s3Sqb/YRpJZWfvbrd1uWvsuI=; b=N0x6vfb7l+F8xOgyCutoXW6CoIvOrWhmplNEUv8E3w1drIjrCGUQbo1hzmxn6bLMYY FXoiJs0mfO3f2EuRbV40G6Yev1DXg5p0Ul7ZoDsUQq9qI3IXdjr/S7Vgla63jXQVxQY5 PUUJ1OTZ/aGP3PAYLyTIMkoCc6DCbK9+dBCvukFSF5ysQjqeT5EimU/KXC/IlH74XQY0 6PdWBbW89Jyclk03ajctQ1WnPqselB/WO54A1n9M+H2TTbX3IkG0Og+Pk12OwaYajfHe UJgE2SnQ6LAOT8AdWmoVkAOS+sh1qvOH5zm31zLASc1/lBzeVjVB7S5/fala7fr5sCqJ z0WQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si6388037jat.98.2021.07.28.01.00.13; Wed, 28 Jul 2021 01:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235190AbhG1H7V (ORCPT + 99 others); Wed, 28 Jul 2021 03:59:21 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:38248 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235007AbhG1H7O (ORCPT ); Wed, 28 Jul 2021 03:59:14 -0400 X-UUID: 39d2ffd073da434c8c06c7e04c9a09a9-20210728 X-UUID: 39d2ffd073da434c8c06c7e04c9a09a9-20210728 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 150082954; Wed, 28 Jul 2021 15:59:10 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Jul 2021 15:59:08 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 28 Jul 2021 15:59:07 +0800 From: Chunfeng Yun To: Vinod Koul , Rob Herring , Chun-Kuang Hu CC: Chunfeng Yun , Kishon Vijay Abraham I , Philipp Zabel , Matthias Brugger , , , , , , , Eddie Hung Subject: [PATCH 6/9] phy: phy-mtk-ufs: use clock bulk to get clocks Date: Wed, 28 Jul 2021 15:58:28 +0800 Message-ID: <1627459111-2907-6-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1627459111-2907-1-git-send-email-chunfeng.yun@mediatek.com> References: <1627459111-2907-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use clock bulk helpers to get/enable/disable clocks Signed-off-by: Chunfeng Yun --- drivers/phy/mediatek/phy-mtk-ufs.c | 44 ++++++++---------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-ufs.c b/drivers/phy/mediatek/phy-mtk-ufs.c index 769b00b038d8..a6af06941203 100644 --- a/drivers/phy/mediatek/phy-mtk-ufs.c +++ b/drivers/phy/mediatek/phy-mtk-ufs.c @@ -31,11 +31,12 @@ #define FRC_CDR_ISO_EN BIT(19) #define CDR_ISO_EN BIT(20) +#define UFSPHY_CLKS_CNT 2 + struct ufs_mtk_phy { struct device *dev; void __iomem *mmio; - struct clk *mp_clk; - struct clk *unipro_clk; + struct clk_bulk_data clks[UFSPHY_CLKS_CNT]; }; static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg) @@ -74,20 +75,11 @@ static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy) static int ufs_mtk_phy_clk_init(struct ufs_mtk_phy *phy) { struct device *dev = phy->dev; + struct clk_bulk_data *clks = phy->clks; - phy->unipro_clk = devm_clk_get(dev, "unipro"); - if (IS_ERR(phy->unipro_clk)) { - dev_err(dev, "failed to get clock: unipro"); - return PTR_ERR(phy->unipro_clk); - } - - phy->mp_clk = devm_clk_get(dev, "mp"); - if (IS_ERR(phy->mp_clk)) { - dev_err(dev, "failed to get clock: mp"); - return PTR_ERR(phy->mp_clk); - } - - return 0; + clks[0].id = "unipro"; + clks[1].id = "mp"; + return devm_clk_bulk_get(dev, UFSPHY_CLKS_CNT, clks); } static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy) @@ -150,26 +142,13 @@ static int ufs_mtk_phy_power_on(struct phy *generic_phy) struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy); int ret; - ret = clk_prepare_enable(phy->unipro_clk); - if (ret) { - dev_err(phy->dev, "unipro_clk enable failed %d\n", ret); - goto out; - } - - ret = clk_prepare_enable(phy->mp_clk); - if (ret) { - dev_err(phy->dev, "mp_clk enable failed %d\n", ret); - goto out_unprepare_unipro_clk; - } + ret = clk_bulk_prepare_enable(UFSPHY_CLKS_CNT, phy->clks); + if (ret) + return ret; ufs_mtk_phy_set_active(phy); return 0; - -out_unprepare_unipro_clk: - clk_disable_unprepare(phy->unipro_clk); -out: - return ret; } static int ufs_mtk_phy_power_off(struct phy *generic_phy) @@ -178,8 +157,7 @@ static int ufs_mtk_phy_power_off(struct phy *generic_phy) ufs_mtk_phy_set_deep_hibern(phy); - clk_disable_unprepare(phy->unipro_clk); - clk_disable_unprepare(phy->mp_clk); + clk_bulk_disable_unprepare(UFSPHY_CLKS_CNT, phy->clks); return 0; } -- 2.18.0