diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/pcmcia/sa1111_generic.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/pcmcia/sa1111_generic.c')
-rw-r--r-- | drivers/pcmcia/sa1111_generic.c | 196 |
1 files changed, 196 insertions, 0 deletions
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c new file mode 100644 index 000000000000..bd9d6b2fad68 --- /dev/null +++ b/drivers/pcmcia/sa1111_generic.c | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/sa1111_generic.c | ||
3 | * | ||
4 | * We implement the generic parts of a SA1111 PCMCIA driver. This | ||
5 | * basically means we handle everything except controlling the | ||
6 | * power. Power is machine specific... | ||
7 | */ | ||
8 | #include <linux/config.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/ioport.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/init.h> | ||
15 | |||
16 | #include <pcmcia/ss.h> | ||
17 | |||
18 | #include <asm/hardware.h> | ||
19 | #include <asm/hardware/sa1111.h> | ||
20 | #include <asm/io.h> | ||
21 | #include <asm/irq.h> | ||
22 | |||
23 | #include "sa1111_generic.h" | ||
24 | |||
25 | static struct pcmcia_irqs irqs[] = { | ||
26 | { 0, IRQ_S0_CD_VALID, "SA1111 PCMCIA card detect" }, | ||
27 | { 0, IRQ_S0_BVD1_STSCHG, "SA1111 PCMCIA BVD1" }, | ||
28 | { 1, IRQ_S1_CD_VALID, "SA1111 CF card detect" }, | ||
29 | { 1, IRQ_S1_BVD1_STSCHG, "SA1111 CF BVD1" }, | ||
30 | }; | ||
31 | |||
32 | int sa1111_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
33 | { | ||
34 | if (skt->irq == NO_IRQ) | ||
35 | skt->irq = skt->nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT; | ||
36 | |||
37 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
38 | } | ||
39 | |||
40 | void sa1111_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
41 | { | ||
42 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
43 | } | ||
44 | |||
45 | void sa1111_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) | ||
46 | { | ||
47 | struct sa1111_dev *sadev = SA1111_DEV(skt->dev); | ||
48 | unsigned long status = sa1111_readl(sadev->mapbase + SA1111_PCSR); | ||
49 | |||
50 | switch (skt->nr) { | ||
51 | case 0: | ||
52 | state->detect = status & PCSR_S0_DETECT ? 0 : 1; | ||
53 | state->ready = status & PCSR_S0_READY ? 1 : 0; | ||
54 | state->bvd1 = status & PCSR_S0_BVD1 ? 1 : 0; | ||
55 | state->bvd2 = status & PCSR_S0_BVD2 ? 1 : 0; | ||
56 | state->wrprot = status & PCSR_S0_WP ? 1 : 0; | ||
57 | state->vs_3v = status & PCSR_S0_VS1 ? 0 : 1; | ||
58 | state->vs_Xv = status & PCSR_S0_VS2 ? 0 : 1; | ||
59 | break; | ||
60 | |||
61 | case 1: | ||
62 | state->detect = status & PCSR_S1_DETECT ? 0 : 1; | ||
63 | state->ready = status & PCSR_S1_READY ? 1 : 0; | ||
64 | state->bvd1 = status & PCSR_S1_BVD1 ? 1 : 0; | ||
65 | state->bvd2 = status & PCSR_S1_BVD2 ? 1 : 0; | ||
66 | state->wrprot = status & PCSR_S1_WP ? 1 : 0; | ||
67 | state->vs_3v = status & PCSR_S1_VS1 ? 0 : 1; | ||
68 | state->vs_Xv = status & PCSR_S1_VS2 ? 0 : 1; | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | int sa1111_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) | ||
74 | { | ||
75 | struct sa1111_dev *sadev = SA1111_DEV(skt->dev); | ||
76 | unsigned int pccr_skt_mask, pccr_set_mask, val; | ||
77 | unsigned long flags; | ||
78 | |||
79 | switch (skt->nr) { | ||
80 | case 0: | ||
81 | pccr_skt_mask = PCCR_S0_RST|PCCR_S0_FLT|PCCR_S0_PWAITEN|PCCR_S0_PSE; | ||
82 | break; | ||
83 | |||
84 | case 1: | ||
85 | pccr_skt_mask = PCCR_S1_RST|PCCR_S1_FLT|PCCR_S1_PWAITEN|PCCR_S1_PSE; | ||
86 | break; | ||
87 | |||
88 | default: | ||
89 | return -1; | ||
90 | } | ||
91 | |||
92 | pccr_set_mask = 0; | ||
93 | |||
94 | if (state->Vcc != 0) | ||
95 | pccr_set_mask |= PCCR_S0_PWAITEN|PCCR_S1_PWAITEN; | ||
96 | if (state->Vcc == 50) | ||
97 | pccr_set_mask |= PCCR_S0_PSE|PCCR_S1_PSE; | ||
98 | if (state->flags & SS_RESET) | ||
99 | pccr_set_mask |= PCCR_S0_RST|PCCR_S1_RST; | ||
100 | if (state->flags & SS_OUTPUT_ENA) | ||
101 | pccr_set_mask |= PCCR_S0_FLT|PCCR_S1_FLT; | ||
102 | |||
103 | local_irq_save(flags); | ||
104 | val = sa1111_readl(sadev->mapbase + SA1111_PCCR); | ||
105 | val &= ~pccr_skt_mask; | ||
106 | val |= pccr_set_mask & pccr_skt_mask; | ||
107 | sa1111_writel(val, sadev->mapbase + SA1111_PCCR); | ||
108 | local_irq_restore(flags); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | void sa1111_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
114 | { | ||
115 | soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
116 | } | ||
117 | |||
118 | void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
119 | { | ||
120 | soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
121 | } | ||
122 | |||
123 | static int pcmcia_probe(struct sa1111_dev *dev) | ||
124 | { | ||
125 | char *base; | ||
126 | |||
127 | if (!request_mem_region(dev->res.start, 512, | ||
128 | SA1111_DRIVER_NAME(dev))) | ||
129 | return -EBUSY; | ||
130 | |||
131 | base = dev->mapbase; | ||
132 | |||
133 | /* | ||
134 | * Initialise the suspend state. | ||
135 | */ | ||
136 | sa1111_writel(PCSSR_S0_SLEEP | PCSSR_S1_SLEEP, base + SA1111_PCSSR); | ||
137 | sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + SA1111_PCCR); | ||
138 | |||
139 | #ifdef CONFIG_SA1100_BADGE4 | ||
140 | pcmcia_badge4_init(&dev->dev); | ||
141 | #endif | ||
142 | #ifdef CONFIG_SA1100_JORNADA720 | ||
143 | pcmcia_jornada720_init(&dev->dev); | ||
144 | #endif | ||
145 | #ifdef CONFIG_ARCH_LUBBOCK | ||
146 | pcmcia_lubbock_init(dev); | ||
147 | #endif | ||
148 | #ifdef CONFIG_ASSABET_NEPONSET | ||
149 | pcmcia_neponset_init(dev); | ||
150 | #endif | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static int __devexit pcmcia_remove(struct sa1111_dev *dev) | ||
155 | { | ||
156 | soc_common_drv_pcmcia_remove(&dev->dev); | ||
157 | release_mem_region(dev->res.start, 512); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int pcmcia_suspend(struct sa1111_dev *dev, u32 state) | ||
162 | { | ||
163 | return pcmcia_socket_dev_suspend(&dev->dev, state); | ||
164 | } | ||
165 | |||
166 | static int pcmcia_resume(struct sa1111_dev *dev) | ||
167 | { | ||
168 | return pcmcia_socket_dev_resume(&dev->dev); | ||
169 | } | ||
170 | |||
171 | static struct sa1111_driver pcmcia_driver = { | ||
172 | .drv = { | ||
173 | .name = "sa1111-pcmcia", | ||
174 | }, | ||
175 | .devid = SA1111_DEVID_PCMCIA, | ||
176 | .probe = pcmcia_probe, | ||
177 | .remove = __devexit_p(pcmcia_remove), | ||
178 | .suspend = pcmcia_suspend, | ||
179 | .resume = pcmcia_resume, | ||
180 | }; | ||
181 | |||
182 | static int __init sa1111_drv_pcmcia_init(void) | ||
183 | { | ||
184 | return sa1111_driver_register(&pcmcia_driver); | ||
185 | } | ||
186 | |||
187 | static void __exit sa1111_drv_pcmcia_exit(void) | ||
188 | { | ||
189 | sa1111_driver_unregister(&pcmcia_driver); | ||
190 | } | ||
191 | |||
192 | module_init(sa1111_drv_pcmcia_init); | ||
193 | module_exit(sa1111_drv_pcmcia_exit); | ||
194 | |||
195 | MODULE_DESCRIPTION("SA1111 PCMCIA card socket driver"); | ||
196 | MODULE_LICENSE("GPL"); | ||