From patchwork Mon May 25 08:10:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 25777 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4P8DM2o019924 for ; Mon, 25 May 2009 08:13:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752050AbZEYINo (ORCPT ); Mon, 25 May 2009 04:13:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752136AbZEYINn (ORCPT ); Mon, 25 May 2009 04:13:43 -0400 Received: from rv-out-0506.google.com ([209.85.198.236]:48692 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbZEYINm (ORCPT ); Mon, 25 May 2009 04:13:42 -0400 Received: by rv-out-0506.google.com with SMTP id f9so990007rvb.1 for ; Mon, 25 May 2009 01:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=z5eoQtdDMiUveg8SjRJZTKeQtV5vnxZZAhPHvKJCHCY=; b=U9EAWCTZ2gHwXC/K/9xqSE6CfuyKQ5n8zEdM7Q6k7yMsbGMOh0kOkoiKH0jLWgJf7K Tq2TIYhD0y8YU8SoiWl512Wvj5SmOLlXNnZUr+vSTK2lP2ms+zJscPVeGyyR7Z8qTrjs An8xBO6tu3T6HhIcyWBLtkuaRw5NjgT4zcblQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=t27c89uPTOY3yJPs9B53pWAi00bHVtidiB0H+HzGKEHrAGDVBu0M7FufegNNQs+5qh 2S7RbdlTaZfg0fbEUO1ssL3kGzX4YacHCxveyKHde7O9PJKpjHxlodp1cGVgwwdULmEC 2I/Yx1rZUp2F3LKMzI8EQ/Mx9v9d+NnI5FBq4= Received: by 10.141.194.6 with SMTP id w6mr10490rvp.267.1243239224975; Mon, 25 May 2009 01:13:44 -0700 (PDT) Received: from rx1.opensource.se (mailhost.igel.co.jp [219.106.231.130]) by mx.google.com with ESMTPS id b8sm18740188rvf.14.2009.05.25.01.13.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 25 May 2009 01:13:44 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Mon, 25 May 2009 17:10:36 +0900 Message-Id: <20090525081036.7893.45142.sendpatchset@rx1.opensource.se> In-Reply-To: <20090525081011.7893.47950.sendpatchset@rx1.opensource.se> References: <20090525081011.7893.47950.sendpatchset@rx1.opensource.se> Subject: [PATCH 03/04] sh: use shared frequency tables on sh7785 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch converts the sh7785 clock code to make use of clk_rate_table_build() and clk_rate_table_round(). The ->build_rate_table() callback is removed, the table building is instead handled in ->recalc(). Signed-off-by: Magnus Damm --- For the clkfwk topic branch. arch/sh/kernel/cpu/sh4a/clock-sh7785.c | 77 ++++---------------------------- 1 file changed, 12 insertions(+), 65 deletions(-) -- 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 --- 0002/arch/sh/kernel/cpu/sh4a/clock-sh7785.c +++ work/arch/sh/kernel/cpu/sh4a/clock-sh7785.c 2009-05-25 16:20:54.000000000 +0900 @@ -19,6 +19,12 @@ static unsigned int div2[] = { 1, 2, 4, 6, 8, 12, 16, 18, 24, 32, 36, 48 }; + +static struct clk_div_mult_table cpg_div = { + .divisors = div2, + .nr_divisors = ARRAY_SIZE(div2), +}; + struct clk_priv { unsigned int shift; @@ -52,82 +58,23 @@ FRQMR_CLK_DATA(ifc, 28, 0x000e); static unsigned long frqmr_recalc(struct clk *clk) { struct clk_priv *data = clk->priv; - unsigned int idx; - - idx = (__raw_readl(FRQMR1) >> data->shift) & 0x000f; - - return clk->parent->rate / div2[idx]; -} - -static void frqmr_build_rate_table(struct clk *clk) -{ - struct clk_priv *data = clk->priv; - int i, entry; + unsigned int idx = (__raw_readl(FRQMR1) >> data->shift) & 0x000f; - for (i = entry = 0; i < ARRAY_SIZE(div2); i++) { - if ((data->div_bitmap & (1 << i)) == 0) - continue; - - data->freq_table[entry].index = entry; - data->freq_table[entry].frequency = - clk->parent->rate / div2[i]; - - entry++; - } - - if (entry == 0) { - pr_warning("clkfwk: failed to build frequency table " - "for \"%s\" clk!\n", clk->name); - return; - } - - /* Termination entry */ - data->freq_table[entry].index = entry; - data->freq_table[entry].frequency = CPUFREQ_TABLE_END; + clk_rate_table_build(clk, data->freq_table, ARRAY_SIZE(div2), + &cpg_div, &data->div_bitmap); + + return data->freq_table[idx].frequency; } static long frqmr_round_rate(struct clk *clk, unsigned long rate) { struct clk_priv *data = clk->priv; - unsigned long rate_error, rate_error_prev = ~0UL; - unsigned long rate_best_fit = rate; - unsigned long highest, lowest; - int i; - - highest = lowest = 0; - - for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { - unsigned long freq = data->freq_table[i].frequency; - - if (freq == CPUFREQ_ENTRY_INVALID) - continue; - - if (freq > highest) - highest = freq; - if (freq < lowest) - lowest = freq; - - rate_error = abs(freq - rate); - if (rate_error < rate_error_prev) { - rate_best_fit = freq; - rate_error_prev = rate_error; - } - - if (rate_error == 0) - break; - } - - if (rate >= highest) - rate_best_fit = highest; - if (rate <= lowest) - rate_best_fit = lowest; - return rate_best_fit; + return clk_rate_table_round(clk, data->freq_table, rate); } static struct clk_ops frqmr_clk_ops = { .recalc = frqmr_recalc, - .build_rate_table = frqmr_build_rate_table, .round_rate = frqmr_round_rate, };