From patchwork Fri Jul 19 15:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11050237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A3C9746 for ; Fri, 19 Jul 2019 15:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A18F21FAD for ; Fri, 19 Jul 2019 15:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E5B6288FD; Fri, 19 Jul 2019 15:06:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B870121FAD for ; Fri, 19 Jul 2019 15:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729873AbfGSPF5 (ORCPT ); Fri, 19 Jul 2019 11:05:57 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40834 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729834AbfGSPF4 (ORCPT ); Fri, 19 Jul 2019 11:05:56 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190719150555euoutp02f8a12020ac4e10a88da92df90b2da16d~y108fZ_0h1346313463euoutp02L for ; Fri, 19 Jul 2019 15:05:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190719150555euoutp02f8a12020ac4e10a88da92df90b2da16d~y108fZ_0h1346313463euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563548755; bh=a1WebjF2OCLaB+DQY5uyD0tPKoaanwf9vnr7gRJblR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goeb8seWqSnnhARcvPSacU2hwbVYQqLpmeqhPWT/0ST96OLA9oS94kJfvwSKVnxMQ nwlfcxJSTUl4bYlqzrbzgAWXFky94SwGgOh8QUhPbhRCrf/N7WktO7azAZDm+lMTHM DhlF/d/pN6PIl6ahfny4ebpdJe2/a6vIcDcEj4SM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190719150554eucas1p1693f01d005c30f29c8ef1a3d774d6b3c~y10717Hgp0634306343eucas1p17; Fri, 19 Jul 2019 15:05:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D0.19.04377.25CD13D5; Fri, 19 Jul 2019 16:05:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851~y1066L7oI3265032650eucas1p1T; Fri, 19 Jul 2019 15:05:53 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190719150553eusmtrp2288792d67239db11e8a0629d1f8087f4~y106pXSji3123131231eusmtrp2L; Fri, 19 Jul 2019 15:05:53 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-73-5d31dc52c077 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FF.8F.04146.15CD13D5; Fri, 19 Jul 2019 16:05:53 +0100 (BST) Received: from AMDC3218.DIGITAL.local (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190719150552eusmtip100d326709c0801bfea6ad15e33e67358~y1057cU3u2866928669eusmtip1B; Fri, 19 Jul 2019 15:05:52 +0000 (GMT) From: k.konieczny@partner.samsung.com To: k.konieczny@partner.samsung.com Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , Mark Rutland , MyungJoo Ham , Nishanth Menon , Rob Herring , Stephen Boyd , Viresh Kumar , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v3 1/5] devfreq: exynos-bus: correct clock enable sequence Date: Fri, 19 Jul 2019 17:05:31 +0200 Message-Id: <20190719150535.15501-2-k.konieczny@partner.samsung.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190719150535.15501-1-k.konieczny@partner.samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAKsWRmVeSWpSXmKPExsWy7djP87pBdwxjDc5PlbDYOGM9q8X1L89Z LeYfOcdq0bfvP6NF/+PXzBbnz29gtzjb9IbdYtPja6wWl3fNYbP43HuE0WLG+X1MFmuP3GW3 WHr9IpPF7cYVbBZvfpxlsmjde4Td4t+1jSwWmx8cY3MQ8lgzbw2jx6ZVnWwem5fUexx8t4fJ o2/LKkaP4ze2M3l83iQXwB7FZZOSmpNZllqkb5fAlbG99zprwVeFitbHa5gaGFdKdTFyckgI mEj0TFvF1MXIxSEksIJRom3iSijnC6PEif9/GCGcz4wSJ7vPMMO0XFv7hQ0isZxR4u/zqaxw LQ+3vmcEqWITUJXYMuMlO4gtIqAsMfnedGaQImaBnywSGy5vBEsIC3hJLHl5iAXEZgFq2Phq GlicV8BF4sOxRlaIdfISnTt2g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W+HHwPViMEVLNj 5TxmiHpBiZMzn4DVMAPVN2+dzTyBUWAWktQsJKkFjEyrGEVSS4tz03OLDfWKE3OLS/PS9ZLz czcxAuNy27Gfm3cwXtoYfIhRgINRiYf3wy3DWCHWxLLiytxDjBIczEoivLdf6scK8aYkVlal FuXHF5XmpBYfYjQFemIis5Rocj4wZeSVxBuaGppbWBqaG5sbm1koifN2CByMERJITyxJzU5N LUgtgulj4uCUamCsmuLtNqsvcdWbt9YHfrKs+XrWtOp/4OMPkgtndk/zs/jaeP/qtvZDbzKN 79he2ZI1i/mU0sQap+vnP5478njORespdg/jWefO1TuTcSr+2MaPpcJObzauT3JvvpP9+Lyx b1L2x7p9FzqtsjIlL5pZWpolXfOpNN579UWf0dzfel4Ccd8Ox3s2KrEUZyQaajEXFScCACJB st7hAgAA X-CMS-MailID: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 X-Msg-Generator: CA X-RootMTR: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 References: <20190719150535.15501-1-k.konieczny@partner.samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Regulators should be enabled before clocks to avoid h/w hang. This require change in exynos_bus_probe() to move exynos_bus_parse_of() after exynos_bus_parent_parse_of() and change in enabling sequence of regulator and clock in exynos_bus_parse_of(). Similar change is needed in exynos_bus_exit() where clock should be disabled first. Signed-off-by: Kamil Konieczny Acked-by: Chanwoo Choi --- This patch is new to this series. --- drivers/devfreq/exynos-bus.c | 58 ++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 486cc5b422f1..f391044aa39d 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -194,11 +194,11 @@ static void exynos_bus_exit(struct device *dev) if (ret < 0) dev_warn(dev, "failed to disable the devfreq-event devices\n"); + clk_disable_unprepare(bus->clk); if (bus->regulator) regulator_disable(bus->regulator); dev_pm_opp_of_remove_table(dev); - clk_disable_unprepare(bus->clk); } /* @@ -326,8 +326,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np, return ret; } -static int exynos_bus_parse_of(struct device_node *np, - struct exynos_bus *bus) +static int exynos_bus_parse_of(struct exynos_bus *bus) { struct device *dev = bus->dev; struct dev_pm_opp *opp; @@ -341,36 +340,35 @@ static int exynos_bus_parse_of(struct device_node *np, return PTR_ERR(bus->clk); } - ret = clk_prepare_enable(bus->clk); + /* Get the freq and voltage from OPP table to scale the bus freq */ + ret = dev_pm_opp_of_add_table(dev); if (ret < 0) { - dev_err(dev, "failed to get enable clock\n"); + dev_err(dev, "failed to get OPP table\n"); return ret; } - /* Get the freq and voltage from OPP table to scale the bus freq */ - ret = dev_pm_opp_of_add_table(dev); + ret = clk_prepare_enable(bus->clk); if (ret < 0) { - dev_err(dev, "failed to get OPP table\n"); + dev_err(dev, "failed to enable clock\n"); goto err_clk; } - rate = clk_get_rate(bus->clk); opp = devfreq_recommended_opp(dev, &rate, 0); if (IS_ERR(opp)) { dev_err(dev, "failed to find dev_pm_opp\n"); ret = PTR_ERR(opp); - goto err_opp; + goto err; } bus->curr_freq = dev_pm_opp_get_freq(opp); dev_pm_opp_put(opp); return 0; -err_opp: - dev_pm_opp_of_remove_table(dev); -err_clk: +err: clk_disable_unprepare(bus->clk); +err_clk: + dev_pm_opp_of_remove_table(dev); return ret; } @@ -386,6 +384,7 @@ static int exynos_bus_probe(struct platform_device *pdev) struct exynos_bus *bus; int ret, max_state; unsigned long min_freq, max_freq; + bool passive = false; if (!np) { dev_err(dev, "failed to find devicetree node\n"); @@ -399,27 +398,31 @@ static int exynos_bus_probe(struct platform_device *pdev) bus->dev = &pdev->dev; platform_set_drvdata(pdev, bus); - /* Parse the device-tree to get the resource information */ - ret = exynos_bus_parse_of(np, bus); - if (ret < 0) - return ret; - profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL); - if (!profile) { - ret = -ENOMEM; - goto err; - } + if (!profile) + return -ENOMEM; node = of_parse_phandle(dev->of_node, "devfreq", 0); if (node) { of_node_put(node); - goto passive; + passive = true; } else { ret = exynos_bus_parent_parse_of(np, bus); + if (ret < 0) + return ret; } - if (ret < 0) - goto err; + /* Parse the device-tree to get the resource information */ + ret = exynos_bus_parse_of(bus); + if (ret < 0) { + if (!passive) + regulator_disable(bus->regulator); + + return ret; + } + + if (passive) + goto passive; /* Initialize the struct profile and governor data for parent device */ profile->polling_ms = 50; @@ -508,8 +511,11 @@ static int exynos_bus_probe(struct platform_device *pdev) return 0; err: - dev_pm_opp_of_remove_table(dev); clk_disable_unprepare(bus->clk); + if (!passive) + regulator_disable(bus->regulator); + + dev_pm_opp_of_remove_table(dev); return ret; }