Commit 2a125dd5 authored by Eric Miao's avatar Eric Miao

ARM: pxa: remove get_memclk_frequency_10khz()

Introduce 'struct clk' for memory and remove
get_memclk_frequency_10khz().
Signed-off-by: default avatarEric Miao <eric.y.miao@gmail.com>
parent 4029813c
...@@ -71,19 +71,6 @@ unsigned int get_clk_frequency_khz(int info) ...@@ -71,19 +71,6 @@ unsigned int get_clk_frequency_khz(int info)
} }
EXPORT_SYMBOL(get_clk_frequency_khz); EXPORT_SYMBOL(get_clk_frequency_khz);
/*
* Return the current memory clock frequency in units of 10kHz
*/
unsigned int get_memclk_frequency_10khz(void)
{
if (cpu_is_pxa25x())
return pxa25x_get_memclk_frequency_10khz();
else if (cpu_is_pxa27x())
return pxa27x_get_memclk_frequency_10khz();
return 0;
}
EXPORT_SYMBOL(get_memclk_frequency_10khz);
/* /*
* Intel PXA2xx internal register mapping. * Intel PXA2xx internal register mapping.
* *
......
...@@ -36,18 +36,14 @@ extern unsigned int get_clk_frequency_khz(int info); ...@@ -36,18 +36,14 @@ extern unsigned int get_clk_frequency_khz(int info);
#ifdef CONFIG_PXA25x #ifdef CONFIG_PXA25x
extern unsigned pxa25x_get_clk_frequency_khz(int); extern unsigned pxa25x_get_clk_frequency_khz(int);
extern unsigned pxa25x_get_memclk_frequency_10khz(void);
#else #else
#define pxa25x_get_clk_frequency_khz(x) (0) #define pxa25x_get_clk_frequency_khz(x) (0)
#define pxa25x_get_memclk_frequency_10khz() (0)
#endif #endif
#ifdef CONFIG_PXA27x #ifdef CONFIG_PXA27x
extern unsigned pxa27x_get_clk_frequency_khz(int); extern unsigned pxa27x_get_clk_frequency_khz(int);
extern unsigned pxa27x_get_memclk_frequency_10khz(void);
#else #else
#define pxa27x_get_clk_frequency_khz(x) (0) #define pxa27x_get_clk_frequency_khz(x) (0)
#define pxa27x_get_memclk_frequency_10khz() (0)
#endif #endif
#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x) #if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
......
...@@ -92,23 +92,21 @@ unsigned int pxa25x_get_clk_frequency_khz(int info) ...@@ -92,23 +92,21 @@ unsigned int pxa25x_get_clk_frequency_khz(int info)
return (turbo & 1) ? (N/1000) : (M/1000); return (turbo & 1) ? (N/1000) : (M/1000);
} }
/* static unsigned long clk_pxa25x_mem_getrate(struct clk *clk)
* Return the current memory clock frequency in units of 10kHz
*/
unsigned int pxa25x_get_memclk_frequency_10khz(void)
{ {
return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK / 10000; return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK;
} }
static unsigned long clk_pxa25x_lcd_getrate(struct clk *clk) static const struct clkops clk_pxa25x_mem_ops = {
{ .enable = clk_dummy_enable,
return pxa25x_get_memclk_frequency_10khz() * 10000; .disable = clk_dummy_disable,
} .getrate = clk_pxa25x_mem_getrate,
};
static const struct clkops clk_pxa25x_lcd_ops = { static const struct clkops clk_pxa25x_lcd_ops = {
.enable = clk_pxa2xx_cken_enable, .enable = clk_pxa2xx_cken_enable,
.disable = clk_pxa2xx_cken_disable, .disable = clk_pxa2xx_cken_disable,
.getrate = clk_pxa25x_lcd_getrate, .getrate = clk_pxa25x_mem_getrate,
}; };
static unsigned long gpio12_config_32k[] = { static unsigned long gpio12_config_32k[] = {
...@@ -185,6 +183,7 @@ static DEFINE_PXA2_CKEN(pxa25x_ficp, FICP, 47923000, 0); ...@@ -185,6 +183,7 @@ static DEFINE_PXA2_CKEN(pxa25x_ficp, FICP, 47923000, 0);
static DEFINE_CK(pxa25x_lcd, LCD, &clk_pxa25x_lcd_ops); static DEFINE_CK(pxa25x_lcd, LCD, &clk_pxa25x_lcd_ops);
static DEFINE_CLK(pxa25x_gpio11, &clk_pxa25x_gpio11_ops, 3686400, 0); static DEFINE_CLK(pxa25x_gpio11, &clk_pxa25x_gpio11_ops, 3686400, 0);
static DEFINE_CLK(pxa25x_gpio12, &clk_pxa25x_gpio12_ops, 32768, 0); static DEFINE_CLK(pxa25x_gpio12, &clk_pxa25x_gpio12_ops, 32768, 0);
static DEFINE_CLK(pxa25x_mem, &clk_pxa25x_mem_ops, 0, 0);
static struct clk_lookup pxa25x_clkregs[] = { static struct clk_lookup pxa25x_clkregs[] = {
INIT_CLKREG(&clk_pxa25x_lcd, "pxa2xx-fb", NULL), INIT_CLKREG(&clk_pxa25x_lcd, "pxa2xx-fb", NULL),
...@@ -205,6 +204,7 @@ static struct clk_lookup pxa25x_clkregs[] = { ...@@ -205,6 +204,7 @@ static struct clk_lookup pxa25x_clkregs[] = {
INIT_CLKREG(&clk_pxa25x_ac97, NULL, "AC97CLK"), INIT_CLKREG(&clk_pxa25x_ac97, NULL, "AC97CLK"),
INIT_CLKREG(&clk_pxa25x_gpio11, NULL, "GPIO11_CLK"), INIT_CLKREG(&clk_pxa25x_gpio11, NULL, "GPIO11_CLK"),
INIT_CLKREG(&clk_pxa25x_gpio12, NULL, "GPIO12_CLK"), INIT_CLKREG(&clk_pxa25x_gpio12, NULL, "GPIO12_CLK"),
INIT_CLKREG(&clk_pxa25x_mem, "pxa2xx-pcmcia", NULL),
}; };
static struct clk_lookup pxa25x_hwuart_clkreg = static struct clk_lookup pxa25x_hwuart_clkreg =
......
...@@ -111,10 +111,9 @@ unsigned int pxa27x_get_clk_frequency_khz(int info) ...@@ -111,10 +111,9 @@ unsigned int pxa27x_get_clk_frequency_khz(int info)
} }
/* /*
* Return the current mem clock frequency in units of 10kHz as * Return the current mem clock frequency as reflected by CCCR[A], B, and L
* reflected by CCCR[A], B, and L
*/ */
unsigned int pxa27x_get_memclk_frequency_10khz(void) static unsigned long clk_pxa27x_mem_getrate(struct clk *clk)
{ {
unsigned long ccsr, clkcfg; unsigned long ccsr, clkcfg;
unsigned int l, L, m, M; unsigned int l, L, m, M;
...@@ -133,9 +132,15 @@ unsigned int pxa27x_get_memclk_frequency_10khz(void) ...@@ -133,9 +132,15 @@ unsigned int pxa27x_get_memclk_frequency_10khz(void)
L = l * BASE_CLK; L = l * BASE_CLK;
M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2)); M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
return (M / 10000); return M;
} }
static const struct clkops clk_pxa27x_mem_ops = {
.enable = clk_dummy_enable,
.disable = clk_dummy_disable,
.getrate = clk_pxa27x_mem_getrate,
};
/* /*
* Return the current LCD clock frequency in units of 10kHz as * Return the current LCD clock frequency in units of 10kHz as
*/ */
...@@ -192,6 +197,7 @@ static DEFINE_PXA2_CKEN(pxa27x_memc, MEMC, 0, 0); ...@@ -192,6 +197,7 @@ static DEFINE_PXA2_CKEN(pxa27x_memc, MEMC, 0, 0);
static DEFINE_CK(pxa27x_lcd, LCD, &clk_pxa27x_lcd_ops); static DEFINE_CK(pxa27x_lcd, LCD, &clk_pxa27x_lcd_ops);
static DEFINE_CK(pxa27x_camera, CAMERA, &clk_pxa27x_lcd_ops); static DEFINE_CK(pxa27x_camera, CAMERA, &clk_pxa27x_lcd_ops);
static DEFINE_CLK(pxa27x_mem, &clk_pxa27x_mem_ops, 0, 0);
static struct clk_lookup pxa27x_clkregs[] = { static struct clk_lookup pxa27x_clkregs[] = {
INIT_CLKREG(&clk_pxa27x_lcd, "pxa2xx-fb", NULL), INIT_CLKREG(&clk_pxa27x_lcd, "pxa2xx-fb", NULL),
...@@ -220,6 +226,7 @@ static struct clk_lookup pxa27x_clkregs[] = { ...@@ -220,6 +226,7 @@ static struct clk_lookup pxa27x_clkregs[] = {
INIT_CLKREG(&clk_pxa27x_memstk, NULL, "MSTKCLK"), INIT_CLKREG(&clk_pxa27x_memstk, NULL, "MSTKCLK"),
INIT_CLKREG(&clk_pxa27x_im, NULL, "IMCLK"), INIT_CLKREG(&clk_pxa27x_im, NULL, "IMCLK"),
INIT_CLKREG(&clk_pxa27x_memc, NULL, "MEMCLK"), INIT_CLKREG(&clk_pxa27x_memc, NULL, "MEMCLK"),
INIT_CLKREG(&clk_pxa27x_mem, "pxa2xx-pcmcia", NULL),
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -179,8 +179,8 @@ static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int cl ...@@ -179,8 +179,8 @@ static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int cl
static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt)
{ {
unsigned int clk = get_memclk_frequency_10khz(); unsigned long clk = clk_get_rate(skt->clk);
return pxa2xx_pcmcia_set_mcxx(skt, clk); return pxa2xx_pcmcia_set_mcxx(skt, clk / 10000);
} }
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
...@@ -282,24 +282,33 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) ...@@ -282,24 +282,33 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
struct pcmcia_low_level *ops; struct pcmcia_low_level *ops;
struct skt_dev_info *sinfo; struct skt_dev_info *sinfo;
struct soc_pcmcia_socket *skt; struct soc_pcmcia_socket *skt;
struct clk *clk;
ops = (struct pcmcia_low_level *)dev->dev.platform_data; ops = (struct pcmcia_low_level *)dev->dev.platform_data;
if (!ops) if (!ops)
return -ENODEV; return -ENODEV;
clk = clk_get(&dev->dev, NULL);
if (!clk)
return -ENODEV;
pxa2xx_drv_pcmcia_ops(ops); pxa2xx_drv_pcmcia_ops(ops);
sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
if (!sinfo) if (!sinfo) {
clk_put(clk);
return -ENOMEM; return -ENOMEM;
}
sinfo->nskt = ops->nr; sinfo->nskt = ops->nr;
sinfo->clk = clk;
/* Initialize processor specific parameters */ /* Initialize processor specific parameters */
for (i = 0; i < ops->nr; i++) { for (i = 0; i < ops->nr; i++) {
skt = &sinfo->skt[i]; skt = &sinfo->skt[i];
skt->nr = ops->first + i; skt->nr = ops->first + i;
skt->clk = clk;
skt->ops = ops; skt->ops = ops;
skt->socket.owner = ops->owner; skt->socket.owner = ops->owner;
skt->socket.dev.parent = &dev->dev; skt->socket.dev.parent = &dev->dev;
...@@ -314,6 +323,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) ...@@ -314,6 +323,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
while (--i >= 0) while (--i >= 0)
soc_pcmcia_remove_one(&sinfo->skt[i]); soc_pcmcia_remove_one(&sinfo->skt[i]);
kfree(sinfo); kfree(sinfo);
clk_put(clk);
} else { } else {
pxa2xx_configure_sockets(&dev->dev); pxa2xx_configure_sockets(&dev->dev);
dev_set_drvdata(&dev->dev, sinfo); dev_set_drvdata(&dev->dev, sinfo);
...@@ -332,6 +342,7 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev) ...@@ -332,6 +342,7 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
for (i = 0; i < sinfo->nskt; i++) for (i = 0; i < sinfo->nskt; i++)
soc_pcmcia_remove_one(&sinfo->skt[i]); soc_pcmcia_remove_one(&sinfo->skt[i]);
clk_put(sinfo->clk);
kfree(sinfo); kfree(sinfo);
return 0; return 0;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define _ASM_ARCH_PCMCIA #define _ASM_ARCH_PCMCIA
/* include the world */ /* include the world */
#include <linux/clk.h>
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
#include <pcmcia/cistpl.h> #include <pcmcia/cistpl.h>
...@@ -29,6 +30,7 @@ struct soc_pcmcia_socket { ...@@ -29,6 +30,7 @@ struct soc_pcmcia_socket {
* Info from low level handler * Info from low level handler
*/ */
unsigned int nr; unsigned int nr;
struct clk *clk;
/* /*
* Core PCMCIA state * Core PCMCIA state
...@@ -56,6 +58,7 @@ struct soc_pcmcia_socket { ...@@ -56,6 +58,7 @@ struct soc_pcmcia_socket {
struct skt_dev_info { struct skt_dev_info {
int nskt; int nskt;
struct clk *clk;
struct soc_pcmcia_socket skt[0]; struct soc_pcmcia_socket skt[0];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment