Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/pcmcia/pxa2xx_palmld.c |
| 3 | * |
| 4 | * Driver for Palm LifeDrive PCMCIA |
| 5 | * |
| 6 | * Copyright (C) 2006 Alex Osborne <ato@meshy.org> |
Marek Vasut | 9ed3fbf | 2011-01-15 19:22:19 +0100 | [diff] [blame] | 7 | * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com> |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 8 | * |
| 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. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/gpio.h> |
| 18 | |
| 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/palmld.h> |
| 21 | #include "soc_common.h" |
| 22 | |
Marek Vasut | 2070417 | 2011-01-15 18:49:07 +0100 | [diff] [blame] | 23 | static struct gpio palmld_pcmcia_gpios[] = { |
| 24 | { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" }, |
| 25 | { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" }, |
Marek Vasut | 2070417 | 2011-01-15 18:49:07 +0100 | [diff] [blame] | 26 | }; |
| 27 | |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 28 | static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 29 | { |
| 30 | int ret; |
| 31 | |
Marek Vasut | 2070417 | 2011-01-15 18:49:07 +0100 | [diff] [blame] | 32 | ret = gpio_request_array(palmld_pcmcia_gpios, |
| 33 | ARRAY_SIZE(palmld_pcmcia_gpios)); |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 34 | |
Russell King | a9bb5a4 | 2012-01-13 22:56:32 +0000 | [diff] [blame] | 35 | skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY; |
| 36 | skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready"; |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 37 | |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 38 | return ret; |
| 39 | } |
| 40 | |
| 41 | static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 42 | { |
Marek Vasut | 2070417 | 2011-01-15 18:49:07 +0100 | [diff] [blame] | 43 | gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios)); |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
| 47 | struct pcmcia_state *state) |
| 48 | { |
| 49 | state->detect = 1; /* always inserted */ |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 50 | state->vs_3v = 1; |
| 51 | state->vs_Xv = 0; |
| 52 | } |
| 53 | |
| 54 | static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 55 | const socket_state_t *state) |
| 56 | { |
| 57 | gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1); |
| 58 | gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET, |
| 59 | !!(state->flags & SS_RESET)); |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 64 | static struct pcmcia_low_level palmld_pcmcia_ops = { |
| 65 | .owner = THIS_MODULE, |
| 66 | |
Marek Vasut | d66ea8d | 2009-03-28 17:56:28 +0800 | [diff] [blame] | 67 | .first = 1, |
| 68 | .nr = 1, |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 69 | |
| 70 | .hw_init = palmld_pcmcia_hw_init, |
| 71 | .hw_shutdown = palmld_pcmcia_hw_shutdown, |
| 72 | |
| 73 | .socket_state = palmld_pcmcia_socket_state, |
| 74 | .configure_socket = palmld_pcmcia_configure_socket, |
Marek Vašut | 6d34167 | 2008-08-16 15:35:57 +0100 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static struct platform_device *palmld_pcmcia_device; |
| 78 | |
| 79 | static int __init palmld_pcmcia_init(void) |
| 80 | { |
| 81 | int ret; |
| 82 | |
| 83 | if (!machine_is_palmld()) |
| 84 | return -ENODEV; |
| 85 | |
| 86 | palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); |
| 87 | if (!palmld_pcmcia_device) |
| 88 | return -ENOMEM; |
| 89 | |
| 90 | ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops, |
| 91 | sizeof(palmld_pcmcia_ops)); |
| 92 | |
| 93 | if (!ret) |
| 94 | ret = platform_device_add(palmld_pcmcia_device); |
| 95 | |
| 96 | if (ret) |
| 97 | platform_device_put(palmld_pcmcia_device); |
| 98 | |
| 99 | return ret; |
| 100 | } |
| 101 | |
| 102 | static void __exit palmld_pcmcia_exit(void) |
| 103 | { |
| 104 | platform_device_unregister(palmld_pcmcia_device); |
| 105 | } |
| 106 | |
| 107 | module_init(palmld_pcmcia_init); |
| 108 | module_exit(palmld_pcmcia_exit); |
| 109 | |
| 110 | MODULE_AUTHOR("Alex Osborne <ato@meshy.org>," |
| 111 | " Marek Vasut <marek.vasut@gmail.com>"); |
| 112 | MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive"); |
| 113 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); |
| 114 | MODULE_LICENSE("GPL"); |