linux/drivers/pcmcia/sa1100_shannon.c
<<
>>
Prefs
   1/*
   2 * drivers/pcmcia/sa1100_shannon.c
   3 *
   4 * PCMCIA implementation routines for Shannon
   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 <mach/shannon.h>
  15#include <asm/irq.h>
  16#include "sa1100_generic.h"
  17
  18static struct pcmcia_irqs irqs[] = {
  19        { 0, SHANNON_IRQ_GPIO_EJECT_0, "PCMCIA_CD_0" },
  20        { 1, SHANNON_IRQ_GPIO_EJECT_1, "PCMCIA_CD_1" },
  21};
  22
  23static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  24{
  25        /* All those are inputs */
  26        GPDR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 | 
  27                  SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
  28        GAFR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 | 
  29                  SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
  30
  31        skt->irq = skt->nr ? SHANNON_IRQ_GPIO_RDY_1 : SHANNON_IRQ_GPIO_RDY_0;
  32
  33        return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
  34}
  35
  36static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  37{
  38        soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
  39}
  40
  41static void
  42shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  43                            struct pcmcia_state *state)
  44{
  45        unsigned long levels = GPLR;
  46
  47        switch (skt->nr) {
  48        case 0:
  49                state->detect = (levels & SHANNON_GPIO_EJECT_0) ? 0 : 1;
  50                state->ready  = (levels & SHANNON_GPIO_RDY_0) ? 1 : 0;
  51                state->wrprot = 0; /* Not available on Shannon. */
  52                state->bvd1   = 1; 
  53                state->bvd2   = 1; 
  54                state->vs_3v  = 1; /* FIXME Can only apply 3.3V on Shannon. */
  55                state->vs_Xv  = 0;
  56                break;
  57
  58        case 1:
  59                state->detect = (levels & SHANNON_GPIO_EJECT_1) ? 0 : 1;
  60                state->ready  = (levels & SHANNON_GPIO_RDY_1) ? 1 : 0;
  61                state->wrprot = 0; /* Not available on Shannon. */
  62                state->bvd1   = 1; 
  63                state->bvd2   = 1; 
  64                state->vs_3v  = 1; /* FIXME Can only apply 3.3V on Shannon. */
  65                state->vs_Xv  = 0;
  66                break;
  67        }
  68}
  69
  70static int
  71shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  72                                const socket_state_t *state)
  73{
  74        switch (state->Vcc) {
  75        case 0: /* power off */
  76                printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
  77                break;
  78        case 50:
  79                printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
  80        case 33:
  81                break;
  82        default:
  83                printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  84                       __func__, state->Vcc);
  85                return -1;
  86        }
  87
  88        printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
  89        
  90        /* Silently ignore Vpp, output enable, speaker enable. */
  91
  92        return 0;
  93}
  94
  95static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  96{
  97        soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  98}
  99
 100static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
 101{
 102        soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
 103}
 104
 105static struct pcmcia_low_level shannon_pcmcia_ops = {
 106        .owner                  = THIS_MODULE,
 107        .hw_init                = shannon_pcmcia_hw_init,
 108        .hw_shutdown            = shannon_pcmcia_hw_shutdown,
 109        .socket_state           = shannon_pcmcia_socket_state,
 110        .configure_socket       = shannon_pcmcia_configure_socket,
 111
 112        .socket_init            = shannon_pcmcia_socket_init,
 113        .socket_suspend         = shannon_pcmcia_socket_suspend,
 114};
 115
 116int __init pcmcia_shannon_init(struct device *dev)
 117{
 118        int ret = -ENODEV;
 119
 120        if (machine_is_shannon())
 121                ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
 122
 123        return ret;
 124}
 125