diff options
| -rw-r--r-- | arch/mips/alchemy/common/platform.c | 6 | ||||
| -rw-r--r-- | arch/mips/alchemy/common/setup.c | 3 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-au1x00/au1000.h | 14 | ||||
| -rw-r--r-- | drivers/pcmcia/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/pcmcia/Makefile | 9 | ||||
| -rw-r--r-- | drivers/pcmcia/au1000_db1x00.c | 307 | ||||
| -rw-r--r-- | drivers/pcmcia/au1000_generic.h | 12 | ||||
| -rw-r--r-- | drivers/pcmcia/au1000_pb1x00.c | 119 | ||||
| -rw-r--r-- | drivers/pcmcia/db1xxx_ss.c | 630 |
9 files changed, 660 insertions, 451 deletions
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c index 117f99f70649..2b76a57c4947 100644 --- a/arch/mips/alchemy/common/platform.c +++ b/arch/mips/alchemy/common/platform.c | |||
| @@ -308,11 +308,6 @@ static struct platform_device au1200_mmc1_device = { | |||
| 308 | #endif /* #ifndef CONFIG_MIPS_DB1200 */ | 308 | #endif /* #ifndef CONFIG_MIPS_DB1200 */ |
| 309 | #endif /* #ifdef CONFIG_SOC_AU1200 */ | 309 | #endif /* #ifdef CONFIG_SOC_AU1200 */ |
| 310 | 310 | ||
| 311 | static struct platform_device au1x00_pcmcia_device = { | ||
| 312 | .name = "au1x00-pcmcia", | ||
| 313 | .id = 0, | ||
| 314 | }; | ||
| 315 | |||
| 316 | /* All Alchemy demoboards with I2C have this #define in their headers */ | 311 | /* All Alchemy demoboards with I2C have this #define in their headers */ |
| 317 | #ifdef SMBUS_PSC_BASE | 312 | #ifdef SMBUS_PSC_BASE |
| 318 | static struct resource pbdb_smbus_resources[] = { | 313 | static struct resource pbdb_smbus_resources[] = { |
| @@ -334,7 +329,6 @@ static struct platform_device pbdb_smbus_device = { | |||
| 334 | static struct platform_device *au1xxx_platform_devices[] __initdata = { | 329 | static struct platform_device *au1xxx_platform_devices[] __initdata = { |
| 335 | &au1xx0_uart_device, | 330 | &au1xx0_uart_device, |
| 336 | &au1xxx_usb_ohci_device, | 331 | &au1xxx_usb_ohci_device, |
| 337 | &au1x00_pcmcia_device, | ||
| 338 | #ifdef CONFIG_FB_AU1100 | 332 | #ifdef CONFIG_FB_AU1100 |
| 339 | &au1100_lcd_device, | 333 | &au1100_lcd_device, |
| 340 | #endif | 334 | #endif |
diff --git a/arch/mips/alchemy/common/setup.c b/arch/mips/alchemy/common/setup.c index 6184baa56786..375984e5c2e6 100644 --- a/arch/mips/alchemy/common/setup.c +++ b/arch/mips/alchemy/common/setup.c | |||
| @@ -107,7 +107,8 @@ phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size) | |||
| 107 | * The pseudo address we use is 0xF400 0000. Any address over | 107 | * The pseudo address we use is 0xF400 0000. Any address over |
| 108 | * 0xF400 0000 is a PCMCIA pseudo address. | 108 | * 0xF400 0000 is a PCMCIA pseudo address. |
| 109 | */ | 109 | */ |
| 110 | if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) | 110 | if ((phys_addr >= PCMCIA_ATTR_PSEUDO_PHYS) && |
| 111 | (phys_addr < PCMCIA_PSEUDO_END)) | ||
| 111 | return (phys_t)(phys_addr << 4); | 112 | return (phys_t)(phys_addr << 4); |
| 112 | 113 | ||
| 113 | /* default nop */ | 114 | /* default nop */ |
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h index 05078224e933..fceeca883359 100644 --- a/arch/mips/include/asm/mach-au1x00/au1000.h +++ b/arch/mips/include/asm/mach-au1x00/au1000.h | |||
| @@ -1724,6 +1724,20 @@ enum soc_au1200_ints { | |||
| 1724 | 1724 | ||
| 1725 | #endif | 1725 | #endif |
| 1726 | 1726 | ||
| 1727 | /* | ||
| 1728 | * All Au1xx0 SOCs have a PCMCIA controller. | ||
| 1729 | * We setup our 32-bit pseudo addresses to be equal to the | ||
| 1730 | * 36-bit addr >> 4, to make it easier to check the address | ||
| 1731 | * and fix it. | ||
| 1732 | * The PCMCIA socket 0 physical attribute address is 0xF 4000 0000. | ||
| 1733 | * The pseudo address we use is 0xF400 0000. Any address over | ||
| 1734 | * 0xF400 0000 is a PCMCIA pseudo address. | ||
| 1735 | */ | ||
| 1736 | #define PCMCIA_IO_PSEUDO_PHYS (PCMCIA_IO_PHYS_ADDR >> 4) | ||
| 1737 | #define PCMCIA_ATTR_PSEUDO_PHYS (PCMCIA_ATTR_PHYS_ADDR >> 4) | ||
| 1738 | #define PCMCIA_MEM_PSEUDO_PHYS (PCMCIA_MEM_PHYS_ADDR >> 4) | ||
| 1739 | #define PCMCIA_PSEUDO_END (0xffffffff) | ||
| 1740 | |||
| 1727 | #ifndef _LANGUAGE_ASSEMBLY | 1741 | #ifndef _LANGUAGE_ASSEMBLY |
| 1728 | typedef volatile struct { | 1742 | typedef volatile struct { |
| 1729 | /* 0x0000 */ u32 toytrim; | 1743 | /* 0x0000 */ u32 toytrim; |
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 9f3adbd9f700..7c16d35679a6 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
| @@ -174,6 +174,17 @@ config PCMCIA_AU1X00 | |||
| 174 | tristate "Au1x00 pcmcia support" | 174 | tristate "Au1x00 pcmcia support" |
| 175 | depends on SOC_AU1X00 && PCMCIA | 175 | depends on SOC_AU1X00 && PCMCIA |
| 176 | 176 | ||
| 177 | config PCMCIA_ALCHEMY_DEVBOARD | ||
| 178 | tristate "Alchemy Db/Pb1xxx PCMCIA socket services" | ||
| 179 | depends on SOC_AU1X00 && PCMCIA | ||
| 180 | select 64BIT_PHYS_ADDR | ||
| 181 | help | ||
| 182 | Enable this driver of you want PCMCIA support on your Alchemy | ||
| 183 | Db1000, Db/Pb1100, Db/Pb1500, Db/Pb1550, Db/Pb1200 board. | ||
| 184 | NOT suitable for the PB1000! | ||
| 185 | |||
| 186 | This driver is also available as a module called db1xxx_ss.ko | ||
| 187 | |||
| 177 | config PCMCIA_BCM63XX | 188 | config PCMCIA_BCM63XX |
| 178 | tristate "bcm63xx pcmcia support" | 189 | tristate "bcm63xx pcmcia support" |
| 179 | depends on BCM63XX && PCMCIA | 190 | depends on BCM63XX && PCMCIA |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 83ff802de544..f128d71c74c2 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
| @@ -35,17 +35,10 @@ obj-$(CONFIG_OMAP_CF) += omap_cf.o | |||
| 35 | obj-$(CONFIG_BFIN_CFPCMCIA) += bfin_cf_pcmcia.o | 35 | obj-$(CONFIG_BFIN_CFPCMCIA) += bfin_cf_pcmcia.o |
| 36 | obj-$(CONFIG_AT91_CF) += at91_cf.o | 36 | obj-$(CONFIG_AT91_CF) += at91_cf.o |
| 37 | obj-$(CONFIG_ELECTRA_CF) += electra_cf.o | 37 | obj-$(CONFIG_ELECTRA_CF) += electra_cf.o |
| 38 | obj-$(CONFIG_PCMCIA_ALCHEMY_DEVBOARD) += db1xxx_ss.o | ||
| 38 | 39 | ||
| 39 | au1x00_ss-y += au1000_generic.o | 40 | au1x00_ss-y += au1000_generic.o |
| 40 | au1x00_ss-$(CONFIG_MIPS_PB1000) += au1000_pb1x00.o | 41 | au1x00_ss-$(CONFIG_MIPS_PB1000) += au1000_pb1x00.o |
| 41 | au1x00_ss-$(CONFIG_MIPS_PB1100) += au1000_pb1x00.o | ||
| 42 | au1x00_ss-$(CONFIG_MIPS_PB1200) += au1000_db1x00.o | ||
| 43 | au1x00_ss-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o | ||
| 44 | au1x00_ss-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o | ||
| 45 | au1x00_ss-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o | ||
| 46 | au1x00_ss-$(CONFIG_MIPS_DB1200) += au1000_db1x00.o | ||
| 47 | au1x00_ss-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o | ||
| 48 | au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o | ||
| 49 | au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o | 42 | au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o |
| 50 | 43 | ||
| 51 | sa1111_cs-y += sa1111_generic.o | 44 | sa1111_cs-y += sa1111_generic.o |
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c deleted file mode 100644 index 3fdd664e41c6..000000000000 --- a/drivers/pcmcia/au1000_db1x00.c +++ /dev/null | |||
| @@ -1,307 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * Alchemy Semi Db1x00 boards specific pcmcia routines. | ||
| 4 | * | ||
| 5 | * Copyright 2002 MontaVista Software Inc. | ||
| 6 | * Author: MontaVista Software, Inc. | ||
| 7 | * ppopov@mvista.com or source@mvista.com | ||
| 8 | * | ||
| 9 | * Copyright 2004 Pete Popov, updated the driver to 2.6. | ||
| 10 | * Followed the sa11xx API and largely copied many of the hardware | ||
| 11 | * independent functions. | ||
| 12 | * | ||
| 13 | * ######################################################################## | ||
| 14 | * | ||
| 15 | * This program is free software; you can distribute it and/or modify it | ||
| 16 | * under the terms of the GNU General Public License (Version 2) as | ||
| 17 | * published by the Free Software Foundation. | ||
| 18 | * | ||
| 19 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 22 | * for more details. | ||
| 23 | * | ||
| 24 | * You should have received a copy of the GNU General Public License along | ||
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 26 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
| 27 | * | ||
| 28 | * ######################################################################## | ||
| 29 | * | ||
| 30 | * | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/kernel.h> | ||
| 35 | #include <linux/errno.h> | ||
| 36 | #include <linux/interrupt.h> | ||
| 37 | #include <linux/device.h> | ||
| 38 | #include <linux/init.h> | ||
| 39 | |||
| 40 | #include <asm/irq.h> | ||
| 41 | #include <asm/signal.h> | ||
| 42 | #include <asm/mach-au1x00/au1000.h> | ||
| 43 | |||
| 44 | #if defined(CONFIG_MIPS_DB1200) | ||
| 45 | #include <db1200.h> | ||
| 46 | #elif defined(CONFIG_MIPS_PB1200) | ||
| 47 | #include <pb1200.h> | ||
| 48 | #else | ||
| 49 | #include <asm/mach-db1x00/db1x00.h> | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #include <asm/mach-db1x00/bcsr.h> | ||
| 53 | #include "au1000_generic.h" | ||
| 54 | |||
| 55 | #if 0 | ||
| 56 | #define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args) | ||
| 57 | #else | ||
| 58 | #define debug(x,args...) | ||
| 59 | #endif | ||
| 60 | |||
| 61 | |||
| 62 | struct au1000_pcmcia_socket au1000_pcmcia_socket[PCMCIA_NUM_SOCKS]; | ||
| 63 | extern int au1x00_pcmcia_socket_probe(struct device *, struct pcmcia_low_level *, int, int); | ||
| 64 | |||
| 65 | static int db1x00_pcmcia_hw_init(struct au1000_pcmcia_socket *skt) | ||
| 66 | { | ||
| 67 | #ifdef CONFIG_MIPS_DB1550 | ||
| 68 | skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_3; | ||
| 69 | #elif defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200) | ||
| 70 | skt->irq = skt->nr ? BOARD_PC1_INT : BOARD_PC0_INT; | ||
| 71 | #else | ||
| 72 | skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_2; | ||
| 73 | #endif | ||
| 74 | return 0; | ||
| 75 | } | ||
| 76 | |||
| 77 | static void db1x00_pcmcia_shutdown(struct au1000_pcmcia_socket *skt) | ||
| 78 | { | ||
| 79 | bcsr_write(BCSR_PCMCIA, 0); /* turn off power */ | ||
| 80 | msleep(2); | ||
| 81 | } | ||
| 82 | |||
| 83 | static void | ||
| 84 | db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state *state) | ||
| 85 | { | ||
| 86 | u32 inserted; | ||
| 87 | unsigned char vs; | ||
| 88 | |||
| 89 | state->ready = 0; | ||
| 90 | state->vs_Xv = 0; | ||
| 91 | state->vs_3v = 0; | ||
| 92 | state->detect = 0; | ||
| 93 | |||
| 94 | switch (skt->nr) { | ||
| 95 | case 0: | ||
| 96 | vs = bcsr_read(BCSR_STATUS) & 0x3; | ||
| 97 | #if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200) | ||
| 98 | inserted = BOARD_CARD_INSERTED(0); | ||
| 99 | #else | ||
| 100 | inserted = !(bcsr_read(BCSR_STATUS) & (1 << 4)); | ||
| 101 | #endif | ||
| 102 | break; | ||
| 103 | case 1: | ||
| 104 | vs = (bcsr_read(BCSR_STATUS) & 0xC) >> 2; | ||
| 105 | #if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200) | ||
| 106 | inserted = BOARD_CARD_INSERTED(1); | ||
| 107 | #else | ||
| 108 | inserted = !(bcsr_read(BCSR_STATUS) & (1<<5)); | ||
| 109 | #endif | ||
| 110 | break; | ||
| 111 | default:/* should never happen */ | ||
| 112 | return; | ||
| 113 | } | ||
| 114 | |||
| 115 | if (inserted) | ||
| 116 | debug("db1x00 socket %d: inserted %d, vs %d pcmcia %x\n", | ||
| 117 | skt->nr, inserted, vs, bcsr_read(BCSR_PCMCIA)); | ||
| 118 | |||
| 119 | if (inserted) { | ||
| 120 | switch (vs) { | ||
| 121 | case 0: | ||
| 122 | case 2: | ||
| 123 | state->vs_3v=1; | ||
| 124 | break; | ||
| 125 | case 3: /* 5V */ | ||
| 126 | break; | ||
| 127 | default: | ||
| 128 | /* return without setting 'detect' */ | ||
| 129 | printk(KERN_ERR "db1x00 bad VS (%d)\n", | ||
| 130 | vs); | ||
| 131 | } | ||
| 132 | state->detect = 1; | ||
| 133 | state->ready = 1; | ||
| 134 | } | ||
| 135 | else { | ||
| 136 | /* if the card was previously inserted and then ejected, | ||
| 137 | * we should turn off power to it | ||
| 138 | */ | ||
| 139 | if ((skt->nr == 0) && | ||
| 140 | (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC0RST)) { | ||
| 141 | bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC0RST | | ||
| 142 | BCSR_PCMCIA_PC0DRVEN | | ||
| 143 | BCSR_PCMCIA_PC0VPP | | ||
| 144 | BCSR_PCMCIA_PC0VCC, 0); | ||
| 145 | msleep(10); | ||
| 146 | } | ||
| 147 | else if ((skt->nr == 1) && | ||
| 148 | (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC1RST)) { | ||
| 149 | bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC1RST | | ||
| 150 | BCSR_PCMCIA_PC1DRVEN | | ||
| 151 | BCSR_PCMCIA_PC1VPP | | ||
| 152 | BCSR_PCMCIA_PC1VCC, 0); | ||
| 153 | msleep(10); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | state->bvd1=1; | ||
| 158 | state->bvd2=1; | ||
| 159 | state->wrprot=0; | ||
| 160 | } | ||
| 161 | |||
| 162 | static int | ||
| 163 | db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_state_t *state) | ||
| 164 | { | ||
| 165 | u16 pwr; | ||
| 166 | int sock = skt->nr; | ||
| 167 | |||
| 168 | debug("config_skt %d Vcc %dV Vpp %dV, reset %d\n", | ||
| 169 | sock, state->Vcc, state->Vpp, | ||
| 170 | state->flags & SS_RESET); | ||
| 171 | |||
| 172 | /* pcmcia reg was set to zero at init time. Be careful when | ||
| 173 | * initializing a socket not to wipe out the settings of the | ||
| 174 | * other socket. | ||
| 175 | */ | ||
| 176 | pwr = bcsr_read(BCSR_PCMCIA); | ||
| 177 | pwr &= ~(0xf << sock*8); /* clear voltage settings */ | ||
| 178 | |||
| 179 | state->Vpp = 0; | ||
| 180 | switch(state->Vcc){ | ||
| 181 | case 0: /* Vcc 0 */ | ||
| 182 | pwr |= SET_VCC_VPP(0,0,sock); | ||
| 183 | break; | ||
| 184 | case 50: /* Vcc 5V */ | ||
| 185 | switch(state->Vpp) { | ||
| 186 | case 0: | ||
| 187 | pwr |= SET_VCC_VPP(2,0,sock); | ||
| 188 | break; | ||
| 189 | case 50: | ||
| 190 | pwr |= SET_VCC_VPP(2,1,sock); | ||
| 191 | break; | ||
| 192 | case 12: | ||
| 193 | pwr |= SET_VCC_VPP(2,2,sock); | ||
| 194 | break; | ||
| 195 | case 33: | ||
| 196 | default: | ||
| 197 | pwr |= SET_VCC_VPP(0,0,sock); | ||
| 198 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | ||
| 199 | __func__, | ||
| 200 | state->Vcc, | ||
| 201 | state->Vpp); | ||
| 202 | break; | ||
| 203 | } | ||
| 204 | break; | ||
| 205 | case 33: /* Vcc 3.3V */ | ||
| 206 | switch(state->Vpp) { | ||
| 207 | case 0: | ||
| 208 | pwr |= SET_VCC_VPP(1,0,sock); | ||
| 209 | break; | ||
| 210 | case 12: | ||
| 211 | pwr |= SET_VCC_VPP(1,2,sock); | ||
| 212 | break; | ||
| 213 | case 33: | ||
| 214 | pwr |= SET_VCC_VPP(1,1,sock); | ||
| 215 | break; | ||
| 216 | case 50: | ||
| 217 | default: | ||
| 218 | pwr |= SET_VCC_VPP(0,0,sock); | ||
| 219 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | ||
| 220 | __func__, | ||
| 221 | state->Vcc, | ||
| 222 | state->Vpp); | ||
| 223 | break; | ||
| 224 | } | ||
| 225 | break; | ||
| 226 | default: /* what's this ? */ | ||
| 227 | pwr |= SET_VCC_VPP(0,0,sock); | ||
| 228 | printk(KERN_ERR "%s: bad Vcc %d\n", | ||
| 229 | __func__, state->Vcc); | ||
| 230 | break; | ||
| 231 | } | ||
| 232 | |||
| 233 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 234 | msleep(300); | ||
| 235 | |||
| 236 | if (sock == 0) { | ||
| 237 | if (!(state->flags & SS_RESET)) { | ||
| 238 | pwr |= BCSR_PCMCIA_PC0DRVEN; | ||
| 239 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 240 | msleep(300); | ||
| 241 | pwr |= BCSR_PCMCIA_PC0RST; | ||
| 242 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 243 | msleep(100); | ||
| 244 | } | ||
| 245 | else { | ||
| 246 | pwr &= ~(BCSR_PCMCIA_PC0RST | BCSR_PCMCIA_PC0DRVEN); | ||
| 247 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 248 | msleep(100); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | else { | ||
| 252 | if (!(state->flags & SS_RESET)) { | ||
| 253 | pwr |= BCSR_PCMCIA_PC1DRVEN; | ||
| 254 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 255 | msleep(300); | ||
| 256 | pwr |= BCSR_PCMCIA_PC1RST; | ||
| 257 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 258 | msleep(100); | ||
| 259 | } | ||
| 260 | else { | ||
| 261 | pwr &= ~(BCSR_PCMCIA_PC1RST | BCSR_PCMCIA_PC1DRVEN); | ||
| 262 | bcsr_write(BCSR_PCMCIA, pwr); | ||
| 263 | msleep(100); | ||
| 264 | } | ||
| 265 | } | ||
| 266 | return 0; | ||
| 267 | } | ||
| 268 | |||
| 269 | /* | ||
| 270 | * Enable card status IRQs on (re-)initialisation. This can | ||
| 271 | * be called at initialisation, power management event, or | ||
| 272 | * pcmcia event. | ||
| 273 | */ | ||
| 274 | void db1x00_socket_init(struct au1000_pcmcia_socket *skt) | ||
| 275 | { | ||
| 276 | /* nothing to do for now */ | ||
| 277 | } | ||
| 278 | |||
| 279 | /* | ||
| 280 | * Disable card status IRQs and PCMCIA bus on suspend. | ||
| 281 | */ | ||
| 282 | void db1x00_socket_suspend(struct au1000_pcmcia_socket *skt) | ||
| 283 | { | ||
| 284 | /* nothing to do for now */ | ||
| 285 | } | ||
| 286 | |||
| 287 | struct pcmcia_low_level db1x00_pcmcia_ops = { | ||
| 288 | .owner = THIS_MODULE, | ||
| 289 | |||
| 290 | .hw_init = db1x00_pcmcia_hw_init, | ||
| 291 | .hw_shutdown = db1x00_pcmcia_shutdown, | ||
| 292 | |||
| 293 | .socket_state = db1x00_pcmcia_socket_state, | ||
| 294 | .configure_socket = db1x00_pcmcia_configure_socket, | ||
| 295 | |||
| 296 | .socket_init = db1x00_socket_init, | ||
| 297 | .socket_suspend = db1x00_socket_suspend | ||
| 298 | }; | ||
| 299 | |||
| 300 | int au1x_board_init(struct device *dev) | ||
| 301 | { | ||
| 302 | int ret = -ENODEV; | ||
| 303 | bcsr_write(BCSR_PCMCIA, 0); /* turn off power, if it's not already off */ | ||
| 304 | msleep(2); | ||
| 305 | ret = au1x00_pcmcia_socket_probe(dev, &db1x00_pcmcia_ops, 0, 2); | ||
| 306 | return ret; | ||
| 307 | } | ||
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h index 13a4fbc58711..aa743f6875bd 100644 --- a/drivers/pcmcia/au1000_generic.h +++ b/drivers/pcmcia/au1000_generic.h | |||
| @@ -44,22 +44,12 @@ | |||
| 44 | /* pcmcia socket 1 needs external glue logic so the memory map | 44 | /* pcmcia socket 1 needs external glue logic so the memory map |
| 45 | * differs from board to board. | 45 | * differs from board to board. |
| 46 | */ | 46 | */ |
| 47 | #if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || \ | 47 | #if defined(CONFIG_MIPS_PB1000) |
| 48 | defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1550) || \ | ||
| 49 | defined(CONFIG_MIPS_PB1200) | ||
| 50 | #define AU1X_SOCK1_IO 0xF08000000ULL | 48 | #define AU1X_SOCK1_IO 0xF08000000ULL |
| 51 | #define AU1X_SOCK1_PHYS_ATTR 0xF48000000ULL | 49 | #define AU1X_SOCK1_PHYS_ATTR 0xF48000000ULL |
| 52 | #define AU1X_SOCK1_PHYS_MEM 0xF88000000ULL | 50 | #define AU1X_SOCK1_PHYS_MEM 0xF88000000ULL |
| 53 | #define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000 | 51 | #define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000 |
| 54 | #define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000 | 52 | #define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000 |
| 55 | #elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || \ | ||
| 56 | defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) || \ | ||
| 57 | defined(CONFIG_MIPS_DB1200) | ||
| 58 | #define AU1X_SOCK1_IO 0xF04000000ULL | ||
| 59 | #define AU1X_SOCK1_PHYS_ATTR 0xF44000000ULL | ||
| 60 | #define AU1X_SOCK1_PHYS_MEM 0xF84000000ULL | ||
| 61 | #define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4400000 | ||
| 62 | #define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8400000 | ||
| 63 | #endif | 53 | #endif |
| 64 | 54 | ||
| 65 | struct pcmcia_state { | 55 | struct pcmcia_state { |
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c index b1984ed72d1d..5a979cb8f3e6 100644 --- a/drivers/pcmcia/au1000_pb1x00.c +++ b/drivers/pcmcia/au1000_pb1x00.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * | 2 | * |
| 3 | * Alchemy Semi Pb1x00 boards specific pcmcia routines. | 3 | * Alchemy Semi Pb1000 boards specific pcmcia routines. |
| 4 | * | 4 | * |
| 5 | * Copyright 2002 MontaVista Software Inc. | 5 | * Copyright 2002 MontaVista Software Inc. |
| 6 | * Author: MontaVista Software, Inc. | 6 | * Author: MontaVista Software, Inc. |
| @@ -46,20 +46,11 @@ | |||
| 46 | 46 | ||
| 47 | #define debug(fmt, arg...) do { } while (0) | 47 | #define debug(fmt, arg...) do { } while (0) |
| 48 | 48 | ||
| 49 | #ifdef CONFIG_MIPS_PB1000 | ||
| 50 | #include <asm/pb1000.h> | 49 | #include <asm/pb1000.h> |
| 51 | #define PCMCIA_IRQ AU1000_GPIO_15 | 50 | #define PCMCIA_IRQ AU1000_GPIO_15 |
| 52 | #elif defined (CONFIG_MIPS_PB1500) | ||
| 53 | #include <asm/pb1500.h> | ||
| 54 | #define PCMCIA_IRQ AU1500_GPIO_203 | ||
| 55 | #elif defined (CONFIG_MIPS_PB1100) | ||
| 56 | #include <asm/pb1100.h> | ||
| 57 | #define PCMCIA_IRQ AU1000_GPIO_11 | ||
| 58 | #endif | ||
| 59 | 51 | ||
| 60 | static int pb1x00_pcmcia_init(struct pcmcia_init *init) | 52 | static int pb1x00_pcmcia_init(struct pcmcia_init *init) |
| 61 | { | 53 | { |
| 62 | #ifdef CONFIG_MIPS_PB1000 | ||
| 63 | u16 pcr; | 54 | u16 pcr; |
| 64 | pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; | 55 | pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; |
| 65 | 56 | ||
| @@ -74,21 +65,10 @@ static int pb1x00_pcmcia_init(struct pcmcia_init *init) | |||
| 74 | au_sync_delay(20); | 65 | au_sync_delay(20); |
| 75 | 66 | ||
| 76 | return PCMCIA_NUM_SOCKS; | 67 | return PCMCIA_NUM_SOCKS; |
| 77 | |||
| 78 | #else /* fixme -- take care of the Pb1500 at some point */ | ||
| 79 | |||
| 80 | u16 pcr; | ||
| 81 | pcr = au_readw(PCMCIA_BOARD_REG) & ~0xf; /* turn off power */ | ||
| 82 | pcr &= ~(PC_DEASSERT_RST | PC_DRV_EN); | ||
| 83 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 84 | au_sync_delay(500); | ||
| 85 | return PCMCIA_NUM_SOCKS; | ||
| 86 | #endif | ||
| 87 | } | 68 | } |
| 88 | 69 | ||
| 89 | static int pb1x00_pcmcia_shutdown(void) | 70 | static int pb1x00_pcmcia_shutdown(void) |
| 90 | { | 71 | { |
| 91 | #ifdef CONFIG_MIPS_PB1000 | ||
| 92 | u16 pcr; | 72 | u16 pcr; |
| 93 | pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; | 73 | pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST; |
| 94 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0); | 74 | pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0); |
| @@ -96,14 +76,6 @@ static int pb1x00_pcmcia_shutdown(void) | |||
| 96 | au_writel(pcr, PB1000_PCR); | 76 | au_writel(pcr, PB1000_PCR); |
| 97 | au_sync_delay(20); | 77 | au_sync_delay(20); |
| 98 | return 0; | 78 | return 0; |
| 99 | #else | ||
| 100 | u16 pcr; | ||
| 101 | pcr = au_readw(PCMCIA_BOARD_REG) & ~0xf; /* turn off power */ | ||
| 102 | pcr &= ~(PC_DEASSERT_RST | PC_DRV_EN); | ||
| 103 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 104 | au_sync_delay(2); | ||
| 105 | return 0; | ||
| 106 | #endif | ||
| 107 | } | 79 | } |
| 108 | 80 | ||
| 109 | static int | 81 | static int |
| @@ -112,21 +84,11 @@ pb1x00_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) | |||
| 112 | u32 inserted0, inserted1; | 84 | u32 inserted0, inserted1; |
| 113 | u16 vs0, vs1; | 85 | u16 vs0, vs1; |
| 114 | 86 | ||
| 115 | #ifdef CONFIG_MIPS_PB1000 | ||
| 116 | vs0 = vs1 = (u16)au_readl(PB1000_ACR1); | 87 | vs0 = vs1 = (u16)au_readl(PB1000_ACR1); |
| 117 | inserted0 = !(vs0 & (ACR1_SLOT_0_CD1 | ACR1_SLOT_0_CD2)); | 88 | inserted0 = !(vs0 & (ACR1_SLOT_0_CD1 | ACR1_SLOT_0_CD2)); |
| 118 | inserted1 = !(vs1 & (ACR1_SLOT_1_CD1 | ACR1_SLOT_1_CD2)); | 89 | inserted1 = !(vs1 & (ACR1_SLOT_1_CD1 | ACR1_SLOT_1_CD2)); |
| 119 | vs0 = (vs0 >> 4) & 0x3; | 90 | vs0 = (vs0 >> 4) & 0x3; |
| 120 | vs1 = (vs1 >> 12) & 0x3; | 91 | vs1 = (vs1 >> 12) & 0x3; |
| 121 | #else | ||
| 122 | vs0 = (au_readw(BOARD_STATUS_REG) >> 4) & 0x3; | ||
| 123 | #ifdef CONFIG_MIPS_PB1500 | ||
| 124 | inserted0 = !((au_readl(GPIO2_PINSTATE) >> 1) & 0x1); /* gpio 201 */ | ||
| 125 | #else /* Pb1100 */ | ||
| 126 | inserted0 = !((au_readl(SYS_PINSTATERD) >> 9) & 0x1); /* gpio 9 */ | ||
| 127 | #endif | ||
| 128 | inserted1 = 0; | ||
| 129 | #endif | ||
| 130 | 92 | ||
| 131 | state->ready = 0; | 93 | state->ready = 0; |
| 132 | state->vs_Xv = 0; | 94 | state->vs_Xv = 0; |
| @@ -203,7 +165,6 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
| 203 | 165 | ||
| 204 | if(configure->sock > PCMCIA_MAX_SOCK) return -1; | 166 | if(configure->sock > PCMCIA_MAX_SOCK) return -1; |
| 205 | 167 | ||
| 206 | #ifdef CONFIG_MIPS_PB1000 | ||
| 207 | pcr = au_readl(PB1000_PCR); | 168 | pcr = au_readl(PB1000_PCR); |
| 208 | 169 | ||
| 209 | if (configure->sock == 0) { | 170 | if (configure->sock == 0) { |
| @@ -323,84 +284,6 @@ pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure) | |||
| 323 | au_writel(pcr, PB1000_PCR); | 284 | au_writel(pcr, PB1000_PCR); |
| 324 | au_sync_delay(300); | 285 | au_sync_delay(300); |
| 325 | 286 | ||
| 326 | #else | ||
| 327 | |||
| 328 | pcr = au_readw(PCMCIA_BOARD_REG) & ~0xf; | ||
| 329 | |||
| 330 | debug("Vcc %dV Vpp %dV, pcr %x, reset %d\n", | ||
| 331 | configure->vcc, configure->vpp, pcr, configure->reset); | ||
| 332 | |||
| 333 | |||
| 334 | switch(configure->vcc){ | ||
| 335 | case 0: /* Vcc 0 */ | ||
| 336 | pcr |= SET_VCC_VPP(0,0); | ||
| 337 | break; | ||
| 338 | case 50: /* Vcc 5V */ | ||
| 339 | switch(configure->vpp) { | ||
| 340 | case 0: | ||
| 341 | pcr |= SET_VCC_VPP(2,0); | ||
| 342 | break; | ||
| 343 | case 50: | ||
| 344 | pcr |= SET_VCC_VPP(2,1); | ||
| 345 | break; | ||
| 346 | case 12: | ||
| 347 | pcr |= SET_VCC_VPP(2,2); | ||
| 348 | break; | ||
| 349 | case 33: | ||
| 350 | default: | ||
| 351 | pcr |= SET_VCC_VPP(0,0); | ||
| 352 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | ||
| 353 | __func__, | ||
| 354 | configure->vcc, | ||
| 355 | configure->vpp); | ||
| 356 | break; | ||
| 357 | } | ||
| 358 | break; | ||
| 359 | case 33: /* Vcc 3.3V */ | ||
| 360 | switch(configure->vpp) { | ||
| 361 | case 0: | ||
| 362 | pcr |= SET_VCC_VPP(1,0); | ||
| 363 | break; | ||
| 364 | case 12: | ||
| 365 | pcr |= SET_VCC_VPP(1,2); | ||
| 366 | break; | ||
| 367 | case 33: | ||
| 368 | pcr |= SET_VCC_VPP(1,1); | ||
| 369 | break; | ||
| 370 | case 50: | ||
| 371 | default: | ||
| 372 | pcr |= SET_VCC_VPP(0,0); | ||
| 373 | printk("%s: bad Vcc/Vpp (%d:%d)\n", | ||
| 374 | __func__, | ||
| 375 | configure->vcc, | ||
| 376 | configure->vpp); | ||
| 377 | break; | ||
| 378 | } | ||
| 379 | break; | ||
| 380 | default: /* what's this ? */ | ||
| 381 | pcr |= SET_VCC_VPP(0,0); | ||
| 382 | printk(KERN_ERR "%s: bad Vcc %d\n", | ||
| 383 | __func__, configure->vcc); | ||
| 384 | break; | ||
| 385 | } | ||
| 386 | |||
| 387 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 388 | au_sync_delay(300); | ||
| 389 | |||
| 390 | if (!configure->reset) { | ||
| 391 | pcr |= PC_DRV_EN; | ||
| 392 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 393 | au_sync_delay(100); | ||
| 394 | pcr |= PC_DEASSERT_RST; | ||
| 395 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 396 | au_sync_delay(100); | ||
| 397 | } | ||
| 398 | else { | ||
| 399 | pcr &= ~(PC_DEASSERT_RST | PC_DRV_EN); | ||
| 400 | au_writew(pcr, PCMCIA_BOARD_REG); | ||
| 401 | au_sync_delay(100); | ||
| 402 | } | ||
| 403 | #endif | ||
| 404 | return 0; | 287 | return 0; |
| 405 | } | 288 | } |
| 406 | 289 | ||
diff --git a/drivers/pcmcia/db1xxx_ss.c b/drivers/pcmcia/db1xxx_ss.c new file mode 100644 index 000000000000..b35b72b0d5b5 --- /dev/null +++ b/drivers/pcmcia/db1xxx_ss.c | |||
| @@ -0,0 +1,630 @@ | |||
| 1 | /* | ||
| 2 | * PCMCIA socket code for the Alchemy Db1xxx/Pb1xxx boards. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2009 Manuel Lauss <manuel.lauss@gmail.com> | ||
| 5 | * | ||
| 6 | */ | ||
| 7 | |||
| 8 | /* This is a fairly generic PCMCIA socket driver suitable for the | ||
| 9 | * following Alchemy Development boards: | ||
| 10 | * Db1000, Db/Pb1500, Db/Pb1100, Db/Pb1550, Db/Pb1200. | ||
| 11 | * | ||
| 12 | * The Db1000 is used as a reference: Per-socket card-, carddetect- and | ||
| 13 | * statuschange IRQs connected to SoC GPIOs, control and status register | ||
| 14 | * bits arranged in per-socket groups in an external PLD. All boards | ||
| 15 | * listed here use this layout, including bit positions and meanings. | ||
| 16 | * Of course there are exceptions in later boards: | ||
| 17 | * | ||
| 18 | * - Pb1100/Pb1500: single socket only; voltage key bits VS are | ||
| 19 | * at STATUS[5:4] (instead of STATUS[1:0]). | ||
| 20 | * - Au1200-based: additional card-eject irqs, irqs not gpios! | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/delay.h> | ||
| 24 | #include <linux/gpio.h> | ||
| 25 | #include <linux/interrupt.h> | ||
| 26 | #include <linux/pm.h> | ||
| 27 | #include <linux/platform_device.h> | ||
| 28 | #include <linux/resource.h> | ||
| 29 | #include <linux/spinlock.h> | ||
| 30 | |||
| 31 | #include <pcmcia/cs_types.h> | ||
| 32 | #include <pcmcia/ss.h> | ||
| 33 | |||
| 34 | #include <asm/mach-au1x00/au1000.h> | ||
| 35 | #include <asm/mach-db1x00/bcsr.h> | ||
| 36 | |||
| 37 | #define MEM_MAP_SIZE 0x400000 | ||
| 38 | #define IO_MAP_SIZE 0x1000 | ||
| 39 | |||
| 40 | struct db1x_pcmcia_sock { | ||
| 41 | struct pcmcia_socket socket; | ||
| 42 | int nr; /* socket number */ | ||
| 43 | void *virt_io; | ||
| 44 | |||
| 45 | /* the "pseudo" addresses of the PCMCIA space. */ | ||
| 46 | unsigned long phys_io; | ||
| 47 | unsigned long phys_attr; | ||
| 48 | unsigned long phys_mem; | ||
| 49 | |||
| 50 | /* previous flags for set_socket() */ | ||
| 51 | unsigned int old_flags; | ||
| 52 | |||
| 53 | /* interrupt sources: linux irq numbers! */ | ||
| 54 | int insert_irq; /* default carddetect irq */ | ||
| 55 | int stschg_irq; /* card-status-change irq */ | ||
| 56 | int card_irq; /* card irq */ | ||
| 57 | int eject_irq; /* db1200/pb1200 have these */ | ||
| 58 | |||
| 59 | #define BOARD_TYPE_DEFAULT 0 /* most boards */ | ||
| 60 | #define BOARD_TYPE_DB1200 1 /* IRQs aren't gpios */ | ||
| 61 | #define BOARD_TYPE_PB1100 2 /* VS bits slightly different */ | ||
| 62 | int board_type; | ||
| 63 | }; | ||
| 64 | |||
| 65 | #define to_db1x_socket(x) container_of(x, struct db1x_pcmcia_sock, socket) | ||
| 66 | |||
| 67 | /* DB/PB1200: check CPLD SIGSTATUS register bit 10/12 */ | ||
| 68 | static int db1200_card_inserted(struct db1x_pcmcia_sock *sock) | ||
| 69 | { | ||
| 70 | unsigned short sigstat; | ||
| 71 | |||
| 72 | sigstat = bcsr_read(BCSR_SIGSTAT); | ||
| 73 | return sigstat & 1 << (8 + 2 * sock->nr); | ||
| 74 | } | ||
| 75 | |||
| 76 | /* carddetect gpio: low-active */ | ||
| 77 | static int db1000_card_inserted(struct db1x_pcmcia_sock *sock) | ||
| 78 | { | ||
| 79 | return !gpio_get_value(irq_to_gpio(sock->insert_irq)); | ||
| 80 | } | ||
| 81 | |||
| 82 | static int db1x_card_inserted(struct db1x_pcmcia_sock *sock) | ||
| 83 | { | ||
| 84 | switch (sock->board_type) { | ||
| 85 | case BOARD_TYPE_DB1200: | ||
| 86 | return db1200_card_inserted(sock); | ||
| 87 | default: | ||
| 88 | return db1000_card_inserted(sock); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | /* STSCHG tends to bounce heavily when cards are inserted/ejected. | ||
| 93 | * To avoid this, the interrupt is normally disabled and only enabled | ||
| 94 | * after reset to a card has been de-asserted. | ||
| 95 | */ | ||
| 96 | static inline void set_stschg(struct db1x_pcmcia_sock *sock, int en) | ||
| 97 | { | ||
| 98 | if (sock->stschg_irq != -1) { | ||
| 99 | if (en) | ||
| 100 | enable_irq(sock->stschg_irq); | ||
| 101 | else | ||
| 102 | disable_irq(sock->stschg_irq); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | static irqreturn_t db1000_pcmcia_cdirq(int irq, void *data) | ||
| 107 | { | ||
| 108 | struct db1x_pcmcia_sock *sock = data; | ||
| 109 | |||
| 110 | pcmcia_parse_events(&sock->socket, SS_DETECT); | ||
| 111 | |||
| 112 | return IRQ_HANDLED; | ||
| 113 | } | ||
| 114 | |||
| 115 | static irqreturn_t db1000_pcmcia_stschgirq(int irq, void *data) | ||
| 116 | { | ||
| 117 | struct db1x_pcmcia_sock *sock = data; | ||
| 118 | |||
| 119 | pcmcia_parse_events(&sock->socket, SS_STSCHG); | ||
| 120 | |||
| 121 | return IRQ_HANDLED; | ||
| 122 | } | ||
| 123 | |||
| 124 | static irqreturn_t db1200_pcmcia_cdirq(int irq, void *data) | ||
| 125 | { | ||
| 126 | struct db1x_pcmcia_sock *sock = data; | ||
| 127 | |||
| 128 | /* Db/Pb1200 have separate per-socket insertion and ejection | ||
| 129 | * interrupts which stay asserted as long as the card is | ||
| 130 | * inserted/missing. The one which caused us to be called | ||
| 131 | * needs to be disabled and the other one enabled. | ||
| 132 | */ | ||
| 133 | if (irq == sock->insert_irq) { | ||
| 134 | disable_irq_nosync(sock->insert_irq); | ||
| 135 | enable_irq(sock->eject_irq); | ||
| 136 | } else { | ||
| 137 | disable_irq_nosync(sock->eject_irq); | ||
| 138 | enable_irq(sock->insert_irq); | ||
| 139 | } | ||
| 140 | |||
| 141 | pcmcia_parse_events(&sock->socket, SS_DETECT); | ||
| 142 | |||
| 143 | return IRQ_HANDLED; | ||
| 144 | } | ||
| 145 | |||
| 146 | static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock) | ||
| 147 | { | ||
| 148 | int ret; | ||
| 149 | unsigned long flags; | ||
| 150 | |||
| 151 | if (sock->stschg_irq != -1) { | ||
| 152 | ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq, | ||
| 153 | 0, "pcmcia_stschg", sock); | ||
| 154 | if (ret) | ||
| 155 | return ret; | ||
| 156 | } | ||
| 157 | |||
| 158 | /* Db/Pb1200 have separate per-socket insertion and ejection | ||
| 159 | * interrupts, which should show edge behaviour but don't. | ||
| 160 | * So interrupts are disabled until both insertion and | ||
| 161 | * ejection handler have been registered and the currently | ||
| 162 | * active one disabled. | ||
| 163 | */ | ||
| 164 | if (sock->board_type == BOARD_TYPE_DB1200) { | ||
| 165 | local_irq_save(flags); | ||
| 166 | |||
| 167 | ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq, | ||
| 168 | IRQF_DISABLED, "pcmcia_insert", sock); | ||
| 169 | if (ret) | ||
| 170 | goto out1; | ||
| 171 | |||
| 172 | ret = request_irq(sock->eject_irq, db1200_pcmcia_cdirq, | ||
| 173 | IRQF_DISABLED, "pcmcia_eject", sock); | ||
| 174 | if (ret) { | ||
| 175 | free_irq(sock->insert_irq, sock); | ||
| 176 | local_irq_restore(flags); | ||
| 177 | goto out1; | ||
| 178 | } | ||
| 179 | |||
| 180 | /* disable the currently active one */ | ||
| 181 | if (db1200_card_inserted(sock)) | ||
| 182 | disable_irq_nosync(sock->insert_irq); | ||
| 183 | else | ||
| 184 | disable_irq_nosync(sock->eject_irq); | ||
| 185 | |||
| 186 | local_irq_restore(flags); | ||
| 187 | } else { | ||
| 188 | /* all other (older) Db1x00 boards use a GPIO to show | ||
| 189 | * card detection status: use both-edge triggers. | ||
| 190 | */ | ||
| 191 | set_irq_type(sock->insert_irq, IRQ_TYPE_EDGE_BOTH); | ||
| 192 | ret = request_irq(sock->insert_irq, db1000_pcmcia_cdirq, | ||
| 193 | 0, "pcmcia_carddetect", sock); | ||
| 194 | |||
| 195 | if (ret) | ||
| 196 | goto out1; | ||
| 197 | } | ||
| 198 | |||
| 199 | return 0; /* all done */ | ||
| 200 | |||
| 201 | out1: | ||
| 202 | if (sock->stschg_irq != -1) | ||
| 203 | free_irq(sock->stschg_irq, sock); | ||
| 204 | |||
| 205 | return ret; | ||
| 206 | } | ||
| 207 | |||
| 208 | static void db1x_pcmcia_free_irqs(struct db1x_pcmcia_sock *sock) | ||
| 209 | { | ||
| 210 | if (sock->stschg_irq != -1) | ||
| 211 | free_irq(sock->stschg_irq, sock); | ||
| 212 | |||
| 213 | free_irq(sock->insert_irq, sock); | ||
| 214 | if (sock->eject_irq != -1) | ||
| 215 | free_irq(sock->eject_irq, sock); | ||
| 216 | } | ||
| 217 | |||
| 218 | /* | ||
| 219 | * configure a PCMCIA socket on the Db1x00 series of boards (and | ||
| 220 | * compatibles). | ||
| 221 | * | ||
| 222 | * 2 external registers are involved: | ||
| 223 | * pcmcia_status (offset 0x04): bits [0:1/2:3]: read card voltage id | ||
| 224 | * pcmcia_control(offset 0x10): | ||
| 225 | * bits[0:1] set vcc for card | ||
| 226 | * bits[2:3] set vpp for card | ||
| 227 | * bit 4: enable data buffers | ||
| 228 | * bit 7: reset# for card | ||
| 229 | * add 8 for second socket. | ||
| 230 | */ | ||
| 231 | static int db1x_pcmcia_configure(struct pcmcia_socket *skt, | ||
| 232 | struct socket_state_t *state) | ||
| 233 | { | ||
| 234 | struct db1x_pcmcia_sock *sock = to_db1x_socket(skt); | ||
| 235 | unsigned short cr_clr, cr_set; | ||
| 236 | unsigned int changed; | ||
| 237 | int v, p, ret; | ||
| 238 | |||
| 239 | /* card voltage setup */ | ||
| 240 | cr_clr = (0xf << (sock->nr * 8)); /* clear voltage settings */ | ||
| 241 | cr_set = 0; | ||
| 242 | v = p = ret = 0; | ||
| 243 | |||
| 244 | switch (state->Vcc) { | ||
| 245 | case 50: | ||
| 246 | ++v; | ||
| 247 | case 33: | ||
| 248 | ++v; | ||
| 249 | case 0: | ||
| 250 | break; | ||
| 251 | default: | ||
| 252 | printk(KERN_INFO "pcmcia%d unsupported Vcc %d\n", | ||
| 253 | sock->nr, state->Vcc); | ||
| 254 | } | ||
| 255 | |||
| 256 | switch (state->Vpp) { | ||
| 257 | case 12: | ||
| 258 | ++p; | ||
| 259 | case 33: | ||
| 260 | case 50: | ||
| 261 | ++p; | ||
| 262 | case 0: | ||
| 263 | break; | ||
| 264 | default: | ||
| 265 | printk(KERN_INFO "pcmcia%d unsupported Vpp %d\n", | ||
| 266 | sock->nr, state->Vpp); | ||
| 267 | } | ||
| 268 | |||
| 269 | /* sanity check: Vpp must be 0, 12, or Vcc */ | ||
| 270 | if (((state->Vcc == 33) && (state->Vpp == 50)) || | ||
| 271 | ((state->Vcc == 50) && (state->Vpp == 33))) { | ||
| 272 | printk(KERN_INFO "pcmcia%d bad Vcc/Vpp combo (%d %d)\n", | ||
| 273 | sock->nr, state->Vcc, state->Vpp); | ||
| 274 | v = p = 0; | ||
| 275 | ret = -EINVAL; | ||
| 276 | } | ||
| 277 | |||
| 278 | /* create new voltage code */ | ||
| 279 | cr_set |= ((v << 2) | p) << (sock->nr * 8); | ||
| 280 | |||
| 281 | changed = state->flags ^ sock->old_flags; | ||
| 282 | |||
| 283 | if (changed & SS_RESET) { | ||
| 284 | if (state->flags & SS_RESET) { | ||
| 285 | set_stschg(sock, 0); | ||
| 286 | /* assert reset, disable io buffers */ | ||
| 287 | cr_clr |= (1 << (7 + (sock->nr * 8))); | ||
| 288 | cr_clr |= (1 << (4 + (sock->nr * 8))); | ||
| 289 | } else { | ||
| 290 | /* de-assert reset, enable io buffers */ | ||
| 291 | cr_set |= 1 << (7 + (sock->nr * 8)); | ||
| 292 | cr_set |= 1 << (4 + (sock->nr * 8)); | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 | /* update PCMCIA configuration */ | ||
| 297 | bcsr_mod(BCSR_PCMCIA, cr_clr, cr_set); | ||
| 298 | |||
| 299 | sock->old_flags = state->flags; | ||
| 300 | |||
| 301 | /* reset was taken away: give card time to initialize properly */ | ||
| 302 | if ((changed & SS_RESET) && !(state->flags & SS_RESET)) { | ||
| 303 | msleep(500); | ||
| 304 | set_stschg(sock, 1); | ||
| 305 | } | ||
| 306 | |||
| 307 | return ret; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* VCC bits at [3:2]/[11:10] */ | ||
| 311 | #define GET_VCC(cr, socknr) \ | ||
| 312 | ((((cr) >> 2) >> ((socknr) * 8)) & 3) | ||
| 313 | |||
| 314 | /* VS bits at [0:1]/[3:2] */ | ||
| 315 | #define GET_VS(sr, socknr) \ | ||
| 316 | (((sr) >> (2 * (socknr))) & 3) | ||
| 317 | |||
| 318 | /* reset bits at [7]/[15] */ | ||
| 319 | #define GET_RESET(cr, socknr) \ | ||
| 320 | ((cr) & (1 << (7 + (8 * (socknr))))) | ||
| 321 | |||
| 322 | static int db1x_pcmcia_get_status(struct pcmcia_socket *skt, | ||
| 323 | unsigned int *value) | ||
| 324 | { | ||
| 325 | struct db1x_pcmcia_sock *sock = to_db1x_socket(skt); | ||
| 326 | unsigned short cr, sr; | ||
| 327 | unsigned int status; | ||
| 328 | |||
| 329 | status = db1x_card_inserted(sock) ? SS_DETECT : 0; | ||
| 330 | |||
| 331 | cr = bcsr_read(BCSR_PCMCIA); | ||
| 332 | sr = bcsr_read(BCSR_STATUS); | ||
| 333 | |||
| 334 | /* PB1100/PB1500: voltage key bits are at [5:4] */ | ||
| 335 | if (sock->board_type == BOARD_TYPE_PB1100) | ||
| 336 | sr >>= 4; | ||
| 337 | |||
| 338 | /* determine card type */ | ||
| 339 | switch (GET_VS(sr, sock->nr)) { | ||
| 340 | case 0: | ||
| 341 | case 2: | ||
| 342 | status |= SS_3VCARD; /* 3V card */ | ||
| 343 | case 3: | ||
| 344 | break; /* 5V card: set nothing */ | ||
| 345 | default: | ||
| 346 | status |= SS_XVCARD; /* treated as unsupported in core */ | ||
| 347 | } | ||
| 348 | |||
| 349 | /* if Vcc is not zero, we have applied power to a card */ | ||
| 350 | status |= GET_VCC(cr, sock->nr) ? SS_POWERON : 0; | ||
| 351 | |||
| 352 | /* reset de-asserted? then we're ready */ | ||
| 353 | status |= (GET_RESET(cr, sock->nr)) ? SS_READY : SS_RESET; | ||
| 354 | |||
| 355 | *value = status; | ||
| 356 | |||
| 357 | return 0; | ||
| 358 | } | ||
| 359 | |||
| 360 | static int db1x_pcmcia_sock_init(struct pcmcia_socket *skt) | ||
| 361 | { | ||
| 362 | return 0; | ||
| 363 | } | ||
| 364 | |||
| 365 | static int db1x_pcmcia_sock_suspend(struct pcmcia_socket *skt) | ||
| 366 | { | ||
| 367 | return 0; | ||
| 368 | } | ||
| 369 | |||
| 370 | static int au1x00_pcmcia_set_io_map(struct pcmcia_socket *skt, | ||
| 371 | struct pccard_io_map *map) | ||
| 372 | { | ||
| 373 | struct db1x_pcmcia_sock *sock = to_db1x_socket(skt); | ||
| 374 | |||
| 375 | map->start = (u32)sock->virt_io; | ||
| 376 | map->stop = map->start + IO_MAP_SIZE; | ||
| 377 | |||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 381 | static int au1x00_pcmcia_set_mem_map(struct pcmcia_socket *skt, | ||
| 382 | struct pccard_mem_map *map) | ||
| 383 | { | ||
| 384 | struct db1x_pcmcia_sock *sock = to_db1x_socket(skt); | ||
| 385 | |||
| 386 | if (map->flags & MAP_ATTRIB) | ||
| 387 | map->static_start = sock->phys_attr + map->card_start; | ||
| 388 | else | ||
| 389 | map->static_start = sock->phys_mem + map->card_start; | ||
| 390 | |||
| 391 | return 0; | ||
| 392 | } | ||
| 393 | |||
| 394 | static struct pccard_operations db1x_pcmcia_operations = { | ||
| 395 | .init = db1x_pcmcia_sock_init, | ||
| 396 | .suspend = db1x_pcmcia_sock_suspend, | ||
| 397 | .get_status = db1x_pcmcia_get_status, | ||
| 398 | .set_socket = db1x_pcmcia_configure, | ||
| 399 | .set_io_map = au1x00_pcmcia_set_io_map, | ||
| 400 | .set_mem_map = au1x00_pcmcia_set_mem_map, | ||
| 401 | }; | ||
| 402 | |||
| 403 | static int __devinit db1x_pcmcia_socket_probe(struct platform_device *pdev) | ||
| 404 | { | ||
| 405 | struct db1x_pcmcia_sock *sock; | ||
| 406 | struct resource *r; | ||
| 407 | phys_t physio; | ||
| 408 | int ret, bid; | ||
| 409 | |||
| 410 | sock = kzalloc(sizeof(struct db1x_pcmcia_sock), GFP_KERNEL); | ||
| 411 | if (!sock) | ||
| 412 | return -ENOMEM; | ||
| 413 | |||
| 414 | sock->nr = pdev->id; | ||
| 415 | |||
| 416 | bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); | ||
| 417 | switch (bid) { | ||
| 418 | case BCSR_WHOAMI_PB1500: | ||
| 419 | case BCSR_WHOAMI_PB1500R2: | ||
| 420 | case BCSR_WHOAMI_PB1100: | ||
| 421 | sock->board_type = BOARD_TYPE_PB1100; | ||
| 422 | break; | ||
| 423 | case BCSR_WHOAMI_DB1000 ... BCSR_WHOAMI_PB1550_SDR: | ||
| 424 | sock->board_type = BOARD_TYPE_DEFAULT; | ||
| 425 | break; | ||
| 426 | case BCSR_WHOAMI_PB1200 ... BCSR_WHOAMI_DB1200: | ||
| 427 | sock->board_type = BOARD_TYPE_DB1200; | ||
| 428 | break; | ||
| 429 | default: | ||
| 430 | printk(KERN_INFO "db1xxx-ss: unknown board %d!\n", bid); | ||
| 431 | ret = -ENODEV; | ||
| 432 | goto out0; | ||
| 433 | }; | ||
| 434 | |||
| 435 | /* | ||
| 436 | * gather resources necessary and optional nice-to-haves to | ||
| 437 | * operate a socket: | ||
| 438 | * This includes IRQs for Carddetection/ejection, the card | ||
| 439 | * itself and optional status change detection. | ||
| 440 | * Also, the memory areas covered by a socket. For these | ||
| 441 | * we require the 32bit "pseudo" addresses (see the au1000.h | ||
| 442 | * header for more information). | ||
| 443 | */ | ||
| 444 | |||
| 445 | /* card: irq assigned to the card itself. */ | ||
| 446 | r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "card"); | ||
| 447 | sock->card_irq = r ? r->start : 0; | ||
| 448 | |||
| 449 | /* insert: irq which triggers on card insertion/ejection */ | ||
| 450 | r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "insert"); | ||
| 451 | sock->insert_irq = r ? r->start : -1; | ||
| 452 | |||
| 453 | /* stschg: irq which trigger on card status change (optional) */ | ||
| 454 | r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "stschg"); | ||
| 455 | sock->stschg_irq = r ? r->start : -1; | ||
| 456 | |||
| 457 | /* eject: irq which triggers on ejection (DB1200/PB1200 only) */ | ||
| 458 | r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "eject"); | ||
| 459 | sock->eject_irq = r ? r->start : -1; | ||
| 460 | |||
| 461 | ret = -ENODEV; | ||
| 462 | |||
| 463 | /* | ||
| 464 | * pseudo-attr: The 32bit address of the PCMCIA attribute space | ||
| 465 | * for this socket (usually the 36bit address shifted 4 to the | ||
| 466 | * right). | ||
| 467 | */ | ||
| 468 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-attr"); | ||
| 469 | if (!r) { | ||
| 470 | printk(KERN_ERR "pcmcia%d has no 'pseudo-attr' resource!\n", | ||
| 471 | sock->nr); | ||
| 472 | goto out0; | ||
| 473 | } | ||
| 474 | sock->phys_attr = r->start; | ||
| 475 | |||
| 476 | /* | ||
| 477 | * pseudo-mem: The 32bit address of the PCMCIA memory space for | ||
| 478 | * this socket (usually the 36bit address shifted 4 to the right) | ||
| 479 | */ | ||
| 480 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-mem"); | ||
| 481 | if (!r) { | ||
| 482 | printk(KERN_ERR "pcmcia%d has no 'pseudo-mem' resource!\n", | ||
| 483 | sock->nr); | ||
| 484 | goto out0; | ||
| 485 | } | ||
| 486 | sock->phys_mem = r->start; | ||
| 487 | |||
| 488 | /* | ||
| 489 | * pseudo-io: The 32bit address of the PCMCIA IO space for this | ||
| 490 | * socket (usually the 36bit address shifted 4 to the right). | ||
| 491 | */ | ||
| 492 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-io"); | ||
| 493 | if (!r) { | ||
| 494 | printk(KERN_ERR "pcmcia%d has no 'pseudo-io' resource!\n", | ||
| 495 | sock->nr); | ||
| 496 | goto out0; | ||
| 497 | } | ||
| 498 | sock->phys_io = r->start; | ||
| 499 | |||
| 500 | |||
| 501 | /* IO: we must remap the full 36bit address (for reference see | ||
| 502 | * alchemy/common/setup.c::__fixup_bigphys_addr()) | ||
| 503 | */ | ||
| 504 | physio = ((phys_t)sock->phys_io) << 4; | ||
| 505 | |||
| 506 | /* | ||
| 507 | * PCMCIA client drivers use the inb/outb macros to access | ||
| 508 | * the IO registers. Since mips_io_port_base is added | ||
| 509 | * to the access address of the mips implementation of | ||
| 510 | * inb/outb, we need to subtract it here because we want | ||
| 511 | * to access the I/O or MEM address directly, without | ||
| 512 | * going through this "mips_io_port_base" mechanism. | ||
| 513 | */ | ||
| 514 | sock->virt_io = (void *)(ioremap(physio, IO_MAP_SIZE) - | ||
| 515 | mips_io_port_base); | ||
| 516 | |||
| 517 | if (!sock->virt_io) { | ||
| 518 | printk(KERN_ERR "pcmcia%d: cannot remap IO area\n", | ||
| 519 | sock->nr); | ||
| 520 | ret = -ENOMEM; | ||
| 521 | goto out0; | ||
| 522 | } | ||
| 523 | |||
| 524 | sock->socket.ops = &db1x_pcmcia_operations; | ||
| 525 | sock->socket.owner = THIS_MODULE; | ||
| 526 | sock->socket.pci_irq = sock->card_irq; | ||
| 527 | sock->socket.features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD; | ||
| 528 | sock->socket.map_size = MEM_MAP_SIZE; | ||
| 529 | sock->socket.io_offset = (unsigned long)sock->virt_io; | ||
| 530 | sock->socket.dev.parent = &pdev->dev; | ||
| 531 | sock->socket.resource_ops = &pccard_static_ops; | ||
| 532 | |||
| 533 | platform_set_drvdata(pdev, sock); | ||
| 534 | |||
| 535 | ret = db1x_pcmcia_setup_irqs(sock); | ||
| 536 | if (ret) { | ||
| 537 | printk(KERN_ERR "pcmcia%d cannot setup interrupts\n", | ||
| 538 | sock->nr); | ||
| 539 | goto out1; | ||
| 540 | } | ||
| 541 | |||
| 542 | set_stschg(sock, 0); | ||
| 543 | |||
| 544 | ret = pcmcia_register_socket(&sock->socket); | ||
| 545 | if (ret) { | ||
| 546 | printk(KERN_ERR "pcmcia%d failed to register\n", sock->nr); | ||
| 547 | goto out2; | ||
| 548 | } | ||
| 549 | |||
| 550 | printk(KERN_INFO "Alchemy Db/Pb1xxx pcmcia%d @ io/attr/mem %08lx" | ||
| 551 | "(%p) %08lx %08lx card/insert/stschg/eject irqs @ %d " | ||
| 552 | "%d %d %d\n", sock->nr, sock->phys_io, sock->virt_io, | ||
| 553 | sock->phys_attr, sock->phys_mem, sock->card_irq, | ||
| 554 | sock->insert_irq, sock->stschg_irq, sock->eject_irq); | ||
| 555 | |||
| 556 | return 0; | ||
| 557 | |||
| 558 | out2: | ||
| 559 | db1x_pcmcia_free_irqs(sock); | ||
| 560 | out1: | ||
| 561 | iounmap((void *)(sock->virt_io + (u32)mips_io_port_base)); | ||
| 562 | out0: | ||
| 563 | kfree(sock); | ||
| 564 | return ret; | ||
| 565 | } | ||
| 566 | |||
| 567 | static int __devexit db1x_pcmcia_socket_remove(struct platform_device *pdev) | ||
| 568 | { | ||
| 569 | struct db1x_pcmcia_sock *sock = platform_get_drvdata(pdev); | ||
| 570 | |||
| 571 | db1x_pcmcia_free_irqs(sock); | ||
| 572 | pcmcia_unregister_socket(&sock->socket); | ||
| 573 | iounmap((void *)(sock->virt_io + (u32)mips_io_port_base)); | ||
| 574 | kfree(sock); | ||
| 575 | |||
| 576 | return 0; | ||
| 577 | } | ||
| 578 | |||
| 579 | #ifdef CONFIG_PM | ||
| 580 | static int db1x_pcmcia_suspend(struct device *dev) | ||
| 581 | { | ||
| 582 | return pcmcia_socket_dev_suspend(dev); | ||
| 583 | } | ||
| 584 | |||
| 585 | static int db1x_pcmcia_resume(struct device *dev) | ||
| 586 | { | ||
| 587 | return pcmcia_socket_dev_resume(dev); | ||
| 588 | } | ||
| 589 | |||
| 590 | static struct dev_pm_ops db1x_pcmcia_pmops = { | ||
| 591 | .resume = db1x_pcmcia_resume, | ||
| 592 | .suspend = db1x_pcmcia_suspend, | ||
| 593 | .thaw = db1x_pcmcia_resume, | ||
| 594 | .freeze = db1x_pcmcia_suspend, | ||
| 595 | }; | ||
| 596 | |||
| 597 | #define DB1XXX_SS_PMOPS &db1x_pcmcia_pmops | ||
| 598 | |||
| 599 | #else | ||
| 600 | |||
| 601 | #define DB1XXX_SS_PMOPS NULL | ||
| 602 | |||
| 603 | #endif | ||
| 604 | |||
| 605 | static struct platform_driver db1x_pcmcia_socket_driver = { | ||
| 606 | .driver = { | ||
| 607 | .name = "db1xxx_pcmcia", | ||
| 608 | .owner = THIS_MODULE, | ||
| 609 | .pm = DB1XXX_SS_PMOPS | ||
| 610 | }, | ||
| 611 | .probe = db1x_pcmcia_socket_probe, | ||
| 612 | .remove = __devexit_p(db1x_pcmcia_socket_remove), | ||
| 613 | }; | ||
| 614 | |||
| 615 | int __init db1x_pcmcia_socket_load(void) | ||
| 616 | { | ||
| 617 | return platform_driver_register(&db1x_pcmcia_socket_driver); | ||
| 618 | } | ||
| 619 | |||
| 620 | void __exit db1x_pcmcia_socket_unload(void) | ||
| 621 | { | ||
| 622 | platform_driver_unregister(&db1x_pcmcia_socket_driver); | ||
| 623 | } | ||
| 624 | |||
| 625 | module_init(db1x_pcmcia_socket_load); | ||
| 626 | module_exit(db1x_pcmcia_socket_unload); | ||
| 627 | |||
| 628 | MODULE_LICENSE("GPL"); | ||
| 629 | MODULE_DESCRIPTION("PCMCIA Socket Services for Alchemy Db/Pb1x00 boards"); | ||
| 630 | MODULE_AUTHOR("Manuel Lauss"); | ||
