aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Miao <eric.y.miao@gmail.com>2010-11-22 09:48:49 -0500
committerEric Miao <eric.y.miao@gmail.com>2010-12-16 01:31:19 -0500
commit2a125dd56b3a853701063fe8a678ad7603e385fd (patch)
tree279a16da435e810fa8490fe4a1557486a54e9cf3
parent4029813c89926ae5d78cc2dff49d845d934424f6 (diff)
ARM: pxa: remove get_memclk_frequency_10khz()
Introduce 'struct clk' for memory and remove get_memclk_frequency_10khz(). Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
-rw-r--r--arch/arm/mach-pxa/generic.c13
-rw-r--r--arch/arm/mach-pxa/generic.h4
-rw-r--r--arch/arm/mach-pxa/pxa25x.c20
-rw-r--r--arch/arm/mach-pxa/pxa27x.c15
-rw-r--r--drivers/pcmcia/pxa2xx_base.c17
-rw-r--r--drivers/pcmcia/soc_common.h3
6 files changed, 38 insertions, 34 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index d4ce8f9233d7..d2bb071b0afc 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -72,19 +72,6 @@ unsigned int get_clk_frequency_khz(int info)
72EXPORT_SYMBOL(get_clk_frequency_khz); 72EXPORT_SYMBOL(get_clk_frequency_khz);
73 73
74/* 74/*
75 * Return the current memory clock frequency in units of 10kHz
76 */
77unsigned int get_memclk_frequency_10khz(void)
78{
79 if (cpu_is_pxa25x())
80 return pxa25x_get_memclk_frequency_10khz();
81 else if (cpu_is_pxa27x())
82 return pxa27x_get_memclk_frequency_10khz();
83 return 0;
84}
85EXPORT_SYMBOL(get_memclk_frequency_10khz);
86
87/*
88 * Intel PXA2xx internal register mapping. 75 * Intel PXA2xx internal register mapping.
89 * 76 *
90 * Note: virtual 0xfffe0000-0xffffffff is reserved for the vector table 77 * Note: virtual 0xfffe0000-0xffffffff is reserved for the vector table
diff --git a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h
index d2e8bc3aa521..0569d82d2592 100644
--- a/arch/arm/mach-pxa/generic.h
+++ b/arch/arm/mach-pxa/generic.h
@@ -36,18 +36,14 @@ extern unsigned int get_clk_frequency_khz(int info);
36 36
37#ifdef CONFIG_PXA25x 37#ifdef CONFIG_PXA25x
38extern unsigned pxa25x_get_clk_frequency_khz(int); 38extern unsigned pxa25x_get_clk_frequency_khz(int);
39extern unsigned pxa25x_get_memclk_frequency_10khz(void);
40#else 39#else
41#define pxa25x_get_clk_frequency_khz(x) (0) 40#define pxa25x_get_clk_frequency_khz(x) (0)
42#define pxa25x_get_memclk_frequency_10khz() (0)
43#endif 41#endif
44 42
45#ifdef CONFIG_PXA27x 43#ifdef CONFIG_PXA27x
46extern unsigned pxa27x_get_clk_frequency_khz(int); 44extern unsigned pxa27x_get_clk_frequency_khz(int);
47extern unsigned pxa27x_get_memclk_frequency_10khz(void);
48#else 45#else
49#define pxa27x_get_clk_frequency_khz(x) (0) 46#define pxa27x_get_clk_frequency_khz(x) (0)
50#define pxa27x_get_memclk_frequency_10khz() (0)
51#endif 47#endif
52 48
53#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x) 49#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index f29775e3e18d..65051bb6d62c 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -92,23 +92,21 @@ unsigned int pxa25x_get_clk_frequency_khz(int info)
92 return (turbo & 1) ? (N/1000) : (M/1000); 92 return (turbo & 1) ? (N/1000) : (M/1000);
93} 93}
94 94
95/* 95static unsigned long clk_pxa25x_mem_getrate(struct clk *clk)
96 * Return the current memory clock frequency in units of 10kHz
97 */
98unsigned int pxa25x_get_memclk_frequency_10khz(void)
99{ 96{
100 return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK / 10000; 97 return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK;
101} 98}
102 99
103static unsigned long clk_pxa25x_lcd_getrate(struct clk *clk) 100static const struct clkops clk_pxa25x_mem_ops = {
104{ 101 .enable = clk_dummy_enable,
105 return pxa25x_get_memclk_frequency_10khz() * 10000; 102 .disable = clk_dummy_disable,
106} 103 .getrate = clk_pxa25x_mem_getrate,
104};
107 105
108static const struct clkops clk_pxa25x_lcd_ops = { 106static const struct clkops clk_pxa25x_lcd_ops = {
109 .enable = clk_pxa2xx_cken_enable, 107 .enable = clk_pxa2xx_cken_enable,
110 .disable = clk_pxa2xx_cken_disable, 108 .disable = clk_pxa2xx_cken_disable,
111 .getrate = clk_pxa25x_lcd_getrate, 109 .getrate = clk_pxa25x_mem_getrate,
112}; 110};
113 111
114static unsigned long gpio12_config_32k[] = { 112static unsigned long gpio12_config_32k[] = {
@@ -185,6 +183,7 @@ static DEFINE_PXA2_CKEN(pxa25x_ficp, FICP, 47923000, 0);
185static DEFINE_CK(pxa25x_lcd, LCD, &clk_pxa25x_lcd_ops); 183static DEFINE_CK(pxa25x_lcd, LCD, &clk_pxa25x_lcd_ops);
186static DEFINE_CLK(pxa25x_gpio11, &clk_pxa25x_gpio11_ops, 3686400, 0); 184static DEFINE_CLK(pxa25x_gpio11, &clk_pxa25x_gpio11_ops, 3686400, 0);
187static DEFINE_CLK(pxa25x_gpio12, &clk_pxa25x_gpio12_ops, 32768, 0); 185static DEFINE_CLK(pxa25x_gpio12, &clk_pxa25x_gpio12_ops, 32768, 0);
186static DEFINE_CLK(pxa25x_mem, &clk_pxa25x_mem_ops, 0, 0);
188 187
189static struct clk_lookup pxa25x_clkregs[] = { 188static struct clk_lookup pxa25x_clkregs[] = {
190 INIT_CLKREG(&clk_pxa25x_lcd, "pxa2xx-fb", NULL), 189 INIT_CLKREG(&clk_pxa25x_lcd, "pxa2xx-fb", NULL),
@@ -205,6 +204,7 @@ static struct clk_lookup pxa25x_clkregs[] = {
205 INIT_CLKREG(&clk_pxa25x_ac97, NULL, "AC97CLK"), 204 INIT_CLKREG(&clk_pxa25x_ac97, NULL, "AC97CLK"),
206 INIT_CLKREG(&clk_pxa25x_gpio11, NULL, "GPIO11_CLK"), 205 INIT_CLKREG(&clk_pxa25x_gpio11, NULL, "GPIO11_CLK"),
207 INIT_CLKREG(&clk_pxa25x_gpio12, NULL, "GPIO12_CLK"), 206 INIT_CLKREG(&clk_pxa25x_gpio12, NULL, "GPIO12_CLK"),
207 INIT_CLKREG(&clk_pxa25x_mem, "pxa2xx-pcmcia", NULL),
208}; 208};
209 209
210static struct clk_lookup pxa25x_hwuart_clkreg = 210static struct clk_lookup pxa25x_hwuart_clkreg =
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 13242f2a3392..6d2254b92adc 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -111,10 +111,9 @@ unsigned int pxa27x_get_clk_frequency_khz(int info)
111} 111}
112 112
113/* 113/*
114 * Return the current mem clock frequency in units of 10kHz as 114 * Return the current mem clock frequency as reflected by CCCR[A], B, and L
115 * reflected by CCCR[A], B, and L
116 */ 115 */
117unsigned int pxa27x_get_memclk_frequency_10khz(void) 116static unsigned long clk_pxa27x_mem_getrate(struct clk *clk)
118{ 117{
119 unsigned long ccsr, clkcfg; 118 unsigned long ccsr, clkcfg;
120 unsigned int l, L, m, M; 119 unsigned int l, L, m, M;
@@ -133,9 +132,15 @@ unsigned int pxa27x_get_memclk_frequency_10khz(void)
133 L = l * BASE_CLK; 132 L = l * BASE_CLK;
134 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2)); 133 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
135 134
136 return (M / 10000); 135 return M;
137} 136}
138 137
138static const struct clkops clk_pxa27x_mem_ops = {
139 .enable = clk_dummy_enable,
140 .disable = clk_dummy_disable,
141 .getrate = clk_pxa27x_mem_getrate,
142};
143
139/* 144/*
140 * Return the current LCD clock frequency in units of 10kHz as 145 * Return the current LCD clock frequency in units of 10kHz as
141 */ 146 */
@@ -192,6 +197,7 @@ static DEFINE_PXA2_CKEN(pxa27x_memc, MEMC, 0, 0);
192 197
193static DEFINE_CK(pxa27x_lcd, LCD, &clk_pxa27x_lcd_ops); 198static DEFINE_CK(pxa27x_lcd, LCD, &clk_pxa27x_lcd_ops);
194static DEFINE_CK(pxa27x_camera, CAMERA, &clk_pxa27x_lcd_ops); 199static DEFINE_CK(pxa27x_camera, CAMERA, &clk_pxa27x_lcd_ops);
200static DEFINE_CLK(pxa27x_mem, &clk_pxa27x_mem_ops, 0, 0);
195 201
196static struct clk_lookup pxa27x_clkregs[] = { 202static struct clk_lookup pxa27x_clkregs[] = {
197 INIT_CLKREG(&clk_pxa27x_lcd, "pxa2xx-fb", NULL), 203 INIT_CLKREG(&clk_pxa27x_lcd, "pxa2xx-fb", NULL),
@@ -220,6 +226,7 @@ static struct clk_lookup pxa27x_clkregs[] = {
220 INIT_CLKREG(&clk_pxa27x_memstk, NULL, "MSTKCLK"), 226 INIT_CLKREG(&clk_pxa27x_memstk, NULL, "MSTKCLK"),
221 INIT_CLKREG(&clk_pxa27x_im, NULL, "IMCLK"), 227 INIT_CLKREG(&clk_pxa27x_im, NULL, "IMCLK"),
222 INIT_CLKREG(&clk_pxa27x_memc, NULL, "MEMCLK"), 228 INIT_CLKREG(&clk_pxa27x_memc, NULL, "MEMCLK"),
229 INIT_CLKREG(&clk_pxa27x_mem, "pxa2xx-pcmcia", NULL),
223}; 230};
224 231
225#ifdef CONFIG_PM 232#ifdef CONFIG_PM
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 55a7d0b045b1..3c01774eb393 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -179,8 +179,8 @@ static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int cl
179 179
180static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) 180static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt)
181{ 181{
182 unsigned int clk = get_memclk_frequency_10khz(); 182 unsigned long clk = clk_get_rate(skt->clk);
183 return pxa2xx_pcmcia_set_mcxx(skt, clk); 183 return pxa2xx_pcmcia_set_mcxx(skt, clk / 10000);
184} 184}
185 185
186#ifdef CONFIG_CPU_FREQ 186#ifdef CONFIG_CPU_FREQ
@@ -282,24 +282,33 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
282 struct pcmcia_low_level *ops; 282 struct pcmcia_low_level *ops;
283 struct skt_dev_info *sinfo; 283 struct skt_dev_info *sinfo;
284 struct soc_pcmcia_socket *skt; 284 struct soc_pcmcia_socket *skt;
285 struct clk *clk;
285 286
286 ops = (struct pcmcia_low_level *)dev->dev.platform_data; 287 ops = (struct pcmcia_low_level *)dev->dev.platform_data;
287 if (!ops) 288 if (!ops)
288 return -ENODEV; 289 return -ENODEV;
289 290
291 clk = clk_get(&dev->dev, NULL);
292 if (!clk)
293 return -ENODEV;
294
290 pxa2xx_drv_pcmcia_ops(ops); 295 pxa2xx_drv_pcmcia_ops(ops);
291 296
292 sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); 297 sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
293 if (!sinfo) 298 if (!sinfo) {
299 clk_put(clk);
294 return -ENOMEM; 300 return -ENOMEM;
301 }
295 302
296 sinfo->nskt = ops->nr; 303 sinfo->nskt = ops->nr;
304 sinfo->clk = clk;
297 305
298 /* Initialize processor specific parameters */ 306 /* Initialize processor specific parameters */
299 for (i = 0; i < ops->nr; i++) { 307 for (i = 0; i < ops->nr; i++) {
300 skt = &sinfo->skt[i]; 308 skt = &sinfo->skt[i];
301 309
302 skt->nr = ops->first + i; 310 skt->nr = ops->first + i;
311 skt->clk = clk;
303 skt->ops = ops; 312 skt->ops = ops;
304 skt->socket.owner = ops->owner; 313 skt->socket.owner = ops->owner;
305 skt->socket.dev.parent = &dev->dev; 314 skt->socket.dev.parent = &dev->dev;
@@ -314,6 +323,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
314 while (--i >= 0) 323 while (--i >= 0)
315 soc_pcmcia_remove_one(&sinfo->skt[i]); 324 soc_pcmcia_remove_one(&sinfo->skt[i]);
316 kfree(sinfo); 325 kfree(sinfo);
326 clk_put(clk);
317 } else { 327 } else {
318 pxa2xx_configure_sockets(&dev->dev); 328 pxa2xx_configure_sockets(&dev->dev);
319 dev_set_drvdata(&dev->dev, sinfo); 329 dev_set_drvdata(&dev->dev, sinfo);
@@ -332,6 +342,7 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
332 for (i = 0; i < sinfo->nskt; i++) 342 for (i = 0; i < sinfo->nskt; i++)
333 soc_pcmcia_remove_one(&sinfo->skt[i]); 343 soc_pcmcia_remove_one(&sinfo->skt[i]);
334 344
345 clk_put(sinfo->clk);
335 kfree(sinfo); 346 kfree(sinfo);
336 return 0; 347 return 0;
337} 348}
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index bbcd5385a221..9daa73615c8b 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -10,6 +10,7 @@
10#define _ASM_ARCH_PCMCIA 10#define _ASM_ARCH_PCMCIA
11 11
12/* include the world */ 12/* include the world */
13#include <linux/clk.h>
13#include <linux/cpufreq.h> 14#include <linux/cpufreq.h>
14#include <pcmcia/ss.h> 15#include <pcmcia/ss.h>
15#include <pcmcia/cistpl.h> 16#include <pcmcia/cistpl.h>
@@ -29,6 +30,7 @@ struct soc_pcmcia_socket {
29 * Info from low level handler 30 * Info from low level handler
30 */ 31 */
31 unsigned int nr; 32 unsigned int nr;
33 struct clk *clk;
32 34
33 /* 35 /*
34 * Core PCMCIA state 36 * Core PCMCIA state
@@ -56,6 +58,7 @@ struct soc_pcmcia_socket {
56 58
57struct skt_dev_info { 59struct skt_dev_info {
58 int nskt; 60 int nskt;
61 struct clk *clk;
59 struct soc_pcmcia_socket skt[0]; 62 struct soc_pcmcia_socket skt[0];
60}; 63};
61 64