From afa54fe7c23f729cc8c3e13b14715e53cd6464b4 Mon Sep 17 00:00:00 2001 From: Rajendra Nayak Date: Thu, 25 Aug 2011 20:12:05 +0530 Subject: [PATCH] OMAP: OPP: Do a round_rate before adding into OPP table Most clock rates can vary to some extent based on the exact M/N values used to lock a dpll. Do a round_rate before updating the rates into the OPP table so that the 'exact' rates appear and a subsequent clk_set_rate works without issues. Signed-off-by: Rajendra Nayak Signed-off-by: Nishanth Menon [vaibhav.bedia@ti.com: Pull in for AM33xx] Signed-off-by: Vaibhav Bedia Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/opp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c index ea8a96d..38500f3 100644 --- a/arch/arm/mach-omap2/opp.c +++ b/arch/arm/mach-omap2/opp.c @@ -18,9 +18,11 @@ */ #include #include +#include #include #include +#include #include "omap_opp_data.h" @@ -39,6 +41,8 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def, u32 opp_def_size) { int i, r; + struct clk *clk; + long round_rate; if (!opp_def || !opp_def_size) { pr_err("%s: invalid params!\n", __func__); @@ -72,6 +76,21 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def, } dev = &oh->od->pdev->dev; + clk = omap_clk_get_by_name(opp_def->clk_name); + if (clk) { + round_rate = clk_round_rate(clk, opp_def->freq); + if (round_rate > 0) { + opp_def->freq = round_rate; + } else { + WARN(1, "%s: round_rate for clock %s failed\n", + __func__, opp_def->clk_name); + goto next; /* skip Bad OPP */ + } + } else { + WARN(1, "%s: No clock by name %s found\n", __func__, + opp_def->clk_name); + goto next; /* skip Bad OPP */ + } r = opp_add(dev, opp_def->freq, opp_def->u_volt); if (r) { dev_err(dev, "%s: add OPP %ld failed for %s [%d] " -- 1.9.1