2
* linux/drivers/pcmcia/pxa2xx_palmtc.c
4
* Driver for Palm Tungsten|C PCMCIA
6
* Copyright (C) 2008 Alex Osborne <ato@meshy.org>
7
* Copyright (C) 2009-2011 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>
18
#include <linux/delay.h>
20
#include <asm/mach-types.h>
21
#include <mach/palmtc.h>
22
#include "soc_common.h"
24
static struct gpio palmtc_pcmcia_gpios[] = {
25
{ GPIO_NR_PALMTC_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" },
26
{ GPIO_NR_PALMTC_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" },
27
{ GPIO_NR_PALMTC_PCMCIA_POWER3, GPIOF_INIT_LOW, "PCMCIA Power 3" },
28
{ GPIO_NR_PALMTC_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
29
{ GPIO_NR_PALMTC_PCMCIA_READY, GPIOF_IN, "PCMCIA Ready" },
30
{ GPIO_NR_PALMTC_PCMCIA_PWRREADY, GPIOF_IN, "PCMCIA Power Ready" },
33
static int palmtc_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
37
ret = gpio_request_array(palmtc_pcmcia_gpios,
38
ARRAY_SIZE(palmtc_pcmcia_gpios));
40
skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMTC_PCMCIA_READY);
45
static void palmtc_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
47
gpio_free_array(palmtc_pcmcia_gpios, ARRAY_SIZE(palmtc_pcmcia_gpios));
50
static void palmtc_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
51
struct pcmcia_state *state)
53
state->detect = 1; /* always inserted */
54
state->ready = !!gpio_get_value(GPIO_NR_PALMTC_PCMCIA_READY);
62
static int palmtc_wifi_powerdown(void)
64
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_RESET, 1);
65
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER2, 0);
67
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER1, 0);
71
static int palmtc_wifi_powerup(void)
75
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER3, 1);
78
/* Power up the card, 1.8V first, after a while 3.3V */
79
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER1, 1);
81
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER2, 1);
83
/* Wait till the card is ready */
84
while (!gpio_get_value(GPIO_NR_PALMTC_PCMCIA_PWRREADY) &&
90
/* Power down the WiFi in case of error */
92
palmtc_wifi_powerdown();
97
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_RESET, 1);
99
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_RESET, 0);
102
gpio_set_value(GPIO_NR_PALMTC_PCMCIA_POWER3, 0);
107
static int palmtc_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
108
const socket_state_t *state)
113
ret = palmtc_wifi_powerdown();
114
else if (state->Vcc == 33)
115
ret = palmtc_wifi_powerup();
120
static struct pcmcia_low_level palmtc_pcmcia_ops = {
121
.owner = THIS_MODULE,
126
.hw_init = palmtc_pcmcia_hw_init,
127
.hw_shutdown = palmtc_pcmcia_hw_shutdown,
129
.socket_state = palmtc_pcmcia_socket_state,
130
.configure_socket = palmtc_pcmcia_configure_socket,
133
static struct platform_device *palmtc_pcmcia_device;
135
static int __init palmtc_pcmcia_init(void)
139
if (!machine_is_palmtc())
142
palmtc_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
143
if (!palmtc_pcmcia_device)
146
ret = platform_device_add_data(palmtc_pcmcia_device, &palmtc_pcmcia_ops,
147
sizeof(palmtc_pcmcia_ops));
150
ret = platform_device_add(palmtc_pcmcia_device);
153
platform_device_put(palmtc_pcmcia_device);
158
static void __exit palmtc_pcmcia_exit(void)
160
platform_device_unregister(palmtc_pcmcia_device);
163
module_init(palmtc_pcmcia_init);
164
module_exit(palmtc_pcmcia_exit);
166
MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
167
" Marek Vasut <marek.vasut@gmail.com>");
168
MODULE_DESCRIPTION("PCMCIA support for Palm Tungsten|C");
169
MODULE_ALIAS("platform:pxa2xx-pcmcia");
170
MODULE_LICENSE("GPL");