Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pcmcia/sa1100_cerf.c |
| 3 | * |
| 4 | * PCMCIA implementation routines for CerfBoard |
| 5 | * Based off the Assabet. |
| 6 | * |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/module.h> |
| 9 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/device.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/delay.h> |
Russell King | bbb58a1 | 2012-01-18 12:32:37 +0000 | [diff] [blame] | 13 | #include <linux/gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 15 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/mach-types.h> |
| 17 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 18 | #include <mach/cerf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include "sa1100_generic.h" |
| 20 | |
| 21 | #define CERF_SOCKET 1 |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 24 | { |
Russell King | bbb58a1 | 2012-01-18 12:32:37 +0000 | [diff] [blame] | 25 | int ret; |
| 26 | |
| 27 | ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, "CF_RESET"); |
| 28 | if (ret) |
| 29 | return ret; |
| 30 | |
Russell King | f793e3a | 2012-01-13 23:03:57 +0000 | [diff] [blame] | 31 | skt->stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD; |
| 32 | skt->stat[SOC_STAT_CD].name = "CF_CD"; |
| 33 | skt->stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1; |
| 34 | skt->stat[SOC_STAT_BVD1].name = "CF_BVD1"; |
| 35 | skt->stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2; |
| 36 | skt->stat[SOC_STAT_BVD2].name = "CF_BVD2"; |
| 37 | skt->stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ; |
| 38 | skt->stat[SOC_STAT_RDY].name = "CF_IRQ"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Russell King | f793e3a | 2012-01-13 23:03:57 +0000 | [diff] [blame] | 40 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Russell King | bbb58a1 | 2012-01-18 12:32:37 +0000 | [diff] [blame] | 43 | static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 44 | { |
| 45 | gpio_free(CERF_GPIO_CF_RESET); |
| 46 | } |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | static void |
| 49 | cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) |
| 50 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | state->vs_3v = 1; |
| 52 | state->vs_Xv = 0; |
| 53 | } |
| 54 | |
| 55 | static int |
| 56 | cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 57 | const socket_state_t *state) |
| 58 | { |
| 59 | switch (state->Vcc) { |
| 60 | case 0: |
| 61 | case 50: |
| 62 | case 33: |
| 63 | break; |
| 64 | |
| 65 | default: |
| 66 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 67 | __func__, state->Vcc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | return -1; |
| 69 | } |
| 70 | |
Russell King | bbb58a1 | 2012-01-18 12:32:37 +0000 | [diff] [blame] | 71 | gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | static struct pcmcia_low_level cerf_pcmcia_ops = { |
| 77 | .owner = THIS_MODULE, |
| 78 | .hw_init = cerf_pcmcia_hw_init, |
Russell King | bbb58a1 | 2012-01-18 12:32:37 +0000 | [diff] [blame] | 79 | .hw_shutdown = cerf_pcmcia_hw_shutdown, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | .socket_state = cerf_pcmcia_socket_state, |
| 81 | .configure_socket = cerf_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Bill Pemberton | 34cdf25 | 2012-11-19 13:23:12 -0500 | [diff] [blame] | 84 | int pcmcia_cerf_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
| 86 | int ret = -ENODEV; |
| 87 | |
| 88 | if (machine_is_cerf()) |
| 89 | ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1); |
| 90 | |
| 91 | return ret; |
| 92 | } |