Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4874080pxb; Tue, 28 Sep 2021 06:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqt+xXxJcysNWTY2arL8rjcgTNmnlb4RvYOOg0AKhMqw91KgbwFj+JqEryiPtC231lsMU4 X-Received: by 2002:a2e:530d:: with SMTP id h13mr5893787ljb.192.1632834415750; Tue, 28 Sep 2021 06:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632834415; cv=none; d=google.com; s=arc-20160816; b=csq2WKZZmIjE2fiYaPxNAPaVG61QQ1BvbyBE2DXiB1erui9A4YFnG8Ipro7XWn+ADX oTuxi3spZ4+bpfSuY3JIiI/JiZmER0kj5fO5sELtt6xEcfr7Xd/iMgT9GMmFHc0QtKZO +KDmWMfO9/bsN1yvQ33UM04Q0Pu5ODC0AHc99wGKaSwfRHT3CsX1erkZv2uJeXt/Qb5P 3XYdX7R/wyCpt5gIwoO5awGAihgM+35ClcVqE92DOiyySB924W4NTKpBdhxzoLpE01tq 2yd9Hwd9UNqnRMYd2kixUGAGFlzvp0BX2QW2jkY3Cm9BcRwctBXRKsAC+Uo4vY5oCemf WuKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=tR2TQX+kVW0rYrRfEEQg7WRnq2clbEFfqF4BNcuxvaQ=; b=fLVLqKXwf6lKGh+dT6VG3hVd7CQMJ0r57i5eLsnsthA7IhlO1A0dtun3N/eYuTqxkh ULpn8d6jFVYw6nvOoYg67dBjbU4c+pgNn6GsFt8oeTmAQFAaDHOChv12W15KVBi/Vb6o dp3SIXC3pktCvpamZ/9GhZc0QHBQaC+JGWqjt9Fy0Pt9FG55tY4dqeBGqz+vr0TVkmnz l6SyqIgbTp0W0Rp2f4FBLYAcmK6+louZfqokj7lfaYKZdBjkMSdIwNsUCfk6+Qttcb8a n2z4sNQZPsgmeK4RvvhbBQV2USaG3Q7F/ZoKOsRcOotxW8N7s1To5pbfrRodOX/kUSAz RfMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xwh+oTfq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si435166ejt.705.2021.09.28.06.06.28; Tue, 28 Sep 2021 06:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xwh+oTfq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240862AbhI1NER (ORCPT + 99 others); Tue, 28 Sep 2021 09:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240300AbhI1NEO (ORCPT ); Tue, 28 Sep 2021 09:04:14 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78A71C061740 for ; Tue, 28 Sep 2021 06:02:34 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id d207-20020a1c1dd8000000b00307e2d1ec1aso2693076wmd.5 for ; Tue, 28 Sep 2021 06:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tR2TQX+kVW0rYrRfEEQg7WRnq2clbEFfqF4BNcuxvaQ=; b=xwh+oTfqAoZAVf+C975YtjHcHNtJ9zw8T+99kEppazEhQ9Vl5ssftS152FY6vNegm3 k+OsjszbH8DC4d1hsrvAoKjYC36oFCuQp+C+wkbUqFLSfXiDXuZBfNIJWzEOHW/gXMpg ChxjbhiD2REH5LsuC4feYLP3d4Ud4fLZpSw+BfJ9A+tkuKExrb68TE/4z3LD+boJudXb gtsjM0oG6dF3opnyolwkIayRbV9ziEAukPrsKo96OguWWzMnBZWzMfJBbDlgxwIvYh1c I6gsf04tAnIIjJngzcxGbkmongAtMTuAgVeXyWdaSmdAcQ/TzA65csd+Z/Rj59DwQylO lJhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=tR2TQX+kVW0rYrRfEEQg7WRnq2clbEFfqF4BNcuxvaQ=; b=vvIOuOsZvdpwCOwqIdjm6nZhXyoyQKPLtQAgZ/hl3vj8TOHPrEAsbST5941aR8t8XR abmv9VNLLOtNipqc0+GvzbWqqNgZnfI5LSjgYPhc8VXAKvnebd578SLZaIRbwgYrj37g Wv7P02LlqsB3FaRCkzMH+XOWMcAepm8GFIEhI+pQlKwfhpu0TxnYPCoxw9F/0S7/GWBW FJBH6EWh2ReQkZ93A3NnnSrx/CT+Jl8lUhW5cspGx42cI2PZaOYr9q8QPss8GO86UYcE vbnfm4ySRz6xviU3/2ELPkXgFs8DKd125FzsIKnErifBa+TD9Q4wsSLe5CRtPGDyWkeX yCKA== X-Gm-Message-State: AOAM532Ncw2EcqUGAZL6CWur6GdF11I2QMZ09XGvPLJW0FUk2Z0YkON1 LAlmOVxp09JAw8FtRbfb3pI5VQ== X-Received: by 2002:a05:600c:40c4:: with SMTP id m4mr4619005wmh.64.1632834152799; Tue, 28 Sep 2021 06:02:32 -0700 (PDT) Received: from ?IPv6:2001:861:44c0:66c0:af32:f180:8ede:d9da? ([2001:861:44c0:66c0:af32:f180:8ede:d9da]) by smtp.gmail.com with ESMTPSA id o7sm24611367wro.45.2021.09.28.06.02.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 06:02:32 -0700 (PDT) Subject: Re: [PATCH v4 06/10] drm/ingenic: Add dw-hdmi driver for jz4780 To: "H. Nikolaus Schaller" , Paul Cercueil , Rob Herring , Mark Rutland , Thomas Bogendoerfer , Geert Uytterhoeven , Kees Cook , "Eric W. Biederman" , Miquel Raynal , David Airlie , Daniel Vetter , Andrzej Hajda , Robert Foss , Laurent Pinchart , Jernej Skrabec , Ezequiel Garcia , Harry Wentland , Sam Ravnborg , Maxime Ripard , Hans Verkuil , Liam Girdwood , Mark Brown , Paul Boddie Cc: 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 References: From: Neil Armstrong Organization: Baylibre Message-ID: <86c61519-697f-9ca8-4257-074173656c38@baylibre.com> Date: Tue, 28 Sep 2021 15:02:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/09/2021 18:44, H. Nikolaus Schaller wrote: > 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. > > 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 | 142 ++++++++++++++++++++++ > 3 files changed, 152 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 3b57f8be007c..4c7d311fbeff 100644 > --- a/drivers/gpu/drm/ingenic/Kconfig > +++ b/drivers/gpu/drm/ingenic/Kconfig > @@ -25,4 +25,13 @@ config DRM_INGENIC_IPU > > The Image Processing Unit (IPU) will appear as a second primary plane. > > +config DRM_INGENIC_DW_HDMI > + bool "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.. > + > endif > diff --git a/drivers/gpu/drm/ingenic/Makefile b/drivers/gpu/drm/ingenic/Makefile > index d313326bdddb..3db9888a6c04 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 > +ingenic-drm-$(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 000000000000..dd9c94ae842e > --- /dev/null > +++ b/drivers/gpu/drm/ingenic/ingenic-dw-hdmi.c > @@ -0,0 +1,142 @@ > +// 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 bool > +ingenic_dw_hdmi_mode_fixup(struct drm_bridge *bridge, > + const struct drm_display_mode *mode, > + struct drm_display_mode *adjusted_mode) > +{ > + adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); > + adjusted_mode->flags &= ~(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); > + > + return true; > +} > + > +static const struct drm_bridge_timings ingenic_dw_hdmi_timings = { > + .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE, > +}; These should go in the intermediate encoder bridge callbacks Paul introduces in his patch at [1]. With that patch 4 can be dropped. [1] https://lore.kernel.org/r/20210922205555.496871-7-paul@crapouillou.net Neil > + > +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, > + .mode_fixup = ingenic_dw_hdmi_mode_fixup, > + .timings = &ingenic_dw_hdmi_timings, > + .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 int ingenic_dw_hdmi_probe(struct platform_device *pdev) > +{ > + struct dw_hdmi *hdmi; > + struct regulator *regulator; > + int ret; > + > + hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data); > + if (IS_ERR(hdmi)) > + return PTR_ERR(hdmi); > + > + platform_set_drvdata(pdev, hdmi); > + > + regulator = devm_regulator_get_optional(&pdev->dev, "hdmi-5v"); > + > + if (IS_ERR(regulator)) { > + ret = PTR_ERR(regulator); > + > + DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %s (%d)\n", > + "hdmi-5v", ret); > + return ret; > + } > + > + ret = regulator_enable(regulator); > + if (ret) { > + DRM_DEV_ERROR(&pdev->dev, "Failed to enable hpd regulator: %d\n", > + ret); > + return ret; > + } > + > + return 0; > +} > + > +static int ingenic_dw_hdmi_remove(struct platform_device *pdev) > +{ > + struct dw_hdmi *hdmi = platform_get_drvdata(pdev); > + > + dw_hdmi_remove(hdmi); > + > + return 0; > +} > + > +static struct platform_driver ingenic_dw_hdmi_driver = { > + .probe = ingenic_dw_hdmi_probe, > + .remove = ingenic_dw_hdmi_remove, > + .driver = { > + .name = "dw-hdmi-ingenic", > + .of_match_table = ingenic_dw_hdmi_dt_ids, > + }, > +}; > + > +struct platform_driver *ingenic_dw_hdmi_driver_ptr = &ingenic_dw_hdmi_driver; >