From patchwork Sun Dec 6 17:27:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Srba X-Patchwork-Id: 11954199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30671C4167B for ; Sun, 6 Dec 2020 17:31:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4AEF22D06 for ; Sun, 6 Dec 2020 17:31:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4AEF22D06 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=seznam.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Wb8Al9UjiPv7BR1XZjX2X8gTeewmQeX0iXio5K2T+/o=; b=PQkS9tJGWISU6HIYF12vRVF3ET j5ZhwnhYIQtzRLs52hhbIsmQvfPnF2/lx++FqKvTmFe5zguMQWeYwXZM37rIb+r50CngqwC3X2XTK XJCgiWVxAuW7i528244uX7ShxjlJ3LXzLkvOcmu0orbwNRzUOPKaJ9c/OHS7seS8lJbuPJ+7yTMKU K5YG15zhe0Adf8Ouf7wfycfo3y1Nv0zTsQrBKlb5YFIf5XiVp0GsyZw7KGnIOBksRgTY5QvpKoQK3 xXB07ZkPzzT1UYo6toN60byNMUlarRpcq6vy0Rx+pJ8zqriy8UdrxtRZdI41bguMp9yChj1TpTtxl U0YZmp3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klxrI-0000Z2-RC; Sun, 06 Dec 2020 17:30:04 +0000 Received: from mxf1.seznam.cz ([2a02:598:a::78:123]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klxrA-0000Wr-AD for linux-arm-kernel@lists.infradead.org; Sun, 06 Dec 2020 17:29:58 +0000 Received: from email.seznam.cz by email-smtpc5b.ko.seznam.cz (email-smtpc5b.ko.seznam.cz [10.53.13.135]) id 177cf2754c72a61c16d53e2b; Sun, 06 Dec 2020 18:29:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seznam.cz; s=beta; t=1607275788; bh=ybBRjPqU6rJbV5rjROFU6Aw8Yi20t5tZm3wNoJxhQoU=; h=Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; b=W0Eb/fahfv3jR1xYww7la/Lvvm4l/ogTeAAj/+iUpVcfGYR3ojFtXfSb7JTmREvAD IoOL3Qt7sV7U/pIHDoFq1j11akEPIFCC9DIR03qJb/uADnVsb3qVqUEgrOiMdyK6w/ iWw9dsc5DPt5t9rUaZw+HSLwt0jQB+w7DfRrtAcI= Received: from localhost.localdomain (ip-228-128.dynamic.ccinternet.cz [212.69.128.228]) by email-relay23.ko.seznam.cz (Seznam SMTPD 1.3.122) with ESMTP; Sun, 06 Dec 2020 18:29:46 +0100 (CET) From: michael.srba@seznam.cz To: Dave Stevenson , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer Subject: [PATCH v2 1/3] media: i2c: imx219: add support for specifying clock-frequencies Date: Sun, 6 Dec 2020 18:27:18 +0100 Message-Id: <20201206172720.9406-1-michael.srba@seznam.cz> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201206_122956_714923_C6CE4E48 X-CRM114-Status: GOOD ( 17.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Geert Uytterhoeven , Magnus Damm , linux-renesas-soc@vger.kernel.org, Michael Srba , NXP Linux Team , Pengutronix Kernel Team , Fabio Estevam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Michael Srba This patch adds 1% tolerance on input clock, similar to other camera sensor drivers. It also allows for specifying the actual clock in the device tree, instead of relying on it being already set to the right frequency (which is often not the case). Signed-off-by: Michael Srba --- changes since v1: default to exactly 24MHz when `clock-frequency` is not present --- drivers/media/i2c/imx219.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index f64c0ef7a897..b6500e2ab19e 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -1443,13 +1443,28 @@ static int imx219_probe(struct i2c_client *client) return PTR_ERR(imx219->xclk); } - imx219->xclk_freq = clk_get_rate(imx219->xclk); - if (imx219->xclk_freq != IMX219_XCLK_FREQ) { + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &imx219->xclk_freq); + if (ret) { + dev_warn(dev, "could not get xclk frequency\n"); + + /* default to 24MHz */ + imx219->xclk_freq = 24000000; + } + + /* this driver currently expects 24MHz; allow 1% tolerance */ + if (imx219->xclk_freq < 23760000 || imx219->xclk_freq > 24240000) { dev_err(dev, "xclk frequency not supported: %d Hz\n", imx219->xclk_freq); return -EINVAL; } + ret = clk_set_rate(imx219->xclk, imx219->xclk_freq); + if (ret) { + dev_err(dev, "could not set xclk frequency\n"); + return ret; + } + + ret = imx219_get_regulators(imx219); if (ret) { dev_err(dev, "failed to get regulators\n");