Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1004447rdb; Wed, 24 Jan 2024 01:38:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYKVafpO+mwDQRhKF2LgOd2i06lleq6ZpB5ROOAAynWfPKF7Zo5rg0CrMZ0FYcZKCOnlSU X-Received: by 2002:a17:903:2283:b0:1d7:5e30:981e with SMTP id b3-20020a170903228300b001d75e30981emr606869plh.23.1706089086784; Wed, 24 Jan 2024 01:38:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706089086; cv=pass; d=google.com; s=arc-20160816; b=XU4op5JPc4nf8OREhwh/dLn+s+eidulPjhVVBKuO+MYBxE1GhPQnc4Bzbj4KKOiPRy oTjfsNy0EnF6Ha8X/fh9p1KIRnMYEPL6DY31PtoF+loHLsDkjwFxDjmlezWxs2xtM/Nh boAg49MWXbUJpozFpX6Gtep6mLhxEFKbTdcCdfTfPKlNaJh31U5d5C6PU5phGkdpCT03 LVYJFv1M9ju2fI/LGaOzuOdIh5nsYfMkQD6MY7SCY0iD4XOOkPsCAfNkWiMsWsv8sJSX YPVU1oGQpf7QN4RFsoRw3czVvCWHhidhArEzt7Q78XZ4xMHvyn4tGGua7oWIjrQoZEwX lSQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=7bKX9WshUJdCDFr0XJcTbAfR2X8wkmHkRmmLWwFg7pM=; fh=myigS1vdF+WURxyIdgNuJleh3NDHincj09Cdj6g72aQ=; b=ChPGp2ZYQjt+kizAOsLBeWpERM8BzpblUEKocBQr9wmsNNqKAU2tv4uUNlVMRb2zA2 s8El6LfiRot4nBdHN5rHNuWpuhEbcWvquME4yJZILJ6+75so7/IG+hYrE/iHWORS+Gnl m0ShTtCxZB5zhIlty345vWaITkUcDiBSg+Kj8mMyz5Lxx62ydEw7tWYVAlef15kzgoHu qiapxupDnYFROEmDTWPQUMDmktbGqXj/y5aaapU1LpybyvFdKQm84JF/+QgHfJtr2IH2 BVUxQpSPFjFoZK0XpSv8I2q6AoVN65uvt+Wh7bWZMbxQ6ooCRDAE2194Bi0UEjtTz/re 8zOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kwiboo.se header.s=fe-e1b5cab7be header.b=mVXBnLlx; arc=pass (i=1 spf=pass spfdomain=fe-bounces.kwiboo.se dkim=pass dkdomain=kwiboo.se dmarc=pass fromdomain=kwiboo.se); spf=pass (google.com: domain of linux-kernel+bounces-36688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36688-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kwiboo.se Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i3-20020a1709026ac300b001d5ce8f91efsi11463596plt.394.2024.01.24.01.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 01:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kwiboo.se header.s=fe-e1b5cab7be header.b=mVXBnLlx; arc=pass (i=1 spf=pass spfdomain=fe-bounces.kwiboo.se dkim=pass dkdomain=kwiboo.se dmarc=pass fromdomain=kwiboo.se); spf=pass (google.com: domain of linux-kernel+bounces-36688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36688-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kwiboo.se Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9CCEAB2B0F0 for ; Wed, 24 Jan 2024 09:17:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4769117C98; Wed, 24 Jan 2024 09:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kwiboo.se header.i=@kwiboo.se header.b="mVXBnLlx" Received: from smtp.forwardemail.net (smtp.forwardemail.net [149.28.215.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C21F17C67 for ; Wed, 24 Jan 2024 09:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=149.28.215.223 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087824; cv=none; b=bG9seTDwGqUqAQ7XDpFIegkDtMWKlcHkdyoQGWoyrqzNNZa9CD/ZW+gTeYBN9j0wZeo6/Avc2gEyi7JvniPLsVCJYikb6oKeCm09u04oqjpt26SfDvOMFDCmP7dKEQmCegsOngDh5V86gwT9KkJsr5kxn3fh1Q9uix1RV8isLQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087824; c=relaxed/simple; bh=iC1q0mZtmUJyO98JwE2idUq+ihslZw8XL0JBpcUFAqg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=obZjMl5kffRFVOnGA0x0za4ezNUdCFpa2ksXul9FOmNauneSwrTC9AFgLKNcieV8fOppd6QNR2JqA8u52ltYqtQjJwDzK1jZKit03AZAI7F/HnaIVPmrdNqD1iKVEXnFX7odx70b3t4YbdQxNBrF16lui1UsCjjA9GKVUFFT1zc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kwiboo.se; spf=pass smtp.mailfrom=fe-bounces.kwiboo.se; dkim=pass (2048-bit key) header.d=kwiboo.se header.i=@kwiboo.se header.b=mVXBnLlx; arc=none smtp.client-ip=149.28.215.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fe-bounces.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: From: References: Cc: To: Subject: MIME-Version: Date: Message-ID; q=dns/txt; s=fe-e1b5cab7be; t=1706087796; bh=7bKX9WshUJdCDFr0XJcTbAfR2X8wkmHkRmmLWwFg7pM=; b=mVXBnLlxod5cfcP9lAWVEKtCWnpvk74qKyTHeDB0arM7KJ/X8TMzB727tPjBsS6NATxGUoGeC PHyzWd3+CDSUuwjItM3t7Z0nSeXGFP3nWTuqXtgG3N8zQDFv3ZX7hrKLYKBWWXaElf920U61nVU 4TjLivoy4qO7upeAxs8I6+BES1Dc6k1IUwh5XAHDgxr9BJi7Bry0jbzicrYWiWLXh4eBkB1i/id BY1DR6MtcLXXOiN1RZAEDUkDVi5Fvgl22MPbKLTy5n1OWkybW/JEuSRyov22dJTGoiD6m6zGth3 yuxGxSl2e0BW5vUcZZ6WNyJzHn/LUaj+6hEIRhfXfCgA== Message-ID: Date: Wed, 24 Jan 2024 10:16:29 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] phy: rockchip: Add Samsung HDMI/DP Combo PHY driver Content-Language: en-US To: Andy Yan , Cristian Ciocaltea , Sascha Hauer Cc: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Philipp Zabel , Johan Jonker , Sebastian Reichel , Algea Cao , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sandor Yu , Maxime Ripard References: <20240119193806.1030214-1-cristian.ciocaltea@collabora.com> <20240119193806.1030214-4-cristian.ciocaltea@collabora.com> <20240122121409.GW4700@pengutronix.de> <00c749f7-3eb9-4bd1-a057-43a692b77d68@collabora.com> From: Jonas Karlman In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Report-Abuse-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Complaints-To: abuse@forwardemail.net X-ForwardEmail-Version: 0.4.40 X-ForwardEmail-Sender: rfc822; jonas@kwiboo.se, smtp.forwardemail.net, 149.28.215.223 X-ForwardEmail-ID: 65b0d574383531b5293f00d7 On 2024-01-24 08:30, Andy Yan wrote: > Hi Cristian: > > On 1/24/24 10:42, Andy Yan wrote: >> Hi Cristian: >> >> On 1/24/24 08:58, Cristian Ciocaltea wrote: >>> On 1/22/24 14:14, Sascha Hauer wrote: >>>> On Fri, Jan 19, 2024 at 09:38:03PM +0200, Cristian Ciocaltea wrote: >>>>> Add driver for the Rockchip HDMI/eDP TX Combo PHY found on RK3588 SoC. >>>>> >>>>> The PHY is based on a Samsung IP block and supports HDMI 2.1 TMDS, FRL >>>>> and eDP links.  The maximum data rate is 12Gbps (HDMI 2.1 FRL), while >>>>> the minimum is 250Mbps (HDMI 2.1 TMDS). >>>>> >>>>> Co-developed-by: Algea Cao >>>>> Signed-off-by: Algea Cao >>>>> Signed-off-by: Cristian Ciocaltea >>>>> --- >>>>>   drivers/phy/rockchip/Kconfig                  |    8 + >>>>>   drivers/phy/rockchip/Makefile                 |    1 + >>>>>   .../phy/rockchip/phy-rockchip-samsung-hdptx.c | 2045 +++++++++++++++++ >>>>>   3 files changed, 2054 insertions(+) >>>>>   create mode 100644 drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c >>>>> >>>>> diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig >>>>> index 94360fc96a6f..95666ac6aa3b 100644 >>>>> --- a/drivers/phy/rockchip/Kconfig >>>>> +++ b/drivers/phy/rockchip/Kconfig >>>>> @@ -83,6 +83,14 @@ config PHY_ROCKCHIP_PCIE >>>>>       help >>>>>         Enable this to support the Rockchip PCIe PHY. >>>>> +config PHY_ROCKCHIP_SAMSUNG_HDPTX >>>>> +    tristate "Rockchip Samsung HDMI/DP Combo PHY driver" >>>>> +    depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF >>>>> +    select GENERIC_PHY >>>>> +    help >>>>> +      Enable this to support the Rockchip HDMI/DP Combo PHY >>>>> +      with Samsung IP block. >>>>> + >>>>>   config PHY_ROCKCHIP_SNPS_PCIE3 >>>>>       tristate "Rockchip Snps PCIe3 PHY Driver" >>>>>       depends on (ARCH_ROCKCHIP && OF) || COMPILE_TEST >>>>> diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile >>>>> index 7eab129230d1..3d911304e654 100644 >>>>> --- a/drivers/phy/rockchip/Makefile >>>>> +++ b/drivers/phy/rockchip/Makefile >>>>> @@ -8,6 +8,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI)    += phy-rockchip-inno-hdmi.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2)    += phy-rockchip-inno-usb2.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_NANENG_COMBO_PHY)    += phy-rockchip-naneng-combphy.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_PCIE)        += phy-rockchip-pcie.o >>>>> +obj-$(CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX)    += phy-rockchip-samsung-hdptx.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_SNPS_PCIE3)    += phy-rockchip-snps-pcie3.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_TYPEC)    += phy-rockchip-typec.o >>>>>   obj-$(CONFIG_PHY_ROCKCHIP_USB)        += phy-rockchip-usb.o >>>>> diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c >>>>> new file mode 100644 >>>>> index 000000000000..d8171ea5ce2b >>>>> --- /dev/null >>>>> +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c >>>>> @@ -0,0 +1,2045 @@ >>>>> +// SPDX-License-Identifier: GPL-2.0+ >>>>> +/* >>>>> + * Copyright (c) 2021-2022 Rockchip Electronics Co., Ltd. >>>>> + * Copyright (c) 2024 Collabora Ltd. >>>>> + * >>>>> + * Author: Algea Cao >>>>> + * Author: Cristian Ciocaltea >>>>> + */ >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> + >>>>> +#define GRF_HDPTX_CON0            0x00 >>>>> +#define HDPTX_I_PLL_EN            BIT(7) >>>>> +#define HDPTX_I_BIAS_EN            BIT(6) >>>>> +#define HDPTX_I_BGR_EN            BIT(5) >>>>> +#define GRF_HDPTX_STATUS        0x80 >>>>> +#define HDPTX_O_PLL_LOCK_DONE        BIT(3) >>>>> +#define HDPTX_O_PHY_CLK_RDY        BIT(2) >>>>> +#define HDPTX_O_PHY_RDY            BIT(1) >>>>> +#define HDPTX_O_SB_RDY            BIT(0) >>>>> + >>>>> +#define CMN_REG0000            0x0000 >>>> >>>> These register names are not particularly helpful. Maybe use a >>>> >>>> #define CMN_REG(x)            ((x) * 4) >>>> >>>> Instead? >>> >>> Yes, sounds good. >>> >>>>> + >>>>> +static int hdptx_lcpll_frl_mode_config(struct rockchip_hdptx_phy *hdptx, >>>>> +                       u32 rate) >>>>> +{ >>>>> +    u32 bit_rate = rate & DATA_RATE_MASK; >>>>> +    u8 color_depth = (rate & COLOR_DEPTH_MASK) ? 1 : 0; >>>>> +    const struct lcpll_config *cfg = lcpll_cfg; >>>>> + >>>>> +    for (; cfg->bit_rate != ~0; cfg++) >>>>> +        if (bit_rate == cfg->bit_rate) >>>>> +            break; >>>> >>>> You could use ARRAY_SIZE() to iterate over the array and save the extra >>>> entry at the end. Likewise for the other arrays used in the driver. >>> >>> Sure, will do. >>> >>>>> + >>>>> +    if (cfg->bit_rate == ~0) >>>>> +        return -EINVAL; >>>>> + >>>> >>>>> +static int rockchip_hdptx_phy_power_on(struct phy *phy) >>>>> +{ >>>>> +    struct rockchip_hdptx_phy *hdptx = phy_get_drvdata(phy); >>>>> +    int bus_width = phy_get_bus_width(hdptx->phy); >>>>> +    int bit_rate = bus_width & DATA_RATE_MASK; >>>> >>>> What is going on here? bus_width is set to 8 in probe() using >>>> phy_set_bus_width(), but the value you pull out of phy_get_bus_width() >>>> is expected to contain the bit_rate and several other flags. >>>> >>>> It looks like you are tunneling flags from some other driver using this >>>> field. Isn't there a better way to accomplish this? If not, I think this >>>> needs some explanation. >>> >>> Indeed, sorry for missing a comment here.  The flags are set by the >>> bridge driver to enable 10-bit color depth, FRL and EARC.  So far I >>> couldn't find an alternative approach to pass custom data using the PHY API. >>> >>>> At least the variable should be renamed. it's called "bus_width" and it's >>>> passed to functions like hdptx_lcpll_frl_mode_config() which has this >>>> parameter named "rate" which is quite confusing. >>> >>> I think for the initial support it's not really necessary to implement >>> all those features.  Andy, should we drop them until a better solution >>> is found? > > How about add a PHY_MODE_HDMI to enum phy_mode, and pass this custom data by extend phy_configure_opts > or the submode of phy_set_mode_ext ? Please see the patch "phy: Add HDMI configuration options" [1] from Sandor Yu. Also the series "drm/connector: Create HDMI Connector infrastructure" [2] from Maxime Ripard may be of interest. [1] https://lore.kernel.org/all/19070c125268cfe900021dea6e7e8379b89c630e.1704785836.git.Sandor.yu@nxp.com/ [2] https://lore.kernel.org/dri-devel/20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org/ Regards, Jonas >> >> I'm fine with it. >> It would be very appreciated if some linux-phy or drm bridge experts can give >> some suggestions about how to pass different custom phy modes. >> >>> >>>> Sascha >>> >>> Thanks for the review, >>> Cristian