Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/pcmcia/sa1100_neponset.c |
| 3 | * |
| 4 | * Neponset PCMCIA specific routines |
| 5 | */ |
| 6 | #include <linux/module.h> |
| 7 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/device.h> |
| 9 | #include <linux/errno.h> |
| 10 | #include <linux/init.h> |
| 11 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 12 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 14 | #include <mach/neponset.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/hardware/sa1111.h> |
| 16 | |
| 17 | #include "sa1111_generic.h" |
| 18 | |
| 19 | /* |
| 20 | * Neponset uses the Maxim MAX1600, with the following connections: |
| 21 | * |
| 22 | * MAX1600 Neponset |
| 23 | * |
| 24 | * A0VCC SA-1111 GPIO A<1> |
| 25 | * A1VCC SA-1111 GPIO A<0> |
| 26 | * A0VPP CPLD NCR A0VPP |
| 27 | * A1VPP CPLD NCR A1VPP |
| 28 | * B0VCC SA-1111 GPIO A<2> |
| 29 | * B1VCC SA-1111 GPIO A<3> |
| 30 | * B0VPP ground (slot B is CF) |
| 31 | * B1VPP ground (slot B is CF) |
| 32 | * |
| 33 | * VX VCC (5V) |
| 34 | * VY VCC3_3 (3.3V) |
| 35 | * 12INA 12V |
| 36 | * 12INB ground (slot B is CF) |
| 37 | * |
| 38 | * The MAX1600 CODE pin is tied to ground, placing the device in |
| 39 | * "Standard Intel code" mode. Refer to the Maxim data sheet for |
| 40 | * the corresponding truth table. |
| 41 | */ |
| 42 | |
| 43 | static int |
| 44 | neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) |
| 45 | { |
Russell King - ARM Linux | 701a5dc | 2009-03-29 19:42:44 +0100 | [diff] [blame] | 46 | struct sa1111_pcmcia_socket *s = to_skt(skt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | unsigned int ncr_mask, ncr_set, pa_dwr_mask, pa_dwr_set; |
| 48 | int ret; |
| 49 | |
| 50 | switch (skt->nr) { |
| 51 | case 0: |
| 52 | pa_dwr_mask = GPIO_A0 | GPIO_A1; |
| 53 | ncr_mask = NCR_A0VPP | NCR_A1VPP; |
| 54 | |
| 55 | if (state->Vpp == 0) |
| 56 | ncr_set = 0; |
| 57 | else if (state->Vpp == 120) |
| 58 | ncr_set = NCR_A1VPP; |
| 59 | else if (state->Vpp == state->Vcc) |
| 60 | ncr_set = NCR_A0VPP; |
| 61 | else { |
| 62 | printk(KERN_ERR "%s(): unrecognized VPP %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 63 | __func__, state->Vpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | return -1; |
| 65 | } |
| 66 | break; |
| 67 | |
| 68 | case 1: |
| 69 | pa_dwr_mask = GPIO_A2 | GPIO_A3; |
| 70 | ncr_mask = 0; |
| 71 | ncr_set = 0; |
| 72 | |
| 73 | if (state->Vpp != state->Vcc && state->Vpp != 0) { |
| 74 | printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 75 | __func__, state->Vpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | return -1; |
| 77 | } |
| 78 | break; |
| 79 | |
| 80 | default: |
| 81 | return -1; |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * pa_dwr_set is the mask for selecting Vcc on both sockets. |
| 86 | * pa_dwr_mask selects which bits (and therefore socket) we change. |
| 87 | */ |
| 88 | switch (state->Vcc) { |
| 89 | default: |
| 90 | case 0: pa_dwr_set = 0; break; |
| 91 | case 33: pa_dwr_set = GPIO_A1|GPIO_A2; break; |
| 92 | case 50: pa_dwr_set = GPIO_A0|GPIO_A3; break; |
| 93 | } |
| 94 | |
| 95 | ret = sa1111_pcmcia_configure_socket(skt, state); |
| 96 | if (ret == 0) { |
Linus Torvalds | 9e4db1c | 2012-03-27 18:17:02 -0700 | [diff] [blame] | 97 | neponset_ncr_frob(ncr_mask, ncr_set); |
Russell King - ARM Linux | 701a5dc | 2009-03-29 19:42:44 +0100 | [diff] [blame] | 98 | sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Russell King | 65c77dc | 2012-01-16 09:27:33 +0000 | [diff] [blame] | 101 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | static struct pcmcia_low_level neponset_pcmcia_ops = { |
| 105 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | .configure_socket = neponset_pcmcia_configure_socket, |
Russell King - ARM Linux | 701a5dc | 2009-03-29 19:42:44 +0100 | [diff] [blame] | 107 | .first = 0, |
| 108 | .nr = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Russell King | b29cf62 | 2009-09-27 17:30:21 +0100 | [diff] [blame] | 111 | int pcmcia_neponset_init(struct sa1111_dev *sadev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | { |
| 113 | int ret = -ENODEV; |
| 114 | |
| 115 | if (machine_is_assabet()) { |
| 116 | /* |
| 117 | * Set GPIO_A<3:0> to be outputs for the MAX1600, |
| 118 | * and switch to standby mode. |
| 119 | */ |
| 120 | sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0); |
| 121 | sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
| 122 | sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0); |
Russell King - ARM Linux | 701a5dc | 2009-03-29 19:42:44 +0100 | [diff] [blame] | 123 | sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops); |
| 124 | ret = sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops, |
| 125 | sa11xx_drv_pcmcia_add_one); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | return ret; |
| 129 | } |