From patchwork Fri Sep 11 13:53:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73DB2746 for ; Fri, 11 Sep 2020 13:54:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 560EF22276 for ; Fri, 11 Sep 2020 13:54:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 560EF22276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C74616EA5E; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E8A16EA58 for ; Fri, 11 Sep 2020 13:54:22 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wO-4Q; Fri, 11 Sep 2020 15:54:20 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnP-JB; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:53:58 +0200 Message-Id: <20200911135413.3654800-2-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 01/16] drm/encoder: remove obsolete documentation of bridge X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent Pinchart , kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In commit 05193dc38197 ("drm/bridge: Make the bridge chain a double-linked list") the bridge has been removed and replaced by a private field. Remove the leftover documentation of the removed field. Signed-off-by: Michael Tretter Reviewed-by: Laurent Pinchart --- v2: none --- include/drm/drm_encoder.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h index a60f5f1555ac..5dfa5f7a80a7 100644 --- a/include/drm/drm_encoder.h +++ b/include/drm/drm_encoder.h @@ -89,7 +89,6 @@ struct drm_encoder_funcs { * @head: list management * @base: base KMS object * @name: human readable name, can be overwritten by the driver - * @bridge: bridge associated to the encoder * @funcs: control functions * @helper_private: mid-layer private data * From patchwork Fri Sep 11 13:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05D06746 for ; Fri, 11 Sep 2020 13:54:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF1C522276 for ; Fri, 11 Sep 2020 13:54:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF1C522276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A95796EA58; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1DF36EA58 for ; Fri, 11 Sep 2020 13:54:21 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wP-4K; Fri, 11 Sep 2020 15:54:19 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnS-Jk; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:53:59 +0200 Message-Id: <20200911135413.3654800-3-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 02/16] drm/exynos: remove in_bridge_node from exynos_dsi X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We do not need to keep a reference to the in_bridge_node, but we can simply drop it, once we found and attached the previous bridge. Signed-off-by: Michael Tretter Reviewed-by: Sam Ravnborg --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 1a1a2853a842..29f941b02210 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -282,7 +282,6 @@ struct exynos_dsi { struct list_head transfer_list; const struct exynos_dsi_driver_data *driver_data; - struct device_node *in_bridge_node; }; #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) @@ -1684,8 +1683,6 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) if (ret < 0) return ret; - dsi->in_bridge_node = of_graph_get_remote_node(node, DSI_PORT_IN, 0); - return 0; } @@ -1695,6 +1692,7 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, struct drm_encoder *encoder = dev_get_drvdata(dev); struct exynos_dsi *dsi = encoder_to_dsi(encoder); struct drm_device *drm_dev = data; + struct device_node *in_bridge_node; struct drm_bridge *in_bridge; int ret; @@ -1706,10 +1704,12 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, if (ret < 0) return ret; - if (dsi->in_bridge_node) { - in_bridge = of_drm_find_bridge(dsi->in_bridge_node); + in_bridge_node = of_graph_get_remote_node(dev->of_node, DSI_PORT_IN, 0); + if (in_bridge_node) { + in_bridge = of_drm_find_bridge(in_bridge_node); if (in_bridge) drm_bridge_attach(encoder, in_bridge, NULL, 0); + of_node_put(in_bridge_node); } return mipi_dsi_host_register(&dsi->dsi_host); @@ -1830,17 +1830,12 @@ static int exynos_dsi_probe(struct platform_device *pdev) err_disable_runtime: pm_runtime_disable(dev); - of_node_put(dsi->in_bridge_node); return ret; } static int exynos_dsi_remove(struct platform_device *pdev) { - struct exynos_dsi *dsi = platform_get_drvdata(pdev); - - of_node_put(dsi->in_bridge_node); - pm_runtime_disable(&pdev->dev); component_del(&pdev->dev, &exynos_dsi_component_ops); From patchwork Fri Sep 11 13:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC683746 for ; Fri, 11 Sep 2020 13:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 90F7822284 for ; Fri, 11 Sep 2020 13:54:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90F7822284 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67D286EA5D; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA7336E34C for ; Fri, 11 Sep 2020 13:54:20 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wQ-4F; Fri, 11 Sep 2020 15:54:18 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnV-KR; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:00 +0200 Message-Id: <20200911135413.3654800-4-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 03/16] drm/exynos: use exynos_dsi as drvdata X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the exynos_dsi as drvdata instead of the encoder to further decouple the driver from the encoder. Signed-off-by: Michael Tretter Reviewed-by: Sam Ravnborg --- v2: drop removal of encoder_to_dsi --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 29f941b02210..ed04064afbb2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1689,8 +1689,8 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) static int exynos_dsi_bind(struct device *dev, struct device *master, void *data) { - struct drm_encoder *encoder = dev_get_drvdata(dev); - struct exynos_dsi *dsi = encoder_to_dsi(encoder); + struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct drm_encoder *encoder = &dsi->encoder; struct drm_device *drm_dev = data; struct device_node *in_bridge_node; struct drm_bridge *in_bridge; @@ -1718,8 +1718,8 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, static void exynos_dsi_unbind(struct device *dev, struct device *master, void *data) { - struct drm_encoder *encoder = dev_get_drvdata(dev); - struct exynos_dsi *dsi = encoder_to_dsi(encoder); + struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct drm_encoder *encoder = &dsi->encoder; exynos_dsi_disable(encoder); @@ -1818,7 +1818,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) if (ret) return ret; - platform_set_drvdata(pdev, &dsi->encoder); + platform_set_drvdata(pdev, dsi); pm_runtime_enable(dev); @@ -1845,8 +1845,7 @@ static int exynos_dsi_remove(struct platform_device *pdev) static int __maybe_unused exynos_dsi_suspend(struct device *dev) { - struct drm_encoder *encoder = dev_get_drvdata(dev); - struct exynos_dsi *dsi = encoder_to_dsi(encoder); + struct exynos_dsi *dsi = dev_get_drvdata(dev); const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; @@ -1876,8 +1875,7 @@ static int __maybe_unused exynos_dsi_suspend(struct device *dev) static int __maybe_unused exynos_dsi_resume(struct device *dev) { - struct drm_encoder *encoder = dev_get_drvdata(dev); - struct exynos_dsi *dsi = encoder_to_dsi(encoder); + struct exynos_dsi *dsi = dev_get_drvdata(dev); const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; From patchwork Fri Sep 11 13:54:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77EE1746 for ; Fri, 11 Sep 2020 13:54:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BFF622276 for ; Fri, 11 Sep 2020 13:54:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BFF622276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76A036EA63; Fri, 11 Sep 2020 13:54:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31B526EA57 for ; Fri, 11 Sep 2020 13:54:23 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wR-4G; Fri, 11 Sep 2020 15:54:21 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnY-Kt; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:01 +0200 Message-Id: <20200911135413.3654800-5-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 04/16] drm/exynos: extract helper functions for probe X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the driver shall be usable with drivers that use the component framework and drivers that don't, split the common probing code into a separate function that can be called from different locations. Signed-off-by: Michael Tretter Reviewed-by: Sam Ravnborg --- v2: - move pm_runtime_enable from helper to calling function --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 40 ++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index ed04064afbb2..f8e64b74a6dd 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1731,7 +1731,7 @@ static const struct component_ops exynos_dsi_component_ops = { .unbind = exynos_dsi_unbind, }; -static int exynos_dsi_probe(struct platform_device *pdev) +static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; @@ -1740,7 +1740,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); if (!dsi) - return -ENOMEM; + return ERR_PTR(-ENOMEM); /* To be checked as invalid one */ dsi->te_gpio = -ENOENT; @@ -1763,14 +1763,14 @@ static int exynos_dsi_probe(struct platform_device *pdev) if (ret) { if (ret != -EPROBE_DEFER) dev_info(dev, "failed to get regulators: %d\n", ret); - return ret; + return ERR_PTR(ret); } dsi->clks = devm_kcalloc(dev, dsi->driver_data->num_clks, sizeof(*dsi->clks), GFP_KERNEL); if (!dsi->clks) - return -ENOMEM; + return ERR_PTR(-ENOMEM); for (i = 0; i < dsi->driver_data->num_clks; i++) { dsi->clks[i] = devm_clk_get(dev, clk_names[i]); @@ -1784,7 +1784,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) dev_info(dev, "failed to get the clock: %s\n", clk_names[i]); - return PTR_ERR(dsi->clks[i]); + return ERR_PTR(PTR_ERR(dsi->clks[i])); } } @@ -1792,18 +1792,18 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi->reg_base = devm_ioremap_resource(dev, res); if (IS_ERR(dsi->reg_base)) { dev_err(dev, "failed to remap io region\n"); - return PTR_ERR(dsi->reg_base); + return dsi->reg_base; } dsi->phy = devm_phy_get(dev, "dsim"); if (IS_ERR(dsi->phy)) { dev_info(dev, "failed to get dsim phy\n"); - return PTR_ERR(dsi->phy); + return ERR_PTR(PTR_ERR(dsi->phy)); } dsi->irq = platform_get_irq(pdev, 0); if (dsi->irq < 0) - return dsi->irq; + return ERR_PTR(dsi->irq); irq_set_status_flags(dsi->irq, IRQ_NOAUTOEN); ret = devm_request_threaded_irq(dev, dsi->irq, NULL, @@ -1811,13 +1811,29 @@ static int exynos_dsi_probe(struct platform_device *pdev) dev_name(dev), dsi); if (ret) { dev_err(dev, "failed to request dsi irq\n"); - return ret; + return ERR_PTR(ret); } ret = exynos_dsi_parse_dt(dsi); if (ret) - return ret; + return ERR_PTR(ret); + + return dsi; +} + +static void __exynos_dsi_remove(struct exynos_dsi *dsi) +{ +} +static int exynos_dsi_probe(struct platform_device *pdev) +{ + struct exynos_dsi *dsi; + struct device *dev = &pdev->dev; + int ret; + + dsi = __exynos_dsi_probe(pdev); + if (IS_ERR(dsi)) + return PTR_ERR(dsi); platform_set_drvdata(pdev, dsi); pm_runtime_enable(dev); @@ -1836,8 +1852,12 @@ static int exynos_dsi_probe(struct platform_device *pdev) static int exynos_dsi_remove(struct platform_device *pdev) { + struct exynos_dsi *dsi = platform_get_drvdata(pdev); + pm_runtime_disable(&pdev->dev); + __exynos_dsi_remove(dsi); + component_del(&pdev->dev, &exynos_dsi_component_ops); return 0; From patchwork Fri Sep 11 13:54:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AE08746 for ; Fri, 11 Sep 2020 13:54:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2DE522276 for ; Fri, 11 Sep 2020 13:54:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2DE522276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AFC66EA5A; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 019166EA59 for ; Fri, 11 Sep 2020 13:54:22 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wS-4E; Fri, 11 Sep 2020 15:54:20 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnb-LN; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:02 +0200 Message-Id: <20200911135413.3654800-6-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 05/16] drm/exynos: move dsi host registration to probe X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Once the driver implements a drm_bridge, the bridge will be attached during bind. The driver has to register the mipi dsi host before making the driver available at the component framework, because the bridge is only initialized when a mipi dsi device attaches. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index f8e64b74a6dd..41000214a5fe 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1712,7 +1712,7 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, of_node_put(in_bridge_node); } - return mipi_dsi_host_register(&dsi->dsi_host); + return 0; } static void exynos_dsi_unbind(struct device *dev, struct device *master, @@ -1722,8 +1722,6 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, struct drm_encoder *encoder = &dsi->encoder; exynos_dsi_disable(encoder); - - mipi_dsi_host_unregister(&dsi->dsi_host); } static const struct component_ops exynos_dsi_component_ops = { @@ -1818,11 +1816,16 @@ static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) if (ret) return ERR_PTR(ret); + ret = mipi_dsi_host_register(&dsi->dsi_host); + if (ret) + return ERR_PTR(ret); + return dsi; } static void __exynos_dsi_remove(struct exynos_dsi *dsi) { + mipi_dsi_host_unregister(&dsi->dsi_host); } static int exynos_dsi_probe(struct platform_device *pdev) From patchwork Fri Sep 11 13:54:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8579A746 for ; Fri, 11 Sep 2020 13:54:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67E8722276 for ; Fri, 11 Sep 2020 13:54:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67E8722276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 483526EA5C; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4009E6EA57 for ; Fri, 11 Sep 2020 13:54:22 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wT-4G; Fri, 11 Sep 2020 15:54:20 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKne-Lw; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:03 +0200 Message-Id: <20200911135413.3654800-7-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL,UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 06/16] drm/exynos: shift register values to fields on write X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The phy timings are already shifted to the field position. If the driver is reused on multiple platforms, this exposes the field positions to the platform code. Store only the timing values in the platform data and shift the value to the field when writing the fields to the registers. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 88 +++++++++++++------------ 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 41000214a5fe..0f2cac7ed944 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -399,54 +399,54 @@ static const unsigned int reg_values[] = { [RESET_TYPE] = DSIM_SWRST, [PLL_TIMER] = 500, [STOP_STATE_CNT] = 0xf, - [PHYCTRL_ULPS_EXIT] = DSIM_PHYCTRL_ULPS_EXIT(0x0af), + [PHYCTRL_ULPS_EXIT] = 0x0af, [PHYCTRL_VREG_LP] = 0, [PHYCTRL_SLEW_UP] = 0, - [PHYTIMING_LPX] = DSIM_PHYTIMING_LPX(0x06), - [PHYTIMING_HS_EXIT] = DSIM_PHYTIMING_HS_EXIT(0x0b), - [PHYTIMING_CLK_PREPARE] = DSIM_PHYTIMING1_CLK_PREPARE(0x07), - [PHYTIMING_CLK_ZERO] = DSIM_PHYTIMING1_CLK_ZERO(0x27), - [PHYTIMING_CLK_POST] = DSIM_PHYTIMING1_CLK_POST(0x0d), - [PHYTIMING_CLK_TRAIL] = DSIM_PHYTIMING1_CLK_TRAIL(0x08), - [PHYTIMING_HS_PREPARE] = DSIM_PHYTIMING2_HS_PREPARE(0x09), - [PHYTIMING_HS_ZERO] = DSIM_PHYTIMING2_HS_ZERO(0x0d), - [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0b), + [PHYTIMING_LPX] = 0x06, + [PHYTIMING_HS_EXIT] = 0x0b, + [PHYTIMING_CLK_PREPARE] = 0x07, + [PHYTIMING_CLK_ZERO] = 0x27, + [PHYTIMING_CLK_POST] = 0x0d, + [PHYTIMING_CLK_TRAIL] = 0x08, + [PHYTIMING_HS_PREPARE] = 0x09, + [PHYTIMING_HS_ZERO] = 0x0d, + [PHYTIMING_HS_TRAIL] = 0x0b, }; static const unsigned int exynos5422_reg_values[] = { [RESET_TYPE] = DSIM_SWRST, [PLL_TIMER] = 500, [STOP_STATE_CNT] = 0xf, - [PHYCTRL_ULPS_EXIT] = DSIM_PHYCTRL_ULPS_EXIT(0xaf), + [PHYCTRL_ULPS_EXIT] = 0xaf, [PHYCTRL_VREG_LP] = 0, [PHYCTRL_SLEW_UP] = 0, - [PHYTIMING_LPX] = DSIM_PHYTIMING_LPX(0x08), - [PHYTIMING_HS_EXIT] = DSIM_PHYTIMING_HS_EXIT(0x0d), - [PHYTIMING_CLK_PREPARE] = DSIM_PHYTIMING1_CLK_PREPARE(0x09), - [PHYTIMING_CLK_ZERO] = DSIM_PHYTIMING1_CLK_ZERO(0x30), - [PHYTIMING_CLK_POST] = DSIM_PHYTIMING1_CLK_POST(0x0e), - [PHYTIMING_CLK_TRAIL] = DSIM_PHYTIMING1_CLK_TRAIL(0x0a), - [PHYTIMING_HS_PREPARE] = DSIM_PHYTIMING2_HS_PREPARE(0x0c), - [PHYTIMING_HS_ZERO] = DSIM_PHYTIMING2_HS_ZERO(0x11), - [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0d), + [PHYTIMING_LPX] = 0x08, + [PHYTIMING_HS_EXIT] = 0x0d, + [PHYTIMING_CLK_PREPARE] = 0x09, + [PHYTIMING_CLK_ZERO] = 0x30, + [PHYTIMING_CLK_POST] = 0x0e, + [PHYTIMING_CLK_TRAIL] = 0x0a, + [PHYTIMING_HS_PREPARE] = 0x0c, + [PHYTIMING_HS_ZERO] = 0x11, + [PHYTIMING_HS_TRAIL] = 0x0d, }; static const unsigned int exynos5433_reg_values[] = { [RESET_TYPE] = DSIM_FUNCRST, [PLL_TIMER] = 22200, [STOP_STATE_CNT] = 0xa, - [PHYCTRL_ULPS_EXIT] = DSIM_PHYCTRL_ULPS_EXIT(0x190), - [PHYCTRL_VREG_LP] = DSIM_PHYCTRL_B_DPHYCTL_VREG_LP, - [PHYCTRL_SLEW_UP] = DSIM_PHYCTRL_B_DPHYCTL_SLEW_UP, - [PHYTIMING_LPX] = DSIM_PHYTIMING_LPX(0x07), - [PHYTIMING_HS_EXIT] = DSIM_PHYTIMING_HS_EXIT(0x0c), - [PHYTIMING_CLK_PREPARE] = DSIM_PHYTIMING1_CLK_PREPARE(0x09), - [PHYTIMING_CLK_ZERO] = DSIM_PHYTIMING1_CLK_ZERO(0x2d), - [PHYTIMING_CLK_POST] = DSIM_PHYTIMING1_CLK_POST(0x0e), - [PHYTIMING_CLK_TRAIL] = DSIM_PHYTIMING1_CLK_TRAIL(0x09), - [PHYTIMING_HS_PREPARE] = DSIM_PHYTIMING2_HS_PREPARE(0x0b), - [PHYTIMING_HS_ZERO] = DSIM_PHYTIMING2_HS_ZERO(0x10), - [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0c), + [PHYCTRL_ULPS_EXIT] = 0x190, + [PHYCTRL_VREG_LP] = 1, + [PHYCTRL_SLEW_UP] = 1, + [PHYTIMING_LPX] = 0x07, + [PHYTIMING_HS_EXIT] = 0x0c, + [PHYTIMING_CLK_PREPARE] = 0x09, + [PHYTIMING_CLK_ZERO] = 0x2d, + [PHYTIMING_CLK_POST] = 0x0e, + [PHYTIMING_CLK_TRAIL] = 0x09, + [PHYTIMING_HS_PREPARE] = 0x0b, + [PHYTIMING_HS_ZERO] = 0x10, + [PHYTIMING_HS_TRAIL] = 0x0c, }; static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { @@ -698,8 +698,11 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi) return; /* B D-PHY: D-PHY Master & Slave Analog Block control */ - reg = reg_values[PHYCTRL_ULPS_EXIT] | reg_values[PHYCTRL_VREG_LP] | - reg_values[PHYCTRL_SLEW_UP]; + reg = DSIM_PHYCTRL_ULPS_EXIT(reg_values[PHYCTRL_ULPS_EXIT]); + if (reg_values[PHYCTRL_VREG_LP]) + reg |= DSIM_PHYCTRL_B_DPHYCTL_VREG_LP; + if (reg_values[PHYCTRL_SLEW_UP]) + reg |= DSIM_PHYCTRL_B_DPHYCTL_SLEW_UP; exynos_dsi_write(dsi, DSIM_PHYCTRL_REG, reg); /* @@ -707,7 +710,8 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi) * T HS-EXIT: Time that the transmitter drives LP-11 following a HS * burst */ - reg = reg_values[PHYTIMING_LPX] | reg_values[PHYTIMING_HS_EXIT]; + reg = DSIM_PHYTIMING_LPX(reg_values[PHYTIMING_LPX]) | + DSIM_PHYTIMING_HS_EXIT(reg_values[PHYTIMING_HS_EXIT]); exynos_dsi_write(dsi, DSIM_PHYTIMING_REG, reg); /* @@ -723,11 +727,10 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi) * T CLK-TRAIL: Time that the transmitter drives the HS-0 state after * the last payload clock bit of a HS transmission burst */ - reg = reg_values[PHYTIMING_CLK_PREPARE] | - reg_values[PHYTIMING_CLK_ZERO] | - reg_values[PHYTIMING_CLK_POST] | - reg_values[PHYTIMING_CLK_TRAIL]; - + reg = DSIM_PHYTIMING1_CLK_PREPARE(reg_values[PHYTIMING_CLK_PREPARE]) | + DSIM_PHYTIMING1_CLK_ZERO(reg_values[PHYTIMING_CLK_ZERO]) | + DSIM_PHYTIMING1_CLK_POST(reg_values[PHYTIMING_CLK_POST]) | + DSIM_PHYTIMING1_CLK_TRAIL(reg_values[PHYTIMING_CLK_TRAIL]); exynos_dsi_write(dsi, DSIM_PHYTIMING1_REG, reg); /* @@ -739,8 +742,9 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi) * T HS-TRAIL: Time that the transmitter drives the flipped differential * state after last payload data bit of a HS transmission burst */ - reg = reg_values[PHYTIMING_HS_PREPARE] | reg_values[PHYTIMING_HS_ZERO] | - reg_values[PHYTIMING_HS_TRAIL]; + reg = DSIM_PHYTIMING2_HS_PREPARE(reg_values[PHYTIMING_HS_PREPARE]) | + DSIM_PHYTIMING2_HS_ZERO(reg_values[PHYTIMING_HS_ZERO]) | + DSIM_PHYTIMING2_HS_TRAIL(reg_values[PHYTIMING_HS_TRAIL]); exynos_dsi_write(dsi, DSIM_PHYTIMING2_REG, reg); } From patchwork Fri Sep 11 13:54:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1D25746 for ; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 915D722276 for ; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 915D722276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 485EC6E34C; Fri, 11 Sep 2020 13:54:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id A72126EA26 for ; Fri, 11 Sep 2020 13:54:20 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wU-46; Fri, 11 Sep 2020 15:54:18 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnh-MM; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:04 +0200 Message-Id: <20200911135413.3654800-8-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.3 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 07/16] drm/exynos: use identifier instead of register offsets X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Different revisions of the MIPI-DSI PHY have slightly different register layouts. Currently, the register layout was stored per platform, which makes it necessary to define the layout for each new platform. Keep the register layout in the driver and use identifiers to specify which register layout shall be used on a platform. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 54 ++++++++++++++++--------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 0f2cac7ed944..1a15ae71205d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -239,8 +239,13 @@ struct exynos_dsi_transfer { #define DSIM_STATE_CMD_LPM BIT(2) #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3) +enum exynos_reg_offset { + EXYNOS_REG_OFS, + EXYNOS5433_REG_OFS +}; + struct exynos_dsi_driver_data { - const unsigned int *reg_ofs; + enum exynos_reg_offset reg_ofs; unsigned int plltmr_reg; unsigned int has_freqband:1; unsigned int has_clklane_stop:1; @@ -317,18 +322,6 @@ enum reg_idx { NUM_REGS }; -static inline void exynos_dsi_write(struct exynos_dsi *dsi, enum reg_idx idx, - u32 val) -{ - - writel(val, dsi->reg_base + dsi->driver_data->reg_ofs[idx]); -} - -static inline u32 exynos_dsi_read(struct exynos_dsi *dsi, enum reg_idx idx) -{ - return readl(dsi->reg_base + dsi->driver_data->reg_ofs[idx]); -} - static const unsigned int exynos_reg_ofs[] = { [DSIM_STATUS_REG] = 0x00, [DSIM_SWRST_REG] = 0x04, @@ -377,6 +370,31 @@ static const unsigned int exynos5433_reg_ofs[] = { [DSIM_PHYTIMING2_REG] = 0xBC, }; +static inline void exynos_dsi_write(struct exynos_dsi *dsi, enum reg_idx idx, + u32 val) +{ + const unsigned int *reg_ofs; + + if (dsi->driver_data->reg_ofs == EXYNOS5433_REG_OFS) + reg_ofs = exynos5433_reg_ofs; + else + reg_ofs = exynos_reg_ofs; + + writel(val, dsi->reg_base + reg_ofs[idx]); +} + +static inline u32 exynos_dsi_read(struct exynos_dsi *dsi, enum reg_idx idx) +{ + const unsigned int *reg_ofs; + + if (dsi->driver_data->reg_ofs == EXYNOS5433_REG_OFS) + reg_ofs = exynos5433_reg_ofs; + else + reg_ofs = exynos_reg_ofs; + + return readl(dsi->reg_base + reg_ofs[idx]); +} + enum reg_value_idx { RESET_TYPE, PLL_TIMER, @@ -450,7 +468,7 @@ static const unsigned int exynos5433_reg_values[] = { }; static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { - .reg_ofs = exynos_reg_ofs, + .reg_ofs = EXYNOS_REG_OFS, .plltmr_reg = 0x50, .has_freqband = 1, .has_clklane_stop = 1, @@ -462,7 +480,7 @@ static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { }; static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { - .reg_ofs = exynos_reg_ofs, + .reg_ofs = EXYNOS_REG_OFS, .plltmr_reg = 0x50, .has_freqband = 1, .has_clklane_stop = 1, @@ -474,7 +492,7 @@ static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { }; static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { - .reg_ofs = exynos_reg_ofs, + .reg_ofs = EXYNOS_REG_OFS, .plltmr_reg = 0x58, .num_clks = 2, .max_freq = 1000, @@ -484,7 +502,7 @@ static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { }; static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { - .reg_ofs = exynos5433_reg_ofs, + .reg_ofs = EXYNOS5433_REG_OFS, .plltmr_reg = 0xa0, .has_clklane_stop = 1, .num_clks = 5, @@ -495,7 +513,7 @@ static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { }; static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = { - .reg_ofs = exynos5433_reg_ofs, + .reg_ofs = EXYNOS5433_REG_OFS, .plltmr_reg = 0xa0, .has_clklane_stop = 1, .num_clks = 2, From patchwork Fri Sep 11 13:54:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06F84112E for ; Fri, 11 Sep 2020 13:54:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB33A22276 for ; Fri, 11 Sep 2020 13:54:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB33A22276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60E176EA62; Fri, 11 Sep 2020 13:54:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53BE06EA58 for ; Fri, 11 Sep 2020 13:54:22 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wV-4I; Fri, 11 Sep 2020 15:54:20 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnk-Mt; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:05 +0200 Message-Id: <20200911135413.3654800-9-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 08/16] drm/exynos: add host_ops callback for platform drivers X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Platform drivers need to be aware if a mipi dsi device attaches or detaches. Add host_ops to the driver_data for attach and detach callbacks and move the i80 mode selection and the hotplug handling into the callback, because these depend on the drm driver. Signed-off-by: Michael Tretter --- v2: - new patch --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 64 ++++++++++++++++++++----- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 1a15ae71205d..684a2fbef08a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -239,6 +239,12 @@ struct exynos_dsi_transfer { #define DSIM_STATE_CMD_LPM BIT(2) #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3) +struct exynos_dsi; +struct exynos_dsi_host_ops { + int (*attach)(struct device *dev, struct mipi_dsi_device *device); + int (*detach)(struct device *dev, struct mipi_dsi_device *device); +}; + enum exynos_reg_offset { EXYNOS_REG_OFS, EXYNOS5433_REG_OFS @@ -254,6 +260,7 @@ struct exynos_dsi_driver_data { unsigned int wait_for_reset; unsigned int num_bits_resol; const unsigned int *reg_values; + const struct exynos_dsi_host_ops *host_ops; }; struct exynos_dsi { @@ -467,6 +474,41 @@ static const unsigned int exynos5433_reg_values[] = { [PHYTIMING_HS_TRAIL] = 0x0c, }; +static int __exynos_dsi_host_attach(struct device *dev, + struct mipi_dsi_device *device) +{ + struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct drm_device *drm = dsi->encoder.dev; + struct exynos_drm_crtc *crtc; + + mutex_lock(&drm->mode_config.mutex); + crtc = exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD); + crtc->i80_mode = !(device->mode_flags & MIPI_DSI_MODE_VIDEO); + mutex_unlock(&drm->mode_config.mutex); + + if (drm->mode_config.poll_enabled) + drm_kms_helper_hotplug_event(drm); + + return 0; +} + +static int __exynos_dsi_host_detach(struct device *dev, + struct mipi_dsi_device *device) +{ + struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct drm_device *drm = dsi->encoder.dev; + + if (drm->mode_config.poll_enabled) + drm_kms_helper_hotplug_event(drm); + + return 0; +} + +static const struct exynos_dsi_host_ops exynos_dsi_host_ops = { + .attach = __exynos_dsi_host_attach, + .detach = __exynos_dsi_host_detach, +}; + static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { .reg_ofs = EXYNOS_REG_OFS, .plltmr_reg = 0x50, @@ -477,6 +519,7 @@ static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { .wait_for_reset = 1, .num_bits_resol = 11, .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { @@ -489,6 +532,7 @@ static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { .wait_for_reset = 1, .num_bits_resol = 11, .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { @@ -499,6 +543,7 @@ static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { .wait_for_reset = 1, .num_bits_resol = 11, .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { @@ -510,6 +555,7 @@ static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { .wait_for_reset = 0, .num_bits_resol = 12, .reg_values = exynos5433_reg_values, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = { @@ -521,6 +567,7 @@ static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = { .wait_for_reset = 1, .num_bits_resol = 12, .reg_values = exynos5422_reg_values, + .host_ops = &exynos_dsi_host_ops, }; static const struct of_device_id exynos_dsi_of_match[] = { @@ -1551,8 +1598,8 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); + const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops; struct drm_encoder *encoder = &dsi->encoder; - struct drm_device *drm = encoder->dev; struct drm_bridge *out_bridge; out_bridge = of_drm_find_bridge(device->dev.of_node); @@ -1590,18 +1637,12 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, return ret; } - mutex_lock(&drm->mode_config.mutex); - dsi->lanes = device->lanes; dsi->format = device->format; dsi->mode_flags = device->mode_flags; - exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD)->i80_mode = - !(dsi->mode_flags & MIPI_DSI_MODE_VIDEO); - mutex_unlock(&drm->mode_config.mutex); - - if (drm->mode_config.poll_enabled) - drm_kms_helper_hotplug_event(drm); + if (ops && ops->attach) + ops->attach(dsi->dsi_host.dev, device); return 0; } @@ -1610,6 +1651,7 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); + const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops; struct drm_device *drm = dsi->encoder.dev; if (dsi->panel) { @@ -1625,8 +1667,8 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, INIT_LIST_HEAD(&dsi->bridge_chain); } - if (drm->mode_config.poll_enabled) - drm_kms_helper_hotplug_event(drm); + if (ops && ops->detach) + ops->detach(dsi->dsi_host.dev, device); exynos_dsi_unregister_te_irq(dsi); From patchwork Fri Sep 11 13:54:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A344746 for ; Fri, 11 Sep 2020 13:54:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEAD422276 for ; Fri, 11 Sep 2020 13:54:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEAD422276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B2486EA5B; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF51A6EA57 for ; Fri, 11 Sep 2020 13:54:20 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wW-47; Fri, 11 Sep 2020 15:54:18 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnn-NO; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:06 +0200 Message-Id: <20200911135413.3654800-10-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.3 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 09/16] drm/exynos: add callback for tearing effect handler X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The tearing effect interrupts are not handled by the MIPI DSI bridge driver, but the display controller driver. Allow platforms to register a callback for the tearing effect interrupt. Signed-off-by: Michael Tretter --- v2: - add handler as callback in host_ops --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 684a2fbef08a..2d75f9877dc0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -243,6 +243,7 @@ struct exynos_dsi; struct exynos_dsi_host_ops { int (*attach)(struct device *dev, struct mipi_dsi_device *device); int (*detach)(struct device *dev, struct mipi_dsi_device *device); + void (*te_handler)(struct device *dev); }; enum exynos_reg_offset { @@ -504,9 +505,17 @@ static int __exynos_dsi_host_detach(struct device *dev, return 0; } +static void __exynos_dsi_te_handler(struct device *dev) +{ + struct exynos_dsi *dsi = dev_get_drvdata(dev); + + exynos_drm_crtc_te_handler(dsi->encoder.crtc); +} + static const struct exynos_dsi_host_ops exynos_dsi_host_ops = { .attach = __exynos_dsi_host_attach, .detach = __exynos_dsi_host_detach, + .te_handler = __exynos_dsi_te_handler, }; static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { @@ -1354,11 +1363,12 @@ static irqreturn_t exynos_dsi_irq(int irq, void *dev_id) static irqreturn_t exynos_dsi_te_irq_handler(int irq, void *dev_id) { - struct exynos_dsi *dsi = (struct exynos_dsi *)dev_id; - struct drm_encoder *encoder = &dsi->encoder; + struct exynos_dsi *dsi = dev_id; + const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops; - if (dsi->state & DSIM_STATE_VIDOUT_AVAILABLE) - exynos_drm_crtc_te_handler(encoder->crtc); + if (ops && ops->te_handler && + (dsi->state & DSIM_STATE_VIDOUT_AVAILABLE)) + ops->te_handler(dsi->dsi_host.dev); return IRQ_HANDLED; } From patchwork Fri Sep 11 13:54:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68A8D112E for ; Fri, 11 Sep 2020 13:54:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AC8522276 for ; Fri, 11 Sep 2020 13:54:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AC8522276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84E9C6EA60; Fri, 11 Sep 2020 13:54:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3148F6EA59 for ; Fri, 11 Sep 2020 13:54:22 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVK-0007wX-4H; Fri, 11 Sep 2020 15:54:20 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnq-Nx; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:07 +0200 Message-Id: <20200911135413.3654800-11-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 10/16] drm/exynos: implement a drm bridge X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make the exynos_dsi driver a full drm bridge that can be found and used from other drivers. Other drivers can only attach to the bridge, if a mipi dsi device already attached to the bridge. This allows to defer the probe of the display pipe until the downstream bridges are available, too. Signed-off-by: Michael Tretter --- v2: - move attach of out_bridge to bridge_attach - add bridge_detach - don't cleanup encoder if create_connector failed --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 103 +++++++++++++++++------- 1 file changed, 75 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 2d75f9877dc0..5e7c1a99a3ee 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -266,6 +266,7 @@ struct exynos_dsi_driver_data { struct exynos_dsi { struct drm_encoder encoder; + struct drm_bridge bridge; struct mipi_dsi_host dsi_host; struct drm_connector connector; struct drm_panel *panel; @@ -1602,6 +1603,60 @@ static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { .disable = exynos_dsi_disable, }; +static int exynos_dsi_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct exynos_dsi *dsi = bridge->driver_private; + struct drm_encoder *encoder = bridge->encoder; + int ret; + + if (!dsi->out_bridge && !dsi->panel) + return -EPROBE_DEFER; + + if (dsi->out_bridge) { + ret = drm_bridge_attach(encoder, dsi->out_bridge, + bridge, flags); + if (ret) + return ret; + list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); + } else { + ret = exynos_dsi_create_connector(encoder); + if (ret) + return ret; + + if (dsi->panel) { + dsi->connector.status = connector_status_connected; + } + } + + return 0; +} + +static void exynos_dsi_bridge_detach(struct drm_bridge *bridge) +{ + struct exynos_dsi *dsi = bridge->driver_private; + struct drm_encoder *encoder = bridge->encoder; + struct drm_device *drm = encoder->dev; + + if (dsi->panel) { + mutex_lock(&drm->mode_config.mutex); + exynos_dsi_disable(&dsi->encoder); + dsi->panel = NULL; + dsi->connector.status = connector_status_disconnected; + mutex_unlock(&drm->mode_config.mutex); + } else { + if (dsi->out_bridge->funcs->detach) + dsi->out_bridge->funcs->detach(dsi->out_bridge); + dsi->out_bridge = NULL; + INIT_LIST_HEAD(&dsi->bridge_chain); + } +} + +static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { + .attach = exynos_dsi_bridge_attach, + .detach = exynos_dsi_bridge_detach, +}; + MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); static int exynos_dsi_host_attach(struct mipi_dsi_host *host, @@ -1609,25 +1664,12 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, { struct exynos_dsi *dsi = host_to_dsi(host); const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops; - struct drm_encoder *encoder = &dsi->encoder; struct drm_bridge *out_bridge; - out_bridge = of_drm_find_bridge(device->dev.of_node); + out_bridge = of_drm_find_bridge(device->dev.of_node); if (out_bridge) { - drm_bridge_attach(encoder, out_bridge, NULL, 0); dsi->out_bridge = out_bridge; - list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); } else { - int ret = exynos_dsi_create_connector(encoder); - - if (ret) { - DRM_DEV_ERROR(dsi->dev, - "failed to create connector ret = %d\n", - ret); - drm_encoder_cleanup(encoder); - return ret; - } - dsi->panel = of_drm_find_panel(device->dev.of_node); if (IS_ERR(dsi->panel)) dsi->panel = NULL; @@ -1662,20 +1704,6 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, { struct exynos_dsi *dsi = host_to_dsi(host); const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops; - struct drm_device *drm = dsi->encoder.dev; - - if (dsi->panel) { - mutex_lock(&drm->mode_config.mutex); - exynos_dsi_disable(&dsi->encoder); - dsi->panel = NULL; - dsi->connector.status = connector_status_disconnected; - mutex_unlock(&drm->mode_config.mutex); - } else { - if (dsi->out_bridge->funcs->detach) - dsi->out_bridge->funcs->detach(dsi->out_bridge); - dsi->out_bridge = NULL; - INIT_LIST_HEAD(&dsi->bridge_chain); - } if (ops && ops->detach) ops->detach(dsi->dsi_host.dev, device); @@ -1786,7 +1814,15 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, of_node_put(in_bridge_node); } + ret = drm_bridge_attach(encoder, &dsi->bridge, in_bridge, 0); + if (ret) + goto err; + return 0; + +err: + drm_encoder_cleanup(encoder); + return ret; } static void exynos_dsi_unbind(struct device *dev, struct device *master, @@ -1796,6 +1832,8 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, struct drm_encoder *encoder = &dsi->encoder; exynos_dsi_disable(encoder); + + drm_encoder_cleanup(encoder); } static const struct component_ops exynos_dsi_component_ops = { @@ -1806,6 +1844,7 @@ static const struct component_ops exynos_dsi_component_ops = { static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct drm_bridge *bridge; struct resource *res; struct exynos_dsi *dsi; int ret, i; @@ -1894,11 +1933,19 @@ static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) if (ret) return ERR_PTR(ret); + bridge = &dsi->bridge; + bridge->driver_private = dsi; + bridge->funcs = &exynos_dsi_bridge_funcs; + bridge->of_node = dev->of_node; + drm_bridge_add(bridge); + return dsi; } static void __exynos_dsi_remove(struct exynos_dsi *dsi) { + drm_bridge_remove(&dsi->bridge); + mipi_dsi_host_unregister(&dsi->dsi_host); } From patchwork Fri Sep 11 13:54:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04F0D112E for ; Fri, 11 Sep 2020 13:54:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA6DE22276 for ; Fri, 11 Sep 2020 13:54:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA6DE22276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 080406EA59; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D05C6EA58 for ; Fri, 11 Sep 2020 13:54:24 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wY-Ql; Fri, 11 Sep 2020 15:54:22 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnt-OQ; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:08 +0200 Message-Id: <20200911135413.3654800-12-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 11/16] drm/exynos: convert encoder functions to bridge function X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If other drivers use the exynos_dsi driver as a bridge, they might bring their own encoder. Enable and disable the MIPI-DSI bridge using the bridge functions instead of the encoder functions. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 33 +++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 5e7c1a99a3ee..a4f17d50d1d8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1455,9 +1455,8 @@ static void exynos_dsi_unregister_te_irq(struct exynos_dsi *dsi) } } -static void exynos_dsi_enable(struct drm_encoder *encoder) +static void exynos_dsi_enable(struct exynos_dsi *dsi) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); struct drm_bridge *iter; int ret; @@ -1505,9 +1504,8 @@ static void exynos_dsi_enable(struct drm_encoder *encoder) pm_runtime_put(dsi->dev); } -static void exynos_dsi_disable(struct drm_encoder *encoder) +static void exynos_dsi_disable(struct exynos_dsi *dsi) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); struct drm_bridge *iter; if (!(dsi->state & DSIM_STATE_ENABLED)) @@ -1598,11 +1596,6 @@ static int exynos_dsi_create_connector(struct drm_encoder *encoder) return 0; } -static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { - .enable = exynos_dsi_enable, - .disable = exynos_dsi_disable, -}; - static int exynos_dsi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -1640,7 +1633,7 @@ static void exynos_dsi_bridge_detach(struct drm_bridge *bridge) if (dsi->panel) { mutex_lock(&drm->mode_config.mutex); - exynos_dsi_disable(&dsi->encoder); + exynos_dsi_disable(dsi); dsi->panel = NULL; dsi->connector.status = connector_status_disconnected; mutex_unlock(&drm->mode_config.mutex); @@ -1652,9 +1645,25 @@ static void exynos_dsi_bridge_detach(struct drm_bridge *bridge) } } +static void exynos_dsi_bridge_enable(struct drm_bridge *bridge) +{ + struct exynos_dsi *dsi = bridge->driver_private; + + exynos_dsi_enable(dsi); +} + +static void exynos_dsi_bridge_disable(struct drm_bridge *bridge) +{ + struct exynos_dsi *dsi = bridge->driver_private; + + exynos_dsi_disable(dsi); +} + static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { .attach = exynos_dsi_bridge_attach, .detach = exynos_dsi_bridge_detach, + .enable = exynos_dsi_bridge_enable, + .disable = exynos_dsi_bridge_disable, }; MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); @@ -1800,8 +1809,6 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS); - drm_encoder_helper_add(encoder, &exynos_dsi_encoder_helper_funcs); - ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD); if (ret < 0) return ret; @@ -1831,7 +1838,7 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, struct exynos_dsi *dsi = dev_get_drvdata(dev); struct drm_encoder *encoder = &dsi->encoder; - exynos_dsi_disable(encoder); + exynos_dsi_disable(dsi); drm_encoder_cleanup(encoder); } From patchwork Fri Sep 11 13:54:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAD2B112E for ; Fri, 11 Sep 2020 13:54:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A103922276 for ; Fri, 11 Sep 2020 13:54:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A103922276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E03A6EA68; Fri, 11 Sep 2020 13:54:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35D5B6EA57 for ; Fri, 11 Sep 2020 13:54:24 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wZ-R3; Fri, 11 Sep 2020 15:54:22 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnw-Ot; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:09 +0200 Message-Id: <20200911135413.3654800-13-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 12/16] drm/exynos: configure mode on drm bridge X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver uses the encoder to get the mode that shall be configured. This is not possible, if the driver is used as a bridge, because the encoder might not be used. Use the mode_set function to set the display mode. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index a4f17d50d1d8..988447812333 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -288,6 +288,8 @@ struct exynos_dsi { u32 mode_flags; u32 format; + struct drm_display_mode mode; + int state; struct drm_property *brightness; struct completion completed; @@ -961,7 +963,7 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi) static void exynos_dsi_set_display_mode(struct exynos_dsi *dsi) { - struct drm_display_mode *m = &dsi->encoder.crtc->state->adjusted_mode; + struct drm_display_mode *m = &dsi->mode; unsigned int num_bits_resol = dsi->driver_data->num_bits_resol; u32 reg; @@ -1659,11 +1661,22 @@ static void exynos_dsi_bridge_disable(struct drm_bridge *bridge) exynos_dsi_disable(dsi); } +static void exynos_dsi_bridge_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + const struct drm_display_mode *adjusted_mode) +{ + struct exynos_dsi *dsi = bridge->driver_private; + + /* The mode is set when actually enabling the device. */ + drm_mode_copy(&dsi->mode, adjusted_mode); +} + static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { .attach = exynos_dsi_bridge_attach, .detach = exynos_dsi_bridge_detach, .enable = exynos_dsi_bridge_enable, .disable = exynos_dsi_bridge_disable, + .mode_set = exynos_dsi_bridge_mode_set, }; MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); From patchwork Fri Sep 11 13:54:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFB87746 for ; Fri, 11 Sep 2020 13:54:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3DCB22276 for ; Fri, 11 Sep 2020 13:54:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3DCB22276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84D9B6EA57; Fri, 11 Sep 2020 13:54:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 686736EA57 for ; Fri, 11 Sep 2020 13:54:24 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wa-RF; Fri, 11 Sep 2020 15:54:22 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKnz-PN; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:10 +0200 Message-Id: <20200911135413.3654800-14-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 13/16] drm/exynos: get encoder from bridge whenever possible X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The bridge will not necessarily use the encoder of struct exynos_dsi, but might use another encoder from another drm driver. Therefore, the driver has to use the encoder from the bridge instead of the one from exynos_dsi. In the future, the struct exynos_dsi will not have an encoder at all. Signed-off-by: Michael Tretter --- v2: - add removal of encoder_to_dsi --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 988447812333..b9216785b2d7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -303,11 +303,6 @@ struct exynos_dsi { #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) #define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector) -static inline struct exynos_dsi *encoder_to_dsi(struct drm_encoder *e) -{ - return container_of(e, struct exynos_dsi, encoder); -} - enum reg_idx { DSIM_STATUS_REG, /* Status register */ DSIM_SWRST_REG, /* Software reset register */ @@ -1570,11 +1565,10 @@ static const struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs .get_modes = exynos_dsi_get_modes, }; -static int exynos_dsi_create_connector(struct drm_encoder *encoder) +static int exynos_dsi_create_connector(struct exynos_dsi *dsi) { - struct exynos_dsi *dsi = encoder_to_dsi(encoder); struct drm_connector *connector = &dsi->connector; - struct drm_device *drm = encoder->dev; + struct drm_device *drm = dsi->bridge.dev; int ret; connector->polled = DRM_CONNECTOR_POLL_HPD; @@ -1589,7 +1583,7 @@ static int exynos_dsi_create_connector(struct drm_encoder *encoder) connector->status = connector_status_disconnected; drm_connector_helper_add(connector, &exynos_dsi_connector_helper_funcs); - drm_connector_attach_encoder(connector, encoder); + drm_connector_attach_encoder(connector, dsi->bridge.encoder); if (!drm->registered) return 0; @@ -1615,7 +1609,7 @@ static int exynos_dsi_bridge_attach(struct drm_bridge *bridge, return ret; list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); } else { - ret = exynos_dsi_create_connector(encoder); + ret = exynos_dsi_create_connector(dsi); if (ret) return ret; From patchwork Fri Sep 11 13:54:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD4A4746 for ; Fri, 11 Sep 2020 13:54:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93B4422276 for ; Fri, 11 Sep 2020 13:54:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93B4422276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD7A36EA61; Fri, 11 Sep 2020 13:54:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id E61C36EA58 for ; Fri, 11 Sep 2020 13:54:24 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wb-RG; Fri, 11 Sep 2020 15:54:23 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKo2-Pu; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:11 +0200 Message-Id: <20200911135413.3654800-15-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 14/16] drm/exynos: add API functions for platform drivers X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add new functions for the probe/remove API, the bind/unbind API and resume/suspend calls. Move everything exynos drm specific into separate functions, which can easily be moved to other files. Also split struct exynos_dsi into a generic and a platform specific struct. Signed-off-by: Michael Tretter --- v2: - new patch --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 114 +++++++++++++++++------- 1 file changed, 82 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index b9216785b2d7..ad70f5ce81ad 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -265,7 +265,6 @@ struct exynos_dsi_driver_data { }; struct exynos_dsi { - struct drm_encoder encoder; struct drm_bridge bridge; struct mipi_dsi_host dsi_host; struct drm_connector connector; @@ -419,6 +418,11 @@ enum reg_value_idx { PHYTIMING_HS_TRAIL }; +struct exynos_dsi_pltfm { + struct exynos_dsi *dsi; + struct drm_encoder encoder; +}; + static const unsigned int reg_values[] = { [RESET_TYPE] = DSIM_SWRST, [PLL_TIMER] = 500, @@ -476,7 +480,7 @@ static const unsigned int exynos5433_reg_values[] = { static int __exynos_dsi_host_attach(struct device *dev, struct mipi_dsi_device *device) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); struct drm_device *drm = dsi->encoder.dev; struct exynos_drm_crtc *crtc; @@ -494,7 +498,7 @@ static int __exynos_dsi_host_attach(struct device *dev, static int __exynos_dsi_host_detach(struct device *dev, struct mipi_dsi_device *device) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); struct drm_device *drm = dsi->encoder.dev; if (drm->mode_config.poll_enabled) @@ -505,7 +509,7 @@ static int __exynos_dsi_host_detach(struct device *dev, static void __exynos_dsi_te_handler(struct device *dev) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); exynos_drm_crtc_te_handler(dsi->encoder.crtc); } @@ -1804,10 +1808,12 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) return 0; } -static int exynos_dsi_bind(struct device *dev, struct device *master, - void *data) +static int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder); +static void exynos_dsi_unbind(struct exynos_dsi *dsi); + +static int exynos_dsi_pltfm_bind(struct device *dev, struct device *master, void *data) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); struct drm_encoder *encoder = &dsi->encoder; struct drm_device *drm_dev = data; struct device_node *in_bridge_node; @@ -1828,7 +1834,7 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, of_node_put(in_bridge_node); } - ret = drm_bridge_attach(encoder, &dsi->bridge, in_bridge, 0); + ret = exynos_dsi_bind(dsi->dsi, encoder); if (ret) goto err; @@ -1839,20 +1845,20 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, return ret; } -static void exynos_dsi_unbind(struct device *dev, struct device *master, - void *data) +static void exynos_dsi_pltfm_unbind(struct device *dev, struct device *master, + void *data) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); struct drm_encoder *encoder = &dsi->encoder; - exynos_dsi_disable(dsi); + exynos_dsi_unbind(dsi->dsi); drm_encoder_cleanup(encoder); } -static const struct component_ops exynos_dsi_component_ops = { - .bind = exynos_dsi_bind, - .unbind = exynos_dsi_unbind, +static const struct component_ops exynos_dsi_pltfm_component_ops = { + .bind = exynos_dsi_pltfm_bind, + .unbind = exynos_dsi_pltfm_unbind, }; static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) @@ -1963,20 +1969,52 @@ static void __exynos_dsi_remove(struct exynos_dsi *dsi) mipi_dsi_host_unregister(&dsi->dsi_host); } -static int exynos_dsi_probe(struct platform_device *pdev) +/* + * Probe/remove API, used from platforms based on the DRM bridge API. + */ +static struct exynos_dsi *exynos_dsi_probe(struct platform_device *pdev) { - struct exynos_dsi *dsi; + return __exynos_dsi_probe(pdev); +} + +static void exynos_dsi_remove(struct exynos_dsi *dsi) +{ + return __exynos_dsi_remove(dsi); +} + +/* + * Bind/unbind API, used from platforms based on the component framework. + */ +static int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder) +{ + struct drm_bridge *previous = drm_bridge_chain_get_first_bridge(encoder); + + return drm_bridge_attach(encoder, &dsi->bridge, previous, 0); +} + +static void exynos_dsi_unbind(struct exynos_dsi *dsi) +{ + exynos_dsi_disable(dsi); +} + +static int exynos_dsi_pltfm_probe(struct platform_device *pdev) +{ + struct exynos_dsi_pltfm *dsi; struct device *dev = &pdev->dev; int ret; - dsi = __exynos_dsi_probe(pdev); - if (IS_ERR(dsi)) - return PTR_ERR(dsi); + dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); + if (!dsi) + return -ENOMEM; platform_set_drvdata(pdev, dsi); + dsi->dsi = exynos_dsi_probe(pdev); + if (IS_ERR(dsi->dsi)) + return PTR_ERR(dsi->dsi); + pm_runtime_enable(dev); - ret = component_add(dev, &exynos_dsi_component_ops); + ret = component_add(dev, &exynos_dsi_pltfm_component_ops); if (ret) goto err_disable_runtime; @@ -1988,22 +2026,21 @@ static int exynos_dsi_probe(struct platform_device *pdev) return ret; } -static int exynos_dsi_remove(struct platform_device *pdev) +static int exynos_dsi_pltfm_remove(struct platform_device *pdev) { - struct exynos_dsi *dsi = platform_get_drvdata(pdev); + struct exynos_dsi_pltfm *dsi = platform_get_drvdata(pdev); pm_runtime_disable(&pdev->dev); - __exynos_dsi_remove(dsi); + exynos_dsi_remove(dsi->dsi); - component_del(&pdev->dev, &exynos_dsi_component_ops); + component_del(&pdev->dev, &exynos_dsi_pltfm_component_ops); return 0; } -static int __maybe_unused exynos_dsi_suspend(struct device *dev) +static int exynos_dsi_suspend(struct exynos_dsi *dsi) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; @@ -2031,9 +2068,8 @@ static int __maybe_unused exynos_dsi_suspend(struct device *dev) return 0; } -static int __maybe_unused exynos_dsi_resume(struct device *dev) +static int exynos_dsi_resume(struct exynos_dsi *dsi) { - struct exynos_dsi *dsi = dev_get_drvdata(dev); const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; @@ -2065,15 +2101,29 @@ static int __maybe_unused exynos_dsi_resume(struct device *dev) return ret; } +static int __maybe_unused exynos_dsi_pltfm_suspend(struct device *dev) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + + return exynos_dsi_suspend(dsi->dsi); +} + +static int __maybe_unused exynos_dsi_pltfm_resume(struct device *dev) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + + return exynos_dsi_resume(dsi->dsi); +} + static const struct dev_pm_ops exynos_dsi_pm_ops = { - SET_RUNTIME_PM_OPS(exynos_dsi_suspend, exynos_dsi_resume, NULL) + SET_RUNTIME_PM_OPS(exynos_dsi_pltfm_suspend, exynos_dsi_pltfm_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) }; struct platform_driver dsi_driver = { - .probe = exynos_dsi_probe, - .remove = exynos_dsi_remove, + .probe = exynos_dsi_pltfm_probe, + .remove = exynos_dsi_pltfm_remove, .driver = { .name = "exynos-dsi", .owner = THIS_MODULE, From patchwork Fri Sep 11 13:54:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBB2A112E for ; Fri, 11 Sep 2020 13:54:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B92C922276 for ; Fri, 11 Sep 2020 13:54:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B92C922276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A24E6EA6B; Fri, 11 Sep 2020 13:54:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FD556EA57 for ; Fri, 11 Sep 2020 13:54:25 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wc-Qz; Fri, 11 Sep 2020 15:54:24 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKo5-QP; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:12 +0200 Message-Id: <20200911135413.3654800-16-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 15/16] drm/exynos: split out platform specific code X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Split the driver into the drm bridge driver and the exynos platform specific driver. Signed-off-by: Michael Tretter --- v2: none --- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 372 +----------------- drivers/gpu/drm/exynos/exynos_drm_dsi.h | 64 +++ drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c | 333 ++++++++++++++++ 4 files changed, 405 insertions(+), 366 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_dsi.h create mode 100644 drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile index 2fd2f3ee4fcf..add70b336935 100644 --- a/drivers/gpu/drm/exynos/Makefile +++ b/drivers/gpu/drm/exynos/Makefile @@ -11,7 +11,7 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON) += exynos7_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS_DPI) += exynos_drm_dpi.o -exynosdrm-$(CONFIG_DRM_EXYNOS_DSI) += exynos_drm_dsi.o +exynosdrm-$(CONFIG_DRM_EXYNOS_DSI) += exynos_drm_dsi.o exynos_drm_dsi_pltfm.o exynosdrm-$(CONFIG_DRM_EXYNOS_DP) += exynos_dp.o exynosdrm-$(CONFIG_DRM_EXYNOS_MIXER) += exynos_mixer.o exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI) += exynos_hdmi.o diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index ad70f5ce81ad..e8aea9d90c34 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -32,8 +32,7 @@ #include #include -#include "exynos_drm_crtc.h" -#include "exynos_drm_drv.h" +#include "exynos_drm_dsi.h" /* returns true iff both arguments logically differs */ #define NEQV(a, b) (!(a) ^ !(b)) @@ -44,10 +43,6 @@ #define DSIM_TX_READY_HS_CLK (1 << 10) #define DSIM_PLL_STABLE (1 << 31) -/* DSIM_SWRST */ -#define DSIM_FUNCRST (1 << 16) -#define DSIM_SWRST (1 << 0) - /* DSIM_TIMEOUT */ #define DSIM_LPDR_TIMEOUT(x) ((x) << 0) #define DSIM_BTA_TIMEOUT(x) ((x) << 16) @@ -239,31 +234,6 @@ struct exynos_dsi_transfer { #define DSIM_STATE_CMD_LPM BIT(2) #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3) -struct exynos_dsi; -struct exynos_dsi_host_ops { - int (*attach)(struct device *dev, struct mipi_dsi_device *device); - int (*detach)(struct device *dev, struct mipi_dsi_device *device); - void (*te_handler)(struct device *dev); -}; - -enum exynos_reg_offset { - EXYNOS_REG_OFS, - EXYNOS5433_REG_OFS -}; - -struct exynos_dsi_driver_data { - enum exynos_reg_offset reg_ofs; - unsigned int plltmr_reg; - unsigned int has_freqband:1; - unsigned int has_clklane_stop:1; - unsigned int num_clks; - unsigned int max_freq; - unsigned int wait_for_reset; - unsigned int num_bits_resol; - const unsigned int *reg_values; - const struct exynos_dsi_host_ops *host_ops; -}; - struct exynos_dsi { struct drm_bridge bridge; struct mipi_dsi_host dsi_host; @@ -400,201 +370,6 @@ static inline u32 exynos_dsi_read(struct exynos_dsi *dsi, enum reg_idx idx) return readl(dsi->reg_base + reg_ofs[idx]); } -enum reg_value_idx { - RESET_TYPE, - PLL_TIMER, - STOP_STATE_CNT, - PHYCTRL_ULPS_EXIT, - PHYCTRL_VREG_LP, - PHYCTRL_SLEW_UP, - PHYTIMING_LPX, - PHYTIMING_HS_EXIT, - PHYTIMING_CLK_PREPARE, - PHYTIMING_CLK_ZERO, - PHYTIMING_CLK_POST, - PHYTIMING_CLK_TRAIL, - PHYTIMING_HS_PREPARE, - PHYTIMING_HS_ZERO, - PHYTIMING_HS_TRAIL -}; - -struct exynos_dsi_pltfm { - struct exynos_dsi *dsi; - struct drm_encoder encoder; -}; - -static const unsigned int reg_values[] = { - [RESET_TYPE] = DSIM_SWRST, - [PLL_TIMER] = 500, - [STOP_STATE_CNT] = 0xf, - [PHYCTRL_ULPS_EXIT] = 0x0af, - [PHYCTRL_VREG_LP] = 0, - [PHYCTRL_SLEW_UP] = 0, - [PHYTIMING_LPX] = 0x06, - [PHYTIMING_HS_EXIT] = 0x0b, - [PHYTIMING_CLK_PREPARE] = 0x07, - [PHYTIMING_CLK_ZERO] = 0x27, - [PHYTIMING_CLK_POST] = 0x0d, - [PHYTIMING_CLK_TRAIL] = 0x08, - [PHYTIMING_HS_PREPARE] = 0x09, - [PHYTIMING_HS_ZERO] = 0x0d, - [PHYTIMING_HS_TRAIL] = 0x0b, -}; - -static const unsigned int exynos5422_reg_values[] = { - [RESET_TYPE] = DSIM_SWRST, - [PLL_TIMER] = 500, - [STOP_STATE_CNT] = 0xf, - [PHYCTRL_ULPS_EXIT] = 0xaf, - [PHYCTRL_VREG_LP] = 0, - [PHYCTRL_SLEW_UP] = 0, - [PHYTIMING_LPX] = 0x08, - [PHYTIMING_HS_EXIT] = 0x0d, - [PHYTIMING_CLK_PREPARE] = 0x09, - [PHYTIMING_CLK_ZERO] = 0x30, - [PHYTIMING_CLK_POST] = 0x0e, - [PHYTIMING_CLK_TRAIL] = 0x0a, - [PHYTIMING_HS_PREPARE] = 0x0c, - [PHYTIMING_HS_ZERO] = 0x11, - [PHYTIMING_HS_TRAIL] = 0x0d, -}; - -static const unsigned int exynos5433_reg_values[] = { - [RESET_TYPE] = DSIM_FUNCRST, - [PLL_TIMER] = 22200, - [STOP_STATE_CNT] = 0xa, - [PHYCTRL_ULPS_EXIT] = 0x190, - [PHYCTRL_VREG_LP] = 1, - [PHYCTRL_SLEW_UP] = 1, - [PHYTIMING_LPX] = 0x07, - [PHYTIMING_HS_EXIT] = 0x0c, - [PHYTIMING_CLK_PREPARE] = 0x09, - [PHYTIMING_CLK_ZERO] = 0x2d, - [PHYTIMING_CLK_POST] = 0x0e, - [PHYTIMING_CLK_TRAIL] = 0x09, - [PHYTIMING_HS_PREPARE] = 0x0b, - [PHYTIMING_HS_ZERO] = 0x10, - [PHYTIMING_HS_TRAIL] = 0x0c, -}; - -static int __exynos_dsi_host_attach(struct device *dev, - struct mipi_dsi_device *device) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - struct drm_device *drm = dsi->encoder.dev; - struct exynos_drm_crtc *crtc; - - mutex_lock(&drm->mode_config.mutex); - crtc = exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD); - crtc->i80_mode = !(device->mode_flags & MIPI_DSI_MODE_VIDEO); - mutex_unlock(&drm->mode_config.mutex); - - if (drm->mode_config.poll_enabled) - drm_kms_helper_hotplug_event(drm); - - return 0; -} - -static int __exynos_dsi_host_detach(struct device *dev, - struct mipi_dsi_device *device) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - struct drm_device *drm = dsi->encoder.dev; - - if (drm->mode_config.poll_enabled) - drm_kms_helper_hotplug_event(drm); - - return 0; -} - -static void __exynos_dsi_te_handler(struct device *dev) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - - exynos_drm_crtc_te_handler(dsi->encoder.crtc); -} - -static const struct exynos_dsi_host_ops exynos_dsi_host_ops = { - .attach = __exynos_dsi_host_attach, - .detach = __exynos_dsi_host_detach, - .te_handler = __exynos_dsi_te_handler, -}; - -static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { - .reg_ofs = EXYNOS_REG_OFS, - .plltmr_reg = 0x50, - .has_freqband = 1, - .has_clklane_stop = 1, - .num_clks = 2, - .max_freq = 1000, - .wait_for_reset = 1, - .num_bits_resol = 11, - .reg_values = reg_values, - .host_ops = &exynos_dsi_host_ops, -}; - -static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { - .reg_ofs = EXYNOS_REG_OFS, - .plltmr_reg = 0x50, - .has_freqband = 1, - .has_clklane_stop = 1, - .num_clks = 2, - .max_freq = 1000, - .wait_for_reset = 1, - .num_bits_resol = 11, - .reg_values = reg_values, - .host_ops = &exynos_dsi_host_ops, -}; - -static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { - .reg_ofs = EXYNOS_REG_OFS, - .plltmr_reg = 0x58, - .num_clks = 2, - .max_freq = 1000, - .wait_for_reset = 1, - .num_bits_resol = 11, - .reg_values = reg_values, - .host_ops = &exynos_dsi_host_ops, -}; - -static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { - .reg_ofs = EXYNOS5433_REG_OFS, - .plltmr_reg = 0xa0, - .has_clklane_stop = 1, - .num_clks = 5, - .max_freq = 1500, - .wait_for_reset = 0, - .num_bits_resol = 12, - .reg_values = exynos5433_reg_values, - .host_ops = &exynos_dsi_host_ops, -}; - -static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = { - .reg_ofs = EXYNOS5433_REG_OFS, - .plltmr_reg = 0xa0, - .has_clklane_stop = 1, - .num_clks = 2, - .max_freq = 1500, - .wait_for_reset = 1, - .num_bits_resol = 12, - .reg_values = exynos5422_reg_values, - .host_ops = &exynos_dsi_host_ops, -}; - -static const struct of_device_id exynos_dsi_of_match[] = { - { .compatible = "samsung,exynos3250-mipi-dsi", - .data = &exynos3_dsi_driver_data }, - { .compatible = "samsung,exynos4210-mipi-dsi", - .data = &exynos4_dsi_driver_data }, - { .compatible = "samsung,exynos5410-mipi-dsi", - .data = &exynos5_dsi_driver_data }, - { .compatible = "samsung,exynos5422-mipi-dsi", - .data = &exynos5422_dsi_driver_data }, - { .compatible = "samsung,exynos5433-mipi-dsi", - .data = &exynos5433_dsi_driver_data }, - { } -}; - static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi) { if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300))) @@ -1677,8 +1452,6 @@ static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { .mode_set = exynos_dsi_bridge_mode_set, }; -MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); - static int exynos_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { @@ -1779,11 +1552,6 @@ static int exynos_dsi_of_read_u32(const struct device_node *np, return ret; } -enum { - DSI_PORT_IN, - DSI_PORT_OUT -}; - static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) { struct device *dev = dsi->dev; @@ -1808,59 +1576,6 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) return 0; } -static int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder); -static void exynos_dsi_unbind(struct exynos_dsi *dsi); - -static int exynos_dsi_pltfm_bind(struct device *dev, struct device *master, void *data) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - struct drm_encoder *encoder = &dsi->encoder; - struct drm_device *drm_dev = data; - struct device_node *in_bridge_node; - struct drm_bridge *in_bridge; - int ret; - - drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS); - - ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD); - if (ret < 0) - return ret; - - in_bridge_node = of_graph_get_remote_node(dev->of_node, DSI_PORT_IN, 0); - if (in_bridge_node) { - in_bridge = of_drm_find_bridge(in_bridge_node); - if (in_bridge) - drm_bridge_attach(encoder, in_bridge, NULL, 0); - of_node_put(in_bridge_node); - } - - ret = exynos_dsi_bind(dsi->dsi, encoder); - if (ret) - goto err; - - return 0; - -err: - drm_encoder_cleanup(encoder); - return ret; -} - -static void exynos_dsi_pltfm_unbind(struct device *dev, struct device *master, - void *data) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - struct drm_encoder *encoder = &dsi->encoder; - - exynos_dsi_unbind(dsi->dsi); - - drm_encoder_cleanup(encoder); -} - -static const struct component_ops exynos_dsi_pltfm_component_ops = { - .bind = exynos_dsi_pltfm_bind, - .unbind = exynos_dsi_pltfm_unbind, -}; - static struct exynos_dsi *__exynos_dsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1972,12 +1687,12 @@ static void __exynos_dsi_remove(struct exynos_dsi *dsi) /* * Probe/remove API, used from platforms based on the DRM bridge API. */ -static struct exynos_dsi *exynos_dsi_probe(struct platform_device *pdev) +struct exynos_dsi *exynos_dsi_probe(struct platform_device *pdev) { return __exynos_dsi_probe(pdev); } -static void exynos_dsi_remove(struct exynos_dsi *dsi) +void exynos_dsi_remove(struct exynos_dsi *dsi) { return __exynos_dsi_remove(dsi); } @@ -1985,61 +1700,19 @@ static void exynos_dsi_remove(struct exynos_dsi *dsi) /* * Bind/unbind API, used from platforms based on the component framework. */ -static int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder) +int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder) { struct drm_bridge *previous = drm_bridge_chain_get_first_bridge(encoder); return drm_bridge_attach(encoder, &dsi->bridge, previous, 0); } -static void exynos_dsi_unbind(struct exynos_dsi *dsi) +void exynos_dsi_unbind(struct exynos_dsi *dsi) { exynos_dsi_disable(dsi); } -static int exynos_dsi_pltfm_probe(struct platform_device *pdev) -{ - struct exynos_dsi_pltfm *dsi; - struct device *dev = &pdev->dev; - int ret; - - dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); - if (!dsi) - return -ENOMEM; - platform_set_drvdata(pdev, dsi); - - dsi->dsi = exynos_dsi_probe(pdev); - if (IS_ERR(dsi->dsi)) - return PTR_ERR(dsi->dsi); - - pm_runtime_enable(dev); - - ret = component_add(dev, &exynos_dsi_pltfm_component_ops); - if (ret) - goto err_disable_runtime; - - return 0; - -err_disable_runtime: - pm_runtime_disable(dev); - - return ret; -} - -static int exynos_dsi_pltfm_remove(struct platform_device *pdev) -{ - struct exynos_dsi_pltfm *dsi = platform_get_drvdata(pdev); - - pm_runtime_disable(&pdev->dev); - - exynos_dsi_remove(dsi->dsi); - - component_del(&pdev->dev, &exynos_dsi_pltfm_component_ops); - - return 0; -} - -static int exynos_dsi_suspend(struct exynos_dsi *dsi) +int exynos_dsi_suspend(struct exynos_dsi *dsi) { const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; @@ -2068,7 +1741,7 @@ static int exynos_dsi_suspend(struct exynos_dsi *dsi) return 0; } -static int exynos_dsi_resume(struct exynos_dsi *dsi) +int exynos_dsi_resume(struct exynos_dsi *dsi) { const struct exynos_dsi_driver_data *driver_data = dsi->driver_data; int ret, i; @@ -2101,37 +1774,6 @@ static int exynos_dsi_resume(struct exynos_dsi *dsi) return ret; } -static int __maybe_unused exynos_dsi_pltfm_suspend(struct device *dev) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - - return exynos_dsi_suspend(dsi->dsi); -} - -static int __maybe_unused exynos_dsi_pltfm_resume(struct device *dev) -{ - struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); - - return exynos_dsi_resume(dsi->dsi); -} - -static const struct dev_pm_ops exynos_dsi_pm_ops = { - SET_RUNTIME_PM_OPS(exynos_dsi_pltfm_suspend, exynos_dsi_pltfm_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) -}; - -struct platform_driver dsi_driver = { - .probe = exynos_dsi_pltfm_probe, - .remove = exynos_dsi_pltfm_remove, - .driver = { - .name = "exynos-dsi", - .owner = THIS_MODULE, - .pm = &exynos_dsi_pm_ops, - .of_match_table = exynos_dsi_of_match, - }, -}; - MODULE_AUTHOR("Tomasz Figa "); MODULE_AUTHOR("Andrzej Hajda "); MODULE_DESCRIPTION("Samsung SoC MIPI DSI Master"); diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.h b/drivers/gpu/drm/exynos/exynos_drm_dsi.h new file mode 100644 index 000000000000..8fa3276889de --- /dev/null +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __EXYNOS_DRM_DSI__ +#define __EXYNOS_DRM_DSI__ + +struct drm_encoder; +struct exynos_dsi; +struct platform_device; +struct mipi_dsi_device; + +enum exynos_reg_offset { + EXYNOS_REG_OFS, + EXYNOS5433_REG_OFS +}; + +struct exynos_dsi *exynos_dsi_probe(struct platform_device *pdev); +void exynos_dsi_remove(struct exynos_dsi *dsi); +int exynos_dsi_bind(struct exynos_dsi *dsi, struct drm_encoder *encoder); +void exynos_dsi_unbind(struct exynos_dsi *dsi); + +int exynos_dsi_suspend(struct exynos_dsi *dsi); +int exynos_dsi_resume(struct exynos_dsi *dsi); + +enum reg_value_idx { + RESET_TYPE, + PLL_TIMER, + STOP_STATE_CNT, + PHYCTRL_ULPS_EXIT, + PHYCTRL_VREG_LP, + PHYCTRL_SLEW_UP, + PHYTIMING_LPX, + PHYTIMING_HS_EXIT, + PHYTIMING_CLK_PREPARE, + PHYTIMING_CLK_ZERO, + PHYTIMING_CLK_POST, + PHYTIMING_CLK_TRAIL, + PHYTIMING_HS_PREPARE, + PHYTIMING_HS_ZERO, + PHYTIMING_HS_TRAIL +}; + +/* DSIM_SWRST */ +#define DSIM_FUNCRST (1 << 16) +#define DSIM_SWRST (1 << 0) + +struct exynos_dsi_host_ops { + int (*attach)(struct device *dev, struct mipi_dsi_device *device); + int (*detach)(struct device *dev, struct mipi_dsi_device *device); + void (*te_handler)(struct device *dev); +}; + +struct exynos_dsi_driver_data { + enum exynos_reg_offset reg_ofs; + unsigned int plltmr_reg; + unsigned int has_freqband:1; + unsigned int has_clklane_stop:1; + unsigned int num_clks; + unsigned int max_freq; + unsigned int wait_for_reset; + unsigned int num_bits_resol; + const unsigned int *reg_values; + const struct exynos_dsi_host_ops *host_ops; +}; + +#endif /* __EXYNOS_DRM_DSI__ */ diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c b/drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c new file mode 100644 index 000000000000..79d9ec6ade45 --- /dev/null +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c @@ -0,0 +1,333 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Samsung SoC MIPI DSI Master driver. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd + * + * Contacts: Tomasz Figa + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "exynos_drm_crtc.h" +#include "exynos_drm_drv.h" +#include "exynos_drm_dsi.h" + +enum { + DSI_PORT_IN, + DSI_PORT_OUT +}; + +struct exynos_dsi_pltfm { + struct exynos_dsi *dsi; + struct drm_encoder encoder; +}; + +static const unsigned int reg_values[] = { + [RESET_TYPE] = DSIM_SWRST, + [PLL_TIMER] = 500, + [STOP_STATE_CNT] = 0xf, + [PHYCTRL_ULPS_EXIT] = 0x0af, + [PHYCTRL_VREG_LP] = 0, + [PHYCTRL_SLEW_UP] = 0, + [PHYTIMING_LPX] = 0x06, + [PHYTIMING_HS_EXIT] = 0x0b, + [PHYTIMING_CLK_PREPARE] = 0x07, + [PHYTIMING_CLK_ZERO] = 0x27, + [PHYTIMING_CLK_POST] = 0x0d, + [PHYTIMING_CLK_TRAIL] = 0x08, + [PHYTIMING_HS_PREPARE] = 0x09, + [PHYTIMING_HS_ZERO] = 0x0d, + [PHYTIMING_HS_TRAIL] = 0x0b, +}; + +static const unsigned int exynos5422_reg_values[] = { + [RESET_TYPE] = DSIM_SWRST, + [PLL_TIMER] = 500, + [STOP_STATE_CNT] = 0xf, + [PHYCTRL_ULPS_EXIT] = 0xaf, + [PHYCTRL_VREG_LP] = 0, + [PHYCTRL_SLEW_UP] = 0, + [PHYTIMING_LPX] = 0x08, + [PHYTIMING_HS_EXIT] = 0x0d, + [PHYTIMING_CLK_PREPARE] = 0x09, + [PHYTIMING_CLK_ZERO] = 0x30, + [PHYTIMING_CLK_POST] = 0x0e, + [PHYTIMING_CLK_TRAIL] = 0x0a, + [PHYTIMING_HS_PREPARE] = 0x0c, + [PHYTIMING_HS_ZERO] = 0x11, + [PHYTIMING_HS_TRAIL] = 0x0d, +}; + +static const unsigned int exynos5433_reg_values[] = { + [RESET_TYPE] = DSIM_FUNCRST, + [PLL_TIMER] = 22200, + [STOP_STATE_CNT] = 0xa, + [PHYCTRL_ULPS_EXIT] = 0x190, + [PHYCTRL_VREG_LP] = 1, + [PHYCTRL_SLEW_UP] = 1, + [PHYTIMING_LPX] = 0x07, + [PHYTIMING_HS_EXIT] = 0x0c, + [PHYTIMING_CLK_PREPARE] = 0x09, + [PHYTIMING_CLK_ZERO] = 0x2d, + [PHYTIMING_CLK_POST] = 0x0e, + [PHYTIMING_CLK_TRAIL] = 0x09, + [PHYTIMING_HS_PREPARE] = 0x0b, + [PHYTIMING_HS_ZERO] = 0x10, + [PHYTIMING_HS_TRAIL] = 0x0c, +}; + +static int __exynos_dsi_host_attach(struct device *dev, + struct mipi_dsi_device *device) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + struct drm_device *drm = dsi->encoder.dev; + struct exynos_drm_crtc *crtc; + + mutex_lock(&drm->mode_config.mutex); + crtc = exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD); + crtc->i80_mode = !(device->mode_flags & MIPI_DSI_MODE_VIDEO); + mutex_unlock(&drm->mode_config.mutex); + + if (drm->mode_config.poll_enabled) + drm_kms_helper_hotplug_event(drm); + + return 0; +} + +static int __exynos_dsi_host_detach(struct device *dev, + struct mipi_dsi_device *device) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + struct drm_device *drm = dsi->encoder.dev; + + if (drm->mode_config.poll_enabled) + drm_kms_helper_hotplug_event(drm); + + return 0; +} + +static void __exynos_dsi_te_handler(struct device *dev) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + + exynos_drm_crtc_te_handler(dsi->encoder.crtc); +} + +static const struct exynos_dsi_host_ops exynos_dsi_host_ops = { + .attach = __exynos_dsi_host_attach, + .detach = __exynos_dsi_host_detach, + .te_handler = __exynos_dsi_te_handler, +}; + +static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = { + .reg_ofs = EXYNOS_REG_OFS, + .plltmr_reg = 0x50, + .has_freqband = 1, + .has_clklane_stop = 1, + .num_clks = 2, + .max_freq = 1000, + .wait_for_reset = 1, + .num_bits_resol = 11, + .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, +}; + +static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = { + .reg_ofs = EXYNOS_REG_OFS, + .plltmr_reg = 0x50, + .has_freqband = 1, + .has_clklane_stop = 1, + .num_clks = 2, + .max_freq = 1000, + .wait_for_reset = 1, + .num_bits_resol = 11, + .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, +}; + +static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = { + .reg_ofs = EXYNOS_REG_OFS, + .plltmr_reg = 0x58, + .num_clks = 2, + .max_freq = 1000, + .wait_for_reset = 1, + .num_bits_resol = 11, + .reg_values = reg_values, + .host_ops = &exynos_dsi_host_ops, +}; + +static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = { + .reg_ofs = EXYNOS5433_REG_OFS, + .plltmr_reg = 0xa0, + .has_clklane_stop = 1, + .num_clks = 5, + .max_freq = 1500, + .wait_for_reset = 0, + .num_bits_resol = 12, + .reg_values = exynos5433_reg_values, + .host_ops = &exynos_dsi_host_ops, +}; + +static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = { + .reg_ofs = EXYNOS5433_REG_OFS, + .plltmr_reg = 0xa0, + .has_clklane_stop = 1, + .num_clks = 2, + .max_freq = 1500, + .wait_for_reset = 1, + .num_bits_resol = 12, + .reg_values = exynos5422_reg_values, + .host_ops = &exynos_dsi_host_ops, +}; + +static const struct of_device_id exynos_dsi_of_match[] = { + { .compatible = "samsung,exynos3250-mipi-dsi", + .data = &exynos3_dsi_driver_data }, + { .compatible = "samsung,exynos4210-mipi-dsi", + .data = &exynos4_dsi_driver_data }, + { .compatible = "samsung,exynos5410-mipi-dsi", + .data = &exynos5_dsi_driver_data }, + { .compatible = "samsung,exynos5422-mipi-dsi", + .data = &exynos5422_dsi_driver_data }, + { .compatible = "samsung,exynos5433-mipi-dsi", + .data = &exynos5433_dsi_driver_data }, + { } +}; + +static int exynos_dsi_pltfm_bind(struct device *dev, struct device *master, void *data) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + struct drm_encoder *encoder = &dsi->encoder; + struct drm_device *drm_dev = data; + struct device_node *in_bridge_node; + struct drm_bridge *in_bridge; + int ret; + + drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS); + + ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD); + if (ret < 0) + return ret; + + in_bridge_node = of_graph_get_remote_node(dev->of_node, DSI_PORT_IN, 0); + if (in_bridge_node) { + in_bridge = of_drm_find_bridge(in_bridge_node); + if (in_bridge) + drm_bridge_attach(encoder, in_bridge, NULL, 0); + of_node_put(in_bridge_node); + } + + ret = exynos_dsi_bind(dsi->dsi, encoder); + if (ret) + goto err; + + return 0; + +err: + drm_encoder_cleanup(encoder); + return ret; +} + +static void exynos_dsi_pltfm_unbind(struct device *dev, struct device *master, + void *data) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + struct drm_encoder *encoder = &dsi->encoder; + + exynos_dsi_unbind(dsi->dsi); + + drm_encoder_cleanup(encoder); +} + +static const struct component_ops exynos_dsi_pltfm_component_ops = { + .bind = exynos_dsi_pltfm_bind, + .unbind = exynos_dsi_pltfm_unbind, +}; + +static int exynos_dsi_pltfm_probe(struct platform_device *pdev) +{ + struct exynos_dsi_pltfm *dsi; + struct device *dev = &pdev->dev; + int ret; + + dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); + if (!dsi) + return -ENOMEM; + platform_set_drvdata(pdev, dsi); + + dsi->dsi = exynos_dsi_probe(pdev); + if (IS_ERR(dsi->dsi)) + return PTR_ERR(dsi->dsi); + + pm_runtime_enable(dev); + + ret = component_add(dev, &exynos_dsi_pltfm_component_ops); + if (ret) + goto err_disable_runtime; + + return 0; + +err_disable_runtime: + pm_runtime_disable(dev); + + return ret; +} + +static int exynos_dsi_pltfm_remove(struct platform_device *pdev) +{ + struct exynos_dsi_pltfm *dsi = platform_get_drvdata(pdev); + + pm_runtime_disable(&pdev->dev); + + exynos_dsi_remove(dsi->dsi); + + component_del(&pdev->dev, &exynos_dsi_pltfm_component_ops); + + return 0; +} + +static int __maybe_unused exynos_dsi_pltfm_suspend(struct device *dev) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + + return exynos_dsi_suspend(dsi->dsi); +} + +static int __maybe_unused exynos_dsi_pltfm_resume(struct device *dev) +{ + struct exynos_dsi_pltfm *dsi = dev_get_drvdata(dev); + + return exynos_dsi_resume(dsi->dsi); +} + +static const struct dev_pm_ops exynos_dsi_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_dsi_pltfm_suspend, exynos_dsi_pltfm_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +}; + +struct platform_driver dsi_driver = { + .probe = exynos_dsi_pltfm_probe, + .remove = exynos_dsi_pltfm_remove, + .driver = { + .name = "exynos-dsi", + .owner = THIS_MODULE, + .pm = &exynos_dsi_pm_ops, + .of_match_table = exynos_dsi_of_match, + }, +}; + +MODULE_AUTHOR("Tomasz Figa "); +MODULE_AUTHOR("Andrzej Hajda "); +MODULE_DESCRIPTION("Samsung SoC MIPI DSI Master"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Sep 11 13:54:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11770705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A4F6112E for ; Fri, 11 Sep 2020 13:54:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CDD922276 for ; Fri, 11 Sep 2020 13:54:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CDD922276 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B0E36EA5F; Fri, 11 Sep 2020 13:54:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id D173F6EA5F for ; Fri, 11 Sep 2020 13:54:31 +0000 (UTC) Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGjVN-0007wd-R8; Fri, 11 Sep 2020 15:54:30 +0200 Received: from mtr by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGjVH-00FKo8-R6; Fri, 11 Sep 2020 15:54:15 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Date: Fri, 11 Sep 2020 15:54:13 +0200 Message-Id: <20200911135413.3654800-17-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911135413.3654800-1-m.tretter@pengutronix.de> References: <20200911135413.3654800-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::39 X-SA-Exim-Mail-From: mtr@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=4.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v2 16/16] drm/exynos: move bridge driver to bridges X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, narmstrong@baylibre.com, sw0312.kim@samsung.com, Michael Tretter , krzk@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, sylvester.nawrocki@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the driver is not platform dependent anymore, move it to the drm bridge driver directory. Signed-off-by: Michael Tretter --- v2: - select DRM_SAMSUNG_DSIM from DRM_EXYNOS_DSI - add removal of depends on !FB_S3C --- drivers/gpu/drm/bridge/Kconfig | 9 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/samsung-dsim.c | 1790 ++++++++++++++++ drivers/gpu/drm/exynos/Kconfig | 5 +- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 1896 ++--------------- drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c | 333 --- .../drm/bridge/samsung-dsim.h | 20 +- 8 files changed, 2037 insertions(+), 2019 deletions(-) create mode 100644 drivers/gpu/drm/bridge/samsung-dsim.c delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_dsi_pltfm.c rename drivers/gpu/drm/exynos/exynos_drm_dsi.h => include/drm/bridge/samsung-dsim.h (69%) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 3e11af4e9f63..55ab5030c6cf 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -125,6 +125,15 @@ config DRM_PARADE_PS8640 The PS8640 is a high-performance and low-power MIPI DSI to eDP converter +config DRM_SAMSUNG_DSIM + tristate "Samsung MIPI DSI bridge" + depends on OF + select DRM_KMS_HELPER + select DRM_MIPI_DSI + select DRM_PANEL + help + Samsung MIPI DSI bridge driver. + config DRM_SIL_SII8620 tristate "Silicon Image SII8620 HDMI/MHL bridge" depends on OF diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index c589a6a7cbe1..5ac7a5c413dc 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o +obj-$(CONFIG_DRM_SAMSUNG_DSIM) += samsung-dsim.o obj-$(CONFIG_DRM_SIL_SII8620) += sil-sii8620.o obj-$(CONFIG_DRM_SII902X) += sii902x.o obj-$(CONFIG_DRM_SII9234) += sii9234.o diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c new file mode 100644 index 000000000000..6d2d8dc027de --- /dev/null +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -0,0 +1,1790 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Samsung SoC MIPI DSI Master driver. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd + * + * Contacts: Tomasz Figa +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include