Version:  2.0.40 2.2.26 2.4.37 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4

Linux/drivers/pcmcia/i82365.c

  1 /*======================================================================
  2 
  3     Device driver for Intel 82365 and compatible PC Card controllers.
  4 
  5     i82365.c 1.265 1999/11/10 18:36:21
  6 
  7     The contents of this file are subject to the Mozilla Public
  8     License Version 1.1 (the "License"); you may not use this file
  9     except in compliance with the License. You may obtain a copy of
 10     the License at http://www.mozilla.org/MPL/
 11 
 12     Software distributed under the License is distributed on an "AS
 13     IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 14     implied. See the License for the specific language governing
 15     rights and limitations under the License.
 16 
 17     The initial developer of the original code is David A. Hinds
 18     <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
 19     are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 20 
 21     Alternatively, the contents of this file may be used under the
 22     terms of the GNU General Public License version 2 (the "GPL"), in which
 23     case the provisions of the GPL are applicable instead of the
 24     above.  If you wish to allow the use of your version of this file
 25     only under the terms of the GPL and not to allow others to use
 26     your version of this file under the MPL, indicate your decision
 27     by deleting the provisions above and replace them with the notice
 28     and other provisions required by the GPL.  If you do not delete
 29     the provisions above, a recipient may use your version of this
 30     file under either the MPL or the GPL.
 31     
 32 ======================================================================*/
 33 
 34 #include <linux/module.h>
 35 #include <linux/moduleparam.h>
 36 #include <linux/init.h>
 37 #include <linux/types.h>
 38 #include <linux/fcntl.h>
 39 #include <linux/string.h>
 40 #include <linux/kernel.h>
 41 #include <linux/errno.h>
 42 #include <linux/timer.h>
 43 #include <linux/ioport.h>
 44 #include <linux/delay.h>
 45 #include <linux/workqueue.h>
 46 #include <linux/interrupt.h>
 47 #include <linux/platform_device.h>
 48 #include <linux/bitops.h>
 49 #include <asm/irq.h>
 50 #include <asm/io.h>
 51 
 52 #include <pcmcia/ss.h>
 53 
 54 #include <linux/isapnp.h>
 55 
 56 /* ISA-bus controllers */
 57 #include "i82365.h"
 58 #include "cirrus.h"
 59 #include "vg468.h"
 60 #include "ricoh.h"
 61 
 62 
 63 static irqreturn_t i365_count_irq(int, void *);
 64 static inline int _check_irq(int irq, int flags)
 65 {
 66     if (request_irq(irq, i365_count_irq, flags, "x", i365_count_irq) != 0)
 67         return -1;
 68     free_irq(irq, i365_count_irq);
 69     return 0;
 70 }
 71 
 72 /*====================================================================*/
 73 
 74 /* Parameters that can be set with 'insmod' */
 75 
 76 /* Default base address for i82365sl and other ISA chips */
 77 static unsigned long i365_base = 0x3e0;
 78 /* Should we probe at 0x3e2 for an extra ISA controller? */
 79 static int extra_sockets = 0;
 80 /* Specify a socket number to ignore */
 81 static int ignore = -1;
 82 /* Bit map or list of interrupts to choose from */
 83 static u_int irq_mask = 0xffff;
 84 static int irq_list[16];
 85 static unsigned int irq_list_count;
 86 /* The card status change interrupt -- 0 means autoselect */
 87 static int cs_irq = 0;
 88 
 89 /* Probe for safe interrupts? */
 90 static int do_scan = 1;
 91 /* Poll status interval -- 0 means default to interrupt */
 92 static int poll_interval = 0;
 93 /* External clock time, in nanoseconds.  120 ns = 8.33 MHz */
 94 static int cycle_time = 120;
 95 
 96 /* Cirrus options */
 97 static int has_dma = -1;
 98 static int has_led = -1;
 99 static int has_ring = -1;
100 static int dynamic_mode = 0;
101 static int freq_bypass = -1;
102 static int setup_time = -1;
103 static int cmd_time = -1;
104 static int recov_time = -1;
105 
106 /* Vadem options */
107 static int async_clock = -1;
108 static int cable_mode = -1;
109 static int wakeup = 0;
110 
111 module_param(i365_base, ulong, 0444);
112 module_param(ignore, int, 0444);
113 module_param(extra_sockets, int, 0444);
114 module_param(irq_mask, int, 0444);
115 module_param_array(irq_list, int, &irq_list_count, 0444);
116 module_param(cs_irq, int, 0444);
117 module_param(async_clock, int, 0444);
118 module_param(cable_mode, int, 0444);
119 module_param(wakeup, int, 0444);
120 
121 module_param(do_scan, int, 0444);
122 module_param(poll_interval, int, 0444);
123 module_param(cycle_time, int, 0444);
124 module_param(has_dma, int, 0444);
125 module_param(has_led, int, 0444);
126 module_param(has_ring, int, 0444);
127 module_param(dynamic_mode, int, 0444);
128 module_param(freq_bypass, int, 0444);
129 module_param(setup_time, int, 0444);
130 module_param(cmd_time, int, 0444);
131 module_param(recov_time, int, 0444);
132 
133 /*====================================================================*/
134 
135 struct cirrus_state {
136     u_char              misc1, misc2;
137     u_char              timer[6];
138 };
139 
140 struct vg46x_state {
141     u_char              ctl, ema;
142 };
143 
144 struct i82365_socket {
145     u_short             type, flags;
146     struct pcmcia_socket        socket;
147     unsigned int        number;
148     unsigned int        ioaddr;
149     u_short             psock;
150     u_char              cs_irq, intr;
151     union {
152         struct cirrus_state             cirrus;
153         struct vg46x_state              vg46x;
154     } state;
155 };
156 
157 /* Where we keep track of our sockets... */
158 static int sockets = 0;
159 static struct i82365_socket socket[8] = {
160     { 0, }, /* ... */
161 };
162 
163 /* Default ISA interrupt mask */
164 #define I365_MASK       0xdeb8  /* irq 15,14,12,11,10,9,7,5,4,3 */
165 
166 static int grab_irq;
167 static DEFINE_SPINLOCK(isa_lock);
168 #define ISA_LOCK(n, f) spin_lock_irqsave(&isa_lock, f)
169 #define ISA_UNLOCK(n, f) spin_unlock_irqrestore(&isa_lock, f)
170 
171 static struct timer_list poll_timer;
172 
173 /*====================================================================*/
174 
175 /* These definitions must match the pcic table! */
176 enum pcic_id {
177     IS_I82365A, IS_I82365B, IS_I82365DF,