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