2 * drivers/pcmcia/sa1100_h3600.c
4 * PCMCIA implementation routines for H3600
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/device.h>
11 #include <linux/interrupt.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
15 #include <asm/hardware.h>
17 #include <asm/mach-types.h>
18 #include <asm/arch/h3600.h>
20 #include "sa1100_generic.h"
22 static struct pcmcia_irqs irqs
[] = {
23 { 0, IRQ_GPIO_H3600_PCMCIA_CD0
, "PCMCIA CD0" },
24 { 1, IRQ_GPIO_H3600_PCMCIA_CD1
, "PCMCIA CD1" }
27 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
29 skt
->irq
= skt
->nr
? IRQ_GPIO_H3600_PCMCIA_IRQ1
30 : IRQ_GPIO_H3600_PCMCIA_IRQ0
;
33 return soc_pcmcia_request_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
36 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
38 soc_pcmcia_free_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
41 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
);
42 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON
);
43 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET
);
47 h3600_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
, struct pcmcia_state
*state
)
49 unsigned long levels
= GPLR
;
53 state
->detect
= levels
& GPIO_H3600_PCMCIA_CD0
? 0 : 1;
54 state
->ready
= levels
& GPIO_H3600_PCMCIA_IRQ0
? 1 : 0;
57 state
->wrprot
= 0; /* Not available on H3600. */
63 state
->detect
= levels
& GPIO_H3600_PCMCIA_CD1
? 0 : 1;
64 state
->ready
= levels
& GPIO_H3600_PCMCIA_IRQ1
? 1 : 0;
67 state
->wrprot
= 0; /* Not available on H3600. */
75 h3600_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
, const socket_state_t
*state
)
77 if (state
->Vcc
!= 0 && state
->Vcc
!= 33 && state
->Vcc
!= 50) {
78 printk(KERN_ERR
"h3600_pcmcia: unrecognized Vcc %u.%uV\n",
79 state
->Vcc
/ 10, state
->Vcc
% 10);
83 if (state
->flags
& SS_RESET
)
84 set_h3600_egpio(IPAQ_EGPIO_CARD_RESET
);
86 clr_h3600_egpio(IPAQ_EGPIO_CARD_RESET
);
88 /* Silently ignore Vpp, output enable, speaker enable. */
93 static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
96 set_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
);
97 set_h3600_egpio(IPAQ_EGPIO_OPT_ON
);
98 clr_h3600_egpio(IPAQ_EGPIO_OPT_RESET
);
102 soc_pcmcia_enable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
105 static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
107 soc_pcmcia_disable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
110 * FIXME: This doesn't fit well. We don't have the mechanism in
111 * the generic PCMCIA layer to deal with the idea of two sockets
112 * on one bus. We rely on the cs.c behaviour shutting down
113 * socket 0 then socket 1.
116 clr_h3600_egpio(IPAQ_EGPIO_OPT_ON
);
117 clr_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
);
118 /* hmm, does this suck power? */
119 set_h3600_egpio(IPAQ_EGPIO_OPT_RESET
);
123 struct pcmcia_low_level h3600_pcmcia_ops
= {
124 .owner
= THIS_MODULE
,
125 .hw_init
= h3600_pcmcia_hw_init
,
126 .hw_shutdown
= h3600_pcmcia_hw_shutdown
,
127 .socket_state
= h3600_pcmcia_socket_state
,
128 .configure_socket
= h3600_pcmcia_configure_socket
,
130 .socket_init
= h3600_pcmcia_socket_init
,
131 .socket_suspend
= h3600_pcmcia_socket_suspend
,
134 int __init
pcmcia_h3600_init(struct device
*dev
)
138 if (machine_is_h3600())
139 ret
= sa11xx_drv_pcmcia_probe(dev
, &h3600_pcmcia_ops
, 0, 2);