Merge branches 'release', 'misc' and 'misc-2.6.25' into release
[pandora-kernel.git] / include / asm-sparc / ide.h
1 /* ide.h: SPARC PCI specific IDE glue.
2  *
3  * Copyright (C) 1997  David S. Miller (davem@davemloft.net)
4  * Copyright (C) 1998  Eddie C. Dost   (ecd@skynet.be)
5  * Adaptation from sparc64 version to sparc by Pete Zaitcev.
6  */
7
8 #ifndef _SPARC_IDE_H
9 #define _SPARC_IDE_H
10
11 #ifdef __KERNEL__
12
13 #include <asm/pgtable.h>
14 #include <asm/io.h>
15 #include <asm/psr.h>
16
17 #undef  MAX_HWIFS
18 #define MAX_HWIFS       2
19
20 #define ide_default_io_ctl(base)        ((base) + 0x206) /* obsolete */
21
22 #define __ide_insl(data_reg, buffer, wcount) \
23         __ide_insw(data_reg, buffer, (wcount)<<1)
24 #define __ide_outsl(data_reg, buffer, wcount) \
25         __ide_outsw(data_reg, buffer, (wcount)<<1)
26
27 /* On sparc, I/O ports and MMIO registers are accessed identically.  */
28 #define __ide_mm_insw   __ide_insw
29 #define __ide_mm_insl   __ide_insl
30 #define __ide_mm_outsw  __ide_outsw
31 #define __ide_mm_outsl  __ide_outsl
32
33 static inline void __ide_insw(unsigned long port,
34                                   void *dst,
35                                   unsigned long count)
36 {
37         volatile unsigned short *data_port;
38         /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
39         u16 *ps = dst;
40         u32 *pi;
41
42         data_port = (volatile unsigned short *)port;
43
44         if(((unsigned long)ps) & 0x2) {
45                 *ps++ = *data_port;
46                 count--;
47         }
48         pi = (u32 *)ps;
49         while(count >= 2) {
50                 u32 w;
51
52                 w  = (*data_port) << 16;
53                 w |= (*data_port);
54                 *pi++ = w;
55                 count -= 2;
56         }
57         ps = (u16 *)pi;
58         if(count)
59                 *ps++ = *data_port;
60
61         /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
62 }
63
64 static inline void __ide_outsw(unsigned long port,
65                                    const void *src,
66                                    unsigned long count)
67 {
68         volatile unsigned short *data_port;
69         /* unsigned long end = (unsigned long)src + (count << 1); */
70         const u16 *ps = src;
71         const u32 *pi;
72
73         data_port = (volatile unsigned short *)port;
74
75         if(((unsigned long)src) & 0x2) {
76                 *data_port = *ps++;
77                 count--;
78         }
79         pi = (const u32 *)ps;
80         while(count >= 2) {
81                 u32 w;
82
83                 w = *pi++;
84                 *data_port = (w >> 16);
85                 *data_port = w;
86                 count -= 2;
87         }
88         ps = (const u16 *)pi;
89         if(count)
90                 *data_port = *ps;
91
92         /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
93 }
94
95 #endif /* __KERNEL__ */
96
97 #endif /* _SPARC_IDE_H */