blob: c2ecf1185e9e02f7df4aebe937d1c4aadc11fd3b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/pcmcia/sa1100_simpad.c
3 *
4 * PCMCIA implementation routines for simpad
5 *
6 */
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>
12
13#include <asm/hardware.h>
14#include <asm/mach-types.h>
15#include <asm/irq.h>
16#include <asm/arch/simpad.h>
17#include "sa1100_generic.h"
18
19extern long get_cs3_shadow(void);
20extern void set_cs3_bit(int value);
21extern void clear_cs3_bit(int value);
22
23static struct pcmcia_irqs irqs[] = {
24 { 1, IRQ_GPIO_CF_CD, "CF_CD" },
25};
26
27static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
28{
29
30 clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
31
32 skt->irq = IRQ_GPIO_CF_IRQ;
33
34 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
35}
36
37static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
38{
39 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
40
41 /* Disable CF bus: */
42 //set_cs3_bit(PCMCIA_BUFF_DIS);
43 clear_cs3_bit(PCMCIA_RESET);
44}
45
46static void
47simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
48 struct pcmcia_state *state)
49{
50 unsigned long levels = GPLR;
51 long cs3reg = get_cs3_shadow();
52
53 state->detect=((levels & GPIO_CF_CD)==0)?1:0;
54 state->ready=(levels & GPIO_CF_IRQ)?1:0;
55 state->bvd1=1; /* Not available on Simpad. */
56 state->bvd2=1; /* Not available on Simpad. */
57 state->wrprot=0; /* Not available on Simpad. */
58
59 if((cs3reg & 0x0c) == 0x0c) {
60 state->vs_3v=0;
61 state->vs_Xv=0;
62 } else {
63 state->vs_3v=1;
64 state->vs_Xv=0;
65 }
66}
67
68static int
69simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
70 const socket_state_t *state)
71{
72 unsigned long flags;
73
74 local_irq_save(flags);
75
76 /* Murphy: see table of MIC2562a-1 */
77 switch (state->Vcc) {
78 case 0:
79 clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
80 break;
81
82 case 33:
83 clear_cs3_bit(VCC_3V_EN|EN1);
84 set_cs3_bit(VCC_5V_EN|EN0);
85 break;
86
87 case 50:
88 clear_cs3_bit(VCC_5V_EN|EN1);
89 set_cs3_bit(VCC_3V_EN|EN0);
90 break;
91
92 default:
93 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
94 __FUNCTION__, state->Vcc);
95 clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
96 local_irq_restore(flags);
97 return -1;
98 }
99
100
101 local_irq_restore(flags);
102
103 return 0;
104}
105
106static void simpad_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
107{
108 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
109}
110
111static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
112{
113 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
114 set_cs3_bit(PCMCIA_RESET);
115}
116
117static struct pcmcia_low_level simpad_pcmcia_ops = {
118 .owner = THIS_MODULE,
119 .hw_init = simpad_pcmcia_hw_init,
120 .hw_shutdown = simpad_pcmcia_hw_shutdown,
121 .socket_state = simpad_pcmcia_socket_state,
122 .configure_socket = simpad_pcmcia_configure_socket,
123 .socket_init = simpad_pcmcia_socket_init,
124 .socket_suspend = simpad_pcmcia_socket_suspend,
125};
126
127int __init pcmcia_simpad_init(struct device *dev)
128{
129 int ret = -ENODEV;
130
131 if (machine_is_simpad())
132 ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
133
134 return ret;
135}