import hh.org
[hh.org.git] / drivers / pcmcia / h3600_pcmcia.c
blob16ccbb6a5f0214cf7f8baaee6fd721a5f01f69d2
1 /*
2 * drivers/pcmcia/sa1100_h3600.c
4 * PCMCIA implementation routines for H3600
5 * All true functionality is shuttled off to the
6 * pcmcia implementation for the current sleeve
7 */
9 /****************************************************/
10 /* Common functions used by the different sleeves */
11 /****************************************************/
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/i2c.h>
18 #include <linux/pm.h>
19 #include <linux/sysctl.h>
21 #include <asm/hardware.h>
22 #include <asm/irq.h>
23 #include <asm/io.h>
25 //#include <asm/arch-sa1100/h3600.h>
26 #include <asm/hardware/ipaq-ops.h>
27 #include <asm/ipaq-sleeve.h>
29 #include "h3600_pcmcia.h"
31 int timing_increment_ns;
33 static struct pcmcia_irqs cd_irqs[] = {
34 { 0, 0, "PCMCIA CD0" },
35 { 1, 0, "PCMCIA CD1" },
38 int
39 h3600_common_pcmcia_init(struct soc_pcmcia_socket *skt)
41 /* Enable PCMCIA/CF bus: */
42 ipaq_sleeve_clear_egpio(IPAQ_EGPIO_OPT_RESET);
43 ipaq_sleeve_clear_egpio(IPAQ_EGPIO_CARD_RESET);
45 skt->irq = ipaq_sleeve_egpio_irq (skt->nr == 0 ? IPAQ_EGPIO_PCMCIA_IRQ0:
46 IPAQ_EGPIO_PCMCIA_IRQ1);
48 cd_irqs[skt->nr].irq = ipaq_sleeve_egpio_irq (skt->nr == 0 ? IPAQ_EGPIO_PCMCIA_CD0_N :
49 IPAQ_EGPIO_PCMCIA_CD1_N);
51 set_irq_type (cd_irqs[skt->nr].irq, IRQT_BOTHEDGE);
53 return soc_pcmcia_request_irqs(skt, cd_irqs, ARRAY_SIZE(cd_irqs));
55 EXPORT_SYMBOL(h3600_common_pcmcia_init);
57 void
58 h3600_common_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
60 soc_pcmcia_free_irqs(skt, cd_irqs, ARRAY_SIZE(cd_irqs));
62 EXPORT_SYMBOL(h3600_common_pcmcia_shutdown);
64 int
65 h3600_common_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
66 struct pcmcia_state *state)
68 memset(state, 0, sizeof (*state));
70 switch (skt->nr) {
71 case 0:
72 state->detect = (ipaq_sleeve_read_egpio(IPAQ_EGPIO_PCMCIA_CD0_N)==0)?1:0;
73 state->ready = (ipaq_sleeve_read_egpio(IPAQ_EGPIO_PCMCIA_IRQ0))?1:0;
74 break;
75 case 1:
76 state->detect = (ipaq_sleeve_read_egpio(IPAQ_EGPIO_PCMCIA_CD1_N)==0)?1:0;
77 state->ready = (ipaq_sleeve_read_egpio(IPAQ_EGPIO_PCMCIA_IRQ1))?1:0;
78 break;
81 return 0;
83 EXPORT_SYMBOL(h3600_common_pcmcia_socket_state);
85 void
86 h3600_common_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
88 /* Enable CF bus: */
89 ipaq_sleeve_clear_egpio(IPAQ_EGPIO_OPT_RESET);
91 set_current_state(TASK_UNINTERRUPTIBLE);
92 schedule_timeout(10*HZ / 1000);
95 EXPORT_SYMBOL(h3600_common_pcmcia_socket_init);
97 void
98 h3600_common_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
100 #if 0
101 switch (skt->nr) {
102 case 0:
103 h3600_egpio_set_irq_type(IPAQ_EGPIO_PCMCIA_IRQ0, IRQT_NOEDGE);
104 h3600_egpio_set_irq_type(IPAQ_EGPIO_PCMCIA_CD0_N, IRQT_NOEDGE);
105 break;
106 case 1:
107 h3600_egpio_set_irq_type(IPAQ_EGPIO_PCMCIA_IRQ1, IRQT_NOEDGE);
108 h3600_egpio_set_irq_type(IPAQ_EGPIO_PCMCIA_CD1_N, IRQT_NOEDGE);
109 break;
111 #endif
113 EXPORT_SYMBOL(h3600_common_pcmcia_socket_suspend);
115 /****************************************************/
116 /* Swapping functions for PCMCIA operations */
117 /****************************************************/
119 void
120 h3600_pcmcia_suspend_sockets (void)
124 void
125 h3600_pcmcia_resume_sockets (void)
129 EXPORT_SYMBOL(h3600_pcmcia_suspend_sockets);
130 EXPORT_SYMBOL(h3600_pcmcia_resume_sockets);