Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 13 | #include <linux/gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 16 | #include <mach/assabet.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | #include "sa1100_generic.h" |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 21 | { |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 22 | skt->stat[SOC_STAT_CD].gpio = ASSABET_GPIO_CF_CD; |
| 23 | skt->stat[SOC_STAT_CD].name = "CF CD"; |
| 24 | skt->stat[SOC_STAT_BVD1].gpio = ASSABET_GPIO_CF_BVD1; |
| 25 | skt->stat[SOC_STAT_BVD1].name = "CF BVD1"; |
| 26 | skt->stat[SOC_STAT_BVD2].gpio = ASSABET_GPIO_CF_BVD2; |
| 27 | skt->stat[SOC_STAT_BVD2].name = "CF BVD2"; |
| 28 | skt->stat[SOC_STAT_RDY].gpio = ASSABET_GPIO_CF_IRQ; |
| 29 | skt->stat[SOC_STAT_RDY].name = "CF RDY"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 31 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | static int |
| 35 | assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) |
| 36 | { |
| 37 | unsigned int mask; |
| 38 | |
| 39 | switch (state->Vcc) { |
| 40 | case 0: |
| 41 | mask = 0; |
| 42 | break; |
| 43 | |
| 44 | case 50: |
| 45 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 46 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | case 33: /* Can only apply 3.3V to the CF slot. */ |
| 49 | mask = ASSABET_BCR_CF_PWR; |
| 50 | break; |
| 51 | |
| 52 | default: |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 53 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | state->Vcc); |
| 55 | return -1; |
| 56 | } |
| 57 | |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 58 | /* Silently ignore Vpp, speaker enable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | if (state->flags & SS_RESET) |
| 61 | mask |= ASSABET_BCR_CF_RST; |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 62 | if (!(state->flags & SS_OUTPUT_ENA)) |
| 63 | mask |= ASSABET_BCR_CF_BUS_OFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Russell King | 03e0092 | 2012-01-13 23:02:15 +0000 | [diff] [blame] | 65 | ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR | |
| 66 | ASSABET_BCR_CF_BUS_OFF, mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | * Disable card status IRQs on suspend. |
| 73 | */ |
| 74 | static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) |
| 75 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | /* |
| 77 | * Tristate the CF bus signals. Also assert CF |
| 78 | * reset as per user guide page 4-11. |
| 79 | */ |
| 80 | ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST); |
| 81 | } |
| 82 | |
| 83 | static struct pcmcia_low_level assabet_pcmcia_ops = { |
| 84 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | .hw_init = assabet_pcmcia_hw_init, |
Russell King | a1d0500 | 2016-08-31 08:49:46 +0100 | [diff] [blame] | 86 | .socket_state = soc_common_cf_socket_state, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | .configure_socket = assabet_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | .socket_suspend = assabet_pcmcia_socket_suspend, |
| 89 | }; |
| 90 | |
Bill Pemberton | 34cdf25 | 2012-11-19 13:23:12 -0500 | [diff] [blame] | 91 | int pcmcia_assabet_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
| 93 | int ret = -ENODEV; |
| 94 | |
| 95 | if (machine_is_assabet() && !machine_has_neponset()) |
| 96 | ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1); |
| 97 | |
| 98 | return ret; |
| 99 | } |