Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3753314pxb; Fri, 4 Feb 2022 15:59:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCwg3qhllGW5acFdyr2sJp0BtyEb90JQk+7k49ofiTKnREfJk5ANGVllRDirXFydLMrvER X-Received: by 2002:a50:aadd:: with SMTP id r29mr1714108edc.236.1644019193737; Fri, 04 Feb 2022 15:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644019193; cv=none; d=google.com; s=arc-20160816; b=GBCYR38BeOaXe6YtafKt23oBuNRW5ATO+uaH8+I63m4EXWNheQR20v4/oGcBwLMdBm B86Gjv4tB63W5CYDzgkuWX1EvZH/MibWj/B9ly9MLnpISzbCi84PywTEpVN2z4E39hYa fIu/JosyLn8bkZegTmIRCf3u7hf5FmScDz3fhgHZplYLdcoBJhAvnPTL6/vweSlbPAvN Y8B3RHh8L9Uu4PS0byRdgmEPgpb3R1Z+yiERBjCP6ibF2170+aG5+0jZtvWv05x9UX7J G6vcnnYaBIJp5tzU5bUXFGIZM5uUx7I2Y3l2tlKHPYNrHsUvyRiWKIyXAgrXoUSrsKzk hPLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=dGcv0eBfSgt9kVJUc4fXn5oEutIWUPqTexX4N+XRhqE=; b=lbz4ofX5fPWFIWagmydVPZIINcrmmiJ6d3Rg/vV0NAurVDv8jMMwauIdqId4lJnwoM xpVatgSpOjHfGOSvbc8am12hzeEtFVlmth8SXX2jB0tc4ehH+bpwne2Pf2ej9lvB8ax7 h3p57idzpwhoNDbxNXG+4prpD9h8as6n2w2FK/LCiJx3Tcg2E+RP+TT6NgdD8Gaqi321 4LjFxGhYJ6ZQy/vMo27SdtblZ4S7+aXRDBObibJpbsSJIDAuv13yFtiZmG+HGZq6YlLi UMQinOgVj0/CY7Z/I6b9eezC6fVnozdFA9NSI9UBs8659yK/dmVz7sdNgz9kOaKzrCrZ RxoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10si2148728ejm.227.2022.02.04.15.59.28; Fri, 04 Feb 2022 15:59:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343496AbiBBKRN convert rfc822-to-8bit (ORCPT + 99 others); Wed, 2 Feb 2022 05:17:13 -0500 Received: from aposti.net ([89.234.176.197]:42656 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240537AbiBBKRK (ORCPT ); Wed, 2 Feb 2022 05:17:10 -0500 Date: Wed, 02 Feb 2022 10:16:49 +0000 From: Paul Cercueil Subject: Re: [PATCH v12 4/9] drm/ingenic: Add dw-hdmi driver specialization for jz4780 To: "H. Nikolaus Schaller" Cc: Rob Herring , Mark Rutland , Thomas Bogendoerfer , Geert Uytterhoeven , Kees Cook , "Eric W. Biederman" , Miquel Raynal , David Airlie , Daniel Vetter , Neil Armstrong , Robert Foss , Laurent Pinchart , Jernej Skrabec , Harry Wentland , Sam Ravnborg , Maxime Ripard , Hans Verkuil , Liam Girdwood , Mark Brown , Paul Boddie , Andrzej Hajda , Kieran Bingham , devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, Jonas Karlman , dri-devel@lists.freedesktop.org, Ezequiel Garcia Message-Id: <1W9O6R.U3T9L7GOJNE81@crapouillou.net> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikolaus, Le lun., janv. 31 2022 at 13:26:50 +0100, H. Nikolaus Schaller a ?crit : > From: Paul Boddie > > A specialisation of the generic Synopsys HDMI driver is employed for > JZ4780 HDMI support. This requires a new driver, plus device tree and > configuration modifications. > > Here we add Kconfig DRM_INGENIC_DW_HDMI, Makefile and driver code. > > Signed-off-by: Paul Boddie > Signed-off-by: Ezequiel Garcia > Signed-off-by: H. Nikolaus Schaller > --- > drivers/gpu/drm/ingenic/Kconfig | 9 ++ > drivers/gpu/drm/ingenic/Makefile | 1 + > drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c | 104 > ++++++++++++++++++++++ > 3 files changed, 114 insertions(+) > create mode 100644 drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c > > diff --git a/drivers/gpu/drm/ingenic/Kconfig > b/drivers/gpu/drm/ingenic/Kconfig > index 001f59fb06d56..ba4a650869cd8 100644 > --- a/drivers/gpu/drm/ingenic/Kconfig > +++ b/drivers/gpu/drm/ingenic/Kconfig > @@ -24,4 +24,13 @@ config DRM_INGENIC_IPU > > The Image Processing Unit (IPU) will appear as a second primary > plane. > > +config DRM_INGENIC_DW_HDMI > + tristate "Ingenic specific support for Synopsys DW HDMI" > + depends on MACH_JZ4780 > + select DRM_DW_HDMI > + help > + Choose this option to enable Synopsys DesignWare HDMI based > driver. > + If you want to enable HDMI on Ingenic JZ4780 based SoC, you should > + select this option.. One dot is enough. > + > endif > diff --git a/drivers/gpu/drm/ingenic/Makefile > b/drivers/gpu/drm/ingenic/Makefile > index d313326bdddbb..f10cc1c5a5f22 100644 > --- a/drivers/gpu/drm/ingenic/Makefile > +++ b/drivers/gpu/drm/ingenic/Makefile > @@ -1,3 +1,4 @@ > obj-$(CONFIG_DRM_INGENIC) += ingenic-drm.o > ingenic-drm-y = ingenic-drm-drv.o > ingenic-drm-$(CONFIG_DRM_INGENIC_IPU) += ingenic-ipu.o > +obj-$(CONFIG_DRM_INGENIC_DW_HDMI) += ingenic-dw-hdmi.o > diff --git a/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c > b/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c > new file mode 100644 > index 0000000000000..34e986dd606cf > --- /dev/null > +++ b/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c > @@ -0,0 +1,104 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. > + * Copyright (C) 2019, 2020 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 > + > +static const struct dw_hdmi_mpll_config ingenic_mpll_cfg[] = { > + { 45250000, { { 0x01e0, 0x0000 }, { 0x21e1, 0x0000 }, { 0x41e2, > 0x0000 } } }, > + { 92500000, { { 0x0140, 0x0005 }, { 0x2141, 0x0005 }, { 0x4142, > 0x0005 } } }, > + { 148500000, { { 0x00a0, 0x000a }, { 0x20a1, 0x000a }, { 0x40a2, > 0x000a } } }, > + { 216000000, { { 0x00a0, 0x000a }, { 0x2001, 0x000f }, { 0x4002, > 0x000f } } }, > + { ~0UL, { { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, > 0x0000 } } } > +}; > + > +static const struct dw_hdmi_curr_ctrl ingenic_cur_ctr[] = { > + /*pixelclk bpp8 bpp10 bpp12 */ > + { 54000000, { 0x091c, 0x091c, 0x06dc } }, > + { 58400000, { 0x091c, 0x06dc, 0x06dc } }, > + { 72000000, { 0x06dc, 0x06dc, 0x091c } }, > + { 74250000, { 0x06dc, 0x0b5c, 0x091c } }, > + { 118800000, { 0x091c, 0x091c, 0x06dc } }, > + { 216000000, { 0x06dc, 0x0b5c, 0x091c } }, > + { ~0UL, { 0x0000, 0x0000, 0x0000 } }, > +}; > + > +/* > + * Resistance term 133Ohm Cfg > + * PREEMP config 0.00 > + * TX/CK level 10 > + */ > +static const struct dw_hdmi_phy_config ingenic_phy_config[] = { > + /*pixelclk symbol term vlev */ > + { 216000000, 0x800d, 0x0005, 0x01ad}, > + { ~0UL, 0x0000, 0x0000, 0x0000} > +}; > + > +static enum drm_mode_status > +ingenic_dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data, > + const struct drm_display_info *info, > + const struct drm_display_mode *mode) > +{ > + if (mode->clock < 13500) > + return MODE_CLOCK_LOW; > + /* FIXME: Hardware is capable of 270MHz, but setup data is missing. > */ > + if (mode->clock > 216000) > + return MODE_CLOCK_HIGH; > + > + return MODE_OK; > +} > + > +static struct dw_hdmi_plat_data ingenic_dw_hdmi_plat_data = { > + .mpll_cfg = ingenic_mpll_cfg, > + .cur_ctr = ingenic_cur_ctr, > + .phy_config = ingenic_phy_config, > + .mode_valid = ingenic_dw_hdmi_mode_valid, > + .output_port = 1, > +}; > + > +static const struct of_device_id ingenic_dw_hdmi_dt_ids[] = { > + { .compatible = "ingenic,jz4780-dw-hdmi" }, > + { /* Sentinel */ }, > +}; > +MODULE_DEVICE_TABLE(of, ingenic_dw_hdmi_dt_ids); > + > +static void ingenic_dw_hdmi_cleanup(void *data) > +{ > + struct dw_hdmi *hdmi = (struct dw_hdmi *)data; > + > + dw_hdmi_remove(hdmi); > +} > + > +static int ingenic_dw_hdmi_probe(struct platform_device *pdev) > +{ > + struct dw_hdmi *hdmi; > + > + hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data); > + if (IS_ERR(hdmi)) > + return PTR_ERR(hdmi); > + > + return devm_add_action_or_reset(&pdev->dev, > ingenic_dw_hdmi_cleanup, hdmi); Nitpick, but your probe function is so simple, you could just have a .remove callback instead of registering a devm action. Then you can just return PTR_ERR_OR_ZERO(hdmi). Cheers, -Paul > +} > + > +static struct platform_driver ingenic_dw_hdmi_driver = { > + .probe = ingenic_dw_hdmi_probe, > + .driver = { > + .name = "dw-hdmi-ingenic", > + .of_match_table = ingenic_dw_hdmi_dt_ids, > + }, > +}; > +module_platform_driver(ingenic_dw_hdmi_driver); > + > +MODULE_DESCRIPTION("JZ4780 Specific DW-HDMI Driver Extension"); > +MODULE_LICENSE("GPL v2"); > +MODULE_ALIAS("platform:dwhdmi-ingenic"); > -- > 2.33.0 >