| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * linux/drivers/pcmcia/pxa2xx_palmtx.c | 
|  | 3 | * | 
|  | 4 | * Driver for Palm T|X PCMCIA | 
|  | 5 | * | 
| Marek Vasut | 9ed3fbf | 2011-01-15 19:22:19 +0100 | [diff] [blame] | 6 | * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com> | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 7 | * | 
|  | 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 Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 17 |  | 
|  | 18 | #include <asm/mach-types.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 19 | #include <mach/palmtx.h> | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 20 | #include "soc_common.h" | 
|  | 21 |  | 
| Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 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" }, | 
|  | 27 | }; | 
|  | 28 |  | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 29 | static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | 
|  | 30 | { | 
| Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 31 | int ret; | 
|  | 32 |  | 
| Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 33 | ret = gpio_request_array(palmtx_pcmcia_gpios, | 
|  | 34 | ARRAY_SIZE(palmtx_pcmcia_gpios)); | 
| Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 35 |  | 
| Russell King - ARM Linux | 66024db | 2009-03-29 22:45:26 +0100 | [diff] [blame] | 36 | skt->socket.pci_irq = gpio_to_irq(GPIO_NR_PALMTX_PCMCIA_READY); | 
| Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 37 |  | 
| Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 38 | return ret; | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 39 | } | 
|  | 40 |  | 
|  | 41 | static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | 
|  | 42 | { | 
| Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 43 | gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios)); | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 44 | } | 
|  | 45 |  | 
|  | 46 | static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | 
|  | 47 | struct pcmcia_state *state) | 
|  | 48 | { | 
|  | 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; | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | static int | 
|  | 59 | palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | 
|  | 60 | const socket_state_t *state) | 
|  | 61 | { | 
|  | 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)); | 
|  | 66 |  | 
|  | 67 | return 0; | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | static void palmtx_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | 
|  | 71 | { | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | static void palmtx_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | 
|  | 75 | { | 
|  | 76 | } | 
|  | 77 |  | 
|  | 78 | static struct pcmcia_low_level palmtx_pcmcia_ops = { | 
|  | 79 | .owner			= THIS_MODULE, | 
|  | 80 |  | 
|  | 81 | .first			= 0, | 
|  | 82 | .nr			= 1, | 
|  | 83 |  | 
|  | 84 | .hw_init		= palmtx_pcmcia_hw_init, | 
|  | 85 | .hw_shutdown		= palmtx_pcmcia_hw_shutdown, | 
|  | 86 |  | 
|  | 87 | .socket_state		= palmtx_pcmcia_socket_state, | 
|  | 88 | .configure_socket	= palmtx_pcmcia_configure_socket, | 
|  | 89 |  | 
|  | 90 | .socket_init		= palmtx_pcmcia_socket_init, | 
|  | 91 | .socket_suspend		= palmtx_pcmcia_socket_suspend, | 
|  | 92 | }; | 
|  | 93 |  | 
|  | 94 | static struct platform_device *palmtx_pcmcia_device; | 
|  | 95 |  | 
|  | 96 | static int __init palmtx_pcmcia_init(void) | 
|  | 97 | { | 
|  | 98 | int ret; | 
|  | 99 |  | 
|  | 100 | if (!machine_is_palmtx()) | 
|  | 101 | return -ENODEV; | 
|  | 102 |  | 
|  | 103 | palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | 
|  | 104 | if (!palmtx_pcmcia_device) | 
|  | 105 | return -ENOMEM; | 
|  | 106 |  | 
|  | 107 | ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops, | 
|  | 108 | sizeof(palmtx_pcmcia_ops)); | 
|  | 109 |  | 
|  | 110 | if (!ret) | 
|  | 111 | ret = platform_device_add(palmtx_pcmcia_device); | 
|  | 112 |  | 
|  | 113 | if (ret) | 
|  | 114 | platform_device_put(palmtx_pcmcia_device); | 
|  | 115 |  | 
|  | 116 | return ret; | 
|  | 117 | } | 
|  | 118 |  | 
|  | 119 | static void __exit palmtx_pcmcia_exit(void) | 
|  | 120 | { | 
|  | 121 | platform_device_unregister(palmtx_pcmcia_device); | 
|  | 122 | } | 
|  | 123 |  | 
| Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 124 | module_init(palmtx_pcmcia_init); | 
| Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 125 | module_exit(palmtx_pcmcia_exit); | 
|  | 126 |  | 
|  | 127 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | 
|  | 128 | MODULE_DESCRIPTION("PCMCIA support for Palm T|X"); | 
|  | 129 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | 
|  | 130 | MODULE_LICENSE("GPL"); |