From patchwork Thu Jan 25 11:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10183935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8D2F60388 for ; Thu, 25 Jan 2018 11:25:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94E48285C5 for ; Thu, 25 Jan 2018 11:25:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88A442866C; Thu, 25 Jan 2018 11:25:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22959285C5 for ; Thu, 25 Jan 2018 11:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751378AbeAYLZV (ORCPT ); Thu, 25 Jan 2018 06:25:21 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:38486 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbeAYLZU (ORCPT ); Thu, 25 Jan 2018 06:25:20 -0500 Received: from w540.lan (unknown [IPv6:2001:b07:6442:1ac4:c4b5:434a:5a04:9386]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id E8A04C5A70; Thu, 25 Jan 2018 12:25:13 +0100 (CET) From: Jacopo Mondi To: magnus.damm@gmail.com, kuninori.morimoto.gx@renesas.com, geert@linux-m68k.org, laurent.pinchart@ideasonboard.com, ysato@users.sourceforge.jp, dalias@libc.org Cc: Jacopo Mondi , linux-sh@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sh: clk: Relax clk rate match test Date: Thu, 25 Jan 2018 12:24:53 +0100 Message-Id: <1516879493-24637-1-git-send-email-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.7.4 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When asking for a clk rate to be set, the sh core clock matches only exact rate values against the calculated frequency table entries. If the rate does not match exactly the test fails, and the whole frequency table is walked, resulting in selection of the last entry, corresponding to the lowest available clock rate. Ie. when asking for a 10MHz clock rate on div6 clocks (ie. "video_clk" line), the calculated clock frequency 10088572 Hz gets ignored, and the clock is actually set to 5201920 Hz, which is the last available entry of the frequencies table. Relax the clock frequency match test, allowing selection of clock rates immediately slower than the required one. Signed-off-by: Jacopo Mondi --- Hello renesas lists, I'm now working on handling frame rate for the ov7720 image sensor to have that driver accepted as part of v4l2. The sensor is installed on on Migo-R board. In order to properly calculate pixel clock and the framerate I noticed the clock signal fed to the sensor from the SH7722 chip was always the lowest available one. This patch fixes the issues and allows me to properly select which clock frequency supply to the sensor, which according to datasheet does not support input clock frequencies slower than 10MHz (but works anyhow). As all patches for SH architecture I wonder where they should be picked up from, as SH seems not maintained at the moment. Thanks j --- drivers/sh/clk/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 92863e3..d2cb94c 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c @@ -198,9 +198,12 @@ int clk_rate_table_find(struct clk *clk, { struct cpufreq_frequency_table *pos; - cpufreq_for_each_valid_entry(pos, freq_table) - if (pos->frequency == rate) - return pos - freq_table; + cpufreq_for_each_valid_entry(pos, freq_table) { + if (pos->frequency > rate) + continue; + + return pos - freq_table; + } return -ENOENT; }