import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / include / asm-arm / sl811-hw.h
1 /*
2 File: include/asm-arm/sl811-hw.h
3
4 19.09.2003 hne@ist1.de
5 Use Kernel 2.4.20 and this source from 2.4.22
6 Splitt hardware depens into file sl811-x86.h and sl811-arm.h.
7 Functions as inline.
8
9 23.09.2003 hne
10 Move Hardware depend header sl811-arm.h into include/asm-arm/sl811-hw.h.
11 GPRD as parameter.
12
13 24.09.2003 hne
14 Use Offset from ADDR to DATA instand of direct io.
15
16 03.10.2003 hne
17 Low level only for port io into hardware-include.
18 */
19
20 #ifndef __LINUX_SL811_HW_H
21 #define __LINUX_SL811_HW_H
22
23 #define MAX_CONTROLERS          1       /* Max number of sl811 controllers */
24                                         /* Always 1 for this architecture! */
25
26 #define SIZEOF_IO_REGION        1       /* Size for request/release region */
27
28 #define OFFSET_DATA_REG data_off        /* Offset from ADDR_IO to DATA_IO (future) */
29                                         /* Can change by arg */
30
31 static int io = 0xf100000e;     /* Base addr_io */
32 static int data_off = 1;        /* Offset from addr_io to addr_io */
33 static int irq = 44;            /* also change gprd !!! */
34 static int gprd = 23;           /* also change irq  !!! */
35
36 MODULE_PARM(io,"i");
37 MODULE_PARM_DESC(io,"sl811 address io port 0xf100000e");
38 MODULE_PARM(data_off,"i");
39 MODULE_PARM_DESC(data_off,"sl811 data io port offset from address port (default 1)");
40 MODULE_PARM(irq,"i");
41 MODULE_PARM_DESC(irq,"sl811 irq 44(default)");
42 MODULE_PARM(gprd,"i");
43 MODULE_PARM_DESC(gprd,"sl811 GPRD port 23(default)");
44
45 /*
46  * Low level: Read from Data port [arm]
47  */
48 static __u8 inline sl811_read_data (struct sl811_hc *hc)
49 {
50         __u8 data;
51         data = readb(hc->data_io);
52         rmb();
53         return data;
54 }
55
56 /*
57  * Low level: Write to index register [arm]
58  */
59 static void inline sl811_write_index (struct sl811_hc *hc, __u8 index)
60 {
61         writeb(index, hc->addr_io);
62         wmb();
63 }
64
65 /*
66  * Low level: Write to Data port [arm]
67  */
68 static void inline sl811_write_data (struct sl811_hc *hc, __u8 data)
69 {
70         writeb(data, hc->data_io);
71         wmb();
72 }
73
74 /*
75  * Low level: Write to index register and data port [arm]
76  */
77 static void inline sl811_write_index_data (struct sl811_hc *hc, __u8 index, __u8 data)
78 {
79         writeb(index, hc->addr_io);
80         writeb(data, hc->data_io);
81         wmb();
82 }
83
84
85 /*
86  * This function is board specific.  It sets up the interrupt to
87  * be an edge trigger and trigger on the rising edge
88  */
89 static void inline sl811_init_irq(void)
90 {
91         GPDR &= ~(1<<gprd);
92         set_GPIO_IRQ_edge(1<<gprd, GPIO_RISING_EDGE);
93 }
94
95 /*****************************************************************
96  *
97  * Function Name: release_regions [arm]
98  *
99  * This function is board specific. It release all io address
100  * from memory (if can).
101  *
102  * Input: struct sl811_hc * *
103  *
104  * Return value  : 0 = OK
105  *
106  *****************************************************************/
107 static void inline sl811_release_regions(struct sl811_hc *hc)
108 {
109         if (hc->addr_io)
110                 release_region(hc->addr_io, SIZEOF_IO_REGION);
111         hc->addr_io = 0;
112
113         if (hc->data_io)
114                 release_region(hc->data_io, SIZEOF_IO_REGION);
115         hc->data_io = 0;
116 }
117
118 /*****************************************************************
119  *
120  * Function Name: request_regions [arm]
121  *
122  * This function is board specific. It request all io address and
123  * maps into memory (if can).
124  *
125  * Input: struct sl811_hc *
126  *
127  * Return value  : 0 = OK
128  *
129  *****************************************************************/
130 static int inline sl811_request_regions (struct sl811_hc *hc, int addr_io, int data_io, const char *name)
131 {
132         if (!request_region(addr_io, SIZEOF_IO_REGION, name)) {
133                 PDEBUG(3, "request address %d failed", addr_io);
134                 return -EBUSY;
135         }
136         hc->addr_io =   addr_io;
137
138         if (!request_region(data_io, SIZEOF_IO_REGION, MODNAME)) {
139                 PDEBUG(3, "request address %d failed", data_io);
140                 /* release_region(hc->addr_io, SIZEOF_IO_REGION); */
141                 return -EBUSY;
142         }
143         hc->data_io =   data_io;
144
145         return 0;
146 }
147
148 #endif // __LINUX_SL811_HW_H