aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/sa1100_assabet.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/pcmcia/sa1100_assabet.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/sa1100_assabet.c')
-rw-r--r--drivers/pcmcia/sa1100_assabet.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c
new file mode 100644
index 000000000000..7c57fdd3c8d7
--- /dev/null
+++ b/drivers/pcmcia/sa1100_assabet.c
@@ -0,0 +1,141 @@
1/*
2 * drivers/pcmcia/sa1100_assabet.c
3 *
4 * PCMCIA implementation routines for Assabet
5 *
6 */
7#include <linux/module.h>
8#include <linux/kernel.h>
9#include <linux/errno.h>
10#include <linux/interrupt.h>
11#include <linux/device.h>
12#include <linux/init.h>
13
14#include <asm/hardware.h>
15#include <asm/mach-types.h>
16#include <asm/irq.h>
17#include <asm/signal.h>
18#include <asm/arch/assabet.h>
19
20#include "sa1100_generic.h"
21
22static struct pcmcia_irqs irqs[] = {
23 { 1, ASSABET_IRQ_GPIO_CF_CD, "CF CD" },
24 { 1, ASSABET_IRQ_GPIO_CF_BVD2, "CF BVD2" },
25 { 1, ASSABET_IRQ_GPIO_CF_BVD1, "CF BVD1" },
26};
27
28static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
29{
30 skt->irq = ASSABET_IRQ_GPIO_CF_IRQ;
31
32 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
33}
34
35/*
36 * Release all resources.
37 */
38static void assabet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
39{
40 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
41}
42
43static void
44assabet_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
45{
46 unsigned long levels = GPLR;
47
48 state->detect = (levels & ASSABET_GPIO_CF_CD) ? 0 : 1;
49 state->ready = (levels & ASSABET_GPIO_CF_IRQ) ? 1 : 0;
50 state->bvd1 = (levels & ASSABET_GPIO_CF_BVD1) ? 1 : 0;
51 state->bvd2 = (levels & ASSABET_GPIO_CF_BVD2) ? 1 : 0;
52 state->wrprot = 0; /* Not available on Assabet. */
53 state->vs_3v = 1; /* Can only apply 3.3V on Assabet. */
54 state->vs_Xv = 0;
55}
56
57static int
58assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
59{
60 unsigned int mask;
61
62 switch (state->Vcc) {
63 case 0:
64 mask = 0;
65 break;
66
67 case 50:
68 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
69 __FUNCTION__);
70
71 case 33: /* Can only apply 3.3V to the CF slot. */
72 mask = ASSABET_BCR_CF_PWR;
73 break;
74
75 default:
76 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
77 state->Vcc);
78 return -1;
79 }
80
81 /* Silently ignore Vpp, output enable, speaker enable. */
82
83 if (state->flags & SS_RESET)
84 mask |= ASSABET_BCR_CF_RST;
85
86 ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR, mask);
87
88 return 0;
89}
90
91/*
92 * Enable card status IRQs on (re-)initialisation. This can
93 * be called at initialisation, power management event, or
94 * pcmcia event.
95 */
96static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
97{
98 /*
99 * Enable CF bus
100 */
101 ASSABET_BCR_clear(ASSABET_BCR_CF_BUS_OFF);
102
103 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
104}
105
106/*
107 * Disable card status IRQs on suspend.
108 */
109static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
110{
111 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
112
113 /*
114 * Tristate the CF bus signals. Also assert CF
115 * reset as per user guide page 4-11.
116 */
117 ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST);
118}
119
120static struct pcmcia_low_level assabet_pcmcia_ops = {
121 .owner = THIS_MODULE,
122
123 .hw_init = assabet_pcmcia_hw_init,
124 .hw_shutdown = assabet_pcmcia_hw_shutdown,
125
126 .socket_state = assabet_pcmcia_socket_state,
127 .configure_socket = assabet_pcmcia_configure_socket,
128
129 .socket_init = assabet_pcmcia_socket_init,
130 .socket_suspend = assabet_pcmcia_socket_suspend,
131};
132
133int __init pcmcia_assabet_init(struct device *dev)
134{
135 int ret = -ENODEV;
136
137 if (machine_is_assabet() && !machine_has_neponset())
138 ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1);
139
140 return ret;
141}