From patchwork Wed Jan 10 11:01:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shradha Todi X-Patchwork-Id: 761677 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6CE440C12 for ; Wed, 10 Jan 2024 11:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="GorskU85" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240110111718epoutp01e8650208c8f0de638a8bf6fdf9198e69~o_EXtTJ0U1291412914epoutp01b for ; Wed, 10 Jan 2024 11:17:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240110111718epoutp01e8650208c8f0de638a8bf6fdf9198e69~o_EXtTJ0U1291412914epoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1704885438; bh=5oVmRhw2DfUJW61C/c9zwKTKzkdVt14suKM8C/BBVEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GorskU85DYGrPGHrFSSOGGWqYfUVdu/wh2OYQ1kU1UQqP5VSpm3mV/kwdKurLxAuy OjvoiVYG6oe+58PITzAbzi0iAUPanX2EiP2mSIw+9lIiTlBdTcINVVZV0QVwDOiGB/ lnV+n+WmfBW5TLQiPFUfcs/IwgILPUIjwwEbGExA= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240110111717epcas5p183dc719452830456683bf33f66b9b428~o_EWnxG_l3020330203epcas5p19; Wed, 10 Jan 2024 11:17:17 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.177]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4T94yM2zMwz4x9Pp; Wed, 10 Jan 2024 11:17:15 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 62.98.10009.BBC7E956; Wed, 10 Jan 2024 20:17:15 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240110110156epcas5p36bac4093be0fa6eaa501d7eaed4d43d3~o929HlXk90210902109epcas5p33; Wed, 10 Jan 2024 11:01:56 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240110110156epsmtrp25c8f09c24cebfbf0b2aad59d9d9cacab~o929Gty2p2407724077epsmtrp25; Wed, 10 Jan 2024 11:01:56 +0000 (GMT) X-AuditID: b6c32a4a-261fd70000002719-b7-659e7cbba513 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 88.50.18939.4297E956; Wed, 10 Jan 2024 20:01:56 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240110110153epsmtip1c77ed0ded73c66bdf11224772f4a851b~o926taL6P2247622476epsmtip1d; Wed, 10 Jan 2024 11:01:53 +0000 (GMT) From: Shradha Todi To: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: mturquette@baylibre.com, sboyd@kernel.org, jingoohan1@gmail.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, linux@armlinux.org.uk, m.szyprowski@samsung.com, manivannan.sadhasivam@linaro.org, Shradha Todi Subject: [PATCH v3 1/2] clk: Provide managed helper to get and enable bulk clocks Date: Wed, 10 Jan 2024 16:31:14 +0530 Message-Id: <20240110110115.56270-2-shradha.t@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240110110115.56270-1-shradha.t@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNJsWRmVeSWpSXmKPExsWy7bCmhu7umnmpBnMui1g8mLeNzWJJU4bF ii8z2S32vt7KbtHQ85vVYtPja6wWH3vusVpc3jWHzeLsvONsFjPO72OyODR1L6NFy58WFou1 R+6yW9xt6WS1uHjK1eL/nh3sFv+ubWSx6D1c6yDkcfnaRWaP9zda2T12zrrL7rFgU6nHplWd bB53ru1h83hyZTqTx+Yl9R59W1YxenzeJBfAFZVtk5GamJJapJCal5yfkpmXbqvkHRzvHG9q ZmCoa2hpYa6kkJeYm2qr5OIToOuWmQP0kZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jEVim1 ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO2P3hwusBT2yFScuL2NrYPwr3sXIySEhYCLx es47ti5GLg4hgd2MEp92LmaCcD4xSuxcvA3B6Vt0iaWLkQOs5eItGYj4TkaJWT1XGCGcViaJ o8e+sYPMZRPQkmj82sUMkhARWMwocWvHZlYQh1ngBFDV2W2MIFXCAsESnQ1/WUBsFgFViel9 e9hAVvAKWEk0H5aCOFBeYvWGA8wgNqeAtcTqxbPZQeZICGzhkDh2bBETRJGLxKy20ywQtrDE q+Nb2CFsKYnP7/ayQdjpEis3z2CGsHMkvm1eAtVrL3Hgyhyw15gFNCXW79KHCMtKTD21DqyE WYBPovf3E6hyXokd82BsZYkvf/dArZWUmHfsMiuE7SFxZMYzsBeFBPoYJfZ9M5zAKDcLYcMC RsZVjJKpBcW56anFpgVGeanl8FhLzs/dx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MjEwXiIUYKDWUmEV+HznFQh3pTEyqrUovz4 otKc1OJDjNIcLErivMo5nSlCAumJJanZqakFqUUwWSYOTqkGJlNtpQlTHubf+aIudGTxX/uf twozHKecC7J87hwlpK3K5Xxvfan0r3Ncc3f9WGAf92Wl5duW1U/SXh0K3PQnsvpz/OeQzOTC 99v7QtaceH6zzz71XXjDzObvgs/75CKvZpUGnf/C5f3mZ+Ru+V3HJmZ/zNdzDjsi15Fd0Mxw aOknnejNFUfy/m5+xPVsfur6x18br3A5NO09Pv3Jp2c/W4v228xyS+a07wjbfP7KotZnv5TD nRfefb92pQa3arin5PrvQYfqV3qsutIZcYXZinEGo2rqK+ulzoldCTFvjnzUUMw7xlc2XWez T3tOr9DtVzlB0UkiW6OOrL0nK799Dq+Ttb3cWd8fE1qicnol2JRYijMSDbWYi4oTAdwxEfHx AgAA X-CMS-MailID: 20240110110156epcas5p36bac4093be0fa6eaa501d7eaed4d43d3 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240110110156epcas5p36bac4093be0fa6eaa501d7eaed4d43d3 References: <20240110110115.56270-1-shradha.t@samsung.com> Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Provide a managed devm_clk_bulk* wrapper to get and enable all bulk clocks in order to simplify drivers that keeps all clocks enabled for the time of driver operation. Suggested-by: Marek Szyprowski Signed-off-by: Shradha Todi --- drivers/clk/clk-devres.c | 41 ++++++++++++++++++++++++++++++++++++++++ include/linux/clk.h | 25 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 4fb4fd4b06bd..05b0ff4bc1d4 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -102,6 +102,7 @@ EXPORT_SYMBOL_GPL(devm_clk_get_optional_enabled); struct clk_bulk_devres { struct clk_bulk_data *clks; int num_clks; + void (*exit)(int num_clks, const struct clk_bulk_data *clks); }; static void devm_clk_bulk_release(struct device *dev, void *res) @@ -182,6 +183,46 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, } EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all); +static void devm_clk_bulk_release_all_enabled(struct device *dev, void *res) +{ + struct clk_bulk_devres *devres = res; + + if (devres->exit) + devres->exit(devres->num_clks, devres->clks); + + clk_bulk_put_all(devres->num_clks, devres->clks); +} + +int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, + struct clk_bulk_data **clks, int *num_clks) +{ + struct clk_bulk_devres *devres; + int ret; + + devres = devres_alloc(devm_clk_bulk_release_all_enabled, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return -ENOMEM; + + ret = clk_bulk_get_all(dev, &devres->clks); + if (ret > 0) { + *clks = devres->clks; + devres->num_clks = ret; + *num_clks = ret; + devres_add(dev, devres); + } else { + devres_free(devres); + return ret; + } + + ret = clk_bulk_prepare_enable(devres->num_clks, *clks); + if (!ret) + devres->exit = clk_bulk_disable_unprepare; + + return ret; +} +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enabled); + static int devm_clk_match(struct device *dev, void *res, void *data) { struct clk **c = res; diff --git a/include/linux/clk.h b/include/linux/clk.h index 1ef013324237..bf3e9bee5754 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -438,6 +438,24 @@ int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, int __must_check devm_clk_bulk_get_all(struct device *dev, struct clk_bulk_data **clks); +/** + * devm_clk_bulk_get_all_enabled - managed get multiple clk consumers and + * enable all clk + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * @num_clks: out parameter to store the number of clk_bulk_data + * + * Returns success (0) or negative errno. + * + * This helper function allows drivers to get several clk + * consumers and enable all of them in one operation with management. + * The clks will automatically be disabled and freed when the device + * is unbound. + */ + +int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, + struct clk_bulk_data **clks, int *num_clks); + /** * devm_clk_get - lookup and obtain a managed reference to a clock producer. * @dev: device for clock "consumer" @@ -960,6 +978,13 @@ static inline int __must_check devm_clk_bulk_get_all(struct device *dev, return 0; } +static inline int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, + struct clk_bulk_data **clks, int *num_clks) +{ + + return 0; +} + static inline struct clk *devm_get_clk_from_child(struct device *dev, struct device_node *np, const char *con_id) { From patchwork Wed Jan 10 11:01:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shradha Todi X-Patchwork-Id: 762413 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8FEA4779E for ; Wed, 10 Jan 2024 11:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="l4uRLInj" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240110111729epoutp02dadceba40d83e4f254068861e96fd379~o_Eh_sX7q2088020880epoutp02I for ; Wed, 10 Jan 2024 11:17:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240110111729epoutp02dadceba40d83e4f254068861e96fd379~o_Eh_sX7q2088020880epoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1704885449; bh=M1+QsjggvLUaZn03qUqB6f3xooklVjON6VKY3+lVzh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4uRLInjCgN/P2j6C+SrPdyBo5tEeufB+R+VvMx66aSOyFZNRynDU0/ba1Ns6e40X 13ptVW2FgE8586oXgevWybHW2cPa1tk6gNUzECjTB64VpsEkHo2EkvPEaQENh7vaxO 5AjnPV1eKRegKt/87ohIGS77tNlCxJht3a/gRGPo= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240110111727epcas5p3f546c7ee89bc89d8e29ef87297a0c708~o_Eg1YAYW2559725597epcas5p3v; Wed, 10 Jan 2024 11:17:27 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4T94yZ2KzCz4x9Q1; Wed, 10 Jan 2024 11:17:26 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D6.98.10009.6CC7E956; Wed, 10 Jan 2024 20:17:26 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240110110209epcas5p3130d90db3c4ebd19ff09f2f3c37958f4~o93JTPjUl0210902109epcas5p3l; Wed, 10 Jan 2024 11:02:09 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240110110209epsmtrp18b7fd6b1a016d438edfe0a095a87cd96~o93JSO7lY2403524035epsmtrp1s; Wed, 10 Jan 2024 11:02:09 +0000 (GMT) X-AuditID: b6c32a4a-261fd70000002719-cf-659e7cc67be7 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.90.07368.1397E956; Wed, 10 Jan 2024 20:02:09 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240110110206epsmtip1ce78e7296382e697f5148d5f277c3608~o93GxJZ8w2247222472epsmtip1h; Wed, 10 Jan 2024 11:02:06 +0000 (GMT) From: Shradha Todi To: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: mturquette@baylibre.com, sboyd@kernel.org, jingoohan1@gmail.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, linux@armlinux.org.uk, m.szyprowski@samsung.com, manivannan.sadhasivam@linaro.org, Shradha Todi Subject: [PATCH v3 2/2] PCI: exynos: Adapt to clk_bulk_* APIs Date: Wed, 10 Jan 2024 16:31:15 +0530 Message-Id: <20240110110115.56270-3-shradha.t@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240110110115.56270-1-shradha.t@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFJsWRmVeSWpSXmKPExsWy7bCmpu6xmnmpBvMv8Vs8mLeNzWJJU4bF ii8z2S32vt7KbtHQ85vVYtPja6wWH3vusVpc3jWHzeLsvONsFjPO72OyODR1L6NFy58WFou1 R+6yW9xt6WS1uHjK1eL/nh3sFv+ubWSx6D1c6yDkcfnaRWaP9zda2T12zrrL7rFgU6nHplWd bB53ru1h83hyZTqTx+Yl9R59W1YxenzeJBfAFZVtk5GamJJapJCal5yfkpmXbqvkHRzvHG9q ZmCoa2hpYa6kkJeYm2qr5OIToOuWmQP0kZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jEVim1 ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO+NQY1jBMcmKffcVGxi7RLsYOTkkBEwkHh1b wtLFyMUhJLCbUeLEg6VQzidGiZ3nHzODVAkJfGOU2LhFGaaj9/0DdoiivYwSW/ecYocoamWS WHLICcRmE9CSaPzaxQxSJCKwmFHi1o7NrCAOs8AJJomjZ7cxglQJC9hKL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ODgkBE4ne9w/Yuxi5OIQEdjNKPLl0nR0iISnx+eI6JghbWGLlv+dQRc1MEhO7bzKD JNgEtCQav3YxgyREBJYzSvw8+ZQJxGEWuMEk0dg4F2yUsICtxKJOiA4WAVWJTycfsoLYvAJW Em/uXoJaIS+xesMBsBpOAWuJ1Ytng/UKAdWs2HuYdQIj3wJGhlWMkqkFxbnpucmGBYZ5qeV6 xYm5xaV56XrJ+bmbGMHRoKWxg/He/H96hxiZOBgPMUpwMCuJ8Cp8npMqxJuSWFmVWpQfX1Sa k1p8iFGag0VJnNdwxuwUIYH0xJLU7NTUgtQimCwTB6dUA9OUqhPM95et+m5wYYpsx0atNQJt /iv+HWBdf0TjXPe2pzzvJ+Q//Zh+kPe8Ppv36y1lX+Ja7Joizxf4WToW7JmusGZKdcgunc83 3dPPTd63uOjSFCs/JV+TWztmd/W8D5W9rLwplutlcX6c5wfZFcsevt69RSCZ+aapv+UP2edp htrztnYwXE2/Wv+vXny6RIPhyqq5Yqo/U4/WbHhUvnvXFNX1Z+yvT36zqfSnhUUSc/KnM/me J5UrQ3ZM8Ou89DN3mejs9K32c5w2zr7f/q/yE/fH+1z7ApbWaaxh+3QvfaK4fMdua31tvdaE zw/eBjO+X/T69Tr3tapSOtO4vgZL7D6a2bz9NtPam84MKVHHlViKMxINtZiLihMB0EF5cfUC AAA= X-CMS-MailID: 20240110110209epcas5p3130d90db3c4ebd19ff09f2f3c37958f4 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240110110209epcas5p3130d90db3c4ebd19ff09f2f3c37958f4 References: <20240110110115.56270-1-shradha.t@samsung.com> Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: There is no need to hardcode the clock info in the driver as driver can rely on the devicetree to supply the clocks required for the functioning of the peripheral. Get rid of the static clock info and obtain the platform supplied clocks. The total number of clocks supplied is obtained and enabled using the devm_clk_bulk_get_all_enabled() API. Signed-off-by: Shradha Todi --- drivers/pci/controller/dwc/pci-exynos.c | 55 +++---------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c index ec5611005566..3c0bc2505602 100644 --- a/drivers/pci/controller/dwc/pci-exynos.c +++ b/drivers/pci/controller/dwc/pci-exynos.c @@ -54,43 +54,12 @@ struct exynos_pcie { struct dw_pcie pci; void __iomem *elbi_base; - struct clk *clk; - struct clk *bus_clk; + struct clk_bulk_data *clks; + int clk_cnt; struct phy *phy; struct regulator_bulk_data supplies[2]; }; -static int exynos_pcie_init_clk_resources(struct exynos_pcie *ep) -{ - struct device *dev = ep->pci.dev; - int ret; - - ret = clk_prepare_enable(ep->clk); - if (ret) { - dev_err(dev, "cannot enable pcie rc clock"); - return ret; - } - - ret = clk_prepare_enable(ep->bus_clk); - if (ret) { - dev_err(dev, "cannot enable pcie bus clock"); - goto err_bus_clk; - } - - return 0; - -err_bus_clk: - clk_disable_unprepare(ep->clk); - - return ret; -} - -static void exynos_pcie_deinit_clk_resources(struct exynos_pcie *ep) -{ - clk_disable_unprepare(ep->bus_clk); - clk_disable_unprepare(ep->clk); -} - static void exynos_pcie_writel(void __iomem *base, u32 val, u32 reg) { writel(val, base + reg); @@ -332,17 +301,9 @@ static int exynos_pcie_probe(struct platform_device *pdev) if (IS_ERR(ep->elbi_base)) return PTR_ERR(ep->elbi_base); - ep->clk = devm_clk_get(dev, "pcie"); - if (IS_ERR(ep->clk)) { - dev_err(dev, "Failed to get pcie rc clock\n"); - return PTR_ERR(ep->clk); - } - - ep->bus_clk = devm_clk_get(dev, "pcie_bus"); - if (IS_ERR(ep->bus_clk)) { - dev_err(dev, "Failed to get pcie bus clock\n"); - return PTR_ERR(ep->bus_clk); - } + ret = devm_clk_bulk_get_all_enabled(dev, &ep->clks, &ep->clk_cnt); + if (ret < 0) + return ret; ep->supplies[0].supply = "vdd18"; ep->supplies[1].supply = "vdd10"; @@ -351,10 +312,6 @@ static int exynos_pcie_probe(struct platform_device *pdev) if (ret) return ret; - ret = exynos_pcie_init_clk_resources(ep); - if (ret) - return ret; - ret = regulator_bulk_enable(ARRAY_SIZE(ep->supplies), ep->supplies); if (ret) return ret; @@ -369,7 +326,6 @@ static int exynos_pcie_probe(struct platform_device *pdev) fail_probe: phy_exit(ep->phy); - exynos_pcie_deinit_clk_resources(ep); regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies); return ret; @@ -383,7 +339,6 @@ static int __exit exynos_pcie_remove(struct platform_device *pdev) exynos_pcie_assert_core_reset(ep); phy_power_off(ep->phy); phy_exit(ep->phy); - exynos_pcie_deinit_clk_resources(ep); regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies); return 0;