blob: eb89928f2338a52077f47b1c34158aaf20ed16c5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/pcmcia/sa1100_cerf.c
3 *
4 * PCMCIA implementation routines for CerfBoard
5 * Based off the Assabet.
6 *
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/module.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <linux/device.h>
12#include <linux/init.h>
13#include <linux/delay.h>
14
15#include <asm/hardware.h>
16#include <asm/mach-types.h>
17#include <asm/irq.h>
18#include <asm/arch/cerf.h>
19#include "sa1100_generic.h"
20
21#define CERF_SOCKET 1
22
23static struct pcmcia_irqs irqs[] = {
24 { CERF_SOCKET, CERF_IRQ_GPIO_CF_CD, "CF_CD" },
25 { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD2, "CF_BVD2" },
26 { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD1, "CF_BVD1" }
27};
28
29static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
30{
31 skt->irq = CERF_IRQ_GPIO_CF_IRQ;
32
33 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
34}
35
36static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
37{
38 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
39}
40
41static void
42cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
43{
44 unsigned long levels = GPLR;
45
46 state->detect = (levels & CERF_GPIO_CF_CD) ?0:1;
47 state->ready = (levels & CERF_GPIO_CF_IRQ) ?1:0;
48 state->bvd1 = (levels & CERF_GPIO_CF_BVD1)?1:0;
49 state->bvd2 = (levels & CERF_GPIO_CF_BVD2)?1:0;
50 state->wrprot = 0;
51 state->vs_3v = 1;
52 state->vs_Xv = 0;
53}
54
55static int
56cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
57 const socket_state_t *state)
58{
59 switch (state->Vcc) {
60 case 0:
61 case 50:
62 case 33:
63 break;
64
65 default:
66 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
67 __FUNCTION__, state->Vcc);
68 return -1;
69 }
70
71 if (state->flags & SS_RESET) {
72 GPSR = CERF_GPIO_CF_RESET;
73 } else {
74 GPCR = CERF_GPIO_CF_RESET;
75 }
76
77 return 0;
78}
79
80static void cerf_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
81{
82 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
83}
84
85static void cerf_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
86{
87 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
88}
89
90static struct pcmcia_low_level cerf_pcmcia_ops = {
91 .owner = THIS_MODULE,
92 .hw_init = cerf_pcmcia_hw_init,
93 .hw_shutdown = cerf_pcmcia_hw_shutdown,
94 .socket_state = cerf_pcmcia_socket_state,
95 .configure_socket = cerf_pcmcia_configure_socket,
96
97 .socket_init = cerf_pcmcia_socket_init,
98 .socket_suspend = cerf_pcmcia_socket_suspend,
99};
100
101int __init pcmcia_cerf_init(struct device *dev)
102{
103 int ret = -ENODEV;
104
105 if (machine_is_cerf())
106 ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
107
108 return ret;
109}