ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / pcmcia / au1000_generic.c
1 /*
2  *
3  * Alchemy Semi Au1000 pcmcia driver
4  *
5  * Copyright 2001 MontaVista Software Inc.
6  * Author: MontaVista Software, Inc.
7  *              ppopov@mvista.com or source@mvista.com
8  *
9  * ########################################################################
10  *
11  *  This program is free software; you can distribute it and/or modify it
12  *  under the terms of the GNU General Public License (Version 2) as
13  *  published by the Free Software Foundation.
14  *
15  *  This program is distributed in the hope it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18  *  for more details.
19  *
20  *  You should have received a copy of the GNU General Public License along
21  *  with this program; if not, write to the Free Software Foundation, Inc.,
22  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23  *
24  * ########################################################################
25  *
26  * 
27  */
28 #include <linux/module.h>
29 #include <linux/moduleparam.h>
30 #include <linux/init.h>
31 #include <linux/config.h>
32 #include <linux/delay.h>
33 #include <linux/ioport.h>
34 #include <linux/kernel.h>
35 #include <linux/tqueue.h>
36 #include <linux/timer.h>
37 #include <linux/mm.h>
38 #include <linux/proc_fs.h>
39 #include <linux/types.h>
40 #include <linux/vmalloc.h>
41
42 #include <pcmcia/version.h>
43 #include <pcmcia/cs_types.h>
44 #include <pcmcia/cs.h>
45 #include <pcmcia/ss.h>
46 #include <pcmcia/bulkmem.h>
47 #include <pcmcia/cistpl.h>
48 #include <pcmcia/bus_ops.h>
49 #include "cs_internal.h"
50
51 #include <asm/io.h>
52 #include <asm/irq.h>
53 #include <asm/system.h>
54
55 #include <asm/au1000.h>
56 #include <asm/au1000_pcmcia.h>
57
58 #ifdef DEBUG
59 static int pc_debug;
60
61 module_param(pc_debug, int, 0644);
62
63 #define debug(lvl,fmt) do {                     \
64         if (pc_debug > (lvl))                   \
65                 printk(KERN_DEBUG fmt);         \
66 } while (0)
67 #else
68 #define debug(lvl,fmt) do { } while (0)
69 #endif
70
71 MODULE_LICENSE("GPL");
72 MODULE_AUTHOR("Pete Popov, MontaVista Software <ppopov@mvista.com>");
73 MODULE_DESCRIPTION("Linux PCMCIA Card Services: Au1x00 Socket Controller");
74
75 #define MAP_SIZE 0x1000000
76
77 /* This structure maintains housekeeping state for each socket, such
78  * as the last known values of the card detect pins, or the Card Services
79  * callback value associated with the socket:
80  */
81 static struct au1000_pcmcia_socket *pcmcia_socket;
82 static int socket_count;
83
84
85 /* Returned by the low-level PCMCIA interface: */
86 static struct pcmcia_low_level *pcmcia_low_level;
87
88 /* Event poll timer structure */
89 static struct timer_list poll_timer;
90
91
92 /* Prototypes for routines which are used internally: */
93
94 static int  au1000_pcmcia_driver_init(void);
95 static void au1000_pcmcia_driver_shutdown(void);
96 static void au1000_pcmcia_task_handler(void *data);
97 static void au1000_pcmcia_poll_event(unsigned long data);
98 static void au1000_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs);
99 static struct tq_struct au1000_pcmcia_task;
100
101 #ifdef CONFIG_PROC_FS
102 static int au1000_pcmcia_proc_status(char *buf, char **start, 
103                 off_t pos, int count, int *eof, void *data);
104 #endif
105
106
107 /* Prototypes for operations which are exported to the
108  * new-and-impr^H^H^H^H^H^H^H^H^H^H in-kernel PCMCIA core:
109  */
110
111 static int au1000_pcmcia_init(u32 sock);
112 static int au1000_pcmcia_suspend(u32 sock);
113 static int au1000_pcmcia_register_callback(u32 sock, 
114                 void (*handler)(void *, u32), void *info);
115 static int au1000_pcmcia_inquire_socket(u32 sock, socket_cap_t *cap);
116 static int au1000_pcmcia_get_status(u32 sock, u_int *value);
117 static int au1000_pcmcia_get_socket(u32 sock, socket_state_t *state);
118 static int au1000_pcmcia_set_socket(u32 sock, socket_state_t *state);
119 static int au1000_pcmcia_get_io_map(u32 sock, struct pccard_io_map *io);
120 static int au1000_pcmcia_set_io_map(u32 sock, struct pccard_io_map *io);
121 static int au1000_pcmcia_get_mem_map(u32 sock, struct pccard_mem_map *mem);
122 static int au1000_pcmcia_set_mem_map(u32 sock, struct pccard_mem_map *mem);
123 #ifdef CONFIG_PROC_FS
124 static void au1000_pcmcia_proc_setup(u32 sock, struct proc_dir_entry *base);
125 #endif
126
127 static struct pccard_operations au1000_pcmcia_operations = {
128         au1000_pcmcia_init,
129         au1000_pcmcia_suspend,
130         au1000_pcmcia_register_callback,
131         au1000_pcmcia_inquire_socket,
132         au1000_pcmcia_get_status,
133         au1000_pcmcia_get_socket,
134         au1000_pcmcia_set_socket,
135         au1000_pcmcia_get_io_map,
136         au1000_pcmcia_set_io_map,
137         au1000_pcmcia_get_mem_map,
138         au1000_pcmcia_set_mem_map,
139 #ifdef CONFIG_PROC_FS
140         au1000_pcmcia_proc_setup
141 #endif
142 };
143
144 static spinlock_t pcmcia_lock = SPIN_LOCK_UNLOCKED;
145
146 static int __init au1000_pcmcia_driver_init(void)
147 {
148         struct pcmcia_init pcmcia_init;
149         struct pcmcia_state state;
150         unsigned int i;
151
152         printk("\nAu1x00 PCMCIA\n");
153
154 #ifndef CONFIG_64BIT_PHYS_ADDR
155         printk(KERN_ERR "Au1x00 PCMCIA 36 bit IO support not enabled\n");
156         return -1;
157 #endif
158
159 #if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500)
160         pcmcia_low_level=&pb1x00_pcmcia_ops;
161 #else
162 #error Unsupported AU1000 board.
163 #endif
164
165         pcmcia_init.handler=au1000_pcmcia_interrupt;
166         if((socket_count=pcmcia_low_level->init(&pcmcia_init))<0) {
167                 printk(KERN_ERR "Unable to initialize PCMCIA service.\n");
168                 return -EIO;
169         }
170
171         /* NOTE: the chip select must already be setup */
172
173         pcmcia_socket = 
174                 kmalloc(sizeof(struct au1000_pcmcia_socket) * socket_count, 
175                                 GFP_KERNEL);
176         if (!pcmcia_socket) {
177                 printk(KERN_ERR "Card Services can't get memory \n");
178                 return -1;
179         }
180         memset(pcmcia_socket, 0,
181                         sizeof(struct au1000_pcmcia_socket) * socket_count);
182                         
183         /* 
184          * Assuming max of 2 sockets, which the Au1000 supports.
185          * WARNING: the Pb1000 has two sockets, and both work, but you
186          * can't use them both at the same time due to glue logic conflicts.
187          */
188         for(i=0; i < socket_count; i++) {
189
190                 if(pcmcia_low_level->socket_state(i, &state)<0){
191                         printk(KERN_ERR "Unable to get PCMCIA status\n");
192                         return -EIO;
193                 }
194                 pcmcia_socket[i].k_state=state;
195                 pcmcia_socket[i].cs_state.csc_mask=SS_DETECT;
196                 
197                 if (i == 0) {
198                         pcmcia_socket[i].virt_io = 
199                                 (u32)ioremap((ioaddr_t)0xF00000000, 0x1000);
200                         pcmcia_socket[i].phys_attr = (memaddr_t)0xF40000000;
201                         pcmcia_socket[i].phys_mem = (memaddr_t)0xF80000000;
202                 }
203                 else  {
204                         pcmcia_socket[i].virt_io = 
205                                 (u32)ioremap((ioaddr_t)0xF08000000, 0x1000);
206                         pcmcia_socket[i].phys_attr = (memaddr_t)0xF48000000;
207                         pcmcia_socket[i].phys_mem = (memaddr_t)0xF88000000;
208                 }
209         }
210
211         /* Only advertise as many sockets as we can detect: */
212         if(register_ss_entry(socket_count, &au1000_pcmcia_operations)<0){
213                 printk(KERN_ERR "Unable to register socket service routine\n");
214                 return -ENXIO;
215         }
216
217         /* Start the event poll timer.  
218          * It will reschedule by itself afterwards. 
219          */
220         au1000_pcmcia_poll_event(0);
221
222         debug(1, "au1000: initialization complete\n");
223         return 0;
224
225 }  /* au1000_pcmcia_driver_init() */
226
227 module_init(au1000_pcmcia_driver_init);
228
229 static void __exit au1000_pcmcia_driver_shutdown(void)
230 {
231         int i;
232
233         del_timer_sync(&poll_timer);
234         unregister_ss_entry(&au1000_pcmcia_operations);
235         pcmcia_low_level->shutdown();
236         flush_scheduled_tasks();
237         for(i=0; i < socket_count; i++) {
238                 if (pcmcia_socket[i].virt_io) 
239                         iounmap((void *)pcmcia_socket[i].virt_io);
240         }
241         debug(1, "au1000: shutdown complete\n");
242 }
243
244 module_exit(au1000_pcmcia_driver_shutdown);
245
246 static int au1000_pcmcia_init(unsigned int sock) { return 0; }
247
248 static int au1000_pcmcia_suspend(unsigned int sock)
249 {
250         return 0;
251 }
252
253
254 static inline unsigned 
255 au1000_pcmcia_events(struct pcmcia_state *state, 
256                 struct pcmcia_state *prev_state, 
257                 unsigned int mask, unsigned int flags)
258 {
259         unsigned int events=0;
260
261         if(state->detect!=prev_state->detect){
262                 debug(2, "%s(): card detect value %u\n", 
263                                 __FUNCTION__, state->detect);
264                 events |= mask&SS_DETECT;
265         }
266
267
268         if(state->ready!=prev_state->ready){
269                 debug(2, "%s(): card ready value %u\n", 
270                                 __FUNCTION__, state->ready);
271                 events |= mask&((flags&SS_IOCARD)?0:SS_READY);
272         }
273
274         *prev_state=*state;
275         return events;
276
277 }  /* au1000_pcmcia_events() */
278
279
280 /* 
281  * Au1000_pcmcia_task_handler()
282  * Processes socket events.
283  */
284 static void au1000_pcmcia_task_handler(void *data) 
285 {
286         struct pcmcia_state state;
287         int i, events, irq_status;
288
289         for(i=0; i<socket_count; i++)  {
290                 if((irq_status = pcmcia_low_level->socket_state(i, &state))<0)
291                         printk(KERN_ERR "low-level PCMCIA error\n");
292
293                 events = au1000_pcmcia_events(&state, 
294                                 &pcmcia_socket[i].k_state, 
295                                 pcmcia_socket[i].cs_state.csc_mask, 
296                                 pcmcia_socket[i].cs_state.flags);
297                 if(pcmcia_socket[i].handler!=NULL) {
298                         pcmcia_socket[i].handler(pcmcia_socket[i].handler_info,
299                                         events);
300                 }
301         }
302
303 }  /* au1000_pcmcia_task_handler() */
304
305 static struct tq_struct au1000_pcmcia_task = {
306         routine: au1000_pcmcia_task_handler
307 };
308
309
310 static void au1000_pcmcia_poll_event(unsigned long dummy)
311 {
312         poll_timer.function = au1000_pcmcia_poll_event;
313         poll_timer.expires = jiffies + AU1000_PCMCIA_POLL_PERIOD;
314         add_timer(&poll_timer);
315         schedule_task(&au1000_pcmcia_task);
316 }
317
318
319 /* 
320  * au1000_pcmcia_interrupt()
321  * The actual interrupt work is performed by au1000_pcmcia_task(), 
322  * because the Card Services event handling code performs scheduling 
323  * operations which cannot be executed from within an interrupt context.
324  */
325 static void 
326 au1000_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
327 {
328         schedule_task(&au1000_pcmcia_task);
329 }
330
331
332 static int 
333 au1000_pcmcia_register_callback(unsigned int sock, 
334                 void (*handler)(void *, unsigned int), void *info)
335 {
336         if(handler==NULL){
337                 pcmcia_socket[sock].handler=NULL;
338                 MOD_DEC_USE_COUNT;
339         } else {
340                 MOD_INC_USE_COUNT;
341                 pcmcia_socket[sock].handler=handler;
342                 pcmcia_socket[sock].handler_info=info;
343         }
344         return 0;
345 }
346
347
348 /* au1000_pcmcia_inquire_socket()
349  *
350  * From the sa1100 socket driver : 
351  *
352  * Implements the inquire_socket() operation for the in-kernel PCMCIA
353  * service (formerly SS_InquireSocket in Card Services).  We set 
354  * SS_CAP_STATIC_MAP, which disables the memory resource database check. 
355  * (Mapped memory is set up within the socket driver itself.)
356  *
357  * In conjunction with the STATIC_MAP capability is a new field,
358  * `io_offset', recommended by David Hinds. Rather than go through
359  * the SetIOMap interface (which is not quite suited for communicating
360  * window locations up from the socket driver), we just pass up 
361  * an offset which is applied to client-requested base I/O addresses
362  * in alloc_io_space().
363  *
364  * Returns: 0 on success, -1 if no pin has been configured for `sock'
365  */
366 static int au1000_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap)
367 {
368         struct pcmcia_irq_info irq_info;
369
370         if(sock > socket_count){
371                 printk(KERN_ERR "au1000: socket %u not configured\n", sock);
372                 return -1;
373         }
374
375         /* from the sa1100_generic driver: */
376
377         /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the
378         *   force_low argument to validate_mem() in rsrc_mgr.c -- since in
379         *   general, the mapped * addresses of the PCMCIA memory regions
380         *   will not be within 0xffff, setting force_low would be
381         *   undesirable.
382         *
383         * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory
384         *   resource database; we instead pass up physical address ranges
385         *   and allow other parts of Card Services to deal with remapping.
386         *
387         * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but
388         *   not 32-bit CardBus devices.
389         */
390         cap->features=(SS_CAP_PAGE_REGS  | SS_CAP_STATIC_MAP | SS_CAP_PCCARD);
391
392         irq_info.sock=sock;
393         irq_info.irq=-1;
394
395         if(pcmcia_low_level->get_irq_info(&irq_info)<0){
396                 printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock);
397                 return -1;
398         }
399
400         cap->irq_mask=0;
401         cap->map_size=MAP_SIZE;
402         cap->pci_irq=irq_info.irq;
403         cap->io_offset=pcmcia_socket[sock].virt_io;
404
405         return 0;
406
407 }  /* au1000_pcmcia_inquire_socket() */
408
409
410 static int 
411 au1000_pcmcia_get_status(unsigned int sock, unsigned int *status)
412 {
413         struct pcmcia_state state;
414
415
416         if((pcmcia_low_level->socket_state(sock, &state))<0){
417                 printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
418                 return -1;
419         }
420
421         pcmcia_socket[sock].k_state = state;
422
423         *status = state.detect?SS_DETECT:0;
424
425         *status |= state.ready?SS_READY:0;
426
427         *status |= pcmcia_socket[sock].cs_state.Vcc?SS_POWERON:0;
428
429         if(pcmcia_socket[sock].cs_state.flags&SS_IOCARD)
430                 *status |= state.bvd1?SS_STSCHG:0;
431         else {
432                 if(state.bvd1==0)
433                         *status |= SS_BATDEAD;
434                 else if(state.bvd2 == 0)
435                         *status |= SS_BATWARN;
436         }
437
438         *status|=state.vs_3v?SS_3VCARD:0;
439
440         *status|=state.vs_Xv?SS_XVCARD:0;
441
442         debug(2, "\tstatus: %s%s%s%s%s%s%s%s\n",
443         (*status&SS_DETECT)?"DETECT ":"",
444         (*status&SS_READY)?"READY ":"", 
445         (*status&SS_BATDEAD)?"BATDEAD ":"",
446         (*status&SS_BATWARN)?"BATWARN ":"",
447         (*status&SS_POWERON)?"POWERON ":"",
448         (*status&SS_STSCHG)?"STSCHG ":"",
449         (*status&SS_3VCARD)?"3VCARD ":"",
450         (*status&SS_XVCARD)?"XVCARD ":"");
451
452         return 0;
453
454 }  /* au1000_pcmcia_get_status() */
455
456
457 static int 
458 au1000_pcmcia_get_socket(unsigned int sock, socket_state_t *state)
459 {
460         *state = pcmcia_socket[sock].cs_state;
461         return 0;
462 }
463
464
465 static int 
466 au1000_pcmcia_set_socket(unsigned int sock, socket_state_t *state)
467 {
468         struct pcmcia_configure configure;
469
470         debug(2, "\tmask:  %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n"
471         "\tVcc %d  Vpp %d  irq %d\n",
472         (state->csc_mask==0)?"<NONE>":"",
473         (state->csc_mask&SS_DETECT)?"DETECT ":"",
474         (state->csc_mask&SS_READY)?"READY ":"",
475         (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
476         (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
477         (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
478         (state->flags==0)?"<NONE>":"",
479         (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
480         (state->flags&SS_IOCARD)?"IOCARD ":"",
481         (state->flags&SS_RESET)?"RESET ":"",
482         (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
483         (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
484         state->Vcc, state->Vpp, state->io_irq);
485
486         configure.sock=sock;
487         configure.vcc=state->Vcc;
488         configure.vpp=state->Vpp;
489         configure.output=(state->flags&SS_OUTPUT_ENA)?1:0;
490         configure.speaker=(state->flags&SS_SPKR_ENA)?1:0;
491         configure.reset=(state->flags&SS_RESET)?1:0;
492
493         if(pcmcia_low_level->configure_socket(&configure)<0){
494                 printk(KERN_ERR "Unable to configure socket %u\n", sock);
495                 return -1;
496         }
497
498         pcmcia_socket[sock].cs_state = *state;
499         return 0;
500
501 }  /* au1000_pcmcia_set_socket() */
502
503
504 static int 
505 au1000_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map)
506 {
507         debug(1, "au1000_pcmcia_get_io_map: sock %d\n", sock);
508         if(map->map>=MAX_IO_WIN){
509                 printk(KERN_ERR "%s(): map (%d) out of range\n", 
510                                 __FUNCTION__, map->map);
511                 return -1;
512         }
513         *map=pcmcia_socket[sock].io_map[map->map];
514         return 0;
515 }
516
517
518 int 
519 au1000_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map)
520 {
521         unsigned int speed;
522         unsigned long start;
523
524         if(map->map>=MAX_IO_WIN){
525                 printk(KERN_ERR "%s(): map (%d) out of range\n", 
526                                 __FUNCTION__, map->map);
527                 return -1;
528         }
529
530         if(map->flags&MAP_ACTIVE){
531                 speed=(map->speed>0)?map->speed:AU1000_PCMCIA_IO_SPEED;
532                 pcmcia_socket[sock].speed_io=speed;
533         }
534
535         start=map->start;
536
537         if(map->stop==1) {
538                 map->stop=PAGE_SIZE-1;
539         }
540
541         map->start=pcmcia_socket[sock].virt_io;
542         map->stop=map->start+(map->stop-start);
543         pcmcia_socket[sock].io_map[map->map]=*map;
544         debug(3, "set_io_map %d start %x stop %x\n", 
545                         map->map, map->start, map->stop);
546         return 0;
547
548 }  /* au1000_pcmcia_set_io_map() */
549
550
551 static int 
552 au1000_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map)
553 {
554
555         if(map->map>=MAX_WIN) {
556                 printk(KERN_ERR "%s(): map (%d) out of range\n", 
557                                 __FUNCTION__, map->map);
558                 return -1;
559         }
560         *map=pcmcia_socket[sock].mem_map[map->map];
561         return 0;
562 }
563
564
565 static int 
566 au1000_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map)
567 {
568         unsigned int speed;
569         unsigned long start;
570         u_long flags;
571
572         if(map->map>=MAX_WIN){
573                 printk(KERN_ERR "%s(): map (%d) out of range\n", 
574                                 __FUNCTION__, map->map);
575                 return -1;
576         }
577
578         if(map->flags&MAP_ACTIVE){
579                 speed=(map->speed>0)?map->speed:AU1000_PCMCIA_MEM_SPEED;
580
581                 /* TBD */
582                 if(map->flags&MAP_ATTRIB){
583                         pcmcia_socket[sock].speed_attr=speed;
584                 } 
585                 else {
586                         pcmcia_socket[sock].speed_mem=speed;
587                 }
588         }
589
590         spin_lock_irqsave(&pcmcia_lock, flags);
591         start=map->sys_start;
592
593         if(map->sys_stop==0)
594                 map->sys_stop=MAP_SIZE-1;
595
596         if (map->flags & MAP_ATTRIB) {
597                 map->sys_start = pcmcia_socket[sock].phys_attr + 
598                         map->card_start;
599         }
600         else {
601                 map->sys_start = pcmcia_socket[sock].phys_mem + 
602                         map->card_start;
603         }
604
605         map->sys_stop=map->sys_start+(map->sys_stop-start);
606         pcmcia_socket[sock].mem_map[map->map]=*map;
607         spin_unlock_irqrestore(&pcmcia_lock, flags);
608         debug(3, "set_mem_map %d start %x stop %x card_start %x\n", 
609                         map->map, map->sys_start, map->sys_stop, 
610                         map->card_start);
611         return 0;
612
613 }  /* au1000_pcmcia_set_mem_map() */
614
615
616 #if defined(CONFIG_PROC_FS)
617
618 static void 
619 au1000_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base)
620 {
621         struct proc_dir_entry *entry;
622
623         if((entry=create_proc_entry("status", 0, base))==NULL){
624                 printk(KERN_ERR "Unable to install \"status\" procfs entry\n");
625                 return;
626         }
627
628         entry->read_proc=au1000_pcmcia_proc_status;
629         entry->data=(void *)sock;
630 }
631
632
633 /* au1000_pcmcia_proc_status()
634  * Implements the /proc/bus/pccard/??/status file.
635  *
636  * Returns: the number of characters added to the buffer
637  */
638 static int 
639 au1000_pcmcia_proc_status(char *buf, char **start, off_t pos, 
640                 int count, int *eof, void *data)
641 {
642         char *p=buf;
643         unsigned int sock=(unsigned int)data;
644
645         p+=sprintf(p, "k_flags  : %s%s%s%s%s%s%s\n", 
646              pcmcia_socket[sock].k_state.detect?"detect ":"",
647              pcmcia_socket[sock].k_state.ready?"ready ":"",
648              pcmcia_socket[sock].k_state.bvd1?"bvd1 ":"",
649              pcmcia_socket[sock].k_state.bvd2?"bvd2 ":"",
650              pcmcia_socket[sock].k_state.wrprot?"wrprot ":"",
651              pcmcia_socket[sock].k_state.vs_3v?"vs_3v ":"",
652              pcmcia_socket[sock].k_state.vs_Xv?"vs_Xv ":"");
653
654         p+=sprintf(p, "status   : %s%s%s%s%s%s%s%s%s\n",
655              pcmcia_socket[sock].k_state.detect?"SS_DETECT ":"",
656              pcmcia_socket[sock].k_state.ready?"SS_READY ":"",
657              pcmcia_socket[sock].cs_state.Vcc?"SS_POWERON ":"",
658              pcmcia_socket[sock].cs_state.flags&SS_IOCARD?\
659              "SS_IOCARD ":"",
660              (pcmcia_socket[sock].cs_state.flags&SS_IOCARD &&
661               pcmcia_socket[sock].k_state.bvd1)?"SS_STSCHG ":"",
662              ((pcmcia_socket[sock].cs_state.flags&SS_IOCARD)==0 &&
663               (pcmcia_socket[sock].k_state.bvd1==0))?"SS_BATDEAD ":"",
664              ((pcmcia_socket[sock].cs_state.flags&SS_IOCARD)==0 &&
665               (pcmcia_socket[sock].k_state.bvd2==0))?"SS_BATWARN ":"",
666              pcmcia_socket[sock].k_state.vs_3v?"SS_3VCARD ":"",
667              pcmcia_socket[sock].k_state.vs_Xv?"SS_XVCARD ":"");
668
669         p+=sprintf(p, "mask     : %s%s%s%s%s\n",
670              pcmcia_socket[sock].cs_state.csc_mask&SS_DETECT?\
671              "SS_DETECT ":"",
672              pcmcia_socket[sock].cs_state.csc_mask&SS_READY?\
673              "SS_READY ":"",
674              pcmcia_socket[sock].cs_state.csc_mask&SS_BATDEAD?\
675              "SS_BATDEAD ":"",
676              pcmcia_socket[sock].cs_state.csc_mask&SS_BATWARN?\
677              "SS_BATWARN ":"",
678              pcmcia_socket[sock].cs_state.csc_mask&SS_STSCHG?\
679              "SS_STSCHG ":"");
680
681         p+=sprintf(p, "cs_flags : %s%s%s%s%s\n",
682              pcmcia_socket[sock].cs_state.flags&SS_PWR_AUTO?\
683              "SS_PWR_AUTO ":"",
684              pcmcia_socket[sock].cs_state.flags&SS_IOCARD?\
685              "SS_IOCARD ":"",
686              pcmcia_socket[sock].cs_state.flags&SS_RESET?\
687              "SS_RESET ":"",
688              pcmcia_socket[sock].cs_state.flags&SS_SPKR_ENA?\
689              "SS_SPKR_ENA ":"",
690              pcmcia_socket[sock].cs_state.flags&SS_OUTPUT_ENA?\
691              "SS_OUTPUT_ENA ":"");
692
693         p+=sprintf(p, "Vcc      : %d\n", pcmcia_socket[sock].cs_state.Vcc);
694         p+=sprintf(p, "Vpp      : %d\n", pcmcia_socket[sock].cs_state.Vpp);
695         p+=sprintf(p, "irq      : %d\n", pcmcia_socket[sock].cs_state.io_irq);
696         p+=sprintf(p, "I/O      : %u\n", pcmcia_socket[sock].speed_io);
697         p+=sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr);
698         p+=sprintf(p, "common   : %u\n", pcmcia_socket[sock].speed_mem);
699         return p-buf;
700 }
701
702
703 #endif  /* defined(CONFIG_PROC_FS) */