1/* 2 * drivers/pcmcia/sa1100_assabet.c 3 * 4 * PCMCIA implementation routines for Assabet 5 * 6 */ 7#include <linux/module.h> 8#include <linux/kernel.h> 9#include <linux/errno.h> 10#include <linux/interrupt.h> 11#include <linux/device.h> 12#include <linux/init.h> 13 14#include <asm/hardware.h> 15#include <asm/mach-types.h> 16#include <asm/irq.h> 17#include <asm/signal.h> 18#include <asm/arch/assabet.h> 19 20#include "sa1100_generic.h" 21 22static struct pcmcia_irqs irqs[] = { 23 { 1, ASSABET_IRQ_GPIO_CF_CD, "CF CD" }, 24 { 1, ASSABET_IRQ_GPIO_CF_BVD2, "CF BVD2" }, 25 { 1, ASSABET_IRQ_GPIO_CF_BVD1, "CF BVD1" }, 26}; 27 28static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 29{ 30 skt->irq = ASSABET_IRQ_GPIO_CF_IRQ; 31 32 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 33} 34 35/* 36 * Release all resources. 37 */ 38static void assabet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 39{ 40 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 41} 42 43static void 44assabet_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) 45{ 46 unsigned long levels = GPLR; 47 48 state->detect = (levels & ASSABET_GPIO_CF_CD) ? 0 : 1; 49 state->ready = (levels & ASSABET_GPIO_CF_IRQ) ? 1 : 0; 50 state->bvd1 = (levels & ASSABET_GPIO_CF_BVD1) ? 1 : 0; 51 state->bvd2 = (levels & ASSABET_GPIO_CF_BVD2) ? 1 : 0; 52 state->wrprot = 0; /* Not available on Assabet. */ 53 state->vs_3v = 1; /* Can only apply 3.3V on Assabet. */ 54 state->vs_Xv = 0; 55} 56 57static int 58assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) 59{ 60 unsigned int mask; 61 62 switch (state->Vcc) { 63 case 0: 64 mask = 0; 65 break; 66 67 case 50: 68 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", 69 __FUNCTION__); 70 71 case 33: /* Can only apply 3.3V to the CF slot. */ 72 mask = ASSABET_BCR_CF_PWR; 73 break; 74 75 default: 76 printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__, 77 state->Vcc); 78 return -1; 79 } 80 81 /* Silently ignore Vpp, output enable, speaker enable. */ 82 83 if (state->flags & SS_RESET) 84 mask |= ASSABET_BCR_CF_RST; 85 86 ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR, mask); 87 88 return 0; 89} 90 91/* 92 * Enable card status IRQs on (re-)initialisation. This can 93 * be called at initialisation, power management event, or 94 * pcmcia event. 95 */ 96static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt) 97{ 98 /* 99 * Enable CF bus 100 */ 101 ASSABET_BCR_clear(ASSABET_BCR_CF_BUS_OFF); 102 103 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); 104} 105 106/* 107 * Disable card status IRQs on suspend. 108 */ 109static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) 110{ 111 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs)); 112 113 /* 114 * Tristate the CF bus signals. Also assert CF 115 * reset as per user guide page 4-11. 116 */ 117 ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST); 118} 119 120static struct pcmcia_low_level assabet_pcmcia_ops = { 121 .owner = THIS_MODULE, 122 123 .hw_init = assabet_pcmcia_hw_init, 124 .hw_shutdown = assabet_pcmcia_hw_shutdown, 125 126 .socket_state = assabet_pcmcia_socket_state, 127 .configure_socket = assabet_pcmcia_configure_socket, 128 129 .socket_init = assabet_pcmcia_socket_init, 130 .socket_suspend = assabet_pcmcia_socket_suspend, 131}; 132 133int __init pcmcia_assabet_init(struct device *dev) 134{ 135 int ret = -ENODEV; 136 137 if (machine_is_assabet() && !machine_has_neponset()) 138 ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1); 139 140 return ret; 141} 142