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/device.h>
10 #include <linux/interrupt.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
14 #include <mach/hardware.h>
16 #include <asm/mach-types.h>
17 #include <mach/h3600.h>
19 #include "sa1100_generic.h"
21 static struct pcmcia_irqs irqs
[] = {
22 { 0, IRQ_GPIO_H3600_PCMCIA_CD0
, "PCMCIA CD0" },
23 { 1, IRQ_GPIO_H3600_PCMCIA_CD1
, "PCMCIA CD1" }
26 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
28 skt
->irq
= skt
->nr
? IRQ_GPIO_H3600_PCMCIA_IRQ1
29 : IRQ_GPIO_H3600_PCMCIA_IRQ0
;
32 return soc_pcmcia_request_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
35 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
37 soc_pcmcia_free_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
40 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
, 0);
41 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON
, 0);
42 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET
, 1);
46 h3600_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
, struct pcmcia_state
*state
)
48 unsigned long levels
= GPLR
;
52 state
->detect
= levels
& GPIO_H3600_PCMCIA_CD0
? 0 : 1;
53 state
->ready
= levels
& GPIO_H3600_PCMCIA_IRQ0
? 1 : 0;
56 state
->wrprot
= 0; /* Not available on H3600. */
62 state
->detect
= levels
& GPIO_H3600_PCMCIA_CD1
? 0 : 1;
63 state
->ready
= levels
& GPIO_H3600_PCMCIA_IRQ1
? 1 : 0;
66 state
->wrprot
= 0; /* Not available on H3600. */
74 h3600_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
, const socket_state_t
*state
)
76 if (state
->Vcc
!= 0 && state
->Vcc
!= 33 && state
->Vcc
!= 50) {
77 printk(KERN_ERR
"h3600_pcmcia: unrecognized Vcc %u.%uV\n",
78 state
->Vcc
/ 10, state
->Vcc
% 10);
82 assign_h3600_egpio(IPAQ_EGPIO_CARD_RESET
, !!(state
->flags
& SS_RESET
));
84 /* Silently ignore Vpp, output enable, speaker enable. */
89 static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
92 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
, 1);
93 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON
, 1);
94 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET
, 0);
98 soc_pcmcia_enable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
101 static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
103 soc_pcmcia_disable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
106 * FIXME: This doesn't fit well. We don't have the mechanism in
107 * the generic PCMCIA layer to deal with the idea of two sockets
108 * on one bus. We rely on the cs.c behaviour shutting down
109 * socket 0 then socket 1.
112 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON
, 0);
113 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON
, 0);
114 /* hmm, does this suck power? */
115 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET
, 1);
119 struct pcmcia_low_level h3600_pcmcia_ops
= {
120 .owner
= THIS_MODULE
,
121 .hw_init
= h3600_pcmcia_hw_init
,
122 .hw_shutdown
= h3600_pcmcia_hw_shutdown
,
123 .socket_state
= h3600_pcmcia_socket_state
,
124 .configure_socket
= h3600_pcmcia_configure_socket
,
126 .socket_init
= h3600_pcmcia_socket_init
,
127 .socket_suspend
= h3600_pcmcia_socket_suspend
,
130 int __init
pcmcia_h3600_init(struct device
*dev
)
134 if (machine_is_h3600())
135 ret
= sa11xx_drv_pcmcia_probe(dev
, &h3600_pcmcia_ops
, 0, 2);