From patchwork Thu Aug 5 14:07:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 492966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B50FC4338F for ; Thu, 5 Aug 2021 14:14:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E436060238 for ; Thu, 5 Aug 2021 14:14:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241619AbhHEOOS (ORCPT ); Thu, 5 Aug 2021 10:14:18 -0400 Received: from mo4-p04-ob.smtp.rzone.de ([81.169.146.178]:17421 "EHLO mo4-p04-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240281AbhHEOOR (ORCPT ); Thu, 5 Aug 2021 10:14:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1628172486; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=CliIVqvNzA/bGBlLAYmf7rIejrGR22i5z/kGrFUsuDU=; b=aQQJPEJ0jCM1iMaL2MFUfRGIIzKEaRcDNf2tGiFM8NcjZCfz4p8vQhjt1lrN7k83ZO BzAU7bAQB9qHCReArzr1c6eZ37KgHwnTGuom6o8amMiIRiaD6CzR3lexc1yketsDJ/Jg pIF7LOcdEkFt83UmjT+B1Z+Aoas3a6BwuStYAzUjWVtM1AIDYeiEiC30DeuJaIjTkK12 dEduqK0sP6iJghpdd/R5/cmb1H9RTxOFL47/C8jmtBLJKxB7OIZeELY0TjU2sBEBHQJb MM/BWyMduC99sODYMs4Lx+Lwpd9KaVCIb4CMIanxDUVLhkiSzvEboTPjsPUg6/AjtFml TKJg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o12DNOsPj0lByOdbLzk=" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 47.31.0 DYNA|AUTH) with ESMTPSA id Q02727x75E85789 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 5 Aug 2021 16:08:05 +0200 (CEST) From: "H. Nikolaus Schaller" To: Paul Cercueil , Rob Herring , Mark Rutland , Thomas Bogendoerfer , "H. Nikolaus Schaller" , Geert Uytterhoeven , Kees Cook , "Eric W. Biederman" , Miquel Raynal , David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jernej Skrabec , Ezequiel Garcia , Harry Wentland , Sam Ravnborg , Maxime Ripard , Hans Verkuil Cc: devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, Paul Boddie , Jonas Karlman , dri-devel@lists.freedesktop.org Subject: [PATCH v2 8/8] [RFC] drm/ingenic: convert to component framework for jz4780 hdmi Date: Thu, 5 Aug 2021 16:07:57 +0200 Message-Id: <77554dd2612f418f6ab74a8be06c82b71410e0e6.1628172477.git.hns@goldelico.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch attempts to convert the ingenic-dw-hdmi driver into a version that uses the component framework. Unfortunately the new version does not work. Debugging shows that ingenic_dw_hdmi_bind() is never called. Suggestions for reasons and fixes are welcome. Signed-off-by: Paul Boddie Co-authored-by: Paul Boddie Signed-off-by: H. Nikolaus Schaller --- drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c | 57 ++++++++++++++++++----- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c b/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c index 61e7a57d7cec1..a5ba0b69baa8c 100644 --- a/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c +++ b/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c @@ -1,17 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. - * Copyright (C) 2019, 2020 Paul Boddie + * Copyright (C) 2019, 2020, 2021 Paul Boddie * * Derived from dw_hdmi-imx.c with i.MX portions removed. - * Probe and remove operations derived from rcar_dw_hdmi.c. */ +#include #include #include #include #include #include +#include +#include + +struct ingenic_dw_hdmi_encoder { + struct drm_encoder encoder; + struct dw_hdmi *hdmi; +}; static const struct dw_hdmi_mpll_config ingenic_mpll_cfg[] = { { 45250000, { { 0x01e0, 0x0000 }, { 0x21e1, 0x0000 }, { 0x41e2, 0x0000 } } }, @@ -87,24 +94,52 @@ static const struct of_device_id ingenic_dw_hdmi_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, ingenic_dw_hdmi_dt_ids); -static int ingenic_dw_hdmi_probe(struct platform_device *pdev) +static int ingenic_dw_hdmi_bind(struct device *dev, struct device *master, + void *data) { - struct dw_hdmi *hdmi; + struct platform_device *pdev = to_platform_device(dev); + struct drm_device *drm = data; + struct drm_encoder *enc; + struct ingenic_dw_hdmi_encoder *hdmi_encoder; - hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data); - if (IS_ERR(hdmi)) - return PTR_ERR(hdmi); + hdmi_encoder = drmm_simple_encoder_alloc(drm, struct ingenic_dw_hdmi_encoder, + encoder, DRM_MODE_ENCODER_TMDS); + if (IS_ERR(hdmi_encoder)) + return PTR_ERR(hdmi_encoder); - platform_set_drvdata(pdev, hdmi); + enc = &hdmi_encoder->encoder; + drm_encoder_helper_add(enc, NULL); + hdmi_encoder->hdmi = dw_hdmi_bind(pdev, enc, &ingenic_dw_hdmi_plat_data); + + if (IS_ERR(hdmi_encoder->hdmi)) + return PTR_ERR(hdmi_encoder->hdmi); + + dev_set_drvdata(dev, hdmi_encoder->hdmi); return 0; } -static int ingenic_dw_hdmi_remove(struct platform_device *pdev) +static void ingenic_dw_hdmi_unbind(struct device *dev, struct device *master, + void *data) +{ + struct dw_hdmi *hdmi = dev_get_drvdata(dev); + + dw_hdmi_unbind(hdmi); +} + +static const struct component_ops ingenic_dw_hdmi_ops = { + .bind = ingenic_dw_hdmi_bind, + .unbind = ingenic_dw_hdmi_unbind, +}; + +static int ingenic_dw_hdmi_probe(struct platform_device *pdev) { - struct dw_hdmi *hdmi = platform_get_drvdata(pdev); + return component_add(&pdev->dev, &ingenic_dw_hdmi_ops); +} - dw_hdmi_remove(hdmi); +static int ingenic_dw_hdmi_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &ingenic_dw_hdmi_ops); return 0; }