Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pcmcia/sa1100_jornada720.c |
| 3 | * |
| 4 | * Jornada720 PCMCIA specific routines |
| 5 | * |
| 6 | */ |
| 7 | #include <linux/module.h> |
| 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/device.h> |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/init.h> |
| 12 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 13 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/hardware/sa1111.h> |
| 15 | #include <asm/mach-types.h> |
| 16 | |
| 17 | #include "sa1111_generic.h" |
| 18 | |
| 19 | #define SOCKET0_POWER GPIO_GPIO0 |
| 20 | #define SOCKET0_3V GPIO_GPIO2 |
| 21 | #define SOCKET1_POWER (GPIO_GPIO1 | GPIO_GPIO3) |
| 22 | #warning *** Does SOCKET1_3V actually do anything? |
| 23 | #define SOCKET1_3V GPIO_GPIO3 |
| 24 | |
| 25 | static int jornada720_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 26 | { |
| 27 | /* |
| 28 | * What is all this crap for? |
| 29 | */ |
| 30 | GRER |= 0x00000002; |
| 31 | /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */ |
Michael Gernoth | 821ca47 | 2005-07-26 19:21:47 +0100 | [diff] [blame] | 32 | sa1111_set_io_dir(SA1111_DEV(skt->dev), GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); |
| 33 | sa1111_set_io(SA1111_DEV(skt->dev), GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 34 | sa1111_set_sleep_io(SA1111_DEV(skt->dev), GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
| 36 | return sa1111_pcmcia_hw_init(skt); |
| 37 | } |
| 38 | |
| 39 | static int |
| 40 | jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) |
| 41 | { |
| 42 | unsigned int pa_dwr_mask, pa_dwr_set; |
| 43 | int ret; |
| 44 | |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 45 | printk("%s(): config socket %d vcc %d vpp %d\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | skt->nr, state->Vcc, state->Vpp); |
| 47 | |
| 48 | switch (skt->nr) { |
| 49 | case 0: |
| 50 | pa_dwr_mask = SOCKET0_POWER | SOCKET0_3V; |
| 51 | |
| 52 | switch (state->Vcc) { |
| 53 | default: |
| 54 | case 0: pa_dwr_set = 0; break; |
| 55 | case 33: pa_dwr_set = SOCKET0_POWER | SOCKET0_3V; break; |
| 56 | case 50: pa_dwr_set = SOCKET0_POWER; break; |
| 57 | } |
| 58 | break; |
| 59 | |
| 60 | case 1: |
| 61 | pa_dwr_mask = SOCKET1_POWER; |
| 62 | |
| 63 | switch (state->Vcc) { |
| 64 | default: |
| 65 | case 0: pa_dwr_set = 0; break; |
| 66 | case 33: pa_dwr_set = SOCKET1_POWER; break; |
| 67 | case 50: pa_dwr_set = SOCKET1_POWER; break; |
| 68 | } |
| 69 | break; |
| 70 | |
| 71 | default: |
| 72 | return -1; |
| 73 | } |
| 74 | |
| 75 | if (state->Vpp != state->Vcc && state->Vpp != 0) { |
| 76 | printk(KERN_ERR "%s(): slot cannot support VPP %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 77 | __func__, state->Vpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | return -1; |
| 79 | } |
| 80 | |
| 81 | ret = sa1111_pcmcia_configure_socket(skt, state); |
| 82 | if (ret == 0) { |
| 83 | unsigned long flags; |
| 84 | |
| 85 | local_irq_save(flags); |
Michael Gernoth | 821ca47 | 2005-07-26 19:21:47 +0100 | [diff] [blame] | 86 | sa1111_set_io(SA1111_DEV(skt->dev), pa_dwr_mask, pa_dwr_set); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | local_irq_restore(flags); |
| 88 | } |
| 89 | |
| 90 | return ret; |
| 91 | } |
| 92 | |
| 93 | static struct pcmcia_low_level jornada720_pcmcia_ops = { |
| 94 | .owner = THIS_MODULE, |
| 95 | .hw_init = jornada720_pcmcia_hw_init, |
| 96 | .hw_shutdown = sa1111_pcmcia_hw_shutdown, |
| 97 | .socket_state = sa1111_pcmcia_socket_state, |
| 98 | .configure_socket = jornada720_pcmcia_configure_socket, |
| 99 | |
| 100 | .socket_init = sa1111_pcmcia_socket_init, |
| 101 | .socket_suspend = sa1111_pcmcia_socket_suspend, |
| 102 | }; |
| 103 | |
Kristoffer Ericson | 85e6c7a | 2008-02-03 22:08:10 +0100 | [diff] [blame] | 104 | int __devinit pcmcia_jornada720_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
| 106 | int ret = -ENODEV; |
| 107 | |
| 108 | if (machine_is_jornada720()) |
| 109 | ret = sa11xx_drv_pcmcia_probe(dev, &jornada720_pcmcia_ops, 0, 2); |
| 110 | |
| 111 | return ret; |
| 112 | } |