From patchwork Fri Jun 16 13:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 109154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1366943vqr; Fri, 16 Jun 2023 07:04:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43TvOPnQlVVDCLpWoy6n+DdYtvRKRjc1U2NF3vJDl4W0gyLN0WOmiGyfhj+uOsdARJuKXR X-Received: by 2002:a17:902:e884:b0:1b5:16f2:a4e3 with SMTP id w4-20020a170902e88400b001b516f2a4e3mr2050540plg.30.1686924287391; Fri, 16 Jun 2023 07:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686924287; cv=none; d=google.com; s=arc-20160816; b=HmtUlXZdMfOlunt1W03IN2YhymdPsJYfv3m/0o00KyFRqsPWaC73xDg6oYrC4fjJP+ e9J+3ZXhFs2+wd/4T49iU8wXWS89cZipp3km/1eQ6D2QRG6hxtyymBttqOgLrNnmKg9G sfEMksaZe0BkPM8jWTuPVp9hmySpWHDTq9gyNkkGiDKvzgxgclAVpPO6JB4P88manaTZ e6webmhiGqE2xpwHLUJPszS1I2KYwfx7SyuNlSF156ypzTC/0zRtxHyzjjuvTzyAcdhy fWAaMKpyn/Y65brnQ98AvZ/dHLBNw/HFWQj+Kr/YoRCnILG4dEQcj50/bQ/fpQ7br8IJ zTiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L+Hdv1iNVUn5OIJFyxqDskmnCEE5rLVb5DGHxJOFEvs=; b=ZTDvxRzO7rn90ecTcWSEIGSvagai00a42APpliZD8gaxhrs0QoWTokSBP8W2nrjVsW RM20i53Mwf6BGtlKhw19Olio2JgbKrfDEXvwK5RniTim8a/STgHHXJa6UZXqumBkcYZR yx9aTIojRbPsFgimeUvRWCgVlvUQ6z79pXWntMYakF9E7hLWYa1BdfCKRMlYOSSuRcp0 ibpmxACeXVwNj7wTPBQsXs/XY9Q6DWi60wqoZV3Y+RADDWzhF+LN2hVr64BPgsv1bGqC K8jVmW3xyUcXlykUoZ70wNxJqmL5QAz1tQSh0nCLRtvsLHT5t9L/SdT14vx+JO6rwFjo nv3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=DHqU8tSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a170903124900b001b178baf356si13401906plh.95.2023.06.16.07.04.32; Fri, 16 Jun 2023 07:04:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=DHqU8tSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345062AbjFPOBz (ORCPT + 99 others); Fri, 16 Jun 2023 10:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345361AbjFPOBT (ORCPT ); Fri, 16 Jun 2023 10:01:19 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F67B3A9E; Fri, 16 Jun 2023 07:00:48 -0700 (PDT) Received: from desky.lan (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 70E6013D2; Fri, 16 Jun 2023 15:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686924001; bh=H61sLU+pMDMXwm3oliz8WTwPsmI2d35vuhKG80jM2uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHqU8tSfpK+qDd5oR/fqohDZAguo7YJzdvQbVbDtticn4TZsNLGTQ8bYOe/IB73IY YkaxU8oc9GIa5MT3unVYJ/EhyBsbpY+fJBNrx9iCycsL0RPDasbsJb47q+MxI+yODP MsQEwDiiJmT4ANv4QLmH7N5bQBMnnzpjmLInB5U8= From: Tomi Valkeinen To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Luca Ceresoli , Andy Shevchenko , Matti Vaittinen , Laurent Pinchart , Sakari Ailus Cc: Wolfram Sang , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Peter Rosin , Liam Girdwood , Mark Brown , Michael Tretter , Hans Verkuil , Mike Pagano , =?utf-8?q?Krzysztof_Ha=C5=82asa?= , Marek Vasut , Satish Nagireddy , Tomi Valkeinen Subject: [PATCH v14 14/18] media: i2c: ds90ub913: Use v4l2_fwnode_endpoint_parse() Date: Fri, 16 Jun 2023 16:59:18 +0300 Message-Id: <20230616135922.442979-15-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616135922.442979-1-tomi.valkeinen@ideasonboard.com> References: <20230616135922.442979-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768868321497070516?= X-GMAIL-MSGID: =?utf-8?q?1768868321497070516?= Use v4l2_fwnode_endpoint_parse() to parse the sink endpoint parameters. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub913.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index 203f7cceae23..9f95d0c44feb 100644 --- a/drivers/media/i2c/ds90ub913.c +++ b/drivers/media/i2c/ds90ub913.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include #define UB913_PAD_SINK 0 @@ -83,7 +85,7 @@ struct ub913_data { struct ds90ub9xx_platform_data *plat_data; - u32 pclk_polarity; + u32 pclk_polarity_rising; }; static inline struct ub913_data *sd_to_ub913(struct v4l2_subdev *sd) @@ -675,25 +677,31 @@ static int ub913_add_i2c_adapter(struct ub913_data *priv) static int ub913_parse_dt(struct ub913_data *priv) { struct device *dev = &priv->client->dev; + struct v4l2_fwnode_endpoint vep = {}; struct fwnode_handle *ep_fwnode; int ret; ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), UB913_PAD_SINK, 0, 0); - if (!ep_fwnode) { - dev_err_probe(dev, -ENOENT, "No sink endpoint\n"); - return -ENOENT; - } + if (!ep_fwnode) + return dev_err_probe(dev, -ENOENT, "No sink endpoint\n"); - ret = fwnode_property_read_u32(ep_fwnode, "pclk-sample", - &priv->pclk_polarity); + vep.bus_type = V4L2_MBUS_PARALLEL; + ret = v4l2_fwnode_endpoint_parse(ep_fwnode, &vep); fwnode_handle_put(ep_fwnode); - if (ret) { - dev_err_probe(dev, ret, "failed to parse 'pclk-sample'\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, + "failed to parse sink endpoint data\n"); + + if (vep.bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_RISING) + priv->pclk_polarity_rising = true; + else if (vep.bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_FALLING) + priv->pclk_polarity_rising = false; + else + return dev_err_probe(dev, -EINVAL, + "bad value for 'pclk-sample'\n"); return 0; } @@ -726,7 +734,7 @@ static int ub913_hw_init(struct ub913_data *priv) ub913_read(priv, UB913_REG_GENERAL_CFG, &v); v &= ~UB913_REG_GENERAL_CFG_PCLK_RISING; - v |= priv->pclk_polarity ? UB913_REG_GENERAL_CFG_PCLK_RISING : 0; + v |= priv->pclk_polarity_rising ? UB913_REG_GENERAL_CFG_PCLK_RISING : 0; ub913_write(priv, UB913_REG_GENERAL_CFG, v); return 0;