patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / pcmcia / sa1100_system3.c
1 /*
2  * drivers/pcmcia/sa1100_system3.c
3  *
4  * PT Diagital Board PCMCIA specific routines
5  *
6  * Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
7  *
8  * $Id: sa1100_system3.c,v 1.1.4.2 2002/02/25 13:56:45 seletz Exp $
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * $Log: sa1100_system3.c,v $
15  * Revision 1.1.4.2  2002/02/25 13:56:45  seletz
16  * - more cleanups
17  * - setup interrupts for CF card only ATM
18  *
19  * Revision 1.1.4.1  2002/02/14 02:23:27  seletz
20  * - 2.5.2-rmk6 PCMCIA changes
21  *
22  * Revision 1.1.2.1  2002/02/13 23:49:33  seletz
23  * - added from 2.4.16-rmk2
24  * - cleanups
25  *
26  *
27  */
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/sched.h>
31 #include <linux/init.h>
32 #include <linux/device.h>
33 #include <linux/ioport.h>
34
35 #include <asm/hardware.h>
36 #include <asm/mach-types.h>
37 #include <asm/irq.h>
38 #include <asm/hardware/sa1111.h>
39
40 #include "sa1111_generic.h"
41
42 #define DEBUG 0
43
44 #ifdef DEBUG
45 #       define DPRINTK( x, args... )    printk( "%s: line %d: "x, __FUNCTION__, __LINE__, ## args  );
46 #else
47 #       define DPRINTK( x, args... )    /* nix */
48 #endif
49
50 static int system3_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
51 {
52         skt->irq = skt->nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT;
53
54         /* Don't need no CD and BVD* interrupts */
55         return 0;
56 }
57
58 void system3_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
59 {
60 }
61
62 static void
63 system3_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
64 {
65         unsigned long status = PCSR;
66
67         switch (skt->nr) {
68 #if 0 /* PCMCIA socket not yet connected */
69         case 0:
70                 state->detect = status & PCSR_S0_DETECT ? 0 : 1;
71                 state->ready  = status & PCSR_S0_READY  ? 1 : 0;
72                 state->bvd1   = status & PCSR_S0_BVD1   ? 1 : 0;
73                 state->bvd2   = 1;
74                 state->wrprot = status & PCSR_S0_WP     ? 1 : 0;
75                 state->vs_3v  = 1;
76                 state->vs_Xv  = 0;
77                 break;
78 #endif
79
80         case 1:
81                 state->detect = status & PCSR_S1_DETECT ? 0 : 1;
82                 state->ready  = status & PCSR_S1_READY  ? 1 : 0;
83                 state->bvd1   = status & PCSR_S1_BVD1   ? 1 : 0;
84                 state->bvd2   = 1;
85                 state->wrprot = status & PCSR_S1_WP     ? 1 : 0;
86                 state->vs_3v  = 1;
87                 state->vs_Xv  = 0;
88                 break;
89         }
90
91         DPRINTK("Sock %d PCSR=0x%08lx, Sx_RDY_nIREQ=%d\n",
92                 skt->nr, status, state->ready);
93 }
94
95 struct pcmcia_low_level system3_pcmcia_ops = {
96         .owner                  = THIS_MODULE,
97         .init                   = system3_pcmcia_hw_init,
98         .shutdown               = system3_pcmcia_hw_shutdown,
99         .socket_state           = system3_pcmcia_socket_state,
100         .configure_socket       = sa1111_pcmcia_configure_socket,
101
102         .socket_init            = sa1111_pcmcia_socket_init,
103         .socket_suspend         = sa1111_pcmcia_socket_suspend,
104 };
105
106 int __init pcmcia_system3_init(struct device *dev)
107 {
108         int ret = -ENODEV;
109
110         if (machine_is_pt_system3())
111                 /* only CF ATM */
112                 ret = sa11xx_drv_pcmcia_probe(dev, &system3_pcmcia_ops, 1, 1);
113
114         return ret;
115 }