2 * drivers/pcmcia/sa1100_freebird.c
4 * Created by Eric Peng <ericpeng@coventive.com>
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
13 #include <asm/hardware.h>
14 #include <asm/mach-types.h>
16 #include "sa1100_generic.h"
18 static struct pcmcia_irqs irqs
[] = {
19 { 0, IRQ_GPIO_FREEBIRD_CF_CD
, "CF_CD" },
20 { 0, IRQ_GPIO_FREEBIRD_CF_BVD
, "CF_BVD1" },
23 static int freebird_pcmcia_init(struct soc_pcmcia_socket
*skt
)
25 /* Enable Linkup CF card */
36 skt
->irq
= IRQ_GPIO_FREEBIRD_CF_IRQ
;
38 return soc_pcmcia_request_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
41 static void freebird_pcmcia_shutdown(struct soc_pcmcia_socket
*skt
)
43 soc_pcmcia_free_irqs(skt
, irqs
, ARRAY_SIZE(irqs
);
46 LINKUP_PRC
= 0x40; /* SSP=1 SOE=0 */
51 freebird_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
, struct pcmcia_state
*state
)
53 unsigned long levels
= LINKUP_PRS
;
54 // printk("LINKUP_PRS=%x\n",levels);
56 state
->detect
= ((levels
& (LINKUP_CD1
| LINKUP_CD2
))==0)?1:0;
57 state
->ready
= (levels
& LINKUP_RDY
)?1:0;
58 state
->bvd1
= (levels
& LINKUP_BVD1
)?1:0;
59 state
->bvd2
= (levels
& LINKUP_BVD2
)?1:0;
60 state
->wrprot
= 0; /* Not available on Assabet. */
61 state
->vs_3v
= 1; /* Can only apply 3.3V on Assabet. */
66 freebird_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
67 socket_state_t
*state
)
69 unsigned long value
, flags
;
71 local_irq_save(flags
);
73 value
= 0xc0; /* SSP=1 SOE=1 CFE=1 */
80 printk(KERN_WARNING
"%s(): CS asked for 5V, applying 3.3V...\n",
83 case 33: /* Can only apply 3.3V to the CF slot. */
88 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
89 __FUNCTION__
, state
->Vcc
);
90 local_irq_restore(flags
);
94 if (state
->flags
& SS_RESET
)
95 value
|= LINKUP_RESET
;
97 /* Silently ignore Vpp, output enable, speaker enable. */
100 // printk("LINKUP_PRC=%x\n",value);
101 local_irq_restore(flags
);
106 static void freebird_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
108 soc_pcmcia_disable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
111 static void freebird_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
113 soc_pcmcia_enable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
116 static struct pcmcia_low_level freebird_pcmcia_ops
= {
117 .owner
= THIS_MODULE
,
118 .hw_init
= freebird_pcmcia_hw_init
,
119 .hw_shutdown
= freebird_pcmcia_hw_shutdown
,
120 .socket_state
= freebird_pcmcia_socket_state
,
121 .configure_socket
= freebird_pcmcia_configure_socket
,
123 .socket_init
= freebird_pcmcia_socket_init
,
124 .socket_suspend
= freebird_pcmcia_socket_suspend
,
127 int __init
pcmcia_freebird_init(struct device
*dev
)
131 if (machine_is_freebird())
132 ret
= sa11xx_drv_pcmcia_probe(dev
, &freebird_pcmcia_ops
, 0, 1);