Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 2 | /* |
| 3 | * linux/drivers/pcmcia/pxa2xx_palmtx.c |
| 4 | * |
| 5 | * Driver for Palm T|X PCMCIA |
| 6 | * |
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 | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/platform_device.h> |
Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 12 | #include <linux/gpio.h> |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 13 | |
| 14 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 15 | #include <mach/palmtx.h> |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 16 | #include "soc_common.h" |
| 17 | |
Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 18 | static struct gpio palmtx_pcmcia_gpios[] = { |
| 19 | { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" }, |
| 20 | { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" }, |
| 21 | { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" }, |
Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 22 | }; |
| 23 | |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 24 | static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 25 | { |
Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 26 | int ret; |
| 27 | |
Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 28 | ret = gpio_request_array(palmtx_pcmcia_gpios, |
| 29 | ARRAY_SIZE(palmtx_pcmcia_gpios)); |
Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 30 | |
Russell King | a9bb5a4 | 2012-01-13 22:56:32 +0000 | [diff] [blame] | 31 | skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY; |
| 32 | skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready"; |
Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 33 | |
Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 34 | return ret; |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 38 | { |
Marek Vasut | 235a175 | 2011-01-15 18:59:55 +0100 | [diff] [blame] | 39 | gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios)); |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
| 43 | struct pcmcia_state *state) |
| 44 | { |
| 45 | state->detect = 1; /* always inserted */ |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 46 | state->vs_3v = 1; |
| 47 | state->vs_Xv = 0; |
| 48 | } |
| 49 | |
| 50 | static int |
| 51 | palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 52 | const socket_state_t *state) |
| 53 | { |
| 54 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1); |
| 55 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1); |
| 56 | gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET, |
| 57 | !!(state->flags & SS_RESET)); |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 62 | static struct pcmcia_low_level palmtx_pcmcia_ops = { |
| 63 | .owner = THIS_MODULE, |
| 64 | |
| 65 | .first = 0, |
| 66 | .nr = 1, |
| 67 | |
| 68 | .hw_init = palmtx_pcmcia_hw_init, |
| 69 | .hw_shutdown = palmtx_pcmcia_hw_shutdown, |
| 70 | |
| 71 | .socket_state = palmtx_pcmcia_socket_state, |
| 72 | .configure_socket = palmtx_pcmcia_configure_socket, |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static struct platform_device *palmtx_pcmcia_device; |
| 76 | |
| 77 | static int __init palmtx_pcmcia_init(void) |
| 78 | { |
| 79 | int ret; |
| 80 | |
| 81 | if (!machine_is_palmtx()) |
| 82 | return -ENODEV; |
| 83 | |
| 84 | palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); |
| 85 | if (!palmtx_pcmcia_device) |
| 86 | return -ENOMEM; |
| 87 | |
| 88 | ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops, |
| 89 | sizeof(palmtx_pcmcia_ops)); |
| 90 | |
| 91 | if (!ret) |
| 92 | ret = platform_device_add(palmtx_pcmcia_device); |
| 93 | |
| 94 | if (ret) |
| 95 | platform_device_put(palmtx_pcmcia_device); |
| 96 | |
| 97 | return ret; |
| 98 | } |
| 99 | |
| 100 | static void __exit palmtx_pcmcia_exit(void) |
| 101 | { |
| 102 | platform_device_unregister(palmtx_pcmcia_device); |
| 103 | } |
| 104 | |
Marek Vašut | 574047f | 2008-08-16 15:34:11 +0100 | [diff] [blame] | 105 | module_init(palmtx_pcmcia_init); |
Marek Vašut | 3597840 | 2008-07-07 17:28:59 +0100 | [diff] [blame] | 106 | module_exit(palmtx_pcmcia_exit); |
| 107 | |
| 108 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); |
| 109 | MODULE_DESCRIPTION("PCMCIA support for Palm T|X"); |
| 110 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); |
| 111 | MODULE_LICENSE("GPL"); |