linux/drivers/pcmcia/sa1100_simpad.c
<<
>>
Prefs
   1/*
   2 * drivers/pcmcia/sa1100_simpad.c
   3 *
   4 * PCMCIA implementation routines for simpad
   5 *
   6 */
   7#include <linux/module.h>
   8#include <linux/kernel.h>
   9#include <linux/device.h>
  10#include <linux/init.h>
  11
  12#include <mach/hardware.h>
  13#include <asm/mach-types.h>
  14#include <asm/irq.h>
  15#include <mach/simpad.h>
  16#include "sa1100_generic.h"
  17 
  18static struct pcmcia_irqs irqs[] = {
  19        { 1, IRQ_GPIO_CF_CD, "CF_CD" },
  20};
  21
  22static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  23{
  24
  25        simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  26
  27        skt->socket.pci_irq = IRQ_GPIO_CF_IRQ;
  28
  29        return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
  30}
  31
  32static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  33{
  34        soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
  35
  36        /* Disable CF bus: */
  37        /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
  38        simpad_clear_cs3_bit(PCMCIA_RESET);
  39}
  40
  41static void
  42simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  43                           struct pcmcia_state *state)
  44{
  45        unsigned long levels = GPLR;
  46        long cs3reg = simpad_get_cs3_ro();
  47
  48        state->detect=((levels & GPIO_CF_CD)==0)?1:0;
  49        state->ready=(levels & GPIO_CF_IRQ)?1:0;
  50        state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */
  51        state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */
  52        state->wrprot=0; /* Not available on Simpad. */
  53
  54        if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
  55                        (PCMCIA_VS1|PCMCIA_VS2)) {
  56                state->vs_3v=0;
  57                state->vs_Xv=0;
  58        } else {
  59                state->vs_3v=1;
  60                state->vs_Xv=0;
  61        }
  62}
  63
  64static int
  65simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  66                               const socket_state_t *state)
  67{
  68        unsigned long flags;
  69
  70        local_irq_save(flags);
  71
  72        /* Murphy: see table of MIC2562a-1 */
  73        switch (state->Vcc) {
  74        case 0:
  75                simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  76                break;
  77
  78        case 33:  
  79                simpad_clear_cs3_bit(VCC_3V_EN|EN1);
  80                simpad_set_cs3_bit(VCC_5V_EN|EN0);
  81                break;
  82
  83        case 50:
  84                simpad_clear_cs3_bit(VCC_5V_EN|EN1);
  85                simpad_set_cs3_bit(VCC_3V_EN|EN0);
  86                break;
  87
  88        default:
  89                printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  90                        __func__, state->Vcc);
  91                simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  92                local_irq_restore(flags);
  93                return -1;
  94        }
  95
  96
  97        local_irq_restore(flags);
  98
  99        return 0;
 100}
 101
 102static void simpad_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
 103{
 104        soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
 105}
 106
 107static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
 108{
 109        soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
 110        simpad_set_cs3_bit(PCMCIA_RESET);
 111}
 112
 113static struct pcmcia_low_level simpad_pcmcia_ops = { 
 114        .owner                  = THIS_MODULE,
 115        .hw_init                = simpad_pcmcia_hw_init,
 116        .hw_shutdown            = simpad_pcmcia_hw_shutdown,
 117        .socket_state           = simpad_pcmcia_socket_state,
 118        .configure_socket       = simpad_pcmcia_configure_socket,
 119        .socket_init            = simpad_pcmcia_socket_init,
 120        .socket_suspend         = simpad_pcmcia_socket_suspend,
 121};
 122
 123int __devinit pcmcia_simpad_init(struct device *dev)
 124{
 125        int ret = -ENODEV;
 126
 127        if (machine_is_simpad())
 128                ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
 129
 130        return ret;
 131}
 132