blob: 7ff1b43540b809b2a970638bdbf45dff292d0af3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/pcmcia/sa1100_shannon.c
3 *
4 * PCMCIA implementation routines for Shannon
5 *
6 */
7#include <linux/module.h>
8#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/device.h>
10#include <linux/init.h>
11
Russell Kinga09e64f2008-08-05 16:14:15 +010012#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010014#include <mach/shannon.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/irq.h>
16#include "sa1100_generic.h"
17
18static struct pcmcia_irqs irqs[] = {
19 { 0, SHANNON_IRQ_GPIO_EJECT_0, "PCMCIA_CD_0" },
20 { 1, SHANNON_IRQ_GPIO_EJECT_1, "PCMCIA_CD_1" },
21};
22
23static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
24{
25 /* All those are inputs */
26 GPDR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
27 SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
28 GAFR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
29 SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
30
Russell King - ARM Linux66024db2009-03-29 22:45:26 +010031 skt->socket.pci_irq = skt->nr ? SHANNON_IRQ_GPIO_RDY_1 : SHANNON_IRQ_GPIO_RDY_0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
34}
35
36static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
37{
38 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
39}
40
41static void
42shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
44{
45 unsigned long levels = GPLR;
46
47 switch (skt->nr) {
48 case 0:
49 state->detect = (levels & SHANNON_GPIO_EJECT_0) ? 0 : 1;
50 state->ready = (levels & SHANNON_GPIO_RDY_0) ? 1 : 0;
51 state->wrprot = 0; /* Not available on Shannon. */
52 state->bvd1 = 1;
53 state->bvd2 = 1;
54 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
55 state->vs_Xv = 0;
56 break;
57
58 case 1:
59 state->detect = (levels & SHANNON_GPIO_EJECT_1) ? 0 : 1;
60 state->ready = (levels & SHANNON_GPIO_RDY_1) ? 1 : 0;
61 state->wrprot = 0; /* Not available on Shannon. */
62 state->bvd1 = 1;
63 state->bvd2 = 1;
64 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
65 state->vs_Xv = 0;
66 break;
67 }
68}
69
70static int
71shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
72 const socket_state_t *state)
73{
74 switch (state->Vcc) {
75 case 0: /* power off */
Harvey Harrison2e11cb42008-05-01 04:34:54 -070076 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 break;
78 case 50:
Harvey Harrison2e11cb42008-05-01 04:34:54 -070079 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 case 33:
81 break;
82 default:
83 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070084 __func__, state->Vcc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 return -1;
86 }
87
Harvey Harrison2e11cb42008-05-01 04:34:54 -070088 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 /* Silently ignore Vpp, output enable, speaker enable. */
91
92 return 0;
93}
94
95static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
96{
97 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
98}
99
100static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
101{
102 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
103}
104
105static struct pcmcia_low_level shannon_pcmcia_ops = {
106 .owner = THIS_MODULE,
107 .hw_init = shannon_pcmcia_hw_init,
108 .hw_shutdown = shannon_pcmcia_hw_shutdown,
109 .socket_state = shannon_pcmcia_socket_state,
110 .configure_socket = shannon_pcmcia_configure_socket,
111
112 .socket_init = shannon_pcmcia_socket_init,
113 .socket_suspend = shannon_pcmcia_socket_suspend,
114};
115
Uwe Kleine-König5b85e042010-11-04 10:46:14 +0100116int __devinit pcmcia_shannon_init(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117{
118 int ret = -ENODEV;
119
120 if (machine_is_shannon())
121 ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
122
123 return ret;
124}