Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/drivers/pcmcia/pxa2xx_palmld.c
0004  *
0005  * Driver for Palm LifeDrive PCMCIA
0006  *
0007  * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
0008  * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
0009  */
0010 
0011 #include <linux/module.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/gpio.h>
0014 
0015 #include <asm/mach-types.h>
0016 #include <pcmcia/soc_common.h>
0017 
0018 #include "palmld.h"
0019 
0020 static struct gpio palmld_pcmcia_gpios[] = {
0021     { GPIO_NR_PALMLD_PCMCIA_POWER,  GPIOF_INIT_LOW, "PCMCIA Power" },
0022     { GPIO_NR_PALMLD_PCMCIA_RESET,  GPIOF_INIT_HIGH,"PCMCIA Reset" },
0023 };
0024 
0025 static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
0026 {
0027     int ret;
0028 
0029     ret = gpio_request_array(palmld_pcmcia_gpios,
0030                 ARRAY_SIZE(palmld_pcmcia_gpios));
0031 
0032     skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
0033     skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
0034 
0035     return ret;
0036 }
0037 
0038 static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
0039 {
0040     gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
0041 }
0042 
0043 static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
0044                     struct pcmcia_state *state)
0045 {
0046     state->detect = 1; /* always inserted */
0047     state->vs_3v  = 1;
0048     state->vs_Xv  = 0;
0049 }
0050 
0051 static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
0052                     const socket_state_t *state)
0053 {
0054     gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
0055     gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
0056             !!(state->flags & SS_RESET));
0057 
0058     return 0;
0059 }
0060 
0061 static struct pcmcia_low_level palmld_pcmcia_ops = {
0062     .owner          = THIS_MODULE,
0063 
0064     .first          = 1,
0065     .nr         = 1,
0066 
0067     .hw_init        = palmld_pcmcia_hw_init,
0068     .hw_shutdown        = palmld_pcmcia_hw_shutdown,
0069 
0070     .socket_state       = palmld_pcmcia_socket_state,
0071     .configure_socket   = palmld_pcmcia_configure_socket,
0072 };
0073 
0074 static struct platform_device *palmld_pcmcia_device;
0075 
0076 static int __init palmld_pcmcia_init(void)
0077 {
0078     int ret;
0079 
0080     if (!machine_is_palmld())
0081         return -ENODEV;
0082 
0083     palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
0084     if (!palmld_pcmcia_device)
0085         return -ENOMEM;
0086 
0087     ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
0088                     sizeof(palmld_pcmcia_ops));
0089 
0090     if (!ret)
0091         ret = platform_device_add(palmld_pcmcia_device);
0092 
0093     if (ret)
0094         platform_device_put(palmld_pcmcia_device);
0095 
0096     return ret;
0097 }
0098 
0099 static void __exit palmld_pcmcia_exit(void)
0100 {
0101     platform_device_unregister(palmld_pcmcia_device);
0102 }
0103 
0104 module_init(palmld_pcmcia_init);
0105 module_exit(palmld_pcmcia_exit);
0106 
0107 MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
0108         " Marek Vasut <marek.vasut@gmail.com>");
0109 MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
0110 MODULE_ALIAS("platform:pxa2xx-pcmcia");
0111 MODULE_LICENSE("GPL");