From patchwork Fri Apr 10 05:55:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 6191801 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 00AB2BF4A7 for ; Fri, 10 Apr 2015 05:55:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CA2B203C0 for ; Fri, 10 Apr 2015 05:55:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 190592035D for ; Fri, 10 Apr 2015 05:55:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C7076E893; Thu, 9 Apr 2015 22:55:40 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 01FAA6E88C for ; Thu, 9 Apr 2015 22:55:39 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NMK002FMTSOWG30@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 10 Apr 2015 14:55:36 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.112]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 2F.5E.18889.8D567255; Fri, 10 Apr 2015 14:55:36 +0900 (KST) X-AuditID: cbfee68d-f79266d0000049c9-f2-552765d83bdf Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BF.D3.25346.8D567255; Fri, 10 Apr 2015 14:55:36 +0900 (KST) Received: from localhost.localdomain ([10.252.82.145]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NMK00MM0TSKKM40@mmp1.samsung.com>; Fri, 10 Apr 2015 14:55:35 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, inki.dae@samsung.com, daniel@fooishbar.org Subject: [PATCH v5 07/12] drm/exynos: dsi: make use of array for clock access Date: Fri, 10 Apr 2015 14:55:25 +0900 Message-id: <1428645330-1043-8-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1428645330-1043-1-git-send-email-human.hwang@samsung.com> References: <1428645330-1043-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkQPdGqnqowccjEhbXvzxntbjSOp3V Yv6Rc6wW18/bWVz5+p7NYumMPlaLSfcnsFi8uHeRxWLG5JdsDpweL75uY/a4332cyaNvyypG j8+b5AJYorhsUlJzMstSi/TtErgyFs7rYSr4rlix5NkC9gbG29JdjJwcEgImEi2PZrFA2GIS F+6tZ+ti5OIQEljKKDF14UF2mKJ5z+exQiQWMUrsfLOPCcL5wSjxpm8vE0gVm4CexIJrP8A6 RARyJfpfvAArYhboYZRovDIZbIewgK/Eya5ZrCA2i4CqROvRw2ANvAJuEq++PGaCWCcncfLY ZKAaDg5OAXeJo1tTQcJCQCUf92wDu0JCYBG7xIS3n9gg5ghIfJt8iAWkXkJAVmLTAWaIMZIS B1fcYJnAKLyAkWEVo2hqQXJBcVJ6kaFecWJucWleul5yfu4mRmDAn/73rHcH4+0D1ocYBTgY lXh4G2LVQ4VYE8uKK3MPMZoCbZjILCWanA+Mq7ySeENjMyMLUxNTYyNzSzMlcV5FqZ/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7rK5Es05TjZOXdXlXAqsRRnJBpqMRcVJwIAYE8b rb0CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: dh09.lee@samsung.com, sw0312.kim@samsung.com, Hyungwon Hwang , cw00.choi@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch make the driver to use an array for clock access. The number of clocks are different from the existing MIPI DSI driver and Exynos5433 MIPI DSI driver. So this patch is needed before adding support for Exynos5433 MIPI DSI driver. Signed-off-by: Hyungwon Hwang --- Changes for v5: - Newly added drivers/gpu/drm/exynos/exynos_drm_dsi.c | 64 +++++++++++++++------------------ 1 file changed, 29 insertions(+), 35 deletions(-) -- 1.9.1 diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 83e6798..b78d5f5 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -208,6 +208,8 @@ REG_ADDR((dsi), (reg_idx))) #define DSI_READ(dsi, reg_idx) readl(REG_ADDR((dsi), (reg_idx))) +static char *clk_names[2] = { "bus_clk", "sclk_mipi" }; + enum exynos_dsi_transfer_type { EXYNOS_DSI_TX, EXYNOS_DSI_RX, @@ -256,8 +258,7 @@ struct exynos_dsi { void __iomem *reg_base; struct phy *phy; - struct clk *sclk_clk; - struct clk *bus_clk; + struct clk **clks; struct regulator_bulk_data supplies[2]; int irq; int te_gpio; @@ -1383,7 +1384,8 @@ static const struct mipi_dsi_host_ops exynos_dsi_ops = { static int exynos_dsi_poweron(struct exynos_dsi *dsi) { - int ret; + struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + int ret, i; ret = regulator_bulk_enable(ARRAY_SIZE(dsi->supplies), dsi->supplies); if (ret < 0) { @@ -1391,31 +1393,23 @@ static int exynos_dsi_poweron(struct exynos_dsi *dsi) return ret; } - ret = clk_prepare_enable(dsi->bus_clk); - if (ret < 0) { - dev_err(dsi->dev, "cannot enable bus clock %d\n", ret); - goto err_bus_clk; - } - - ret = clk_prepare_enable(dsi->sclk_clk); - if (ret < 0) { - dev_err(dsi->dev, "cannot enable pll clock %d\n", ret); - goto err_sclk_clk; + for (i = 0; i < driver_data->num_clks; i++) { + ret = clk_prepare_enable(dsi->clks[i]); + if (ret < 0) + goto err_clk; } ret = phy_power_on(dsi->phy); if (ret < 0) { dev_err(dsi->dev, "cannot enable phy %d\n", ret); - goto err_phy; + goto err_clk; } return 0; -err_phy: - clk_disable_unprepare(dsi->sclk_clk); -err_sclk_clk: - clk_disable_unprepare(dsi->bus_clk); -err_bus_clk: +err_clk: + while (--i > -1) + clk_disable_unprepare(dsi->clks[i]); regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies); return ret; @@ -1423,7 +1417,8 @@ err_bus_clk: static void exynos_dsi_poweroff(struct exynos_dsi *dsi) { - int ret; + struct exynos_dsi_driver_data *driver_data = dsi->driver_data; + int ret, i; usleep_range(10000, 20000); @@ -1439,8 +1434,8 @@ static void exynos_dsi_poweroff(struct exynos_dsi *dsi) phy_power_off(dsi->phy); - clk_disable_unprepare(dsi->sclk_clk); - clk_disable_unprepare(dsi->bus_clk); + for (i = driver_data->num_clks - 1; i > -1; i--) + clk_disable_unprepare(dsi->clks[i]); ret = regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies); if (ret < 0) @@ -1762,7 +1757,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; struct exynos_dsi *dsi; - int ret; + int ret, i; dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); if (!dsi) @@ -1802,18 +1797,17 @@ static int exynos_dsi_probe(struct platform_device *pdev) return -EPROBE_DEFER; } - dsi->sclk_clk = devm_clk_get(dev, "sclk_mipi"); - if (IS_ERR(dsi->sclk_clk)) { - dev_info(dev, "failed to get dsi sclk clock\n"); - ret = PTR_ERR(dsi->sclk_clk); - goto err_del_component; - } - - dsi->bus_clk = devm_clk_get(dev, "bus_clk"); - if (IS_ERR(dsi->bus_clk)) { - dev_info(dev, "failed to get dsi bus clock\n"); - ret = PTR_ERR(dsi->bus_clk); - goto err_del_component; + dsi->clks = devm_kzalloc(dev, + sizeof(*dsi->clks) * dsi->driver_data->num_clks, + GFP_KERNEL); + for (i = 0; i < dsi->driver_data->num_clks; i++) { + dsi->clks[i] = devm_clk_get(dev, clk_names[i]); + if (IS_ERR(dsi->clks[i])) { + dev_info(dev, "failed to get the clock: %s\n", + clk_names[i]); + ret = PTR_ERR(dsi->clks[i]); + goto err_del_component; + } } res = platform_get_resource(pdev, IORESOURCE_MEM, 0);