Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 77b2555b52a894a2e39a42e43d993df875c46a6a 190 lines 4.4 kB view raw
1/* 2 * 3 * MyCable board specific pcmcia routines. 4 * 5 * Copyright 2003 MontaVista Software Inc. 6 * Author: Pete Popov, MontaVista Software, Inc. 7 * ppopov@mvista.com or source@mvista.com 8 * 9 * ######################################################################## 10 * 11 * This program is free software; you can distribute it and/or modify it 12 * under the terms of the GNU General Public License (Version 2) as 13 * published by the Free Software Foundation. 14 * 15 * This program is distributed in the hope it will be useful, but WITHOUT 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18 * for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with this program; if not, write to the Free Software Foundation, Inc., 22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 23 * 24 * ######################################################################## 25 * 26 * 27 */ 28#include <linux/module.h> 29#include <linux/init.h> 30#include <linux/config.h> 31#include <linux/delay.h> 32#include <linux/ioport.h> 33#include <linux/kernel.h> 34#include <linux/tqueue.h> 35#include <linux/timer.h> 36#include <linux/mm.h> 37#include <linux/proc_fs.h> 38#include <linux/version.h> 39#include <linux/types.h> 40 41#include <pcmcia/cs_types.h> 42#include <pcmcia/cs.h> 43#include <pcmcia/ss.h> 44#include <pcmcia/bulkmem.h> 45#include <pcmcia/cistpl.h> 46#include <pcmcia/bus_ops.h> 47#include "cs_internal.h" 48 49#include <asm/io.h> 50#include <asm/irq.h> 51#include <asm/system.h> 52 53#include <asm/au1000.h> 54#include <asm/au1000_pcmcia.h> 55#include <asm/xxs1500.h> 56 57#if 0 58#define DEBUG(x,args...) printk(__FUNCTION__ ": " x,##args) 59#else 60#define DEBUG(x,args...) 61#endif 62 63static int xxs1500_pcmcia_init(struct pcmcia_init *init) 64{ 65 return PCMCIA_NUM_SOCKS; 66} 67 68static int xxs1500_pcmcia_shutdown(void) 69{ 70 /* turn off power */ 71 au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30), 72 GPIO2_OUTPUT); 73 au_sync_delay(100); 74 75 /* assert reset */ 76 au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20), 77 GPIO2_OUTPUT); 78 au_sync_delay(100); 79 return 0; 80} 81 82 83static int 84xxs1500_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) 85{ 86 u32 inserted; u32 vs; 87 unsigned long gpio, gpio2; 88 89 if(sock > PCMCIA_MAX_SOCK) return -1; 90 91 gpio = au_readl(SYS_PINSTATERD); 92 gpio2 = au_readl(GPIO2_PINSTATE); 93 94 vs = gpio2 & ((1<<8) | (1<<9)); 95 inserted = (!(gpio & 0x1) && !(gpio & 0x2)); 96 97 state->ready = 0; 98 state->vs_Xv = 0; 99 state->vs_3v = 0; 100 state->detect = 0; 101 102 if (inserted) { 103 switch (vs) { 104 case 0: 105 case 1: 106 case 2: 107 state->vs_3v=1; 108 break; 109 case 3: /* 5V */ 110 default: 111 /* return without setting 'detect' */ 112 printk(KERN_ERR "au1x00_cs: unsupported VS\n", 113 vs); 114 return; 115 } 116 state->detect = 1; 117 } 118 119 if (state->detect) { 120 state->ready = 1; 121 } 122 123 state->bvd1= gpio2 & (1<<10); 124 state->bvd2 = gpio2 & (1<<11); 125 state->wrprot=0; 126 return 1; 127} 128 129 130static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info *info) 131{ 132 133 if(info->sock > PCMCIA_MAX_SOCK) return -1; 134 info->irq = PCMCIA_IRQ; 135 return 0; 136} 137 138 139static int 140xxs1500_pcmcia_configure_socket(const struct pcmcia_configure *configure) 141{ 142 143 if(configure->sock > PCMCIA_MAX_SOCK) return -1; 144 145 DEBUG("Vcc %dV Vpp %dV, reset %d\n", 146 configure->vcc, configure->vpp, configure->reset); 147 148 switch(configure->vcc){ 149 case 33: /* Vcc 3.3V */ 150 /* turn on power */ 151 DEBUG("turn on power\n"); 152 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30), 153 GPIO2_OUTPUT); 154 au_sync_delay(100); 155 break; 156 case 50: /* Vcc 5V */ 157 default: /* what's this ? */ 158 printk(KERN_ERR "au1x00_cs: unsupported VCC\n"); 159 case 0: /* Vcc 0 */ 160 /* turn off power */ 161 au_sync_delay(100); 162 au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30), 163 GPIO2_OUTPUT); 164 break; 165 } 166 167 if (!configure->reset) { 168 DEBUG("deassert reset\n"); 169 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<4))|(1<<20), 170 GPIO2_OUTPUT); 171 au_sync_delay(100); 172 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<5))|(1<<21), 173 GPIO2_OUTPUT); 174 } 175 else { 176 DEBUG("assert reset\n"); 177 au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20), 178 GPIO2_OUTPUT); 179 } 180 au_sync_delay(100); 181 return 0; 182} 183 184struct pcmcia_low_level xxs1500_pcmcia_ops = { 185 xxs1500_pcmcia_init, 186 xxs1500_pcmcia_shutdown, 187 xxs1500_pcmcia_socket_state, 188 xxs1500_pcmcia_get_irq_info, 189 xxs1500_pcmcia_configure_socket 190};