Blame view

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