aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/Makefile6
-rw-r--r--arch/arm/mach-omap2/clock24xx.c23
-rw-r--r--arch/arm/mach-omap2/io.c2
-rw-r--r--arch/arm/mach-omap2/sdrc.c57
-rw-r--r--arch/arm/mach-omap2/sdrc2xxx.c67
-rw-r--r--arch/arm/plat-omap/common.c2
-rw-r--r--arch/arm/plat-omap/include/mach/common.h2
-rw-r--r--arch/arm/plat-omap/include/mach/sdrc.h37
8 files changed, 115 insertions, 81 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bb47d43af396..9717afcdbda7 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := irq.o id.o io.o sdrc2xxx.o control.o prcm.o clock.o mux.o \ 6obj-y := irq.o id.o io.o sdrc.o control.o prcm.o clock.o mux.o \
7 devices.o serial.o gpmc.o timer-gp.o powerdomain.o \ 7 devices.o serial.o gpmc.o timer-gp.o powerdomain.o \
8 clockdomain.o 8 clockdomain.o
9 9
@@ -14,6 +14,10 @@ obj-$(CONFIG_ARCH_OMAP2420) += sram242x.o
14obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o 14obj-$(CONFIG_ARCH_OMAP2430) += sram243x.o
15obj-$(CONFIG_ARCH_OMAP3) += sram34xx.o 15obj-$(CONFIG_ARCH_OMAP3) += sram34xx.o
16 16
17# SMS/SDRC
18obj-$(CONFIG_ARCH_OMAP2) += sdrc2xxx.o
19# obj-$(CONFIG_ARCH_OMAP3) += sdrc3xxx.o
20
17# Power Management 21# Power Management
18ifeq ($(CONFIG_PM),y) 22ifeq ($(CONFIG_PM),y)
19obj-y += pm.o 23obj-y += pm.o
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 83911ad48733..a11e7c71177c 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -389,9 +389,9 @@ static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
389 mult &= OMAP24XX_CORE_CLK_SRC_MASK; 389 mult &= OMAP24XX_CORE_CLK_SRC_MASK;
390 390
391 if ((rate == (cur_rate / 2)) && (mult == 2)) { 391 if ((rate == (cur_rate / 2)) && (mult == 2)) {
392 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL, 1); 392 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1);
393 } else if ((rate == (cur_rate * 2)) && (mult == 1)) { 393 } else if ((rate == (cur_rate * 2)) && (mult == 1)) {
394 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL_X2, 1); 394 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1);
395 } else if (rate != cur_rate) { 395 } else if (rate != cur_rate) {
396 valid_rate = omap2_dpllcore_round_rate(rate); 396 valid_rate = omap2_dpllcore_round_rate(rate);
397 if (valid_rate != rate) 397 if (valid_rate != rate)
@@ -430,15 +430,16 @@ static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
430 if (rate == curr_prcm_set->xtal_speed) /* If asking for 1-1 */ 430 if (rate == curr_prcm_set->xtal_speed) /* If asking for 1-1 */
431 bypass = 1; 431 bypass = 1;
432 432
433 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL_X2, 1); /* For init_mem */ 433 /* For omap2xxx_sdrc_init_params() */
434 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1);
434 435
435 /* Force dll lock mode */ 436 /* Force dll lock mode */
436 omap2_set_prcm(tmpset.cm_clksel1_pll, tmpset.base_sdrc_rfr, 437 omap2_set_prcm(tmpset.cm_clksel1_pll, tmpset.base_sdrc_rfr,
437 bypass); 438 bypass);
438 439
439 /* Errata: ret dll entry state */ 440 /* Errata: ret dll entry state */
440 omap2_init_memory_params(omap2_dll_force_needed()); 441 omap2xxx_sdrc_init_params(omap2xxx_sdrc_dll_is_unlocked());
441 omap2_reprogram_sdrc(done_rate, 0); 442 omap2xxx_sdrc_reprogram(done_rate, 0);
442 } 443 }
443 omap2_dpllcore_recalc(&dpll_ck); 444 omap2_dpllcore_recalc(&dpll_ck);
444 ret = 0; 445 ret = 0;
@@ -525,9 +526,9 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate)
525 cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck); 526 cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck);
526 527
527 if (prcm->dpll_speed == cur_rate / 2) { 528 if (prcm->dpll_speed == cur_rate / 2) {
528 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL, 1); 529 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1);
529 } else if (prcm->dpll_speed == cur_rate * 2) { 530 } else if (prcm->dpll_speed == cur_rate * 2) {
530 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL_X2, 1); 531 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1);
531 } else if (prcm->dpll_speed != cur_rate) { 532 } else if (prcm->dpll_speed != cur_rate) {
532 local_irq_save(flags); 533 local_irq_save(flags);
533 534
@@ -558,14 +559,14 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate)
558 cm_write_mod_reg(prcm->cm_clksel_mdm, 559 cm_write_mod_reg(prcm->cm_clksel_mdm,
559 OMAP2430_MDM_MOD, CM_CLKSEL); 560 OMAP2430_MDM_MOD, CM_CLKSEL);
560 561
561 /* x2 to enter init_mem */ 562 /* x2 to enter omap2xxx_sdrc_init_params() */
562 omap2_reprogram_sdrc(CORE_CLK_SRC_DPLL_X2, 1); 563 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1);
563 564
564 omap2_set_prcm(prcm->cm_clksel1_pll, prcm->base_sdrc_rfr, 565 omap2_set_prcm(prcm->cm_clksel1_pll, prcm->base_sdrc_rfr,
565 bypass); 566 bypass);
566 567
567 omap2_init_memory_params(omap2_dll_force_needed()); 568 omap2xxx_sdrc_init_params(omap2xxx_sdrc_dll_is_unlocked());
568 omap2_reprogram_sdrc(done_rate, 0); 569 omap2xxx_sdrc_reprogram(done_rate, 0);
569 570
570 local_irq_restore(flags); 571 local_irq_restore(flags);
571 } 572 }
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 2b5f28a3c4b4..3c1de3615eb8 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -201,6 +201,6 @@ void __init omap2_init_common_hw(void)
201 pwrdm_init(powerdomains_omap); 201 pwrdm_init(powerdomains_omap);
202 clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps); 202 clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps);
203 omap2_clk_init(); 203 omap2_clk_init();
204 omap2_init_memory(); 204 omap2_sdrc_init();
205 gpmc_init(); 205 gpmc_init();
206} 206}
diff --git a/arch/arm/mach-omap2/sdrc.c b/arch/arm/mach-omap2/sdrc.c
new file mode 100644
index 000000000000..24b54d50b893
--- /dev/null
+++ b/arch/arm/mach-omap2/sdrc.c
@@ -0,0 +1,57 @@
1/*
2 * SMS/SDRC (SDRAM controller) common code for OMAP2/3
3 *
4 * Copyright (C) 2005, 2008 Texas Instruments Inc.
5 * Copyright (C) 2005, 2008 Nokia Corporation
6 *
7 * Tony Lindgren <tony@atomide.com>
8 * Paul Walmsley
9 * Richard Woodruff <r-woodruff2@ti.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/device.h>
19#include <linux/list.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24
25#include <mach/common.h>
26#include <mach/clock.h>
27#include <mach/sram.h>
28
29#include "prm.h"
30
31#include <mach/sdrc.h>
32#include "sdrc.h"
33
34void __iomem *omap2_sdrc_base;
35void __iomem *omap2_sms_base;
36
37void __init omap2_set_globals_sdrc(struct omap_globals *omap2_globals)
38{
39 omap2_sdrc_base = omap2_globals->sdrc;
40 omap2_sms_base = omap2_globals->sms;
41}
42
43/* turn on smart idle modes for SDRAM scheduler and controller */
44void __init omap2_sdrc_init(void)
45{
46 u32 l;
47
48 l = sms_read_reg(SMS_SYSCONFIG);
49 l &= ~(0x3 << 3);
50 l |= (0x2 << 3);
51 sms_write_reg(l, SMS_SYSCONFIG);
52
53 l = sdrc_read_reg(SDRC_SYSCONFIG);
54 l &= ~(0x3 << 3);
55 l |= (0x2 << 3);
56 sdrc_write_reg(l, SDRC_SYSCONFIG);
57}
diff --git a/arch/arm/mach-omap2/sdrc2xxx.c b/arch/arm/mach-omap2/sdrc2xxx.c
index 3e38aa4ea458..3a47aba29031 100644
--- a/arch/arm/mach-omap2/sdrc2xxx.c
+++ b/arch/arm/mach-omap2/sdrc2xxx.c
@@ -3,11 +3,12 @@
3 * 3 *
4 * SDRAM timing related functions for OMAP2xxx 4 * SDRAM timing related functions for OMAP2xxx
5 * 5 *
6 * Copyright (C) 2005 Texas Instruments Inc. 6 * Copyright (C) 2005, 2008 Texas Instruments Inc.
7 * Richard Woodruff <r-woodruff2@ti.com> 7 * Copyright (C) 2005, 2008 Nokia Corporation
8 * 8 *
9 * Copyright (C) 2005 Nokia Corporation
10 * Tony Lindgren <tony@atomide.com> 9 * Tony Lindgren <tony@atomide.com>
10 * Paul Walmsley
11 * Richard Woodruff <r-woodruff2@ti.com>
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
@@ -39,23 +40,20 @@
39#define M_LOCK 1 40#define M_LOCK 1
40 41
41 42
42void __iomem *omap2_sdrc_base;
43void __iomem *omap2_sms_base;
44
45static struct memory_timings mem_timings; 43static struct memory_timings mem_timings;
46static u32 curr_perf_level = CORE_CLK_SRC_DPLL_X2; 44static u32 curr_perf_level = CORE_CLK_SRC_DPLL_X2;
47 45
48u32 omap2_memory_get_slow_dll_ctrl(void) 46static u32 omap2xxx_sdrc_get_slow_dll_ctrl(void)
49{ 47{
50 return mem_timings.slow_dll_ctrl; 48 return mem_timings.slow_dll_ctrl;
51} 49}
52 50
53u32 omap2_memory_get_fast_dll_ctrl(void) 51static u32 omap2xxx_sdrc_get_fast_dll_ctrl(void)
54{ 52{
55 return mem_timings.fast_dll_ctrl; 53 return mem_timings.fast_dll_ctrl;
56} 54}
57 55
58u32 omap2_memory_get_type(void) 56static u32 omap2xxx_sdrc_get_type(void)
59{ 57{
60 return mem_timings.m_type; 58 return mem_timings.m_type;
61} 59}
@@ -64,7 +62,7 @@ u32 omap2_memory_get_type(void)
64 * Check the DLL lock state, and return tue if running in unlock mode. 62 * Check the DLL lock state, and return tue if running in unlock mode.
65 * This is needed to compensate for the shifted DLL value in unlock mode. 63 * This is needed to compensate for the shifted DLL value in unlock mode.
66 */ 64 */
67u32 omap2_dll_force_needed(void) 65u32 omap2xxx_sdrc_dll_is_unlocked(void)
68{ 66{
69 /* dlla and dllb are a set */ 67 /* dlla and dllb are a set */
70 u32 dll_state = sdrc_read_reg(SDRC_DLLA_CTRL); 68 u32 dll_state = sdrc_read_reg(SDRC_DLLA_CTRL);
@@ -79,8 +77,10 @@ u32 omap2_dll_force_needed(void)
79 * 'level' is the value to store to CM_CLKSEL2_PLL.CORE_CLK_SRC. 77 * 'level' is the value to store to CM_CLKSEL2_PLL.CORE_CLK_SRC.
80 * Practical values are CORE_CLK_SRC_DPLL (for CORE_CLK = DPLL_CLK) or 78 * Practical values are CORE_CLK_SRC_DPLL (for CORE_CLK = DPLL_CLK) or
81 * CORE_CLK_SRC_DPLL_X2 (for CORE_CLK = * DPLL_CLK * 2) 79 * CORE_CLK_SRC_DPLL_X2 (for CORE_CLK = * DPLL_CLK * 2)
80 *
81 * Used by the clock framework during CORE DPLL changes
82 */ 82 */
83u32 omap2_reprogram_sdrc(u32 level, u32 force) 83u32 omap2xxx_sdrc_reprogram(u32 level, u32 force)
84{ 84{
85 u32 dll_ctrl, m_type; 85 u32 dll_ctrl, m_type;
86 u32 prev = curr_perf_level; 86 u32 prev = curr_perf_level;
@@ -90,13 +90,13 @@ u32 omap2_reprogram_sdrc(u32 level, u32 force)
90 return prev; 90 return prev;
91 91
92 if (level == CORE_CLK_SRC_DPLL) 92 if (level == CORE_CLK_SRC_DPLL)
93 dll_ctrl = omap2_memory_get_slow_dll_ctrl(); 93 dll_ctrl = omap2xxx_sdrc_get_slow_dll_ctrl();
94 else if (level == CORE_CLK_SRC_DPLL_X2) 94 else if (level == CORE_CLK_SRC_DPLL_X2)
95 dll_ctrl = omap2_memory_get_fast_dll_ctrl(); 95 dll_ctrl = omap2xxx_sdrc_get_fast_dll_ctrl();
96 else 96 else
97 return prev; 97 return prev;
98 98
99 m_type = omap2_memory_get_type(); 99 m_type = omap2xxx_sdrc_get_type();
100 100
101 local_irq_save(flags); 101 local_irq_save(flags);
102 __raw_writel(0xffff, OMAP24XX_PRCM_VOLTSETUP); 102 __raw_writel(0xffff, OMAP24XX_PRCM_VOLTSETUP);
@@ -107,18 +107,8 @@ u32 omap2_reprogram_sdrc(u32 level, u32 force)
107 return prev; 107 return prev;
108} 108}
109 109
110#if !defined(CONFIG_ARCH_OMAP2) 110/* Used by the clock framework during CORE DPLL changes */
111void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl, 111void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode)
112 u32 base_cs, u32 force_unlock)
113{
114}
115void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
116 u32 mem_type)
117{
118}
119#endif
120
121void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
122{ 112{
123 unsigned long dll_cnt; 113 unsigned long dll_cnt;
124 u32 fast_dll = 0; 114 u32 fast_dll = 0;
@@ -171,28 +161,3 @@ void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
171 /* 90 degree phase for anything below 133Mhz + disable DLL filter */ 161 /* 90 degree phase for anything below 133Mhz + disable DLL filter */
172 mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8)); 162 mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8));
173} 163}
174
175void __init omap2_set_globals_memory(struct omap_globals *omap2_globals)
176{
177 omap2_sdrc_base = omap2_globals->sdrc;
178 omap2_sms_base = omap2_globals->sms;
179}
180
181/* turn on smart idle modes for SDRAM scheduler and controller */
182void __init omap2_init_memory(void)
183{
184 u32 l;
185
186 if (!cpu_is_omap2420())
187 return;
188
189 l = sms_read_reg(SMS_SYSCONFIG);
190 l &= ~(0x3 << 3);
191 l |= (0x2 << 3);
192 sms_write_reg(l, SMS_SYSCONFIG);
193
194 l = sdrc_read_reg(SDRC_SYSCONFIG);
195 l &= ~(0x3 << 3);
196 l |= (0x2 << 3);
197 sdrc_write_reg(l, SDRC_SYSCONFIG);
198}
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 0843b8882f93..187239c054c9 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -249,7 +249,7 @@ static struct omap_globals *omap2_globals;
249static void __init __omap2_set_globals(void) 249static void __init __omap2_set_globals(void)
250{ 250{
251 omap2_set_globals_tap(omap2_globals); 251 omap2_set_globals_tap(omap2_globals);
252 omap2_set_globals_memory(omap2_globals); 252 omap2_set_globals_sdrc(omap2_globals);
253 omap2_set_globals_control(omap2_globals); 253 omap2_set_globals_control(omap2_globals);
254 omap2_set_globals_prcm(omap2_globals); 254 omap2_set_globals_prcm(omap2_globals);
255} 255}
diff --git a/arch/arm/plat-omap/include/mach/common.h b/arch/arm/plat-omap/include/mach/common.h
index ef70e2b0f054..f3444a66a57e 100644
--- a/arch/arm/plat-omap/include/mach/common.h
+++ b/arch/arm/plat-omap/include/mach/common.h
@@ -65,7 +65,7 @@ void omap2_set_globals_343x(void);
65 65
66/* These get called from omap2_set_globals_xxxx(), do not call these */ 66/* These get called from omap2_set_globals_xxxx(), do not call these */
67void omap2_set_globals_tap(struct omap_globals *); 67void omap2_set_globals_tap(struct omap_globals *);
68void omap2_set_globals_memory(struct omap_globals *); 68void omap2_set_globals_sdrc(struct omap_globals *);
69void omap2_set_globals_control(struct omap_globals *); 69void omap2_set_globals_control(struct omap_globals *);
70void omap2_set_globals_prcm(struct omap_globals *); 70void omap2_set_globals_prcm(struct omap_globals *);
71 71
diff --git a/arch/arm/plat-omap/include/mach/sdrc.h b/arch/arm/plat-omap/include/mach/sdrc.h
index c905b5268e56..8e0740eb83fb 100644
--- a/arch/arm/plat-omap/include/mach/sdrc.h
+++ b/arch/arm/plat-omap/include/mach/sdrc.h
@@ -4,10 +4,12 @@
4/* 4/*
5 * OMAP2/3 SDRC/SMS register definitions 5 * OMAP2/3 SDRC/SMS register definitions
6 * 6 *
7 * Copyright (C) 2007 Texas Instruments, Inc. 7 * Copyright (C) 2007-2008 Texas Instruments, Inc.
8 * Copyright (C) 2007 Nokia Corporation 8 * Copyright (C) 2007-2008 Nokia Corporation
9 * 9 *
10 * Written by Paul Walmsley 10 * Tony Lindgren
11 * Paul Walmsley
12 * Richard Woodruff
11 * 13 *
12 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 15 * it under the terms of the GNU General Public License version 2 as
@@ -64,18 +66,25 @@
64 * SMS register access 66 * SMS register access
65 */ 67 */
66 68
67 69#define OMAP242X_SMS_REGADDR(reg) \
68#define OMAP242X_SMS_REGADDR(reg) IO_ADDRESS(OMAP2420_SMS_BASE + reg) 70 (void __iomem *)IO_ADDRESS(OMAP2420_SMS_BASE + reg)
69#define OMAP243X_SMS_REGADDR(reg) IO_ADDRESS(OMAP243X_SMS_BASE + reg) 71#define OMAP243X_SMS_REGADDR(reg) \
70#define OMAP343X_SMS_REGADDR(reg) IO_ADDRESS(OMAP343X_SMS_BASE + reg) 72 (void __iomem *)IO_ADDRESS(OMAP243X_SMS_BASE + reg)
73#define OMAP343X_SMS_REGADDR(reg) \
74 (void __iomem *)IO_ADDRESS(OMAP343X_SMS_BASE + reg)
71 75
72/* SMS register offsets - read/write with sms_{read,write}_reg() */ 76/* SMS register offsets - read/write with sms_{read,write}_reg() */
73 77
74#define SMS_SYSCONFIG 0x010 78#define SMS_SYSCONFIG 0x010
75/* REVISIT: fill in other SMS registers here */ 79/* REVISIT: fill in other SMS registers here */
76 80
81
77#ifndef __ASSEMBLER__ 82#ifndef __ASSEMBLER__
78 83
84void __init omap2_sdrc_init(void);
85
86#ifdef CONFIG_ARCH_OMAP2
87
79struct memory_timings { 88struct memory_timings {
80 u32 m_type; /* ddr = 1, sdr = 0 */ 89 u32 m_type; /* ddr = 1, sdr = 0 */
81 u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */ 90 u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */
@@ -84,15 +93,13 @@ struct memory_timings {
84 u32 base_cs; /* base chip select to use for calculations */ 93 u32 base_cs; /* base chip select to use for calculations */
85}; 94};
86 95
87extern void omap2_init_memory_params(u32 force_lock_to_unlock_mode); 96extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);
88extern u32 omap2_memory_get_slow_dll_ctrl(void);
89extern u32 omap2_memory_get_fast_dll_ctrl(void);
90extern u32 omap2_memory_get_type(void);
91u32 omap2_dll_force_needed(void);
92u32 omap2_reprogram_sdrc(u32 level, u32 force);
93void __init omap2_init_memory(void);
94 97
95#endif 98u32 omap2xxx_sdrc_dll_is_unlocked(void);
99u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);
100
101#endif /* CONFIG_ARCH_OMAP2 */
96 102
103#endif /* __ASSEMBLER__ */
97 104
98#endif 105#endif