ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-sparc / ide.h
1 /* $Id: ide.h,v 1.7 2002/01/16 20:58:40 davem Exp $
2  * ide.h: SPARC PCI specific IDE glue.
3  *
4  * Copyright (C) 1997  David S. Miller (davem@caip.rutgers.edu)
5  * Copyright (C) 1998  Eddie C. Dost   (ecd@skynet.be)
6  * Adaptation from sparc64 version to sparc by Pete Zaitcev.
7  */
8
9 #ifndef _SPARC_IDE_H
10 #define _SPARC_IDE_H
11
12 #ifdef __KERNEL__
13
14 #include <linux/config.h>
15 #include <asm/pgtable.h>
16 #include <asm/io.h>
17 #include <asm/psr.h>
18
19 #undef  MAX_HWIFS
20 #define MAX_HWIFS       2
21
22 static __inline__ int ide_default_irq(unsigned long base)
23 {
24         return 0;
25 }
26
27 static __inline__ unsigned long ide_default_io_base(int index)
28 {
29         return 0;
30 }
31
32 #define ide_init_default_irq(base)      (0)
33
34 #define __ide_insl(data_reg, buffer, wcount) \
35         __ide_insw(data_reg, buffer, (wcount)<<1)
36 #define __ide_outsl(data_reg, buffer, wcount) \
37         __ide_outsw(data_reg, buffer, (wcount)<<1)
38
39 /* On sparc, I/O ports and MMIO registers are accessed identically.  */
40 #define __ide_mm_insw   __ide_insw
41 #define __ide_mm_insl   __ide_insl
42 #define __ide_mm_outsw  __ide_outsw
43 #define __ide_mm_outsl  __ide_outsl
44
45 static __inline__ void __ide_insw(unsigned long port,
46                                   void *dst,
47                                   unsigned long count)
48 {
49         volatile unsigned short *data_port;
50         /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
51         u16 *ps = dst;
52         u32 *pi;
53
54         data_port = (volatile unsigned short *)port;
55
56         if(((unsigned long)ps) & 0x2) {
57                 *ps++ = *data_port;
58                 count--;
59         }
60         pi = (u32 *)ps;
61         while(count >= 2) {
62                 u32 w;
63
64                 w  = (*data_port) << 16;
65                 w |= (*data_port);
66                 *pi++ = w;
67                 count -= 2;
68         }
69         ps = (u16 *)pi;
70         if(count)
71                 *ps++ = *data_port;
72
73         /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
74 }
75
76 static __inline__ void __ide_outsw(unsigned long port,
77                                    const void *src,
78                                    unsigned long count)
79 {
80         volatile unsigned short *data_port;
81         /* unsigned long end = (unsigned long)src + (count << 1); */
82         const u16 *ps = src;
83         const u32 *pi;
84
85         data_port = (volatile unsigned short *)port;
86
87         if(((unsigned long)src) & 0x2) {
88                 *data_port = *ps++;
89                 count--;
90         }
91         pi = (const u32 *)ps;
92         while(count >= 2) {
93                 u32 w;
94
95                 w = *pi++;
96                 *data_port = (w >> 16);
97                 *data_port = w;
98                 count -= 2;
99         }
100         ps = (const u16 *)pi;
101         if(count)
102                 *data_port = *ps;
103
104         /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
105 }
106
107 #endif /* __KERNEL__ */
108
109 #endif /* _SPARC_IDE_H */