blob: ee024ff0980a6327a97b77ce427f4e555de4f54d [file] [log] [blame]
Marek Vašut35978402008-07-07 17:28:59 +01001/*
2 * linux/drivers/pcmcia/pxa2xx_palmtx.c
3 *
4 * Driver for Palm T|X PCMCIA
5 *
Marek Vasut9ed3fbf2011-01-15 19:22:19 +01006 * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
Marek Vašut35978402008-07-07 17:28:59 +01007 *
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.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/platform_device.h>
Marek Vasut235a1752011-01-15 18:59:55 +010016#include <linux/gpio.h>
Marek Vašut35978402008-07-07 17:28:59 +010017
18#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010019#include <mach/palmtx.h>
Marek Vašut35978402008-07-07 17:28:59 +010020#include "soc_common.h"
21
Marek Vasut235a1752011-01-15 18:59:55 +010022static 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" },
Marek Vasut235a1752011-01-15 18:59:55 +010026};
27
Marek Vašut35978402008-07-07 17:28:59 +010028static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
29{
Marek Vašut574047f2008-08-16 15:34:11 +010030 int ret;
31
Marek Vasut235a1752011-01-15 18:59:55 +010032 ret = gpio_request_array(palmtx_pcmcia_gpios,
33 ARRAY_SIZE(palmtx_pcmcia_gpios));
Marek Vašut574047f2008-08-16 15:34:11 +010034
Russell Kinga9bb5a42012-01-13 22:56:32 +000035 skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY;
36 skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
Marek Vašut574047f2008-08-16 15:34:11 +010037
Marek Vašut574047f2008-08-16 15:34:11 +010038 return ret;
Marek Vašut35978402008-07-07 17:28:59 +010039}
40
41static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
42{
Marek Vasut235a1752011-01-15 18:59:55 +010043 gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
Marek Vašut35978402008-07-07 17:28:59 +010044}
45
46static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
47 struct pcmcia_state *state)
48{
49 state->detect = 1; /* always inserted */
Marek Vašut35978402008-07-07 17:28:59 +010050 state->wrprot = 0;
51 state->vs_3v = 1;
52 state->vs_Xv = 0;
53}
54
55static int
56palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
57 const socket_state_t *state)
58{
59 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
60 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
61 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
62 !!(state->flags & SS_RESET));
63
64 return 0;
65}
66
Marek Vašut35978402008-07-07 17:28:59 +010067static struct pcmcia_low_level palmtx_pcmcia_ops = {
68 .owner = THIS_MODULE,
69
70 .first = 0,
71 .nr = 1,
72
73 .hw_init = palmtx_pcmcia_hw_init,
74 .hw_shutdown = palmtx_pcmcia_hw_shutdown,
75
76 .socket_state = palmtx_pcmcia_socket_state,
77 .configure_socket = palmtx_pcmcia_configure_socket,
Marek Vašut35978402008-07-07 17:28:59 +010078};
79
80static struct platform_device *palmtx_pcmcia_device;
81
82static int __init palmtx_pcmcia_init(void)
83{
84 int ret;
85
86 if (!machine_is_palmtx())
87 return -ENODEV;
88
89 palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
90 if (!palmtx_pcmcia_device)
91 return -ENOMEM;
92
93 ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
94 sizeof(palmtx_pcmcia_ops));
95
96 if (!ret)
97 ret = platform_device_add(palmtx_pcmcia_device);
98
99 if (ret)
100 platform_device_put(palmtx_pcmcia_device);
101
102 return ret;
103}
104
105static void __exit palmtx_pcmcia_exit(void)
106{
107 platform_device_unregister(palmtx_pcmcia_device);
108}
109
Marek Vašut574047f2008-08-16 15:34:11 +0100110module_init(palmtx_pcmcia_init);
Marek Vašut35978402008-07-07 17:28:59 +0100111module_exit(palmtx_pcmcia_exit);
112
113MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
114MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
115MODULE_ALIAS("platform:pxa2xx-pcmcia");
116MODULE_LICENSE("GPL");