Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp30649lqc; Thu, 7 Mar 2024 09:24:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXSBh12bf3rSquH9QaKZYi/dqA9WvmbNHw70xrnCLbjLwMj2txoaFJzVs9ULIefEdfxpg7aEcTvwwwKdaOu+KERr6sRdnaiZh2a8tp8Wg== X-Google-Smtp-Source: AGHT+IFIPPLV4/YekbxdabffEaFIK0OssulwtiGm2/JW6ZfT1qU2L3ws6mLSiEp5FGUic/RXbtA/ X-Received: by 2002:a17:906:2c0a:b0:a45:4d62:7805 with SMTP id e10-20020a1709062c0a00b00a454d627805mr8558490ejh.50.1709832285124; Thu, 07 Mar 2024 09:24:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709832285; cv=pass; d=google.com; s=arc-20160816; b=aRAkO9cY2RusMv/GYMI8we08MhZzAkgv/E2sPgYC2p9auNuk0hwC+UqkM/ZV/cDvlM Rbyd5RaE+Ec5ZyGg3askgCnfygOxCx1P1g5qoZRhoLiELK8q+2QmiZxgkriiyT8t5TBZ WpURBMp4w3iabfDLHG1eSB7PD3HWniX1dNnnakwLHwaR0pyWxA0bDiTCd8wojzOdXCJq IU7k9hJxOGOh7exlpSDvtlLzM4I0f7N42XWW9BbOFRMicU/2nYpb6WJf5YcckayfUWnw JVsvMvK8BziYFgR7MLUVNwrFq0so0kBLE6yRfHIEmyjOANmvZp9DLhU59GU6EdWR8/dZ cCBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xmPrJNyUvO65Mntmf+dvaDMj3oW/s3VoizSMdUu34t8=; fh=YAAtToetpfsnHAm1J9NBTCrSPftQvWIsfHfENZcC/ck=; b=YWc7altpql2qzzap3Dw51OwAl40+QbYkXeFinzQdK9w2xFuh3nrZKa9mvpvcc48o0i tfQWn7uVq0jZJ9Xf/1BnADNyosS76zuUVnQqTWeUg37eIAM4Pzs6wcvZ3GakTAF7a31w cuTXveGjOQqY6eYUqkH4NuZ26JZT+8USUlnthwOTZnC3PW0XH8bleqXWD2leAzcfticl N/Jk+bUEJ1SyMV0OezN4vvuygAY+ZkIKPZCPxua8NbtVXpAx6cSU+mDrz+hq8Dx/883k nC5Ejv+JaTGP95Y7H9flsWRKpaKxV6I+ssJ+n6RbdVW+6WTIuqZ0IT5LJ89QqVG4f6lj G1CQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=j3AFuLXi; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-95933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ne33-20020a1709077ba100b00a4491dd5766si6075628ejc.60.2024.03.07.09.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 09:24:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=j3AFuLXi; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-95933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D5A841F23029 for ; Thu, 7 Mar 2024 17:24:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98BCE130E31; Thu, 7 Mar 2024 17:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="j3AFuLXi" Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09DAA12F5BD for ; Thu, 7 Mar 2024 17:24:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709832266; cv=none; b=oFDLiZOKkosQuLcz8XVwetcJZgE4y2gftFn9UDyzFyMVJLEJGk7zgLTHbHdjJlgH3te9X6ZfEhNcH3B6muiu7E88Tw+Uu7q+Qt4U0i8STs1uH0e12LgnmmpouAxulJFR25HHZg//lQEhoNnHtsRQUVo7+gFaBDn2hGnHFmoOUPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709832266; c=relaxed/simple; bh=ws4H9kPao/kbxtlIjbBcbT//Q+uZfp2Kpk4H9UHZGXQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ll7U5LxxaGSjCrrzGfzuDcyg4fS2Lz6I/sYkluarBOBtNeIfhusz52p29d0a0m+eKLNLeSlrkwFuPDow61mVaogkB7MNZ5EqEBliwF7aYUEWT9ShnFqOiTob48RavfKderblM8OCP641WQc4o0a2KNub7wSp9zuztAHOfFbH4QI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=j3AFuLXi; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709832263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xmPrJNyUvO65Mntmf+dvaDMj3oW/s3VoizSMdUu34t8=; b=j3AFuLXik9eo9ICVd523SGR28bIWgZ0o34zDX9OdYur9kYxOVNUJnKVThUaJO4TCVRUM23 xihSJpgSxEGBfBG4FABovcdbgH8lXd9RH3e6mnXPYEAn7zoUcCfeghKs09Xy53tfwiJBEg j15uf/YECtv+/tidCxBN39V7T5VsOwE= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v2 4/4] drm-bridge: it66121: Use fwnode API to acquire device properties Date: Fri, 8 Mar 2024 01:23:34 +0800 Message-Id: <20240307172334.1753343-5-sui.jingfeng@linux.dev> In-Reply-To: <20240307172334.1753343-1-sui.jingfeng@linux.dev> References: <20240307172334.1753343-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Make this driver less DT-dependent by calling the freshly created helpers, should be no functional changes for DT based systems. But open the door for otherwise use cases. Even though there is no user emerged yet, this still do no harms. In fact, we reduce some boilerplate across drm bridge drivers. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ite-it66121.c | 63 ++++++++++++++++------------ 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c index 1c3433b5e366..a2cf2be86065 100644 --- a/drivers/gpu/drm/bridge/ite-it66121.c +++ b/drivers/gpu/drm/bridge/ite-it66121.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -1480,7 +1479,7 @@ static int it66121_audio_codec_init(struct it66121_ctx *ctx, struct device *dev) dev_dbg(dev, "%s\n", __func__); - if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) { + if (!fwnode_property_present(dev_fwnode(dev), "#sound-dai-cells")) { dev_info(dev, "No \"#sound-dai-cells\", no audio\n"); return 0; } @@ -1503,13 +1502,37 @@ static const char * const it66121_supplies[] = { "vcn33", "vcn18", "vrf12" }; +static int it66121_read_bus_width(struct fwnode_handle *fwnode, u32 port, + u32 *bus_width) +{ + struct fwnode_handle *endpoint; + u32 val; + int ret; + + endpoint = fwnode_graph_get_endpoint_by_id(fwnode, port, 0, 0); + if (!endpoint) + return -EINVAL; + + ret = fwnode_property_read_u32(endpoint, "bus-width", &val); + fwnode_handle_put(endpoint); + if (ret) + return ret; + + if (val != 12 && val != 24) + return -EINVAL; + + *bus_width = val; + + return 0; +} + static int it66121_probe(struct i2c_client *client) { u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; - struct device_node *ep; int ret; struct it66121_ctx *ctx; struct device *dev = &client->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(dev, "I2C check functionality failed.\n"); @@ -1520,37 +1543,23 @@ static int it66121_probe(struct i2c_client *client) if (!ctx) return -ENOMEM; - ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); - if (!ep) - return -EINVAL; - ctx->dev = dev; ctx->client = client; ctx->info = i2c_get_match_data(client); - of_property_read_u32(ep, "bus-width", &ctx->bus_width); - of_node_put(ep); - - if (ctx->bus_width != 12 && ctx->bus_width != 24) - return -EINVAL; - - ep = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!ep) { - dev_err(ctx->dev, "The endpoint is unconnected\n"); - return -EINVAL; - } - - if (!of_device_is_available(ep)) { - of_node_put(ep); - dev_err(ctx->dev, "The remote device is disabled\n"); - return -ENODEV; - } + /* Endpoint of port@0 contains the bus-width property */ + ret = it66121_read_bus_width(fwnode, 0, &ctx->bus_width); + if (ret) + return ret; - ctx->next_bridge = of_drm_find_bridge(ep); - of_node_put(ep); + ctx->next_bridge = drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); if (!ctx->next_bridge) { dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; + } else if (IS_ERR(ctx->next_bridge)) { + ret = PTR_ERR(ctx->next_bridge); + dev_err(dev, "Error in founding the next bridge: %d\n", ret); + return ret; } i2c_set_clientdata(client, ctx); @@ -1584,9 +1593,9 @@ static int it66121_probe(struct i2c_client *client) } ctx->bridge.funcs = &it66121_bridge_funcs; - ctx->bridge.of_node = dev->of_node; ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA; ctx->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; + drm_bridge_set_node(&ctx->bridge, fwnode); ret = devm_request_threaded_irq(dev, client->irq, NULL, it66121_irq_threaded_handler, IRQF_ONESHOT, dev_name(dev), ctx); -- 2.34.1