i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / pcmcia / pxa2xx_palmtx.c
blob80645a688ee3cf7b2fc3ddc1e55ddda02058e842
1 /*
2 * linux/drivers/pcmcia/pxa2xx_palmtx.c
4 * Driver for Palm T|X PCMCIA
6 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/gpio.h>
18 #include <asm/mach-types.h>
19 #include <mach/palmtx.h>
20 #include "soc_common.h"
22 static struct gpio palmtx_pcmcia_gpios[] = {
23 { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" },
24 { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" },
25 { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
26 { GPIO_NR_PALMTX_PCMCIA_READY, GPIOF_IN, "PCMCIA Ready" },
29 static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
31 int ret;
33 ret = gpio_request_array(palmtx_pcmcia_gpios,
34 ARRAY_SIZE(palmtx_pcmcia_gpios));
36 skt->socket.pci_irq = gpio_to_irq(GPIO_NR_PALMTX_PCMCIA_READY);
38 return ret;
41 static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
43 gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
46 static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
47 struct pcmcia_state *state)
49 state->detect = 1; /* always inserted */
50 state->ready = !!gpio_get_value(GPIO_NR_PALMTX_PCMCIA_READY);
51 state->bvd1 = 1;
52 state->bvd2 = 1;
53 state->wrprot = 0;
54 state->vs_3v = 1;
55 state->vs_Xv = 0;
58 static int
59 palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
60 const socket_state_t *state)
62 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
63 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
64 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
65 !!(state->flags & SS_RESET));
67 return 0;
70 static struct pcmcia_low_level palmtx_pcmcia_ops = {
71 .owner = THIS_MODULE,
73 .first = 0,
74 .nr = 1,
76 .hw_init = palmtx_pcmcia_hw_init,
77 .hw_shutdown = palmtx_pcmcia_hw_shutdown,
79 .socket_state = palmtx_pcmcia_socket_state,
80 .configure_socket = palmtx_pcmcia_configure_socket,
83 static struct platform_device *palmtx_pcmcia_device;
85 static int __init palmtx_pcmcia_init(void)
87 int ret;
89 if (!machine_is_palmtx())
90 return -ENODEV;
92 palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
93 if (!palmtx_pcmcia_device)
94 return -ENOMEM;
96 ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
97 sizeof(palmtx_pcmcia_ops));
99 if (!ret)
100 ret = platform_device_add(palmtx_pcmcia_device);
102 if (ret)
103 platform_device_put(palmtx_pcmcia_device);
105 return ret;
108 static void __exit palmtx_pcmcia_exit(void)
110 platform_device_unregister(palmtx_pcmcia_device);
113 module_init(palmtx_pcmcia_init);
114 module_exit(palmtx_pcmcia_exit);
116 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
117 MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
118 MODULE_ALIAS("platform:pxa2xx-pcmcia");
119 MODULE_LICENSE("GPL");