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