Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3352524rdb; Thu, 16 Nov 2023 07:23:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAPAY/dWdj/051yvZkYdC1uUVXqvks50ZowxOU7ehGe2ltTYQueaZw64eTClS8jB1KbYlw X-Received: by 2002:a05:6808:19a2:b0:3a1:e17a:b3fb with SMTP id bj34-20020a05680819a200b003a1e17ab3fbmr23737169oib.1.1700148236808; Thu, 16 Nov 2023 07:23:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700148236; cv=none; d=google.com; s=arc-20160816; b=DHqinA3xuNgsp8cQCsTPsMgroozEif616xr1NoTT/BOIFnMs5qF1zg2bT21fV9tYMK YKoUSiErVvbfteiofofqGw+eZqG+W6BuyAVkSQCp+A+Rmndasw08Qbu0igFMDGWFxVLA inubBmauGJbETuB3WyOEUXgsrX9k+ZWDPpYI4vIUQvY/gcXiWhgPIoNS2AYBe7U9jNbh G/cC1jxQIkJVHs2v2EtT6K+8EfAZX7d5b+KMGvpzgsj08Suedgc2XDkCr1ECUkG8ZXvP N322VhPX/VHnxU4t0SwEfRxtTUT9tKKmnji7OSayJQI1N+U7/0ZrEPCAxlLLhrccTfpz 0cgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jSgupIeANP5tueuGjabzmCgxHpd7wjSVIIaOyj586g8=; fh=PUK5fDm3R4Vh8/ugS67Ou2J04C3xQTxos56K5jZd8tw=; b=iZv79cCy/OaGcFSrMxMP7Q+AA9ERj8mxKIGhSSNjL+LAwFgSNQvHRjwnFmgieHlFzt 5Ks1Hbvo0XdxgdDsr92kLZB62kv330vLwUjRQyo1JWxtynMfGIuhM3pBqz2BYqXqMxoE d8nBdiYmq1W+bXChox85kEKXR+mgGYk2QeTpv2CKnw5cA+u4IBeU5AyXWbvTZjIXJqDd g3a0m9ktPf1JYyE+W6Qshcq+tNiA1j/YfSt2NxUYosSQnS0TkpbQOr3vR9cvKwzTejIA Mgg34nlXDBrBoQu/75AumHee0z7PTzNkhCardAeWszStHsvDLzxjgLwKwcXgMy/XA96Y 9R+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6VVoZL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x188-20020a6363c5000000b0054fd947f66dsi12088168pgb.210.2023.11.16.07.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 07:23:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6VVoZL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 435F5802C6B6; Thu, 16 Nov 2023 07:23:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbjKPPX1 (ORCPT + 99 others); Thu, 16 Nov 2023 10:23:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbjKPPX0 (ORCPT ); Thu, 16 Nov 2023 10:23:26 -0500 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D4D126 for ; Thu, 16 Nov 2023 07:23:22 -0800 (PST) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-d9fe0a598d8so865928276.2 for ; Thu, 16 Nov 2023 07:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700148201; x=1700753001; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jSgupIeANP5tueuGjabzmCgxHpd7wjSVIIaOyj586g8=; b=C6VVoZL3OWgeErug8AwuxL9UDuqDvihZKZSFEukscobEg+Jy7z9qHAIMnGHEKsMOhi /l687KOFpoU5g/nTN3KrUoivHflhzZ/xTW/KemdUSb4YRmUUcoi0vHB3hZLMx0dEU486 EOBMeNng9Ox8ppMC98cTmuHA7eodcpyGDMsndxK9qDqGUUdaCWaoXMbwWXfkKHxmP/ME MWn1+M144VXf3Coe8rdrwkL5+TGrEEfyvkbM8nTAYSkC0EMmOc2vL1cG/hIaCIHLeRsI Xt6OUo4XlCq6pn2ne/r+COX9QGSZEdmu/jlKsewnaOw16WbkmU/RxdtHYT34hEY+WLBv pe1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700148201; x=1700753001; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jSgupIeANP5tueuGjabzmCgxHpd7wjSVIIaOyj586g8=; b=TONn5aTb7dxy1jNmj2Al/oif/wzWz6lkULq1D/qyjr/c9nGfpEL0aB6lpzyPrlcmNa maoN7OFGLSRylWVP+SwqS+lXxEYUXH2DLY7Q5Sp2w9jmjIawm15pmtSmyL0brTvkh09Q YnBwGspUFMzBm8hvu+4a/i9T06jSjURw6u2Vm0BSUp1ac/6i6SxVqlrMsYyJL82I27V3 8moYvWF4bzBEf+zqHL78Nhl1YNWdrJDcJZN0RBwptczCJOLGmezNJyto+z9n0q7BC680 ork1MHylJ0Lobr1J+YxMEYtvfNZwXmmGu6zzerQcj/BkcjxwksaMbcWtnpP1XNQlyv0a jn5A== X-Gm-Message-State: AOJu0YxPUg5WuXRLk8fW5gg7FjbvQ1JHtr2dh/UJ/ZjTIpHHsZjhp8DW Qod3V6I+Kdzl/GHBdDsL6Nck2HdwcaBkTAL4C63jEA== X-Received: by 2002:a05:6902:188d:b0:d9a:49bb:3d1d with SMTP id cj13-20020a056902188d00b00d9a49bb3d1dmr18422215ybb.3.1700148201540; Thu, 16 Nov 2023 07:23:21 -0800 (PST) MIME-Version: 1.0 References: <20231114150130.497915-1-sui.jingfeng@linux.dev> <20231114150130.497915-9-sui.jingfeng@linux.dev> <1b59d647-c345-4260-b07b-22abb70ae17a@linux.dev> <7b85d057-3d66-435a-a657-dd69067b6bef@linux.dev> In-Reply-To: From: Dmitry Baryshkov Date: Thu, 16 Nov 2023 17:23:09 +0200 Message-ID: Subject: Re: [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib To: Sui Jingfeng Cc: Phong LE , Neil Armstrong , Maxime Ripard , Sui Jingfeng , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent Pinchart , Thomas Zimmermann Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 07:23:30 -0800 (PST) On Thu, 16 Nov 2023 at 14:08, Sui Jingfeng wrote: > > > On 2023/11/16 19:53, Sui Jingfeng wrote: > > Hi, > > > > > > On 2023/11/16 19:29, Dmitry Baryshkov wrote: > >> On Thu, 16 Nov 2023 at 13:18, Sui Jingfeng > >> wrote: > >>> Hi, > >>> > >>> > >>> On 2023/11/15 00:30, Dmitry Baryshkov wrote: > >>>>> + > >>>>> + ctx->connector = connector; > >>>>> + } > >>>>> > >>>>> if (ctx->info->id == ID_IT66121) { > >>>>> ret = regmap_write_bits(ctx->regmap, > >>>>> IT66121_CLK_BANK_REG, > >>>>> @@ -1632,16 +1651,13 @@ static const char * const > >>>>> it66121_supplies[] = { > >>>>> "vcn33", "vcn18", "vrf12" > >>>>> }; > >>>>> > >>>>> -static int it66121_probe(struct i2c_client *client) > >>>>> +int it66121_create_bridge(struct i2c_client *client, bool > >>>>> of_support, > >>>>> + bool hpd_support, bool audio_support, > >>>>> + struct drm_bridge **bridge) > >>>>> { > >>>>> + struct device *dev = &client->dev; > >>>>> int ret; > >>>>> struct it66121_ctx *ctx; > >>>>> - struct device *dev = &client->dev; > >>>>> - > >>>>> - if (!i2c_check_functionality(client->adapter, > >>>>> I2C_FUNC_I2C)) { > >>>>> - dev_err(dev, "I2C check functionality failed.\n"); > >>>>> - return -ENXIO; > >>>>> - } > >>>>> > >>>>> ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); > >>>>> if (!ctx) > >>>>> @@ -1649,24 +1665,19 @@ static int it66121_probe(struct i2c_client > >>>>> *client) > >>>>> > >>>>> ctx->dev = dev; > >>>>> ctx->client = client; > >>>>> - ctx->info = i2c_get_match_data(client); > >>>>> - > >>>>> - ret = it66121_of_read_bus_width(dev, &ctx->bus_width); > >>>>> - if (ret) > >>>>> - return ret; > >>>>> - > >>>>> - ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); > >>>>> - if (ret) > >>>>> - return ret; > >>>>> - > >>>>> - i2c_set_clientdata(client, ctx); > >>>>> mutex_init(&ctx->lock); > >>>>> > >>>>> - ret = devm_regulator_bulk_get_enable(dev, > >>>>> ARRAY_SIZE(it66121_supplies), > >>>>> - it66121_supplies); > >>>>> - if (ret) { > >>>>> - dev_err(dev, "Failed to enable power supplies\n"); > >>>>> - return ret; > >>>>> + if (of_support) { > >>>>> + ret = it66121_of_read_bus_width(dev, > >>>>> &ctx->bus_width); > >>>>> + if (ret) > >>>>> + return ret; > >>>>> + > >>>>> + ret = it66121_of_get_next_bridge(dev, > >>>>> &ctx->next_bridge); > >>>>> + if (ret) > >>>>> + return ret; > >>>>> + } else { > >>>>> + ctx->bus_width = 24; > >>>>> + ctx->next_bridge = NULL; > >>>>> } > >>>> A better alternative would be to turn OF calls into fwnode calls and > >>>> to populate the fwnode properties. See > >>>> drivers/platform/x86/intel/chtwc_int33fe.c for example. > >>> > >>> Honestly, I don't want to leave any scratch(breadcrumbs). > >>> I'm worries about that turn OF calls into fwnode calls will leave > >>> something unwanted. > >>> > >>> Because I am not sure if fwnode calls will make sense in the DT > >>> world, while my patch > >>> *still* be useful in the DT world. > >> fwnode calls work for both DT and non-DT cases. In the DT case they > >> work with DT nodes and properties. In the non-DT case, they work with > >> manually populated properties. > >> > >>> Because the newly introduced it66121_create_bridge() > >>> function is a core. I think It's better leave this task to a more > >>> advance programmer. > >>> if there have use case. It can be introduced at a latter time, > >>> probably parallel with > >>> the DT. > >>> > >>> I think DT and/or ACPI is best for integrated devices, but it66121 > >>> display bridges is > >>> a i2c slave device. Personally, I think slave device shouldn't be > >>> standalone. I'm more > >>> prefer to turn this driver to support hot-plug, even remove the > >>> device on the run time > >>> freely when detach and allow reattach. Like the I2C EEPROM device in > >>> the monitor (which > >>> contains the EDID, with I2C slave address 0x50). The I2C EEPROM > >>> device *also* don't has > >>> a corresponding struct device representation in linux kernel. > >> It has. See i2c_client::dev. > > > > No, what I mean is that there don't have a device driver for > > monitor(display) hardware entity. > > And the drm_do_probe_ddc_edid() is the static linked driver, which is > > similar with the idea > > this series want to express. Because the monitor is not a part of the display pipeline. > > > > > >>> so I still think It is best to make this drivers functional as a > >>> static lib, but I want > >>> to hear you to say more. Why it would be a *better* alternative to > >>> turn OF calls into > >>> fwnode calls? what are the potential benefits? > >> Because then you can populate device properties from your root device. > >> Because it allows the platform to specify the bus width instead of > >> hardcoding 24 bits (which might work in your case, but might not be > >> applicable to another user next week). > > > > > > No, this problem can be easily solved. Simply add another argument. > > > > ``` > > > > int it66121_create_bridge(struct i2c_client *client, bool of_support, > > bool hpd_support, bool audio_support, u32 > > bus_width, > > struct drm_bridge **bridge); > > ``` > > > > > >> Anyway, even without fwnode, I'd strongly suggest you to drop the > >> it66121_create_bridge() as it is now and start by populating the i2c > >> bus from your root device. > > > > This will force all non-DT users to add the similar code patter at the > > display controller side, > > which is another kind of duplication. The monitor is also as I2C slave > > device, can be abstract > > as a identify drm bridges in theory, I guess. > > > > 'identify' -> 'identity' > > > > > >> Then you will need some way (fwnode?) to > >> discover the bridge chain. And at the last point you will get into the > >> device data and/or properties business. > >> > > No, leave that chance to a more better programmer and forgive me please, > > too difficult, I'm afraid of not able to solve. Thanks a lot for the > > trust! From my point of view: no. -- With best wishes Dmitry