From patchwork Fri Jun 16 13:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 109159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1375362vqr; Fri, 16 Jun 2023 07:15:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6x+wxz0Y1z+xdfuEAX2F2IOWUsO8fD094XNlLytpHiAx/dORQt/Td8qskg6jdBVwSRCeIp X-Received: by 2002:a17:90b:1057:b0:258:ebb3:932 with SMTP id gq23-20020a17090b105700b00258ebb30932mr1646628pjb.3.1686924919393; Fri, 16 Jun 2023 07:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686924919; cv=none; d=google.com; s=arc-20160816; b=v86GXINH3LC+SJsEUq6LDxj8/mQjwSvH16Nn2tZsUDfCCcsx0flGmjRBx/lEVFowSn KeBHZCzCC74J1pYBw/Es9D6/mB0i5jh4171kuko27dB1ahtdVfPft78PmL7m9Fmzcgxe lpO6d1436cdnOO+oC/PFqG1A4o3vgY0NBUYOgxIYiwWSbv8E5UsGLO2Idy+yv5nsXYCd a0xBMOPJ7Me7Ux+ZEdyQtHinbLEPDmb/BIo+lCby0HfzYU6Tll+tpw9vDkouxwUWJK8u TPWjn5Qkb+a6JQPQsBhF+SAr8MnxsaiPFAz9dyiNOFxl1mj9BZeQQlk130LL2kUukKwh L6UQ== 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=kaNwsMyrBs4VlZNduHfOdu/VwPuP+MFzTD9JZVwkWx4=; b=VgCaG7asTdR7ee8c/G2uWsLM/TIiuMwEmr6PxbO18F8BPEDj9YBXfLPKnZtzPPGPZt sSWc+F46abKq4YSxyjK58e9g8ja2JpDrM+02McUJXt1w1G8A7vZ+itY9mc3Trnvqw7mG M5pQWz0bGLG4uR6wY16kwpsNIw+zTokCwYC/VPhYJl01SoX+tUfZYqgGwTnvmY3/s0gr gXFXVdXYMjBaY++VyO35gnu9NpghgreWQeOP95UU26nIXTYDVlY2f/1aJ2hp6yO+9/MD RIo6MAqfl3ukxnudpe60FEHg+vRA31HFs3bCly7Uw38YFBw6w1zXuY5qtKs/QNAWKrmM 3IZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=tzJeiLVt; 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 j5-20020a637a45000000b004fb8abdd188si2850118pgn.115.2023.06.16.07.15.04; Fri, 16 Jun 2023 07:15:19 -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=tzJeiLVt; 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 S1344647AbjFPOCA (ORCPT + 99 others); Fri, 16 Jun 2023 10:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345702AbjFPOBX (ORCPT ); Fri, 16 Jun 2023 10:01:23 -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 CEEB53C3E; Fri, 16 Jun 2023 07:00:52 -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 D38349CA; Fri, 16 Jun 2023 16:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686924008; bh=e8hgMd9naRgk1G2Q6oVS0NzY0giecTRVjFGHh0pIH4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tzJeiLVtEg4EztEc7jsNCFtBWIaOg+0aiMLwbXXubqS7yTg0w/XNITL/kuxV5SJk0 ZBtiBzWvdjHj1V/zWydLpPZxlu80z79NuvQSFpQqqmCzuSMeZCaEcEqyc65JfdRAYP XIYWT8Gr3f+WB1LHK2yPrgcu6iS3WXqWb+TbnmC4= 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 18/18] media: i2c: ds90ub953: Support non-sync mode Date: Fri, 16 Jun 2023 16:59:22 +0300 Message-Id: <20230616135922.442979-19-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?1768868984537590846?= X-GMAIL-MSGID: =?utf-8?q?1768868984537590846?= Add support for FPD-Link non-sync mode with external clock. The only thing that needs to be added is the calculation for the clkout. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub953.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index ff55740965eb..ae90a647489a 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -143,6 +143,7 @@ struct ub953_data { struct i2c_client *client; struct regmap *regmap; + struct clk *clkin; u32 num_data_lanes; bool non_cont_clk; @@ -842,15 +843,21 @@ static int ub953_i2c_master_init(struct ub953_data *priv) static u64 ub953_get_fc_rate(struct ub953_data *priv) { - if (priv->mode != UB953_MODE_SYNC) { + switch (priv->mode) { + case UB953_MODE_SYNC: + if (priv->hw_data->is_ub971) + return priv->plat_data->bc_rate * 160ull; + else + return priv->plat_data->bc_rate / 2 * 160ull; + + case UB953_MODE_NONSYNC_EXT: + /* CLKIN_DIV = 1 always */ + return clk_get_rate(priv->clkin) * 80ull; + + default: /* Not supported */ return 0; } - - if (priv->hw_data->is_ub971) - return priv->plat_data->bc_rate * 160ull; - else - return priv->plat_data->bc_rate / 2 * 160ull; } static unsigned long ub953_calc_clkout_ub953(struct ub953_data *priv, @@ -1189,9 +1196,15 @@ static int ub953_hw_init(struct ub953_data *priv) dev_dbg(dev, "mode from %s: %#x\n", mode_override ? "reg" : "strap", priv->mode); - if (priv->mode != UB953_MODE_SYNC) + if (priv->mode != UB953_MODE_SYNC && + priv->mode != UB953_MODE_NONSYNC_EXT) return dev_err_probe(dev, -ENODEV, - "Only synchronous mode supported\n"); + "Unsupported mode selected: %d\n", + priv->mode); + + if (priv->mode == UB953_MODE_NONSYNC_EXT && !priv->clkin) + return dev_err_probe(dev, -EINVAL, + "clkin required for non-sync ext mode\n"); ret = ub953_read(priv, UB953_REG_REV_MASK_ID, &v); if (ret) @@ -1319,6 +1332,11 @@ static int ub953_probe(struct i2c_client *client) goto err_mutex_destroy; } + priv->clkin = devm_clk_get_optional(dev, "clkin"); + if (IS_ERR(priv->clkin)) + return dev_err_probe(dev, PTR_ERR(priv->clkin), + "failed to parse 'clkin'\n"); + ret = ub953_parse_dt(priv); if (ret) goto err_mutex_destroy;