root/drivers/pcmcia/pxa2xx_e740.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. e740_pcmcia_hw_init
  2. e740_pcmcia_socket_state
  3. e740_pcmcia_configure_socket
  4. e740_pcmcia_init
  5. e740_pcmcia_exit

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * Toshiba e740 PCMCIA specific routines.
   4  *
   5  * (c) 2004 Ian Molton <spyro@f2s.com>
   6  */
   7 
   8 #include <linux/init.h>
   9 #include <linux/module.h>
  10 #include <linux/kernel.h>
  11 #include <linux/errno.h>
  12 #include <linux/gpio.h>
  13 #include <linux/interrupt.h>
  14 #include <linux/platform_device.h>
  15 
  16 #include <mach/eseries-gpio.h>
  17 
  18 #include <asm/irq.h>
  19 #include <asm/mach-types.h>
  20 
  21 #include "soc_common.h"
  22 
  23 static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  24 {
  25         if (skt->nr == 0) {
  26                 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD0;
  27                 skt->stat[SOC_STAT_CD].name = "CF card detect";
  28                 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY0;
  29                 skt->stat[SOC_STAT_RDY].name = "CF ready";
  30         } else {
  31                 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD1;
  32                 skt->stat[SOC_STAT_CD].name = "Wifi switch";
  33                 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY1;
  34                 skt->stat[SOC_STAT_RDY].name = "Wifi ready";
  35         }
  36 
  37         return 0;
  38 }
  39 
  40 static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  41                                         struct pcmcia_state *state)
  42 {
  43         state->vs_3v  = 1;
  44         state->vs_Xv  = 0;
  45 }
  46 
  47 static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  48                                         const socket_state_t *state)
  49 {
  50         if (state->flags & SS_RESET) {
  51                 if (skt->nr == 0)
  52                         gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
  53                 else
  54                         gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
  55         } else {
  56                 if (skt->nr == 0)
  57                         gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
  58                 else
  59                         gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
  60         }
  61 
  62         switch (state->Vcc) {
  63         case 0: /* Socket off */
  64                 if (skt->nr == 0)
  65                         gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
  66                 else
  67                         gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
  68                 break;
  69         case 50:
  70         case 33: /* socket on */
  71                 if (skt->nr == 0)
  72                         gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
  73                 else
  74                         gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
  75                 break;
  76         default:
  77                 printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
  78         }
  79 
  80         return 0;
  81 }
  82 
  83 static struct pcmcia_low_level e740_pcmcia_ops = {
  84         .owner            = THIS_MODULE,
  85         .hw_init          = e740_pcmcia_hw_init,
  86         .socket_state     = e740_pcmcia_socket_state,
  87         .configure_socket = e740_pcmcia_configure_socket,
  88         .nr               = 2,
  89 };
  90 
  91 static struct platform_device *e740_pcmcia_device;
  92 
  93 static int __init e740_pcmcia_init(void)
  94 {
  95         int ret;
  96 
  97         if (!machine_is_e740())
  98                 return -ENODEV;
  99 
 100         e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
 101         if (!e740_pcmcia_device)
 102                 return -ENOMEM;
 103 
 104         ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
 105                                         sizeof(e740_pcmcia_ops));
 106 
 107         if (!ret)
 108                 ret = platform_device_add(e740_pcmcia_device);
 109 
 110         if (ret)
 111                 platform_device_put(e740_pcmcia_device);
 112 
 113         return ret;
 114 }
 115 
 116 static void __exit e740_pcmcia_exit(void)
 117 {
 118         platform_device_unregister(e740_pcmcia_device);
 119 }
 120 
 121 module_init(e740_pcmcia_init);
 122 module_exit(e740_pcmcia_exit);
 123 
 124 MODULE_LICENSE("GPL v2");
 125 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
 126 MODULE_ALIAS("platform:pxa2xx-pcmcia");
 127 MODULE_DESCRIPTION("e740 PCMCIA platform support");

/* [<][>][^][v][top][bottom][index][help] */