From 76c2f6e513b3df8031dda383838da2a3820adbe3 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 26 Jan 2012 15:12:23 +0000 Subject: [PATCH] ARM: tegra: Fix EMC pdata initialization from registers Commit d91eeb0 "ARM: tegra: emc: device tree support" modified the EMC driver to create an EMC table from existing register settings when none was provided through platform data or device tree. This code wrote the wrong clock rate into the table; the actual rate in Hz, rather than the expected half-rate in KHz. This caused the BUG_ON in tegra2_emc_clk_round_rate() to fire, since that enormous rate could not be generated. Fixes: [ 2.425921] kernel BUG at arch/arm/mach-tegra/tegra2_clocks.c:1158! ... [ 2.618766] [] (tegra2_emc_clk_round_rate+0x58/0x70) from [] (clk_round_rate+0x48/0x68) [ 2.628494] [] (clk_round_rate+0x48/0x68) from [] (clk_set_rate_locked+0x40/0x68) [ 2.637707] [] (clk_set_rate_locked+0x40/0x68) from [] (clk_set_rate+0x28/0x40) [ 2.646754] [] (clk_set_rate+0x28/0x40) from [] (tegra_update_cpu_speed+0x54/0x144) [ 2.656144] [] (tegra_update_cpu_speed+0x54/0x144) from [] (tegra_target+0xb4/0xe0) [ 2.665538] [] (tegra_target+0xb4/0xe0) from [] (__cpufreq_driver_target+0x88/0xa4) [ 2.674931] [] (__cpufreq_driver_target+0x88/0xa4) from [] (dbs_check_cpu+0x324/0x340) [ 2.684582] [] (dbs_check_cpu+0x324/0x340) from [] (do_dbs_timer+0x54/0xf4) [ 2.693277] [] (do_dbs_timer+0x54/0xf4) from [] (process_one_work+0x1d4/0x320) [ 2.702225] [] (process_one_work+0x1d4/0x320) from [] (worker_thread+0x134/0x230) [ 2.711437] [] (worker_thread+0x134/0x230) from [] (kthread+0x80/0x8c) [ 2.719700] [] (kthread+0x80/0x8c) from [] (kernel_thread_exit+0x0/0x8) Reported-by: Marc Dietrich Signed-off-by: Stephen Warren [olof: fixed calculation of printed values] Signed-off-by: Olof Johansson --- arch/arm/mach-tegra/tegra2_emc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-tegra/tegra2_emc.c b/arch/arm/mach-tegra/tegra2_emc.c index 52df6ca3629..5070d833bdd 100644 --- a/arch/arm/mach-tegra/tegra2_emc.c +++ b/arch/arm/mach-tegra/tegra2_emc.c @@ -284,16 +284,16 @@ static struct tegra_emc_pdata __devinit *tegra_emc_fill_pdata(struct platform_de pdata->tables = devm_kzalloc(&pdev->dev, sizeof(*pdata->tables), GFP_KERNEL); - pdata->tables[0].rate = clk_get_rate(c); + pdata->tables[0].rate = clk_get_rate(c) / 2 / 1000; for (i = 0; i < TEGRA_EMC_NUM_REGS; i++) pdata->tables[0].regs[i] = emc_readl(emc_reg_addr[i]); pdata->num_tables = 1; - khz = pdata->tables[0].rate / 1000; + khz = pdata->tables[0].rate; dev_info(&pdev->dev, "no tables provided, using %ld kHz emc, " - "%ld kHz mem\n", khz, khz/2); + "%ld kHz mem\n", khz * 2, khz); return pdata; }