1 /*
2 * drivers/pcmcia/sa1100_graphicsmaster.c
3 *
4 * PCMCIA implementation routines for GraphicsMaster
5 *
6 * 9/18/01 Woojung
7 * Fixed wrong PCMCIA voltage setting
8 * 7/5/01 Woojung Huh <whuh@applieddata.net>
9 *
10 */
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13
14 #include <asm/hardware.h>
15
16 #include "sa1100_generic.h"
17 #include "sa1111_generic.h"
18
graphicsmaster_pcmcia_init(struct pcmcia_init * init)19 static int graphicsmaster_pcmcia_init(struct pcmcia_init *init)
20 {
21 int return_val=0;
22
23 /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
24 PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
25
26 /* Disable Power 3.3V/5V for PCMCIA/CF */
27 PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
28
29 /* why? */
30 MECR = 0x09430943;
31
32 return sa1111_pcmcia_init(init);
33 }
34
35 static int
graphicsmaster_pcmcia_configure_socket(const struct pcmcia_configure * conf)36 graphicsmaster_pcmcia_configure_socket(const struct pcmcia_configure *conf)
37 {
38 unsigned int pa_dwr_mask, pa_dwr_set;
39 int ret;
40
41 switch (conf->sock) {
42 case 0:
43 pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
44
45 switch (conf->vcc) {
46 default:
47 case 0: pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1; break;
48 case 33: pa_dwr_set = GPIO_GPIO1; break;
49 case 50: pa_dwr_set = GPIO_GPIO0; break;
50 }
51 break;
52
53 case 1:
54 pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
55
56 switch (conf->vcc) {
57 default:
58 case 0: pa_dwr_set = GPIO_GPIO2 | GPIO_GPIO3; break;
59 case 33: pa_dwr_set = GPIO_GPIO3; break;
60 case 50: pa_dwr_set = GPIO_GPIO2; break;
61 }
62 }
63
64 if (conf->vpp != conf->vcc && conf->vpp != 0) {
65 printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", __FUNCTION__,
66 conf->vpp);
67 return -1;
68 }
69
70 ret = sa1111_pcmcia_configure_socket(conf);
71 if (ret == 0) {
72 unsigned long flags;
73
74 local_irq_save(flags);
75 PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
76 local_irq_restore(flags);
77 }
78
79 return ret;
80 }
81
82 struct pcmcia_low_level graphicsmaster_pcmcia_ops = {
83 init: graphicsmaster_pcmcia_init,
84 shutdown: sa1111_pcmcia_shutdown,
85 socket_state: sa1111_pcmcia_socket_state,
86 get_irq_info: sa1111_pcmcia_get_irq_info,
87 configure_socket: graphicsmaster_pcmcia_configure_socket,
88
89 socket_init: sa1111_pcmcia_socket_init,
90 socket_suspend: sa1111_pcmcia_socket_suspend,
91 };
92
93