OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / drivers / pcmcia / sa1100_assabet.c
blobf1e882272ab0e7f2c2c83dce6e271ce04f12c911
1 /*
2 * drivers/pcmcia/sa1100_assabet.c
4 * PCMCIA implementation routines for Assabet
6 */
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/errno.h>
10 #include <linux/interrupt.h>
11 #include <linux/device.h>
12 #include <linux/init.h>
14 #include <mach/hardware.h>
15 #include <asm/mach-types.h>
16 #include <asm/irq.h>
17 #include <asm/signal.h>
18 #include <mach/assabet.h>
20 #include "sa1100_generic.h"
22 static struct pcmcia_irqs irqs[] = {
23 { 1, ASSABET_IRQ_GPIO_CF_CD, "CF CD" },
24 { 1, ASSABET_IRQ_GPIO_CF_BVD2, "CF BVD2" },
25 { 1, ASSABET_IRQ_GPIO_CF_BVD1, "CF BVD1" },
28 static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
30 skt->socket.pci_irq = ASSABET_IRQ_GPIO_CF_IRQ;
32 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
36 * Release all resources.
38 static void assabet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
40 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
43 static void
44 assabet_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
46 unsigned long levels = GPLR;
48 state->detect = (levels & ASSABET_GPIO_CF_CD) ? 0 : 1;
49 state->ready = (levels & ASSABET_GPIO_CF_IRQ) ? 1 : 0;
50 state->bvd1 = (levels & ASSABET_GPIO_CF_BVD1) ? 1 : 0;
51 state->bvd2 = (levels & ASSABET_GPIO_CF_BVD2) ? 1 : 0;
52 state->wrprot = 0; /* Not available on Assabet. */
53 state->vs_3v = 1; /* Can only apply 3.3V on Assabet. */
54 state->vs_Xv = 0;
57 static int
58 assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
60 unsigned int mask;
62 switch (state->Vcc) {
63 case 0:
64 mask = 0;
65 break;
67 case 50:
68 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
69 __func__);
71 case 33: /* Can only apply 3.3V to the CF slot. */
72 mask = ASSABET_BCR_CF_PWR;
73 break;
75 default:
76 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__,
77 state->Vcc);
78 return -1;
81 /* Silently ignore Vpp, output enable, speaker enable. */
83 if (state->flags & SS_RESET)
84 mask |= ASSABET_BCR_CF_RST;
86 ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR, mask);
88 return 0;
92 * Enable card status IRQs on (re-)initialisation. This can
93 * be called at initialisation, power management event, or
94 * pcmcia event.
96 static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
99 * Enable CF bus
101 ASSABET_BCR_clear(ASSABET_BCR_CF_BUS_OFF);
103 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
107 * Disable card status IRQs on suspend.
109 static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
111 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
114 * Tristate the CF bus signals. Also assert CF
115 * reset as per user guide page 4-11.
117 ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST);
120 static struct pcmcia_low_level assabet_pcmcia_ops = {
121 .owner = THIS_MODULE,
123 .hw_init = assabet_pcmcia_hw_init,
124 .hw_shutdown = assabet_pcmcia_hw_shutdown,
126 .socket_state = assabet_pcmcia_socket_state,
127 .configure_socket = assabet_pcmcia_configure_socket,
129 .socket_init = assabet_pcmcia_socket_init,
130 .socket_suspend = assabet_pcmcia_socket_suspend,
133 int __devinit pcmcia_assabet_init(struct device *dev)
135 int ret = -ENODEV;
137 if (machine_is_assabet() && !machine_has_neponset())
138 ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1);
140 return ret;