aboutsummaryrefslogtreecommitdiffstats
path: root/arch/unicore32/kernel/clock.c
diff options
context:
space:
mode:
authorGuanXuetao <gxt@mprc.pku.edu.cn>2011-02-26 08:21:18 -0500
committerGuanXuetao <gxt@mprc.pku.edu.cn>2011-03-16 21:19:19 -0400
commite5abf78b57199a417eb01ff922a5ea6ff9e10b61 (patch)
tree6f72a13d44c0dc8c4d575d84885f5694c16ed1da /arch/unicore32/kernel/clock.c
parent4517366d870b89d6fb8c0c90deb6c73d975908af (diff)
unicore32 io: redefine __REG(x) and re-use readl/writel funcs
-- by advice of Arnd Bergmann Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/unicore32/kernel/clock.c')
-rw-r--r--arch/unicore32/kernel/clock.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/arch/unicore32/kernel/clock.c b/arch/unicore32/kernel/clock.c
index 80323db581fd..18d4563e6fa5 100644
--- a/arch/unicore32/kernel/clock.c
+++ b/arch/unicore32/kernel/clock.c
@@ -20,6 +20,7 @@
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/io.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25 26
@@ -152,28 +153,29 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
152 if (ret) 153 if (ret)
153 return ret; 154 return ret;
154 155
155 if (PM_PLLVGACFG == pll_vgacfg) 156 if (readl(PM_PLLVGACFG) == pll_vgacfg)
156 return 0; 157 return 0;
157 158
158 /* set pll vga cfg reg. */ 159 /* set pll vga cfg reg. */
159 PM_PLLVGACFG = pll_vgacfg; 160 writel(pll_vgacfg, PM_PLLVGACFG);
160 161
161 PM_PMCR = PM_PMCR_CFBVGA; 162 writel(PM_PMCR_CFBVGA, PM_PMCR);
162 while ((PM_PLLDFCDONE & PM_PLLDFCDONE_VGADFC) 163 while ((readl(PM_PLLDFCDONE) & PM_PLLDFCDONE_VGADFC)
163 != PM_PLLDFCDONE_VGADFC) 164 != PM_PLLDFCDONE_VGADFC)
164 udelay(100); /* about 1ms */ 165 udelay(100); /* about 1ms */
165 166
166 /* set div cfg reg. */ 167 /* set div cfg reg. */
167 PM_PCGR |= PM_PCGR_VGACLK; 168 writel(readl(PM_PCGR) | PM_PCGR_VGACLK, PM_PCGR);
168 169
169 PM_DIVCFG = (PM_DIVCFG & ~PM_DIVCFG_VGACLK_MASK) 170 writel((readl(PM_DIVCFG) & ~PM_DIVCFG_VGACLK_MASK)
170 | PM_DIVCFG_VGACLK(pll_vgadiv); 171 | PM_DIVCFG_VGACLK(pll_vgadiv), PM_DIVCFG);
171 172
172 PM_SWRESET |= PM_SWRESET_VGADIV; 173 writel(readl(PM_SWRESET) | PM_SWRESET_VGADIV, PM_SWRESET);
173 while ((PM_SWRESET & PM_SWRESET_VGADIV) == PM_SWRESET_VGADIV) 174 while ((readl(PM_SWRESET) & PM_SWRESET_VGADIV)
175 == PM_SWRESET_VGADIV)
174 udelay(100); /* 65536 bclk32, about 320us */ 176 udelay(100); /* 65536 bclk32, about 320us */
175 177
176 PM_PCGR &= ~PM_PCGR_VGACLK; 178 writel(readl(PM_PCGR) & ~PM_PCGR_VGACLK, PM_PCGR);
177 } 179 }
178#ifdef CONFIG_CPU_FREQ 180#ifdef CONFIG_CPU_FREQ
179 if (clk == &clk_mclk_clk) { 181 if (clk == &clk_mclk_clk) {
@@ -323,15 +325,15 @@ struct {
323static int __init clk_init(void) 325static int __init clk_init(void)
324{ 326{
325#ifdef CONFIG_PUV3_PM 327#ifdef CONFIG_PUV3_PM
326 u32 pllrate, divstatus = PM_DIVSTATUS; 328 u32 pllrate, divstatus = readl(PM_DIVSTATUS);
327 u32 pcgr_val = PM_PCGR; 329 u32 pcgr_val = readl(PM_PCGR);
328 int i; 330 int i;
329 331
330 pcgr_val |= PM_PCGR_BCLKMME | PM_PCGR_BCLKH264E | PM_PCGR_BCLKH264D 332 pcgr_val |= PM_PCGR_BCLKMME | PM_PCGR_BCLKH264E | PM_PCGR_BCLKH264D
331 | PM_PCGR_HECLK | PM_PCGR_HDCLK; 333 | PM_PCGR_HECLK | PM_PCGR_HDCLK;
332 PM_PCGR = pcgr_val; 334 writel(pcgr_val, PM_PCGR);
333 335
334 pllrate = PM_PLLSYSSTATUS; 336 pllrate = readl(PM_PLLSYSSTATUS);
335 337
336 /* lookup pmclk_table */ 338 /* lookup pmclk_table */
337 clk_mclk_clk.rate = 0; 339 clk_mclk_clk.rate = 0;
@@ -346,7 +348,7 @@ static int __init clk_init(void)
346 clk_bclk32_clk.rate = clk_mclk_clk.rate / 348 clk_bclk32_clk.rate = clk_mclk_clk.rate /
347 (((divstatus & 0x0000f000) >> 12) + 1); 349 (((divstatus & 0x0000f000) >> 12) + 1);
348 350
349 pllrate = PM_PLLDDRSTATUS; 351 pllrate = readl(PM_PLLDDRSTATUS);
350 352
351 /* lookup pddr_table */ 353 /* lookup pddr_table */
352 clk_ddr_clk.rate = 0; 354 clk_ddr_clk.rate = 0;
@@ -357,7 +359,7 @@ static int __init clk_init(void)
357 } 359 }
358 } 360 }
359 361
360 pllrate = PM_PLLVGASTATUS; 362 pllrate = readl(PM_PLLVGASTATUS);
361 363
362 /* lookup pvga_table */ 364 /* lookup pvga_table */
363 clk_vga_clk.rate = 0; 365 clk_vga_clk.rate = 0;