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