From patchwork Mon Jul 31 13:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 128722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2040261vqg; Mon, 31 Jul 2023 07:09:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGuzeFqX6rLM/ASEVPBm0UxFKCdgdzvWJ+aDyilDqKijSAG3BpJ0F5iWp9MS9W80stQaH7j X-Received: by 2002:a17:902:ea09:b0:1b8:76ce:9d91 with SMTP id s9-20020a170902ea0900b001b876ce9d91mr11967021plg.1.1690812598573; Mon, 31 Jul 2023 07:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690812598; cv=none; d=google.com; s=arc-20160816; b=qMcxXDSAxGuBb+RLe7qYzqCZOwUr+UySqt1cJO3ecqiH9H8ebh3Vj5IgM7iqzL4FAl iUEABY2sC8deXe9oKmvwZ9A3xnEbOrNZOo/jXFomKNo3df9raenk9L6POitVS2zKgExF sFXsjaeVgIrfX52rBIBaXMkx8ywj2F9B4Nc5u6qeZAOjdTiKm2yvpJgBEwqADUNmJUZO fagEvUkXQ5PpRzhophbakQ7MHzDaEV9vSFzXidb0HKJ2zCJnwK2e7hk0Q2rEvCIPHlaC HXu8hV1siJaya2dpzGrsauC5Z9kJEudjgEAJFGcGWqobZc2lVShlXkZVnxyGRz8Qe2rr hURA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=3t0nZZVH8+qe2utI/7pqQwHejtIOJPiA6NoXeVxGc/M=; fh=jh+7v3szpfmpm7aeAZBeUyBAgjiSgOnhDPEhaInbk38=; b=pTit0TMZYaTs1jUKSgw3IRbesCI2aJ965A3CCs3lkXHDBpb87qYBkPeREGWlrZIwoh HSGPO673h/qQjNoyTzizVCYxjC6N+R5oy2A7Psf26D6M0cqgPcQg2Ge4YdMZ4/GDZifq pQBRXCVhQa9BqyYwYpHx+ehTtzxGpePE1gm82WLyAnsLyjU8bVHM9ILZKJPUWdj56xPJ bVuhO76xUpEo6nRvRa23yv94BLlJDTNF7Z3PBJo0UjgsVqXWGtxsuWZu6F0xgLEzxJ7I tf8DLXjomGfQV8RPzoI7PKWIShtTKKQlZ6RpEHf1VH0PvLpPTrgTLZxN6s0Zj94VnHxr IXbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=fpo+n3u2; 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 n18-20020a170902d2d200b001b9c992945fsi2471449plc.555.2023.07.31.07.09.44; Mon, 31 Jul 2023 07:09:58 -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=fpo+n3u2; 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 S232965AbjGaNZn (ORCPT + 99 others); Mon, 31 Jul 2023 09:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232956AbjGaNZc (ORCPT ); Mon, 31 Jul 2023 09:25:32 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 982B610F0; Mon, 31 Jul 2023 06:25:30 -0700 (PDT) Received: from [127.0.1.1] (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C6981536; Mon, 31 Jul 2023 15:24:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690809864; bh=0yRsXxkV/lQOSYD48MHpa+oMNWDiUXYP+PtboMvfA0g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fpo+n3u2nDplkFqME14iiXcqzAeXE6WfnK/3FCUpz9XeLZWhhe8I0TNNGI2RzOpc4 pPuTWYm13aZ1jm2S5QD+bFt0F96sFeemisuJIb00di4ZMvG2IzDwjgEeDkdUMXYHOQ 7WW+OA3UcI1IVgyImGOpiCeCLcjy6afPiYMLhhcg= From: Tomi Valkeinen Date: Mon, 31 Jul 2023 16:24:38 +0300 Subject: [PATCH v3 4/9] media: i2c: ds90ub913: Use v4l2_fwnode_endpoint_parse() MIME-Version: 1.0 Message-Id: <20230731-fpdlink-additions-v3-4-8acfc49c215a@ideasonboard.com> References: <20230731-fpdlink-additions-v3-0-8acfc49c215a@ideasonboard.com> In-Reply-To: <20230731-fpdlink-additions-v3-0-8acfc49c215a@ideasonboard.com> To: Mauro Carvalho Chehab , Luca Ceresoli , Andy Shevchenko , Laurent Pinchart , Sakari Ailus , Hans Verkuil , Satish Nagireddy , Matti Vaittinen Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , Andy Shevchenko X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2737; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=0yRsXxkV/lQOSYD48MHpa+oMNWDiUXYP+PtboMvfA0g=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBkx7Y/UkF+aCPnDnU61gZ5W+NDaI/oDWZ3ErtOe FxN+bJF0H6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZMe2PwAKCRD6PaqMvJYe 9R10EAClMto+yzFKFHic76uSK/9sKjxdUH7wt+8tedKLXTqQn6WNzQviFcM8LVJAycaBMk6LwZ5 q+520qzpIx4PagGAkHXLFvVXJwwxZdS6/BIoikAns+/3clcQSRclazteVWskCgPSIU1llUQK2Lf 2U0TDkVFzUM4rMyjpT6RXHMUF/DiIKsuuj4RKSPxDbRbozk0kcyPImaAaetMcGYAsGQ/cK7vDf6 54GJxmefhGY3te3ppxhDmjqrfAT4Cd9D9CfIiUHQ+8f9Cb7w6X2nVqkrXnQs7r5EmPfLF7BSjc6 VFL8NeZsVMwXrcTTtz3OLovT+zo5D1GLjqRDZk0liQMuxibYvjrv60GAHkla0qK3P3/rObi7aLz oZQCE12RMhtJ0rNNSdi2nYF1LmuwoYAE9ieLbbJ+PpVs9cu23SHnfXuiqOeX/AAKByfP6Gh/F+s pqfKZ+cNNvdLx1xm8Eoiwztp61m5OPmLFunC4NAA8BQ2y1l7uqi1uVnnbprZ50K1jdwyxe5Dsht nO1o9N0vON9en4g+yzTEygFNtvx4SFri4ORTWkCk05DUdyuyJP7UA9gRuWP1Jney1v0V2NHdVYB 0t4pyPOUJutMDH2rshGeNRWIoE1TEW60maQdLpZBq+NdYExuK/G58iY8ZjDaxMKVrlQrayQEalB mF3F96dTWAdav7A== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772945511210716836 X-GMAIL-MSGID: 1772945511210716836 Use v4l2_fwnode_endpoint_parse() to parse the sink endpoint parameters. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Andy Shevchenko --- drivers/media/i2c/ds90ub913.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index 5410ccb54057..85b664e33482 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; + bool pclk_polarity_rising; }; static inline struct ub913_data *sd_to_ub913(struct v4l2_subdev *sd) @@ -675,25 +677,32 @@ 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 = { + .bus_type = V4L2_MBUS_PARALLEL, + }; 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); + 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 +735,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;