2 * linux/drivers/pcmcia/pxa2xx_palmld.c
4 * Driver for Palm LifeDrive PCMCIA
6 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
7 * Copyright (C) 2007-2008 Marek Vasut <marek.vasut@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
17 #include <linux/gpio.h>
19 #include <asm/mach-types.h>
20 #include <mach/palmld.h>
21 #include "soc_common.h"
23 static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
27 ret
= gpio_request(GPIO_NR_PALMLD_PCMCIA_POWER
, "PCMCIA PWR");
30 ret
= gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_POWER
, 0);
34 ret
= gpio_request(GPIO_NR_PALMLD_PCMCIA_RESET
, "PCMCIA RST");
37 ret
= gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_RESET
, 1);
41 ret
= gpio_request(GPIO_NR_PALMLD_PCMCIA_READY
, "PCMCIA RDY");
44 ret
= gpio_direction_input(GPIO_NR_PALMLD_PCMCIA_READY
);
48 skt
->irq
= IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY
);
52 gpio_free(GPIO_NR_PALMLD_PCMCIA_READY
);
54 gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET
);
56 gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER
);
61 static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
63 gpio_free(GPIO_NR_PALMLD_PCMCIA_READY
);
64 gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET
);
65 gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER
);
68 static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
69 struct pcmcia_state
*state
)
71 state
->detect
= 1; /* always inserted */
72 state
->ready
= !!gpio_get_value(GPIO_NR_PALMLD_PCMCIA_READY
);
80 static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
81 const socket_state_t
*state
)
83 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER
, 1);
84 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET
,
85 !!(state
->flags
& SS_RESET
));
90 static void palmld_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
94 static void palmld_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
98 static struct pcmcia_low_level palmld_pcmcia_ops
= {
104 .hw_init
= palmld_pcmcia_hw_init
,
105 .hw_shutdown
= palmld_pcmcia_hw_shutdown
,
107 .socket_state
= palmld_pcmcia_socket_state
,
108 .configure_socket
= palmld_pcmcia_configure_socket
,
110 .socket_init
= palmld_pcmcia_socket_init
,
111 .socket_suspend
= palmld_pcmcia_socket_suspend
,
114 static struct platform_device
*palmld_pcmcia_device
;
116 static int __init
palmld_pcmcia_init(void)
120 if (!machine_is_palmld())
123 palmld_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
124 if (!palmld_pcmcia_device
)
127 ret
= platform_device_add_data(palmld_pcmcia_device
, &palmld_pcmcia_ops
,
128 sizeof(palmld_pcmcia_ops
));
131 ret
= platform_device_add(palmld_pcmcia_device
);
134 platform_device_put(palmld_pcmcia_device
);
139 static void __exit
palmld_pcmcia_exit(void)
141 platform_device_unregister(palmld_pcmcia_device
);
144 module_init(palmld_pcmcia_init
);
145 module_exit(palmld_pcmcia_exit
);
147 MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
148 " Marek Vasut <marek.vasut@gmail.com>");
149 MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
150 MODULE_ALIAS("platform:pxa2xx-pcmcia");
151 MODULE_LICENSE("GPL");