From: Pete P. <pp...@us...> - 2002-04-19 19:12:57
|
Update of /cvsroot/linux-mips/linux/drivers/pcmcia In directory usw-pr-cvs1:/tmp/cvs-serv30920/drivers/pcmcia Modified Files: Config.in Makefile au1000_generic.c Added Files: au1000_pb1x00.c Removed Files: au1000_pb1000.c Log Message: Consolidated the pcmcia pb1x00 files -- brute force approach. --- NEW FILE: au1000_pb1x00.c --- /* * * Alchemy Semi Pb1x00 boards specific pcmcia routines. * * Copyright 2002 MontaVista Software Inc. * Author: MontaVista Software, Inc. * pp...@mv... or so...@mv... * * ######################################################################## * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * ######################################################################## * * */ #include <linux/module.h> #include <linux/init.h> #include <linux/config.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/kernel.h> #include <linux/tqueue.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/proc_fs.h> #include <linux/version.h> #include <linux/types.h> #include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> #include <pcmcia/ss.h> #include <pcmcia/bulkmem.h> #include <pcmcia/cistpl.h> #include <pcmcia/bus_ops.h> #include "cs_internal.h" #include <asm/io.h> #include <asm/irq.h> #include <asm/system.h> #include <asm/au1000.h> #include <asm/au1000_pcmcia.h> #ifdef CONFIG_MIPS_PB1000 #include <asm/pb1000.h> #define PCMCIA_IRQ AU1000_GPIO_15 #elif defined (CONFIG_MIPS_PB1500) #include <asm/pb1500.h> #define PCMCIA_IRQ AU1000_GPIO_11 /* fixme */ #elif defined (CONFIG_MIPS_PB1100) #include <asm/pb1100.h> #define PCMCIA_IRQ AU1000_GPIO_11 #endif static int pb1x00_pcmcia_init(struct pcmcia_init *init) { #ifdef CONFIG_MIPS_PB1000 u32 pcr; pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; writel(0x8000, PB1000_MDR); /* clear pcmcia interrupt */ au_sync_delay(100); writel(0x4000, PB1000_MDR); /* enable pcmcia interrupt */ au_sync(); pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0); pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,1); writew(pcr, PB1000_PCR); au_sync_delay(20); /* There's two sockets, but only the first one, 0, is used and tested */ return 1; #else /* fixme -- take care of the Pb1500 at some point */ u16 pcr; pcr = readw(PB1100_MEM_PCMCIA) & ~0xf; /* turn off power */ pcr &= ~(PB1100_PC_DEASSERT_RST | PB1100_PC_DRV_EN); writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(500); return 1; #endif } static int pb1x00_pcmcia_shutdown(void) { #ifdef CONFIG_MIPS_PB1000 u16 pcr; pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0); pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,1); writew(pcr, PB1000_PCR); au_sync_delay(20); return 0; #else u16 pcr; pcr = readw(PB1100_MEM_PCMCIA) & ~0xf; /* turn off power */ pcr &= ~(PB1100_PC_DEASSERT_RST | PB1100_PC_DRV_EN); writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(2); return 0; #endif } static int pb1x00_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) { u32 inserted; unsigned char vs; #ifdef CONFIG_MIPS_PB1000 vs = readw(PB1000_ACR1); inserted = !(vs & (ACR1_SLOT_0_CD1 | ACR1_SLOT_0_CD2)); #else vs = (readw(PB1100_BOARD_STATUS) >> 4) & 0x3; inserted = !((readl(SYS_PINSTATERD) >> 9) & 0x1); /* gpio 9 */ #endif state->ready = 0; state->vs_Xv = 0; state->vs_3v = 0; state->detect = 0; if (sock == 0) { if (inserted) { switch (vs) { case 0: case 2: state->vs_3v=1; break; case 3: /* 5V */ break; default: /* return without setting 'detect' */ printk(KERN_ERR "pb1x00 bad VS (%d)\n", vs); return; } state->detect = 1; } } else { printk(KERN_ERR "pb1x00 socket_state bad sock %d\n", sock); } if (state->detect) { state->ready = 1; } state->bvd1=1; state->bvd2=1; state->wrprot=0; return 1; } static int pb1x00_pcmcia_get_irq_info(struct pcmcia_irq_info *info) { if(info->sock > PCMCIA_MAX_SOCK) return -1; if(info->sock == 0) { info->irq = PCMCIA_IRQ; } else info->irq = -1; return 0; } static int pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) { u16 pcr; if(configure->sock > PCMCIA_MAX_SOCK) return -1; #ifdef CONFIG_MIPS_PB1000 pcr = readw(PB1000_PCR); if (configure->sock == 0) { pcr &= ~(PCR_SLOT_0_VCC0 | PCR_SLOT_0_VCC1 | PCR_SLOT_0_VPP0 | PCR_SLOT_0_VPP1); } else { pcr &= ~(PCR_SLOT_1_VCC0 | PCR_SLOT_1_VCC1 | PCR_SLOT_1_VPP0 | PCR_SLOT_1_VPP1); } pcr &= ~PCR_SLOT_0_RST; DEBUG(KERN_INFO "Vcc %dV Vpp %dV, pcr %x\n", configure->vcc, configure->vpp, pcr); switch(configure->vcc){ case 0: /* Vcc 0 */ switch(configure->vpp) { case 0: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_GND, configure->sock); break; case 12: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_12V, configure->sock); break; case 50: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_5V, configure->sock); break; case 33: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_3V, configure->sock); break; default: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, configure->sock); printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, configure->vpp); break; } break; case 50: /* Vcc 5V */ switch(configure->vpp) { case 0: pcr |= SET_VCC_VPP(VCC_5V,VPP_GND, configure->sock); break; case 50: pcr |= SET_VCC_VPP(VCC_5V,VPP_5V, configure->sock); break; case 12: pcr |= SET_VCC_VPP(VCC_5V,VPP_12V, configure->sock); break; case 33: pcr |= SET_VCC_VPP(VCC_5V,VPP_3V, configure->sock); break; default: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, configure->sock); printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, configure->vpp); break; } break; case 33: /* Vcc 3.3V */ switch(configure->vpp) { case 0: pcr |= SET_VCC_VPP(VCC_3V,VPP_GND, configure->sock); break; case 50: pcr |= SET_VCC_VPP(VCC_3V,VPP_5V, configure->sock); break; case 12: pcr |= SET_VCC_VPP(VCC_3V,VPP_12V, configure->sock); break; case 33: pcr |= SET_VCC_VPP(VCC_3V,VPP_3V, configure->sock); break; default: pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ, configure->sock); printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, configure->vpp); break; } break; default: /* what's this ? */ pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock); printk(KERN_ERR "%s: bad Vcc %d\n", __FUNCTION__, configure->vcc); break; } pcr &= ~(PCR_SLOT_0_RST); if (configure->reset) { pcr |= PCR_SLOT_0_RST; } writew(pcr, PB1000_PCR); au_sync_delay(300); #else pcr = readw(PB1100_MEM_PCMCIA) & ~0xf; DEBUG(KERN_INFO "Vcc %dV Vpp %dV, pcr %x, reset %d\n", configure->vcc, configure->vpp, pcr, configure->reset); switch(configure->vcc){ case 0: /* Vcc 0 */ pcr |= SET_VCC_VPP(0,0); break; case 50: /* Vcc 5V */ switch(configure->vpp) { case 0: pcr |= SET_VCC_VPP(2,0); break; case 50: pcr |= SET_VCC_VPP(2,1); break; case 12: pcr |= SET_VCC_VPP(2,2); break; case 33: default: pcr |= SET_VCC_VPP(0,0); printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, configure->vpp); break; } break; case 33: /* Vcc 3.3V */ switch(configure->vpp) { case 0: pcr |= SET_VCC_VPP(1,0); break; case 12: pcr |= SET_VCC_VPP(1,2); break; case 33: pcr |= SET_VCC_VPP(1,1); break; case 50: default: pcr |= SET_VCC_VPP(0,0); printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, configure->vpp); break; } break; default: /* what's this ? */ pcr |= SET_VCC_VPP(0,0); printk(KERN_ERR "%s: bad Vcc %d\n", __FUNCTION__, configure->vcc); break; } writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(300); if (!configure->reset) { pcr |= PB1100_PC_DRV_EN; writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(100); pcr |= PB1100_PC_DEASSERT_RST; writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(100); } else { pcr &= ~(PB1100_PC_DEASSERT_RST | PB1100_PC_DRV_EN); writew(pcr, PB1100_MEM_PCMCIA); au_sync_delay(100); } #endif return 0; } struct pcmcia_low_level pb1x00_pcmcia_ops = { pb1x00_pcmcia_init, pb1x00_pcmcia_shutdown, pb1x00_pcmcia_socket_state, pb1x00_pcmcia_get_irq_info, pb1x00_pcmcia_configure_socket }; Index: Config.in =================================================================== RCS file: /cvsroot/linux-mips/linux/drivers/pcmcia/Config.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Config.in 2 Apr 2002 22:59:40 -0000 1.5 +++ Config.in 19 Apr 2002 19:12:52 -0000 1.6 @@ -25,9 +25,10 @@ dep_tristate ' HD64465 host bridge support' CONFIG_HD64465_PCMCIA $CONFIG_PCMCIA fi if [ "$CONFIG_MIPS_AU1000" = "y" ]; then - dep_tristate ' Au1000 support' CONFIG_PCMCIA_AU1000 $CONFIG_PCMCIA $CONFIG_MIPS_PB1000 - dep_tristate ' Au1500 support' CONFIG_PCMCIA_AU1500 $CONFIG_PCMCIA $CONFIG_MIPS_PB1500 - dep_tristate ' Au1100 support' CONFIG_PCMCIA_AU1100 $CONFIG_PCMCIA $CONFIG_MIPS_PB1100 + dep_tristate ' Au1x00 pcmcia support' CONFIG_PCMCIA_AU1000 $CONFIG_PCMCIA + if [ "$CONFIG_PCMCIA_AU1000" != "n" ]; then + dep_bool ' Pb1x00 board support' CONFIG_PCMCIA_PB1X00 + fi fi fi Index: Makefile =================================================================== RCS file: /cvsroot/linux-mips/linux/drivers/pcmcia/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile 18 Apr 2002 00:03:28 -0000 1.6 +++ Makefile 19 Apr 2002 19:12:52 -0000 1.7 @@ -59,13 +59,9 @@ endif endif -obj-$(CONFIG_PCMCIA_AU1000) += au1000_ss.o -obj-$(CONFIG_PCMCIA_AU1500) += au1500_ss.o -obj-$(CONFIG_PCMCIA_AU1100) += au1100_ss.o +obj-$(CONFIG_PCMCIA_AU1000) += au1x00_ss.o au1000_ss-objs-y := au1000_generic.o -au1000_ss-objs-$(CONFIG_MIPS_PB1000) += au1000_pb1000.o -au1000_ss-objs-$(CONFIG_MIPS_PB1500) += au1000_pb1500.o -au1000_ss-objs-$(CONFIG_MIPS_PB1100) += au1000_pb1100.o +au1000_ss-objs-$(CONFIG_PCMCIA_PB1X00) += au1000_pb1x00.o obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o @@ -95,9 +91,7 @@ sa1100_cs.o: $(sa1100_cs-objs-y) $(LD) -r -o $@ $(sa1100_cs-objs-y) -au1000_ss.o: $(au1000_ss-objs-y) - $(LD) -r -o $@ $(au1000_ss-objs-y) -au1100_ss.o: $(au1000_ss-objs-y) +au1x00_ss.o: $(au1000_ss-objs-y) $(LD) -r -o $@ $(au1000_ss-objs-y) yenta_socket.o: $(yenta_socket-objs) Index: au1000_generic.c =================================================================== RCS file: /cvsroot/linux-mips/linux/drivers/pcmcia/au1000_generic.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- au1000_generic.c 18 Apr 2002 00:03:28 -0000 1.9 +++ au1000_generic.c 19 Apr 2002 19:12:52 -0000 1.10 @@ -154,12 +154,8 @@ return -1; } -#ifdef CONFIG_MIPS_PB1000 - pcmcia_low_level=&pb1000_pcmcia_ops; -#elif defined(CONFIG_MIPS_PB1500) - pcmcia_low_level=&pb1500_pcmcia_ops; -#elif defined(CONFIG_MIPS_PB1100) - pcmcia_low_level=&pb1100_pcmcia_ops; +#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500) + pcmcia_low_level=&pb1x00_pcmcia_ops; #else #error Unsupported AU1000 board. #endif --- au1000_pb1000.c DELETED --- |