From patchwork Thu Mar 19 12:19:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar Mahadev Lad X-Patchwork-Id: 62378 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1jEu8q-002ZJw-UI; Thu, 19 Mar 2020 12:19:17 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbgCSMVW (ORCPT + 1 other); Thu, 19 Mar 2020 08:21:22 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:58800 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726864AbgCSMVV (ORCPT ); Thu, 19 Mar 2020 08:21:21 -0400 X-IronPort-AV: E=Sophos;i="5.70,571,1574089200"; d="scan'208";a="42339811" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 19 Mar 2020 21:21:20 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id CF1A44013DFF; Thu, 19 Mar 2020 21:21:16 +0900 (JST) From: Lad Prabhakar To: Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Kieran Bingham Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lad Prabhakar , Lad Prabhakar Subject: [PATCH v4 2/5] media: i2c: ov5645: Switch to assigned-clock-rates Date: Thu, 19 Mar 2020 12:19:20 +0000 Message-Id: <1584620363-2255-3-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584620363-2255-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <1584620363-2255-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch switches to assigned-clock-rates for specifying the clock rate. The clk-conf.c internally handles setting the clock rate when assigned-clock-rates is passed. The driver now sets the clock frequency only if the deprecated property clock-frequency is defined instead assigned-clock-rates, this is to avoid breakage with existing DT binaries. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index a6c17d15d754..e298acdadeef 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1094,25 +1094,25 @@ static int ov5645_probe(struct i2c_client *client) return PTR_ERR(ov5645->xclk); } - ret = of_property_read_u32(dev->of_node, "clock-frequency", &xclk_freq); - if (ret) { - dev_err(dev, "could not get xclk frequency\n"); - return ret; + /* check if deprecated property clock-frequency is defined */ + ret = of_property_read_u32(dev->of_node, "clock-frequency", + &xclk_freq); + if (!ret) { + ret = clk_set_rate(ov5645->xclk, xclk_freq); + if (ret) { + dev_err(dev, "could not set xclk frequency\n"); + return ret; + } } /* external clock must be 24MHz, allow 1% tolerance */ + xclk_freq = clk_get_rate(ov5645->xclk); if (xclk_freq < 23760000 || xclk_freq > 24240000) { dev_err(dev, "external clock frequency %u is not supported\n", xclk_freq); return -EINVAL; } - ret = clk_set_rate(ov5645->xclk, xclk_freq); - if (ret) { - dev_err(dev, "could not set xclk frequency\n"); - return ret; - } - for (i = 0; i < OV5645_NUM_SUPPLIES; i++) ov5645->supplies[i].supply = ov5645_supply_name[i];