1 /*
2 File: include/asm-i386/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 are inline.
8 
9 Handle multi instances. For two controller on one board.
10 "hc->data_io" not used for x86 arch.
11 
12 22.09.2003 hne
13 Alternate IO-Base for second Controller (CF/USB1).
14 
15 23.09.2003 hne
16 Move Hardware depend header sl811-x86.h into include/asm-i386/sl811-hw.h.
17 
18 03.10.2003 hne
19 Low level only for port io into hardware-include.
20 */
21 
22 #ifndef __LINUX_SL811_HW_H
23 #define __LINUX_SL811_HW_H
24 
25 #define MAX_CONTROLERS  2       /* Max number of SL811 controllers per module */
26 
27 static int io[MAX_CONTROLERS] = { 0x220, 0x222 };	/* IO ports for controllers */
28 static int irq[MAX_CONTROLERS] = { 12, 12 };		/* Interrupt list */
29 
30 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CONTROLERS) "i");
31 MODULE_PARM_DESC(io, "I/O base address(es), 0x220,0x222 default");
32 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CONTROLERS) "i");
33 MODULE_PARM_DESC(irq, "IRQ number(s), 12,12 default");
34 
35 #define OFFSET_DATA_REG		1	/* Offset from ADDR_IO to DATA_IO */
36 					/* Do not change this! */
37 #define SIZEOF_IO_REGION	2	/* Size for request/release region */
38 
39 /*
40  * Low level: Read from Data port [x86]
41  */
sl811_read_data(struct sl811_hc * hc)42 static __u8 inline sl811_read_data (struct sl811_hc *hc)
43 {
44 	return ((__u8) inb (hc->addr_io+OFFSET_DATA_REG));
45 }
46 
47 /*
48  * Low level: Write to index register [x86]
49  */
sl811_write_index(struct sl811_hc * hc,__u8 index)50 static void inline sl811_write_index (struct sl811_hc *hc, __u8 index)
51 {
52 	outb (index, hc->addr_io);
53 }
54 
55 /*
56  * Low level: Write to Data port [x86]
57  */
sl811_write_data(struct sl811_hc * hc,__u8 data)58 static void inline sl811_write_data (struct sl811_hc *hc, __u8 data)
59 {
60 	outb (data, hc->addr_io+OFFSET_DATA_REG);
61 }
62 
63 /*
64  * Low level: Write to index register and data port [x86]
65  */
sl811_write_index_data(struct sl811_hc * hc,__u8 index,__u8 data)66 static void inline sl811_write_index_data (struct sl811_hc *hc, __u8 index, __u8 data)
67 {
68 	outw (index|(((__u16)data) << 8), hc->addr_io);
69 }
70 
71 /*
72  * This	function is board specific.  It	sets up	the interrupt to
73  * be an edge trigger and trigger on the rising	edge
74  */
sl811_init_irq(void)75 static void inline sl811_init_irq(void)
76 {
77 	/* nothing for x86 */
78 }
79 
80 
81 /*****************************************************************
82  *
83  * Function Name: release_regions [x86]
84  *
85  * This function is board specific. It release all io address
86  * from memory (if can).
87  *
88  * Input: struct sl811_hc * *
89  *
90  * Return value  : 0 = OK
91  *
92  *****************************************************************/
sl811_release_regions(struct sl811_hc * hc)93 static void inline sl811_release_regions(struct sl811_hc *hc)
94 {
95 	if (hc->addr_io)
96 		release_region(hc->addr_io, SIZEOF_IO_REGION);
97 	hc->addr_io = 0;
98 
99 	/* data_io unused for x86 */
100 	/* ...
101 	if (hc->data_io)
102 		release_region(hc->data_io, SIZEOF_IO_REGION);
103 	hc->data_io = 0;
104 	... */
105 }
106 
107 /*****************************************************************
108  *
109  * Function Name: request_regions [x86]
110  *
111  * This function is board specific. It request all io address and
112  * maps into memory (if can).
113  *
114  * Input: struct sl811_hc *
115  *
116  * Return value  : 0 = OK
117  *
118  *****************************************************************/
sl811_request_regions(struct sl811_hc * hc,int addr_io,int data_io,const char * name)119 static int inline sl811_request_regions (struct sl811_hc *hc, int addr_io, int data_io, const char *name)
120 {
121 	if (!request_region(addr_io, SIZEOF_IO_REGION, name)) {
122 		PDEBUG(3, "request address %d failed", addr_io);
123 		return -EBUSY;
124 	}
125 	hc->addr_io =	addr_io;
126 
127 	/* data_io unused for x86 */
128 	/* hc->data_io = data_io; */
129 
130 	return 0;
131 }
132 
133 #endif // __LINUX_SL811_HW_H
134