From patchwork Mon Jul 31 13:24:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 128783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2121476vqg; Mon, 31 Jul 2023 09:21:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlFV8RK48PgO8E67lZpIwCaRzNzSMp9R/9zpoJn2u3AsZWCdYSCgJ6H4BFmA/rKORBa9YqPH X-Received: by 2002:ac2:5b9c:0:b0:4fb:8f79:631 with SMTP id o28-20020ac25b9c000000b004fb8f790631mr214680lfn.46.1690820487020; Mon, 31 Jul 2023 09:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690820486; cv=none; d=google.com; s=arc-20160816; b=LhhXaUw5Y1tcHa4agXaYVqu8vNGWku9oB86mbGevmCZRPIyA1hNfiAIKe5dCwSzW7N 5bRMz6oYE4blONiaKhT3c7H7I16Bnp9Fw8AuOaJUMB5abWk8u84RABG34PeuY87NX5sK HEXOL6iUcsLUpNl7uScxNlXcQgPJoazywwZ5z8ARy0YqlBeOQVQBRHBoWEJq6JF0IrSf BWB0OMx3djk8hnhK4CgGZOan5+b6AZ6jTju39Epa0+lwbSXJOlzNeatGAkhK7VQVrp0O 8Re6jES6lHTIoJaDXRoSoitsvVn8szkCBU+f762bEjy8+lGmZ0xEDRJ0WRTdKSZlPNuL XMSQ== 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=752lY+0V7UW7gGjEaIVGPTeDkl3GzKXv+5Pc8DeJsOQ=; fh=jh+7v3szpfmpm7aeAZBeUyBAgjiSgOnhDPEhaInbk38=; b=lzSZ+dFbmNCiiusYrkXq08tTp96Np7+xEtPVnBaXdMaHRiS9pxCImzjA49b/DO9BUK s9jUcsxuwVzUr37EzChj3FdksHC+zNwvCrpviSQ1wRSe+K+jmKqGjIDu2YOZUJYWJA/Q 7lzir+tyrGQbSxTP6/hKxp0Upa0wMF+CDVfItT/mMs4xJayWSAP5X2rLL3AH8CCw0MZs g+dDmJ/Ue0zhkkCfPMKL5Pp0UvJnjF5kJQIwr0am3Dmcgvg1QlhmRwsgHkU2VtdIgegj jK3QhnZLfO6rMJUBF3+7bLaMiD/ASqM++nWxxoZj9xEInVxPv1Vj5aAd8yylFARolwcY 622Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Rtk99JKI; 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 b3-20020a1709062b4300b0098932a90cdasi7199996ejg.255.2023.07.31.09.21.02; Mon, 31 Jul 2023 09:21:26 -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=Rtk99JKI; 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 S233038AbjGaNZx (ORCPT + 99 others); Mon, 31 Jul 2023 09:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232993AbjGaNZn (ORCPT ); Mon, 31 Jul 2023 09:25:43 -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 12CB21713; Mon, 31 Jul 2023 06:25:37 -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 C94A72E4; Mon, 31 Jul 2023 15:24:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690809868; bh=vtei7NXd+I1IEzwPdAa7WkQkNRkfuQphMPBcmKMItug=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rtk99JKIY6VpbmfKxaH8JnhSxvUHMB6WPe9+5CkRVBxS+CfiN+HVmGwfjDNb3vN11 P0PgJZ4IMKfZLZ6Xbha7lTObGQW7Fj8+brwCCRB/8jf33tm/P7MIWX+gkTMiB0bm7C rhug2IknXeRt+g4M+l9JxiOe8Y+FUeI4KkcnmUTU= From: Tomi Valkeinen Date: Mon, 31 Jul 2023 16:24:42 +0300 Subject: [PATCH v3 8/9] media: i2c: ds90ub953: Support non-sync mode MIME-Version: 1.0 Message-Id: <20230731-fpdlink-additions-v3-8-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=2680; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=vtei7NXd+I1IEzwPdAa7WkQkNRkfuQphMPBcmKMItug=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBkx7ZAM29qGUdd4UIvtZBQzT3jVGP1/rrtTIW/o QrNAwqmC7WJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZMe2QAAKCRD6PaqMvJYe 9baDD/wLAwMWF7BQWC6WfEYlcN5XHzdeBo7/yrl3KbHcIh03HJ8k6EPYbEHrt80hPiNidFmBwjo N2/9i8J/N0lUFbNKoE07hyFztFkkpWu7nQoACikbDBuJoRforoidGYDtVwoCeJ0+hh54ThGqMms DIjeRm4rmuCv5O3BYCkAx8995kCx2bcJsMzuqR/q2DgR5HkhIq47Bt/3XeQXutY4VlFZmYYNDwd ZEF7WdtCbT7jOMFZnVqsLn1NFoTRYP+b0ir9YwfkjVrnZiaCjxQM1n8fpAybGEN5225FK+ryKSd ehyBpK0CSD5vqqs4npcOlIvo5k5ymhFluWH+7Tld23IxKwResMXyRww+J44cMqh6KHmsvFcxp2b cHM87nUHio0LE5OCF5hYLdsSjdEdheKPMlqTFWuj1x+H57Ahtb7j26qDXqX69I1ykuldsAP9Zx/ jtf1gRX4TGIjGmYcLBST0rA+8FWO7sE/PruWjRNR+d1z0heALfqBBOQMmBf/t9kEwWW1zXyH5Eo PKj4RuuUDb5vPH8xphY2EVL0wenLxatSzcjX0s6Ejx1DveIhhOoplG8SJwy82/GgMSfSpatMyE6 a4m63D7xs0fa8oHyKQJwLXj/y5+TIb3LNXhS7k+66rG6iImbirOUPs6Yn0uZZQgf8l1HF1acygS GgiWV7DJaliLdHQ== 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,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: 1772953782784125941 X-GMAIL-MSGID: 1772953782784125941 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 Reviewed-by: Laurent Pinchart Reviewed-by: Andy Shevchenko --- drivers/media/i2c/ds90ub953.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index e1bd33e91eff..d56c1dda89b3 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -145,6 +145,7 @@ struct ub953_data { struct i2c_client *client; struct regmap *regmap; + struct clk *clkin; u32 num_data_lanes; bool non_continous_clk; @@ -844,15 +845,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, @@ -1195,9 +1202,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: %u\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) @@ -1314,6 +1327,13 @@ 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)) { + ret = PTR_ERR(priv->clkin); + dev_err_probe(dev, ret, "failed to parse 'clkin'\n"); + goto err_mutex_destroy; + } + ret = ub953_parse_dt(priv); if (ret) goto err_mutex_destroy;