Blame view

drivers/pcmcia/sa1111_badge4.c 3.75 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
9
  /*
   * linux/drivers/pcmcia/sa1100_badge4.c
   *
   * BadgePAD 4 PCMCIA specific routines
   *
   *   Christopher Hoover <ch@hpl.hp.com>
   *
   * Copyright (C) 2002 Hewlett-Packard Company
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
   */
  #include <linux/module.h>
  #include <linux/kernel.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
15
  #include <linux/device.h>
  #include <linux/errno.h>
  #include <linux/init.h>
a09e64fbc   Russell King   [ARM] Move includ...
16
  #include <mach/hardware.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
  #include <asm/mach-types.h>
a09e64fbc   Russell King   [ARM] Move includ...
18
  #include <mach/badge4.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
79
80
  #include <asm/hardware/sa1111.h>
  
  #include "sa1111_generic.h"
  
  /*
   * BadgePAD 4 Details
   *
   * PCM Vcc:
   *
   *  PCM Vcc on BadgePAD 4 can be jumpered for 3v3 (short pins 1 and 3
   *  on JP6) or 5v0 (short pins 3 and 5 on JP6).
   *
   * PCM Vpp:
   *
   *  PCM Vpp on BadgePAD 4 can be jumpered for 12v0 (short pins 4 and 6
   *  on JP6) or tied to PCM Vcc (short pins 2 and 4 on JP6).  N.B.,
   *  12v0 operation requires that the power supply actually supply 12v0
   *  via pin 7 of JP7.
   *
   * CF Vcc:
   *
   *  CF Vcc on BadgePAD 4 can be jumpered either for 3v3 (short pins 1
   *  and 2 on JP10) or 5v0 (short pins 2 and 3 on JP10).
   *
   * Unfortunately there's no way programmatically to determine how a
   * given board is jumpered.  This code assumes a default jumpering
   * as described below.
   *
   * If the defaults aren't correct, you may override them with a pcmv
   * setup argument: pcmv=<pcm vcc>,<pcm vpp>,<cf vcc>.  The units are
   * tenths of volts; e.g. pcmv=33,120,50 indicates 3v3 PCM Vcc, 12v0
   * PCM Vpp, and 5v0 CF Vcc.
   *
   */
  
  static int badge4_pcmvcc = 50;  /* pins 3 and 5 jumpered on JP6 */
  static int badge4_pcmvpp = 50;  /* pins 2 and 4 jumpered on JP6 */
  static int badge4_cfvcc = 33;   /* pins 1 and 2 jumpered on JP10 */
  
  static void complain_about_jumpering(const char *whom,
  				     const char *supply,
  				     int given, int wanted)
  {
  	printk(KERN_ERR
  	 "%s: %s %d.%dV wanted but board is jumpered for %s %d.%dV operation"
  	 "; re-jumper the board and/or use pcmv=xx,xx,xx
  ",
  	       whom, supply,
  	       wanted / 10, wanted % 10,
  	       supply,
  	       given / 10, given % 10);
  }
  
  static int
  badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  {
  	int ret;
  
  	switch (skt->nr) {
  	case 0:
  		if ((state->Vcc != 0) &&
  		    (state->Vcc != badge4_pcmvcc)) {
2e11cb4c5   Harvey Harrison   pcmcia: replace r...
81
  			complain_about_jumpering(__func__, "pcmvcc",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
84
85
86
87
  						 badge4_pcmvcc, state->Vcc);
  			// Apply power regardless of the jumpering.
  			// return -1;
  		}
  		if ((state->Vpp != 0) &&
  		    (state->Vpp != badge4_pcmvpp)) {
2e11cb4c5   Harvey Harrison   pcmcia: replace r...
88
  			complain_about_jumpering(__func__, "pcmvpp",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
90
91
92
93
94
95
96
  						 badge4_pcmvpp, state->Vpp);
  			return -1;
  		}
  		break;
  
  	case 1:
  		if ((state->Vcc != 0) &&
  		    (state->Vcc != badge4_cfvcc)) {
2e11cb4c5   Harvey Harrison   pcmcia: replace r...
97
  			complain_about_jumpering(__func__, "cfvcc",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  						 badge4_cfvcc, state->Vcc);
  			return -1;
  		}
  		break;
  
  	default:
  		return -1;
  	}
  
  	ret = sa1111_pcmcia_configure_socket(skt, state);
  	if (ret == 0) {
  		unsigned long flags;
  		int need5V;
  
  		local_irq_save(flags);
  
  		need5V = ((state->Vcc == 50) || (state->Vpp == 50));
  
  		badge4_set_5V(BADGE4_5V_PCMCIA_SOCK(skt->nr), need5V);
  
  		local_irq_restore(flags);
  	}
65c77dcaa   Russell King   PCMCIA: sa1111: p...
120
  	return ret;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
122
123
124
  }
  
  static struct pcmcia_low_level badge4_pcmcia_ops = {
  	.owner			= THIS_MODULE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
  	.configure_socket	= badge4_pcmcia_configure_socket,
701a5dc05   Russell King - ARM Linux   PCMCIA: sa1111: w...
126
127
  	.first			= 0,
  	.nr			= 2,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  };
cfd1f008c   Dmitry Eremin-Solenikov   pcmcia: sa1111: p...
129
  int pcmcia_badge4_init(struct sa1111_dev *dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130
  {
3f8df892b   Russell King   pcmcia: sa1111: f...
131
132
133
134
135
136
137
138
139
  	printk(KERN_INFO
  	       "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d
  ",
  	       __func__,
  	       badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
  
  	sa11xx_drv_pcmcia_ops(&badge4_pcmcia_ops);
  	return sa1111_pcmcia_add(dev, &badge4_pcmcia_ops,
  				 sa11xx_drv_pcmcia_add_one);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
  }
d4258247d   Arnd Bergmann   drivers/pcmcia/sa...
141
  #ifndef MODULE
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  static int __init pcmv_setup(char *s)
  {
  	int v[4];
  
  	s = get_options(s, ARRAY_SIZE(v), v);
  
  	if (v[0] >= 1) badge4_pcmvcc = v[1];
  	if (v[0] >= 2) badge4_pcmvpp = v[2];
  	if (v[0] >= 3) badge4_cfvcc = v[3];
  
  	return 1;
  }
  
  __setup("pcmv=", pcmv_setup);
d4258247d   Arnd Bergmann   drivers/pcmcia/sa...
156
  #endif