From patchwork Wed Mar 8 16:39:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2790 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9DAD9414B5 for ; Wed, 8 Mar 2023 17:41:17 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id a23-20020a62bd17000000b0058db55a8d7asf9268427pff.21 for ; Wed, 08 Mar 2023 08:41:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678293676; cv=pass; d=google.com; s=arc-20160816; b=QzW633mU09JOClvkqlyxRgyk92bZQlW0Hk7ss29zYrFvz+T0cX+inyg0Yj5CnXssHg 3PQPnkZrpsnCMRB33AiOPtcXguhvXOq/RDAHWW4U8PJkKN9Ovkre0uNqLlBAS6NPTANW xnV3j0gBQ1X/IB5eSbljDNsmCcoZINAlW2k3mT5KFbKp594BR2g6LKsJRFj+cqd18acb F1OZc2y5Tj7Cr+dtJanxeKsZAJr+aEHOsHY8YtIlOETO1fbKK+uDBukrT6/qfkMQsQUq 6DI04af+qDkSCq7NHO0kv1ovviwVj0lJhszfxazB7d0rNZ4bhwioX0asNJE7rSQWaoPh 9xSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5EtoY7aHv0PaBdMVUpWPQDkHsj7vOyeLEjg7Rh1tbPs=; b=F6yz7sH9ztxH+9CjkpVu1BPtUPSquSfKGvrsfTtByMvTrgp86r02QGUV9PXsF0SCYV RjH2vZIV+TNXqHU+Uz3QPr1WBQ2M67cst4r56kahw1qjjPTm9up7Pwm+RjIh0C1ANBr3 YggYl4IiDGgu9YsIqsHdxUraM3bLJi2cmJPEPI/HsE24e38UZcWyH/wnAnUI4Wqv0NP0 6wMPmECgWLUQUKUeM8EIFDu//sSucz+V2fPfbW6wBMlZa+U6inP4nH4wZdnRntovFzBP uXtVwubdaL6Pf8QT4L63dxDjeOYq3icPWFX+MFG7HWSUuttmpFv6kk3SgUZJrnEADgQk QJOQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T6TdM3TJ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1678293676; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=5EtoY7aHv0PaBdMVUpWPQDkHsj7vOyeLEjg7Rh1tbPs=; b=U3sDSpn137y1NGW8VXqtfXqmbosS+gSkVsg+Day+wEawMY/BtYsx/oM8P6P/RN/UUN SooDqiXbQRf0HDxHT80kDye7nJrohlJlS/vehYuopva25Et3uA8Zkf4WHe/FiTvRyDjR oweq/M5PMQIYiwSzKuXScasT73FtCs/aeDckk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678293676; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5EtoY7aHv0PaBdMVUpWPQDkHsj7vOyeLEjg7Rh1tbPs=; b=yiSaTawIquOpsb8+/jQPtHUBeShm3Pk7RtKvhoy21UwaxPYPgco3IO7ghUi00r5uOL hM80JoqgC6REjAHF40A8Mn80dR7nbl+bdtbd91vD7vWSDWp2Rxvz3oCFKqkWCT2Xi2JB gCChmfnZmZIGTYc1Lewu1/QVhxJJStdLLnpDXldT2gYAPdWy4tQxIv4uqDZ0QYrFMJOJ nZ06LTvi4hStENUChOm+4skPAZ0AT/8yYfaAGYQshIC5ib2gJh1nH1oj/O5twUj/P7HA 22PkQ62CVXAoru7l8IIkg5lSmKRuJGZxx3Ss7MWiCVAw4jHq2vhFeAkgNbVYZOkxuf56 VeWg== X-Gm-Message-State: AO0yUKVcA9V//6tyHhks8xaRKNdnT8034exuoIfLIl6vYwXy4gyIYcUK iZi1RbxD/zXBU6K6Nq+KwK0vKKqJ X-Google-Smtp-Source: AK7set91jcFPw1wqFtJwppPaQhL6dS9wNs2AAnlNhuzeSQCDVtMfuDtbWlBkO+9XcYZfwG26LGB4Sg== X-Received: by 2002:a17:902:a3c6:b0:19b:8cbb:30fe with SMTP id q6-20020a170902a3c600b0019b8cbb30femr7239358plb.13.1678293676438; Wed, 08 Mar 2023 08:41:16 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:e742:b0:19c:2b1c:4d75 with SMTP id p2-20020a170902e74200b0019c2b1c4d75ls14100344plf.0.-pod-prod-gmail; Wed, 08 Mar 2023 08:41:15 -0800 (PST) X-Received: by 2002:a17:902:e745:b0:19c:eaab:653d with SMTP id p5-20020a170902e74500b0019ceaab653dmr22482952plf.15.1678293675362; Wed, 08 Mar 2023 08:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678293675; cv=none; d=google.com; s=arc-20160816; b=QWWvCG47k3plAga4rWMPV4Zde5Fk4B4SOqS5pVKsSaroe+9dsaOVVP8A69Mm9WhHn+ jtM1ZKZUVHn6ylpSr4SCkOhA/iSWWbZtsDA9fgPN3A4Tc6wrIb9+YJ4TDAqvTr/PIogl KW6f72C5mDDej8iyGIhyABxgTSQ9qrQa9G5AmSE+jNxVam+yUhl85m5LH51s1FniIr9v Dv0gj1WY8IpfFiZ+WdRZsuxgStz5ek3HJxhHk78nzb0aY0hdiSCTfbtoCZMYzTSzRDmV bedjpGY7AvgY8vAVW7UkAz8ZVZI+t19sATedEO2U3ZSl1nMj4Z0bFiYzhBu37oKLqo7q 5+yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=choR+RZaYvHjo7lhSR6XLRS+PkEWQioBLGP3Z4YHgOU=; b=hMw/fwr2KwmS/kABnsrx1QokS1Al/3bsqYToyfNjxsVUp7WCXPeIUoQAog0lNWKxPL NNjKqrE5hMJz1WNzo5vpd6YyqSOwo7XZf4jGOImkhNK7WKwfFuHzjddCIOVEEEgvyZHa BaSukWGSnHNMxEiRv1Jq1mBZjnE6NzkrE2FItVCGwELcAXjnKwrbPKyPnIxsLtQLCnlM zY7obE8+PFZoS/9dP4Le8Xg5ygzjy2dTOP0FQgNK4Lt5W495k2UFxtvHgkYNKpqcYYpv YXnrnoJXNjAoNZ6er3TkQueAWYWyV3ewy/xcUzMDD4ZgScPeFACn5KGsrPaOsTv9gx6C 0/Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T6TdM3TJ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id f7-20020a170902684700b0019c38c79dd4sor7551353pln.89.2023.03.08.08.41.15 for (Google Transport Security); Wed, 08 Mar 2023 08:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:903:32d2:b0:199:1160:956c with SMTP id i18-20020a17090332d200b001991160956cmr19166520plr.31.1678293674999; Wed, 08 Mar 2023 08:41:14 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a8a1:b545:91cc:80b2:f9fe]) by smtp.gmail.com with ESMTPSA id kq3-20020a170903284300b0019b9a075f1fsm10046540plb.80.2023.03.08.08.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 08:41:14 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Neil Armstrong , Marek Vasut , Maxime Ripard Cc: Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-amarula , Jagan Teki Subject: [PATCH v16 10/16] drm: exynos: dsi: Consolidate component and bridge Date: Wed, 8 Mar 2023 22:09:47 +0530 Message-Id: <20230308163953.28506-11-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308163953.28506-1-jagan@amarulasolutions.com> References: <20230308163953.28506-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T6TdM3TJ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , DSI host registration, attach and detach operations are quite different for the component and bridge-based DRM drivers.  Supporting generic bridge driver to use both component and bridge based DRM drivers can be tricky and would require additional host related operation hooks. Add host operation hooks for registering and unregistering Exynos and generic drivers, where Exynos hooks are used in existing Exynos component based DRM drivers and generic hooks are used in i.MX8M bridge based DRM drivers.  Add host attach and detach operation hooks for Exynos component DRM drivers and those get invoked while DSI core host attach and detach gets called. Tested-by: Marek Szyprowski Reviewed-by: Marek Vasut Signed-off-by: Marek Szyprowski Signed-off-by: Jagan Teki --- Changes for v16: - fix TE_GPIO handling - collect TB from Marek S Changes for v15: - remove leading underscores in function names Changes for v13: - none Changes for v12: - fix unneeded decleration - collect RB from Marek Changes for v11: - none Changes for v10: - split from previous series patch "drm: bridge: Generalize Exynos-DSI driver into a Samsung DSIM bridge" drivers/gpu/drm/exynos/exynos_drm_dsi.c | 138 ++++++++++++++++++++---- 1 file changed, 115 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index bd3bb8622ca3..01ed1677a4fd 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -283,10 +283,10 @@ struct exynos_dsi_driver_data { struct exynos_dsi_plat_data { enum exynos_dsi_type hw_type; + const struct exynos_dsim_host_ops *host_ops; }; struct exynos_dsi { - struct drm_encoder encoder; struct mipi_dsi_host dsi_host; struct drm_bridge bridge; struct drm_bridge *out_bridge; @@ -316,6 +316,19 @@ struct exynos_dsi { const struct exynos_dsi_driver_data *driver_data; const struct exynos_dsi_plat_data *plat_data; + + void *priv; +}; + +struct exynos_dsim_host_ops { + int (*register_host)(struct exynos_dsi *dsim); + void (*unregister_host)(struct exynos_dsi *dsim); + int (*attach)(struct exynos_dsi *dsim, struct mipi_dsi_device *device); + void (*detach)(struct exynos_dsi *dsim, struct mipi_dsi_device *device); +}; + +struct exynos_dsi_enc { + struct drm_encoder encoder; }; #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) @@ -1320,7 +1333,8 @@ 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_enc *dsi_enc = dsi->priv; + struct drm_encoder *encoder = &dsi_enc->encoder; if (dsi->state & DSIM_STATE_VIDOUT_AVAILABLE) exynos_drm_crtc_te_handler(encoder->crtc); @@ -1589,9 +1603,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_plat_data *pdata = dsi->plat_data; struct device *dev = dsi->dev; - struct drm_encoder *encoder = &dsi->encoder; - struct drm_device *drm = encoder->dev; struct device_node *np = dev->of_node; struct device_node *remote; struct drm_panel *panel; @@ -1648,11 +1661,6 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, drm_bridge_add(&dsi->bridge); - drm_bridge_attach(encoder, &dsi->bridge, - list_first_entry_or_null(&encoder->bridge_chain, - struct drm_bridge, - chain_node), 0); - /* * This is a temporary solution and should be made by more generic way. * @@ -1665,18 +1673,15 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, return ret; } - mutex_lock(&drm->mode_config.mutex); + if (pdata->host_ops && pdata->host_ops->attach) { + ret = pdata->host_ops->attach(dsi, device); + if (ret) + return ret; + } 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); return 0; } @@ -1685,12 +1690,12 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct exynos_dsi *dsi = host_to_dsi(host); - struct drm_device *drm = dsi->encoder.dev; + const struct exynos_dsi_plat_data *pdata = dsi->plat_data; dsi->out_bridge = NULL; - if (drm->mode_config.poll_enabled) - drm_kms_helper_hotplug_event(drm); + if (pdata->host_ops && pdata->host_ops->detach) + pdata->host_ops->detach(dsi, device); exynos_dsi_unregister_te_irq(dsi); @@ -1766,11 +1771,50 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) return 0; } +static int exynos_dsim_host_attach(struct exynos_dsi *dsim, + struct mipi_dsi_device *device) +{ + struct exynos_dsi_enc *dsi_enc = dsim->priv; + struct drm_encoder *encoder = &dsi_enc->encoder; + struct drm_device *drm = encoder->dev; + + drm_bridge_attach(encoder, &dsim->bridge, + list_first_entry_or_null(&encoder->bridge_chain, + struct drm_bridge, + chain_node), 0); + + mutex_lock(&drm->mode_config.mutex); + + dsim->lanes = device->lanes; + dsim->format = device->format; + dsim->mode_flags = device->mode_flags; + exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD)->i80_mode = + !(dsim->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 void exynos_dsim_host_detach(struct exynos_dsi *dsim, + struct mipi_dsi_device *device) +{ + struct exynos_dsi_enc *dsi_enc = dsim->priv; + struct drm_device *drm = dsi_enc->encoder.dev; + + if (drm->mode_config.poll_enabled) + drm_kms_helper_hotplug_event(drm); +} + static int exynos_dsi_bind(struct device *dev, struct device *master, void *data) { struct exynos_dsi *dsi = dev_get_drvdata(dev); - struct drm_encoder *encoder = &dsi->encoder; + struct exynos_dsi_enc *dsi_enc = dsi->priv; + struct drm_encoder *encoder = &dsi_enc->encoder; struct drm_device *drm_dev = data; int ret; @@ -1788,7 +1832,7 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, { struct exynos_dsi *dsi = dev_get_drvdata(dev); - exynos_dsi_atomic_disable(&dsi->bridge, NULL); + dsi->bridge.funcs->atomic_disable(&dsi->bridge, NULL); mipi_dsi_host_unregister(&dsi->dsi_host); } @@ -1798,6 +1842,40 @@ static const struct component_ops exynos_dsi_component_ops = { .unbind = exynos_dsi_unbind, }; +static int exynos_dsi_register_host(struct exynos_dsi *dsim) +{ + struct exynos_dsi_enc *dsi_enc; + + dsi_enc = devm_kzalloc(dsim->dev, sizeof(*dsi_enc), GFP_KERNEL); + if (!dsi_enc) + return -ENOMEM; + + dsim->priv = dsi_enc; + dsim->bridge.pre_enable_prev_first = true; + + return component_add(dsim->dev, &exynos_dsi_component_ops); +} + +static void exynos_dsi_unregister_host(struct exynos_dsi *dsim) +{ + component_del(dsim->dev, &exynos_dsi_component_ops); +} + +static int generic_dsim_register_host(struct exynos_dsi *dsim) +{ + return mipi_dsi_host_register(&dsim->dsi_host); +} + +static void generic_dsim_unregister_host(struct exynos_dsi *dsim) +{ + mipi_dsi_host_unregister(&dsim->dsi_host); +} + +static const struct exynos_dsim_host_ops generic_dsim_host_ops = { + .register_host = generic_dsim_register_host, + .unregister_host = generic_dsim_unregister_host, +}; + static const struct drm_bridge_timings dsim_bridge_timings_de_low = { .input_bus_flags = DRM_BUS_FLAG_DE_LOW, }; @@ -1892,7 +1970,9 @@ static int exynos_dsi_probe(struct platform_device *pdev) if (dsi->plat_data->hw_type == DSIM_TYPE_IMX8MM) dsi->bridge.timings = &dsim_bridge_timings_de_low; - ret = component_add(dev, &exynos_dsi_component_ops); + if (dsi->plat_data->host_ops && dsi->plat_data->host_ops->register_host) + ret = dsi->plat_data->host_ops->register_host(dsi); + if (ret) goto err_disable_runtime; @@ -1983,24 +2063,36 @@ static const struct dev_pm_ops exynos_dsi_pm_ops = { pm_runtime_force_resume) }; +static const struct exynos_dsim_host_ops exynos_dsi_host_ops = { + .register_host = exynos_dsi_register_host, + .unregister_host = exynos_dsi_unregister_host, + .attach = exynos_dsim_host_attach, + .detach = exynos_dsim_host_detach, +}; + static const struct exynos_dsi_plat_data exynos3250_dsi_pdata = { .hw_type = DSIM_TYPE_EXYNOS3250, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_plat_data exynos4210_dsi_pdata = { .hw_type = DSIM_TYPE_EXYNOS4210, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_plat_data exynos5410_dsi_pdata = { .hw_type = DSIM_TYPE_EXYNOS5410, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_plat_data exynos5422_dsi_pdata = { .hw_type = DSIM_TYPE_EXYNOS5422, + .host_ops = &exynos_dsi_host_ops, }; static const struct exynos_dsi_plat_data exynos5433_dsi_pdata = { .hw_type = DSIM_TYPE_EXYNOS5433, + .host_ops = &exynos_dsi_host_ops, }; static const struct of_device_id exynos_dsi_of_match[] = {