From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 2C58DC433FE for ; Sun, 6 Dec 2020 17:19:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB470221FC for ; Sun, 6 Dec 2020 17:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbgLFRTZ (ORCPT ); Sun, 6 Dec 2020 12:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbgLFRTZ (ORCPT ); Sun, 6 Dec 2020 12:19:25 -0500 Received: from mxf2.seznam.cz (mxf2.seznam.cz [IPv6:2a02:598:2::123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE7DCC0613D1; Sun, 6 Dec 2020 09:18:39 -0800 (PST) Received: from email.seznam.cz by email-smtpc25a.ng.seznam.cz (email-smtpc25a.ng.seznam.cz [10.23.18.34]) id 1bebbfac40e5ebc51a4273f2; Sun, 06 Dec 2020 18:18:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seznam.cz; s=beta; t=1607275101; bh=hNpVWi7xybD7pNQIgL7OSBGGIcO5ZoO5YUxC5+BpAJI=; h=Received:Subject:To:Cc:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding: Content-Language; b=hpMWLqdXJzPpUjwhhevquRpuYvrPROGViISXrFVSBFfZF3x24MJJSbXmA1qQah/Ks SuzX9o1zvMwC0y6HG3jCYqbfbVX0qoutn22pGhEOWeUz2bnMn7UI1aHYfuA2ydsAjg /v5yMtWcFH22wZVUiaSXIZnq2Agwr6n7I3HKV6Ag= Received: from [192.168.1.213] (ip-228-128.dynamic.ccinternet.cz [212.69.128.228]) by email-relay2.ng.seznam.cz (Seznam SMTPD 1.3.122) with ESMTP; Sun, 06 Dec 2020 18:18:19 +0100 (CET) Subject: Re: [PATCH 1/3] media: i2c: imx219: add support for specifying clock-frequencies To: Geert Uytterhoeven Cc: Dave Stevenson , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Geert Uytterhoeven , Magnus Damm , Linux Media Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux ARM , Linux-Renesas References: <20201205183355.6488-1-michael.srba@seznam.cz> From: Michael Srba Message-ID: Date: Sun, 6 Dec 2020 18:18:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 05. 12. 20 19:54, Geert Uytterhoeven wrote: > Hi Michael, > > On Sat, Dec 5, 2020 at 7:36 PM wrote: >> 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 > Thanks for your patch! > >> --- a/drivers/media/i2c/imx219.c >> +++ b/drivers/media/i2c/imx219.c >> @@ -1443,13 +1443,26 @@ 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_err(dev, "could not get xclk frequency\n"); >> + return ret; > This breaks compatibility with existing DTBs, which do not have the > clock-frequency property. > For backwards compatibility, you should assume the default 24 MHz > instead of returning an error. Good point, will do. >> + } >> + >> + /* 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"); > Gr{oetje,eeting}s, > > Geert > Michael From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.2 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,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 C13D3C4361B for ; Sun, 6 Dec 2020 17:19:49 +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 5DD712224C for ; Sun, 6 Dec 2020 17:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DD712224C 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:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kK3iRM9AFNumW1RqCwL4EtsB5zJFOhPzQ0qwb4o6+3w=; b=zjFNheA0FP5vWaci8GDr3hCcb 6bJb0jNRQw0E5ZFSAmDJM6pNrRtgkd67vKsuBWryfLv3sznIW8EresjavVAqikvUjlT3shK+wicY+ CUVLrcZwr/lMrwEA6pBMlAGTTC4xNYjV9CWfhpnlx0NdW1ELDRbyTPbAMjxOstBE/a85anaJ6sHKj b2HcgEzIMRz+CBb1GhTnZvwsj7O6g0pqHc8dqiFDvibbpWo0CUVohYo6B2aEVHVTRaVFTBB9gMLZc IyvwmFdpnXnS1YiWzylFrKoE8WJHavtbd5CJfvXOg3OdYd+9JqtUbwXTWyb7bAayoKC1w7CHYCGEr UshdBZ+4w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1klxgD-00085b-Gh; Sun, 06 Dec 2020 17:18:37 +0000 Received: from mxf2.seznam.cz ([2a02:598:2::123]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1klxgA-00084s-QF for linux-arm-kernel@lists.infradead.org; Sun, 06 Dec 2020 17:18:35 +0000 Received: from email.seznam.cz by email-smtpc25a.ng.seznam.cz (email-smtpc25a.ng.seznam.cz [10.23.18.34]) id 1bebbfac40e5ebc51a4273f2; Sun, 06 Dec 2020 18:18:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seznam.cz; s=beta; t=1607275101; bh=hNpVWi7xybD7pNQIgL7OSBGGIcO5ZoO5YUxC5+BpAJI=; h=Received:Subject:To:Cc:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding: Content-Language; b=hpMWLqdXJzPpUjwhhevquRpuYvrPROGViISXrFVSBFfZF3x24MJJSbXmA1qQah/Ks SuzX9o1zvMwC0y6HG3jCYqbfbVX0qoutn22pGhEOWeUz2bnMn7UI1aHYfuA2ydsAjg /v5yMtWcFH22wZVUiaSXIZnq2Agwr6n7I3HKV6Ag= Received: from [192.168.1.213] (ip-228-128.dynamic.ccinternet.cz [212.69.128.228]) by email-relay2.ng.seznam.cz (Seznam SMTPD 1.3.122) with ESMTP; Sun, 06 Dec 2020 18:18:19 +0100 (CET) Subject: Re: [PATCH 1/3] media: i2c: imx219: add support for specifying clock-frequencies To: Geert Uytterhoeven References: <20201205183355.6488-1-michael.srba@seznam.cz> From: Michael Srba Message-ID: Date: Sun, 6 Dec 2020 18:18:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201206_121834_983482_EB6690D4 X-CRM114-Status: GOOD ( 22.78 ) 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: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Geert Uytterhoeven , Dave Stevenson , Fabio Estevam , Sascha Hauer , Magnus Damm , Linux-Renesas , Rob Herring , NXP Linux Team , Pengutronix Kernel Team , Mauro Carvalho Chehab , Shawn Guo , Linux ARM , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 05. 12. 20 19:54, Geert Uytterhoeven wrote: > Hi Michael, > > On Sat, Dec 5, 2020 at 7:36 PM wrote: >> 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 > Thanks for your patch! > >> --- a/drivers/media/i2c/imx219.c >> +++ b/drivers/media/i2c/imx219.c >> @@ -1443,13 +1443,26 @@ 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_err(dev, "could not get xclk frequency\n"); >> + return ret; > This breaks compatibility with existing DTBs, which do not have the > clock-frequency property. > For backwards compatibility, you should assume the default 24 MHz > instead of returning an error. Good point, will do. >> + } >> + >> + /* 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"); > Gr{oetje,eeting}s, > > Geert > Michael _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel