Use dentry_path() to create full path to inode object
[pohmelfs.git] / drivers / pcmcia / pxa2xx_stargate2.c
blob6c2366b74a35957af5c471ce10f2f2e10b9ccb12
1 /*
2 * linux/drivers/pcmcia/pxa2xx_stargate2.c
4 * Stargate 2 PCMCIA specific routines.
6 * Created: December 6, 2005
7 * Author: Ed C. Epp
8 * Copyright: Intel Corp 2005
9 * Jonathan Cameron <jic23@cam.ac.uk> 2009
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/kernel.h>
19 #include <linux/interrupt.h>
20 #include <linux/delay.h>
21 #include <linux/platform_device.h>
22 #include <linux/gpio.h>
24 #include <pcmcia/ss.h>
26 #include <asm/irq.h>
27 #include <asm/mach-types.h>
29 #include "soc_common.h"
31 #define SG2_S0_POWER_CTL 108
32 #define SG2_S0_GPIO_RESET 82
33 #define SG2_S0_GPIO_DETECT 53
34 #define SG2_S0_GPIO_READY 81
36 static struct pcmcia_irqs irqs[] = {
37 {.sock = 0, .str = "PCMCIA0 CD" },
40 static struct gpio sg2_pcmcia_gpios[] = {
41 { SG2_S0_GPIO_RESET, GPIOF_OUT_INIT_HIGH, "PCMCIA Reset" },
42 { SG2_S0_POWER_CTL, GPIOF_OUT_INIT_HIGH, "PCMCIA Power Ctrl" },
45 static int sg2_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
47 skt->socket.pci_irq = gpio_to_irq(SG2_S0_GPIO_READY);
48 irqs[0].irq = gpio_to_irq(SG2_S0_GPIO_DETECT);
50 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
53 static void sg2_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
55 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
58 static void sg2_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
59 struct pcmcia_state *state)
61 state->detect = !gpio_get_value(SG2_S0_GPIO_DETECT);
62 state->ready = !!gpio_get_value(SG2_S0_GPIO_READY);
63 state->bvd1 = 0; /* not available - battery detect on card */
64 state->bvd2 = 0; /* not available */
65 state->vs_3v = 1; /* not available - voltage detect for card */
66 state->vs_Xv = 0; /* not available */
67 state->wrprot = 0; /* not available - write protect */
70 static int sg2_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
71 const socket_state_t *state)
73 /* Enable card power */
74 switch (state->Vcc) {
75 case 0:
76 /* sets power ctl register high */
77 gpio_set_value(SG2_S0_POWER_CTL, 1);
78 break;
79 case 33:
80 case 50:
81 /* sets power control register low (clear) */
82 gpio_set_value(SG2_S0_POWER_CTL, 0);
83 msleep(100);
84 break;
85 default:
86 pr_err("%s(): bad Vcc %u\n",
87 __func__, state->Vcc);
88 return -1;
91 /* reset */
92 gpio_set_value(SG2_S0_GPIO_RESET, !!(state->flags & SS_RESET));
94 return 0;
97 static void sg2_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
99 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
102 static void sg2_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
104 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
107 static struct pcmcia_low_level sg2_pcmcia_ops __initdata = {
108 .owner = THIS_MODULE,
109 .hw_init = sg2_pcmcia_hw_init,
110 .hw_shutdown = sg2_pcmcia_hw_shutdown,
111 .socket_state = sg2_pcmcia_socket_state,
112 .configure_socket = sg2_pcmcia_configure_socket,
113 .socket_init = sg2_pcmcia_socket_init,
114 .socket_suspend = sg2_pcmcia_socket_suspend,
115 .nr = 1,
118 static struct platform_device *sg2_pcmcia_device;
120 static int __init sg2_pcmcia_init(void)
122 int ret;
124 if (!machine_is_stargate2())
125 return -ENODEV;
127 sg2_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
128 if (!sg2_pcmcia_device)
129 return -ENOMEM;
131 ret = gpio_request_array(sg2_pcmcia_gpios, ARRAY_SIZE(sg2_pcmcia_gpios));
132 if (ret)
133 goto error_put_platform_device;
135 ret = platform_device_add_data(sg2_pcmcia_device,
136 &sg2_pcmcia_ops,
137 sizeof(sg2_pcmcia_ops));
138 if (ret)
139 goto error_free_gpios;
141 ret = platform_device_add(sg2_pcmcia_device);
142 if (ret)
143 goto error_free_gpios;
145 return 0;
146 error_free_gpios:
147 gpio_free_array(sg2_pcmcia_gpios, ARRAY_SIZE(sg2_pcmcia_gpios));
148 error_put_platform_device:
149 platform_device_put(sg2_pcmcia_device);
151 return ret;
154 static void __exit sg2_pcmcia_exit(void)
156 platform_device_unregister(sg2_pcmcia_device);
157 gpio_free_array(sg2_pcmcia_gpios, ARRAY_SIZE(sg2_pcmcia_gpios));
160 fs_initcall(sg2_pcmcia_init);
161 module_exit(sg2_pcmcia_exit);
163 MODULE_LICENSE("GPL");
164 MODULE_ALIAS("platform:pxa2xx-pcmcia");