Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3208397rdb; Thu, 16 Nov 2023 03:29:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFx9jqh+xGLYfFdaOPBNIbggjcgPTeFos8+SAI/yYtQAO3zTZ0wZdxdRZ9cWAzXi38EPtaR X-Received: by 2002:a05:6a20:4281:b0:187:4118:140 with SMTP id o1-20020a056a20428100b0018741180140mr1737451pzj.24.1700134193085; Thu, 16 Nov 2023 03:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700134193; cv=none; d=google.com; s=arc-20160816; b=wIykGym/oyjyBvMFS2Xkt2YFQukb6vRs528LI1Cqwy1oww45YBTBOaDK+lBu2pSH5q Kfq/Zvt6KuyVg7SOLLHOb96ubKTHP3k1e2zlB+FkejWVj36KTczJLZos/m7P6StBq0fF fYzF/UhaZV3HooqbndS9vC7I+KKquaebzNsu7TngQ7YeuwbVxUY1G4PDpJeIf01S8aVx o8foFRvbLmn3EvBdKNBQcj+D9p5xeIJYSf6y7DxfA8RpP9LcpRBWAjj6borT8flfx/wd DgskPZUyRvrnms4uU+Sq+70TdAX/8S9uSCazJs9PO0PVsDvZq0heHWBqYEf9VLD2lvmk ZitA== 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=S5lTa43//cUFklB5+ZWKlvD2U+T55CUcIy8KREpqNZA=; fh=PUK5fDm3R4Vh8/ugS67Ou2J04C3xQTxos56K5jZd8tw=; b=Ajy41z3L/zykcLJTv2Z/VO6SLxx8j7gugnnF8yEUz5n3jDCB/diumxbL7O+p3Vnoj2 fbRjnUWlIyq7mWdnD/EUeNZxgNzSxw4fK5Yqm6g4A8JYNBcPigQHiO2JhgI5h0DguM+w TDbRUSv2RFI85dTjTu582OWXmX4u0xdzufrvmZgYigHwoNCm6TNiZskYYgOH4l0fBj63 Q8uwth6DCWj3K+34RGMv+ylv1MHCciLoSbExZILUGHfNz5DEOfcJjXIMETB8qR3poQ7G jgYEmpGODsQrPHtSR7lwctGqCXRucgE9uhhsOZgGpnCxuTqUyDsDJJ1G8lc7UnW/jmnU RLeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dn4yo0yC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e186-20020a6369c3000000b005b82f3dcec6si12045915pgc.269.2023.11.16.03.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:29:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dn4yo0yC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id A11C0816F0CB; Thu, 16 Nov 2023 03:29:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231126AbjKPL3Z (ORCPT + 99 others); Thu, 16 Nov 2023 06:29:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjKPL3X (ORCPT ); Thu, 16 Nov 2023 06:29:23 -0500 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7D4C2 for ; Thu, 16 Nov 2023 03:29:20 -0800 (PST) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5a8628e54d4so5697017b3.0 for ; Thu, 16 Nov 2023 03:29:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700134159; x=1700738959; 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=S5lTa43//cUFklB5+ZWKlvD2U+T55CUcIy8KREpqNZA=; b=dn4yo0yCL0T25fTp0gItWCkqazues1hxwSDEHm16+GIUr0zxG/689urb77ku0Jpdbx KlQ8Mk5mzGUi9aARyWms+0JkQessRdTOYD5EbwjGgx690QDRyBDOu0ArCUb/JuIrmsIY 6Q7qzLapZzel12fDxFSjxbNYcvyn+kt+isQIJQyq924U/kRhMtRaB28aRSbojufmVQiQ Yi6REDRwL5eM3xJUy3mE5K3YOhTHHgHkQ98rlSqAMZC066EdeclOZi9MeVvUWoGqGcPd HOVNcplkU6/dzHYqv75ex9dRqLTZOEH2un+fFFHVMnQhzbx7NXa4Qek62bb9Z9K/5jOx /hgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700134159; x=1700738959; 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=S5lTa43//cUFklB5+ZWKlvD2U+T55CUcIy8KREpqNZA=; b=hebUFHvv6Ox+f7OnErjiXO9tNlWQ96c+WmPrYp1S5yIBUzFl73O34quwFhvas3yr5/ rJaHh/KHnl/OQc7tht6rW4vue1ErShjAyiBTSxswIzY5Nt99lol+eBZZNdcMAGXaI90c F4qliEBfwq/nkKrTfe7dmS1UfLvx7xaLJS9lg4Nh4yLCThJByJHI4g0tYoOScPFLM7aO uLINomTXK96/4LoC68ULWk/JNqscfLtcsr4BnGi4xuDs8bv5fe4k9Lq5PoKmPvQ3aYKQ wnqnjYWPZS7vQHBqZ/p3Y5P2gx3WFx5fuxrV/Moy2Uzgd0Y2W1O99oy3BNM2LiEXc13g SzDA== X-Gm-Message-State: AOJu0Yx+Z9m8FxBS58RceP+28nB5Ve4M+FyqEo4z3lab0JDppQ3HGd0H FCsnXT7OV29oEZkFkHpw81++g9eRSpaHXLqI8Lpy+w== X-Received: by 2002:a0d:d686:0:b0:570:2542:cc9b with SMTP id y128-20020a0dd686000000b005702542cc9bmr672414ywd.18.1700134159197; Thu, 16 Nov 2023 03:29:19 -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> In-Reply-To: <1b59d647-c345-4260-b07b-22abb70ae17a@linux.dev> From: Dmitry Baryshkov Date: Thu, 16 Nov 2023 13:29:07 +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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 03:29:50 -0800 (PST) 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. > 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). 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. 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. -- With best wishes Dmitry