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.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C2769C433FE for ; Mon, 7 Dec 2020 09:45:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89C8822C7E for ; Mon, 7 Dec 2020 09:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbgLGJpY (ORCPT ); Mon, 7 Dec 2020 04:45:24 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39173 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgLGJpX (ORCPT ); Mon, 7 Dec 2020 04:45:23 -0500 Received: by mail-wr1-f65.google.com with SMTP id c1so128065wrq.6; Mon, 07 Dec 2020 01:45:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VDaELBJNAHnJCXBlzzeKHCr2UreS9lliSm76y6uffoQ=; b=gy59ZTWN6ENG7kU1yOoJnRr/OAmnMjmu+9sruDAOlz/B/7PsqyWdOZw+pJy7NvfPXE 1EoFT06PVwCF+C8RonZmNu+J46krGGsOapkmdZ2Zm/I9wntlWIYL6aNjacPefbxBxgY5 wqvMtVTsxV4+RRIefudjuJYLsyuZtStISfjCsoTHx0WwVwavqZUbyLBmcfzY3wuXhqdV roL+3kiPrGXTgO601C0yFCfpD3E3jbDk+cDh37iZmPlg3Ic6/XtJqbIrQCPhE17C711H 92KpQUZOlmx0OnRMkzrGD/xDCKeZFbzZl8g3489mKkdQaXP1xWUV3KtiIQq6lH+peK8n GDHg== X-Gm-Message-State: AOAM531cEoE62yjfzncfGJkXUQzdkj+t7MTOTNDMvOCdaCpZ0/5Rv/jp WxIQqZtWaZ+m0uzDC3q+C70= X-Google-Smtp-Source: ABdhPJwfT27kvUX1kkV3sfhoA2umu107YomTUVjpfX0vBm8TaA9H5pQnBuJGrMYFT9xoqapaV/Ri3w== X-Received: by 2002:a5d:414e:: with SMTP id c14mr18452293wrq.256.1607334281147; Mon, 07 Dec 2020 01:44:41 -0800 (PST) Received: from kozik-lap (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.googlemail.com with ESMTPSA id y7sm13652154wmb.37.2020.12.07.01.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 01:44:39 -0800 (PST) Date: Mon, 7 Dec 2020 10:44:38 +0100 From: Krzysztof Kozlowski To: michael.srba@seznam.cz 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@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH 1/3] media: i2c: imx219: add support for specifying clock-frequencies Message-ID: <20201207094438.GA17448@kozik-lap> References: <20201205183355.6488-1-michael.srba@seznam.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201205183355.6488-1-michael.srba@seznam.cz> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Sat, Dec 05, 2020 at 07:33:53PM +0100, michael.srba@seznam.cz 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). All this can be achieved with assigned-clocks-rate and basically you do not add here value. At least not for DT-based systems. The supported clock rates will be the same. The method of choosing frequency is over-complicated comparing to simple assigned-clocks. If this is for ACPI systems, please document in commit msg why you cannot used assigned-clocks and choose this solution. > > Signed-off-by: Michael Srba > --- > drivers/media/i2c/imx219.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c > index f64c0ef7a897..a8f05562d0af 100644 > --- 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 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; > + } > + > + No need for double line break. Best regards, Krzysztof 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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 65AF8C433FE for ; Mon, 7 Dec 2020 09:46:00 +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 1FB242220B for ; Mon, 7 Dec 2020 09:46:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FB242220B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1W6gJKRnzncVLv1vGv4JuVuOrn8ovmpU80OkzrpWOc0=; b=xtSVKbz1hQ2wqAksSbHQde/Wi sBtpTpenRcDExbqKiBfxwAgkhq/sGYstaJ+iXJD4Evqkfj8o+xLj3HJirvPZ5Q+FtMSEpv/o/Cbpd sYaZp5g18oC0HTYQ3SEWCwiHuIm5IJxNA5YI61CyhFnpQlpkp/81tIioWGx7qcLLIA19MBVvBPYgJ MkWYyirdZBhM09ZQRaq6ItyPl7Jru54gRd523ev9sszSQY/I4HpIC3eo+fT5lKKoCJtwOGEIC/oxW ikeuCAIxp/Zt/phhf6YSeNVFsGEB0RyFDN5KedD7OQwAy/c+o+qAYZ6myUWOO+SPoLu+Gd1YEBYmO aDc3C85jg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmD4a-0007Xj-8f; Mon, 07 Dec 2020 09:44:48 +0000 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmD4W-0007WO-4Y for linux-arm-kernel@lists.infradead.org; Mon, 07 Dec 2020 09:44:44 +0000 Received: by mail-wr1-f68.google.com with SMTP id x6so8151937wro.11 for ; Mon, 07 Dec 2020 01:44:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VDaELBJNAHnJCXBlzzeKHCr2UreS9lliSm76y6uffoQ=; b=WV8jh4YUR1Sqg2xPac0Kj4kIBgUHRCd3BPe5gFnprlKIzWnpoSKu62LR0+YF0RYBC+ fUe23+90Ku94QaSpXxy+yDL8STIcAa2zgUYXhf/gZqZx4bWDEkkTS+ObBaSP3irh1VV9 YNH91MKYB9N0uOYySUnrW6tdOdXtSlElbUEMBS1sVczW+xtJl2kkFr6uCAL/AWzK3uSR lz9RuoNz03+4dva2qsm3xw2CQvFCnqiCYtRLaxDew7xQ/6rYtgyyyLQ9mVKCDq5HK6mi wig0v19oodhQy5Cak+3h+CvzoKZ6Lf20AYCw+QTUAKMj5/IFUB8OaHHibgP7vxx/y3s5 5LRw== X-Gm-Message-State: AOAM533sbLVumxYAbPZhrt6BnEhj7Kz/ch/ltC5rCAaj24hT4Sc7t3Gc qJjGbeBAPUldrRSRQxJCc4Y= X-Google-Smtp-Source: ABdhPJwfT27kvUX1kkV3sfhoA2umu107YomTUVjpfX0vBm8TaA9H5pQnBuJGrMYFT9xoqapaV/Ri3w== X-Received: by 2002:a5d:414e:: with SMTP id c14mr18452293wrq.256.1607334281147; Mon, 07 Dec 2020 01:44:41 -0800 (PST) Received: from kozik-lap (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.googlemail.com with ESMTPSA id y7sm13652154wmb.37.2020.12.07.01.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 01:44:39 -0800 (PST) Date: Mon, 7 Dec 2020 10:44:38 +0100 From: Krzysztof Kozlowski To: michael.srba@seznam.cz Subject: Re: [PATCH 1/3] media: i2c: imx219: add support for specifying clock-frequencies Message-ID: <20201207094438.GA17448@kozik-lap> References: <20201205183355.6488-1-michael.srba@seznam.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201205183355.6488-1-michael.srba@seznam.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201207_044444_204426_817D7978 X-CRM114-Status: GOOD ( 25.13 ) 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 , Dave Stevenson , Fabio Estevam , Sascha Hauer , Magnus Damm , linux-renesas-soc@vger.kernel.org, Rob Herring , NXP Linux Team , Pengutronix Kernel Team , Mauro Carvalho Chehab , Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org 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 Sat, Dec 05, 2020 at 07:33:53PM +0100, michael.srba@seznam.cz 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). All this can be achieved with assigned-clocks-rate and basically you do not add here value. At least not for DT-based systems. The supported clock rates will be the same. The method of choosing frequency is over-complicated comparing to simple assigned-clocks. If this is for ACPI systems, please document in commit msg why you cannot used assigned-clocks and choose this solution. > > Signed-off-by: Michael Srba > --- > drivers/media/i2c/imx219.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c > index f64c0ef7a897..a8f05562d0af 100644 > --- 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 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; > + } > + > + No need for double line break. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel