Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/pcmcia/pxa2xx_lubbock.c |
| 3 | * |
| 4 | * Author: George Davis |
| 5 | * Created: Jan 10, 2002 |
| 6 | * Copyright: MontaVista Software Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c |
| 13 | * |
| 14 | * Lubbock PCMCIA specific routines. |
| 15 | * |
| 16 | */ |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/device.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/delay.h> |
| 23 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/hardware/sa1111.h> |
| 26 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #include "sa1111_generic.h" |
Russell King | f1f05ee | 2018-11-28 13:57:23 +0000 | [diff] [blame] | 29 | #include "max1600.h" |
| 30 | |
| 31 | static int lubbock_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 32 | { |
| 33 | struct max1600 *m; |
| 34 | int ret; |
| 35 | |
| 36 | ret = max1600_init(skt->socket.dev.parent, &m, |
| 37 | skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A, |
| 38 | MAX1600_CODE_HIGH); |
| 39 | if (ret == 0) |
| 40 | skt->driver_data = m; |
| 41 | |
| 42 | return ret; |
| 43 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 47 | const socket_state_t *state) |
| 48 | { |
Russell King | f1f05ee | 2018-11-28 13:57:23 +0000 | [diff] [blame] | 49 | struct max1600 *m = skt->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int ret = 0; |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* Lubbock uses the Maxim MAX1602, with the following connections: |
| 53 | * |
| 54 | * Socket 0 (PCMCIA): |
| 55 | * MAX1602 Lubbock Register |
| 56 | * Pin Signal |
| 57 | * ----- ------- ---------------------- |
| 58 | * A0VPP S0_PWR0 SA-1111 GPIO A<0> |
| 59 | * A1VPP S0_PWR1 SA-1111 GPIO A<1> |
| 60 | * A0VCC S0_PWR2 SA-1111 GPIO A<2> |
| 61 | * A1VCC S0_PWR3 SA-1111 GPIO A<3> |
| 62 | * VX VCC |
| 63 | * VY +3.3V |
| 64 | * 12IN +12V |
| 65 | * CODE +3.3V Cirrus Code, CODE = High (VY) |
| 66 | * |
| 67 | * Socket 1 (CF): |
| 68 | * MAX1602 Lubbock Register |
| 69 | * Pin Signal |
| 70 | * ----- ------- ---------------------- |
| 71 | * A0VPP GND VPP is not connected |
| 72 | * A1VPP GND VPP is not connected |
| 73 | * A0VCC S1_PWR0 MISC_WR<14> |
| 74 | * A1VCC S1_PWR1 MISC_WR<15> |
| 75 | * VX VCC |
| 76 | * VY +3.3V |
| 77 | * 12IN GND VPP is not connected |
| 78 | * CODE +3.3V Cirrus Code, CODE = High (VY) |
| 79 | * |
| 80 | */ |
| 81 | |
| 82 | again: |
| 83 | switch (skt->nr) { |
| 84 | case 0: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | case 1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | break; |
| 87 | |
| 88 | default: |
| 89 | ret = -1; |
| 90 | } |
| 91 | |
| 92 | if (ret == 0) |
| 93 | ret = sa1111_pcmcia_configure_socket(skt, state); |
Russell King | f1f05ee | 2018-11-28 13:57:23 +0000 | [diff] [blame] | 94 | if (ret == 0) |
| 95 | ret = max1600_configure(m, state->Vcc, state->Vpp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | #if 1 |
| 98 | if (ret == 0 && state->Vcc == 33) { |
| 99 | struct pcmcia_state new_state; |
| 100 | |
| 101 | /* |
| 102 | * HACK ALERT: |
| 103 | * We can't sense the voltage properly on Lubbock before |
| 104 | * actually applying some power to the socket (catch 22). |
| 105 | * Resense the socket Voltage Sense pins after applying |
| 106 | * socket power. |
| 107 | * |
| 108 | * Note: It takes about 2.5ms for the MAX1602 VCC output |
| 109 | * to rise. |
| 110 | */ |
| 111 | mdelay(3); |
| 112 | |
| 113 | sa1111_pcmcia_socket_state(skt, &new_state); |
| 114 | |
| 115 | if (!new_state.vs_3v && !new_state.vs_Xv) { |
| 116 | /* |
| 117 | * Switch to 5V, Configure socket with 5V voltage |
| 118 | */ |
Russell King | f1f05ee | 2018-11-28 13:57:23 +0000 | [diff] [blame] | 119 | max1600_configure(m, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | /* |
| 122 | * It takes about 100ms to turn off Vcc. |
| 123 | */ |
| 124 | mdelay(100); |
| 125 | |
| 126 | /* |
| 127 | * We need to hack around the const qualifier as |
| 128 | * well to keep this ugly workaround localized and |
| 129 | * not force it to the rest of the code. Barf bags |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 130 | * available in the seat pocket in front of you! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | */ |
| 132 | ((socket_state_t *)state)->Vcc = 50; |
| 133 | ((socket_state_t *)state)->Vpp = 50; |
| 134 | goto again; |
| 135 | } |
| 136 | } |
| 137 | #endif |
| 138 | |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | static struct pcmcia_low_level lubbock_pcmcia_ops = { |
| 143 | .owner = THIS_MODULE, |
Russell King | f1f05ee | 2018-11-28 13:57:23 +0000 | [diff] [blame] | 144 | .hw_init = lubbock_pcmcia_hw_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | .configure_socket = lubbock_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | .first = 0, |
| 147 | .nr = 2, |
| 148 | }; |
| 149 | |
| 150 | #include "pxa2xx_base.h" |
| 151 | |
David Brownell | 7bbaac1 | 2007-12-22 14:03:29 -0800 | [diff] [blame] | 152 | int pcmcia_lubbock_init(struct sa1111_dev *sadev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
Russell King | 3f8df89 | 2016-09-02 10:14:20 +0100 | [diff] [blame] | 154 | pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops); |
Robert Jarzmik | 817ed57 | 2016-09-01 08:31:08 +0200 | [diff] [blame] | 155 | pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops); |
Russell King | 3f8df89 | 2016-09-02 10:14:20 +0100 | [diff] [blame] | 156 | return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops, |
| 157 | pxa2xx_drv_pcmcia_add_one); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | MODULE_LICENSE("GPL"); |