19 #include <linux/module.h>
20 #include <linux/slab.h>
24 #include <linux/kernel.h>
28 #include <mach/hardware.h>
45 #define PCMCIAPrtSp 0x04000000
46 #define PCMCIASp (4*PCMCIAPrtSp)
47 #define PCMCIAIOSp PCMCIAPrtSp
48 #define PCMCIAAttrSp PCMCIAPrtSp
49 #define PCMCIAMemSp PCMCIAPrtSp
51 #define PCMCIA0Sp PCMCIASp
52 #define PCMCIA0IOSp PCMCIAIOSp
53 #define PCMCIA0AttrSp PCMCIAAttrSp
54 #define PCMCIA0MemSp PCMCIAMemSp
56 #define PCMCIA1Sp PCMCIASp
57 #define PCMCIA1IOSp PCMCIAIOSp
58 #define PCMCIA1AttrSp PCMCIAAttrSp
59 #define PCMCIA1MemSp PCMCIAMemSp
62 (0x20000000 + (Nb) * PCMCIASp)
63 #define _PCMCIAIO(Nb) _PCMCIA(Nb)
64 #define _PCMCIAAttr(Nb) \
65 (_PCMCIA(Nb) + 2 * PCMCIAPrtSp)
66 #define _PCMCIAMem(Nb) \
67 (_PCMCIA(Nb) + 3 * PCMCIAPrtSp)
69 #define _PCMCIA0 _PCMCIA(0)
70 #define _PCMCIA0IO _PCMCIAIO(0)
71 #define _PCMCIA0Attr _PCMCIAAttr(0)
72 #define _PCMCIA0Mem _PCMCIAMem(0)
74 #define _PCMCIA1 _PCMCIA(1)
75 #define _PCMCIA1IO _PCMCIAIO(1)
76 #define _PCMCIA1Attr _PCMCIAAttr(1)
77 #define _PCMCIA1Mem _PCMCIAMem(1)
80 #define MCXX_SETUP_MASK (0x7f)
81 #define MCXX_ASST_MASK (0x1f)
82 #define MCXX_HOLD_MASK (0x3f)
83 #define MCXX_SETUP_SHIFT (0)
84 #define MCXX_ASST_SHIFT (7)
85 #define MCXX_HOLD_SHIFT (14)
87 static inline u_int pxa2xx_mcxx_hold(
u_int pcmcia_cycle_ns,
90 u_int code = pcmcia_cycle_ns * mem_clk_10khz;
91 return (code / 300000) + ((code % 300000) ? 1 : 0) - 1;
94 static inline u_int pxa2xx_mcxx_asst(
u_int pcmcia_cycle_ns,
97 u_int code = pcmcia_cycle_ns * mem_clk_10khz;
98 return (code / 300000) + ((code % 300000) ? 1 : 0) + 1;
101 static inline u_int pxa2xx_mcxx_setup(
u_int pcmcia_cycle_ns,
104 u_int code = pcmcia_cycle_ns * mem_clk_10khz;
105 return (code / 100000) + ((code % 100000) ? 1 : 0) - 1;
111 static inline u_int pxa2xx_pcmcia_cmd_time(
u_int mem_clk_10khz,
112 u_int pcmcia_mcxx_asst)
114 return (300000 * (pcmcia_mcxx_asst + 1) / mem_clk_10khz);
117 static int pxa2xx_pcmcia_set_mcmem(
int sock,
int speed,
int clock )
121 val = ((pxa2xx_mcxx_setup(speed, clock)
123 | ((pxa2xx_mcxx_asst(speed, clock)
125 | ((pxa2xx_mcxx_hold(speed, clock)
133 static int pxa2xx_pcmcia_set_mcio(
int sock,
int speed,
int clock )
137 val = ((pxa2xx_mcxx_setup(speed, clock)
139 | ((pxa2xx_mcxx_asst(speed, clock)
141 | ((pxa2xx_mcxx_hold(speed, clock)
149 static int pxa2xx_pcmcia_set_mcatt(
int sock,
int speed,
int clock )
153 val = ((pxa2xx_mcxx_setup(speed, clock)
155 | ((pxa2xx_mcxx_asst(speed, clock)
157 | ((pxa2xx_mcxx_hold(speed, clock)
172 pxa2xx_pcmcia_set_mcmem(sock,
timing.mem, clk);
173 pxa2xx_pcmcia_set_mcatt(sock,
timing.attr, clk);
174 pxa2xx_pcmcia_set_mcio(sock,
timing.io, clk);
182 return pxa2xx_pcmcia_set_mcxx(skt, clk / 10000);
185 #ifdef CONFIG_CPU_FREQ
194 if (freqs->
new > freqs->
old) {
195 debug(skt, 2,
"new frequency %u.%uMHz > %u.%uMHz, "
197 freqs->
new / 1000, (freqs->
new / 100) % 10,
198 freqs->
old / 1000, (freqs->
old / 100) % 10);
199 pxa2xx_pcmcia_set_timing(skt);
204 if (freqs->
new < freqs->
old) {
205 debug(skt, 2,
"new frequency %u.%uMHz < %u.%uMHz, "
207 freqs->
new / 1000, (freqs->
new / 100) % 10,
208 freqs->
old / 1000, (freqs->
old / 100) % 10);
209 pxa2xx_pcmcia_set_timing(skt);
227 if ((ops->
first + ops->
nr) > 1 ||
228 machine_is_viper() || machine_is_arcom_zeus())
235 static const char *skt_names[] = {
240 #define SKT_DEV_INFO_SIZE(n) \
241 (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
273 #ifdef CONFIG_CPU_FREQ
274 ops->frequency_change = pxa2xx_pcmcia_frequency_change;
294 dev_err(&dev->
dev,
"pxa320 supports only one pcmcia slot");
315 for (i = 0; i < ops->
nr; i++) {
316 skt = &sinfo->
skt[
i];
346 platform_set_drvdata(dev,
NULL);
348 for (i = 0; i < sinfo->
nskt; i++)
356 static int pxa2xx_drv_pcmcia_resume(
struct device *dev)
362 static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = {
363 .resume = pxa2xx_drv_pcmcia_resume,
367 .probe = pxa2xx_drv_pcmcia_probe,
368 .remove = pxa2xx_drv_pcmcia_remove,
370 .name =
"pxa2xx-pcmcia",
372 .pm = &pxa2xx_drv_pcmcia_pm_ops,
376 static int __init pxa2xx_pcmcia_init(
void)
381 static void __exit pxa2xx_pcmcia_exit(
void)