This commit was manufactured by cvs2svn to create tag
[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_ARCH_OBSOLETE_INIT
33 #define ide_default_io_ctl(base)        ((base) + 0x206) /* obsolete */
34
35 #define ide_init_default_irq(base)      (0)
36
37 #define __ide_insl(data_reg, buffer, wcount) \
38         __ide_insw(data_reg, buffer, (wcount)<<1)
39 #define __ide_outsl(data_reg, buffer, wcount) \
40         __ide_outsw(data_reg, buffer, (wcount)<<1)
41
42 /* On sparc, I/O ports and MMIO registers are accessed identically.  */
43 #define __ide_mm_insw   __ide_insw
44 #define __ide_mm_insl   __ide_insl
45 #define __ide_mm_outsw  __ide_outsw
46 #define __ide_mm_outsl  __ide_outsl
47
48 static __inline__ void __ide_insw(unsigned long port,
49                                   void *dst,
50                                   unsigned long count)
51 {
52         volatile unsigned short *data_port;
53         /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
54         u16 *ps = dst;
55         u32 *pi;
56
57         data_port = (volatile unsigned short *)port;
58
59         if(((unsigned long)ps) & 0x2) {
60                 *ps++ = *data_port;
61                 count--;
62         }
63         pi = (u32 *)ps;
64         while(count >= 2) {
65                 u32 w;
66
67                 w  = (*data_port) << 16;
68                 w |= (*data_port);
69                 *pi++ = w;
70                 count -= 2;
71         }
72         ps = (u16 *)pi;
73         if(count)
74                 *ps++ = *data_port;
75
76         /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
77 }
78
79 static __inline__ void __ide_outsw(unsigned long port,
80                                    const void *src,
81                                    unsigned long count)
82 {
83         volatile unsigned short *data_port;
84         /* unsigned long end = (unsigned long)src + (count << 1); */
85         const u16 *ps = src;
86         const u32 *pi;
87
88         data_port = (volatile unsigned short *)port;
89
90         if(((unsigned long)src) & 0x2) {
91                 *data_port = *ps++;
92                 count--;
93         }
94         pi = (const u32 *)ps;
95         while(count >= 2) {
96                 u32 w;
97
98                 w = *pi++;
99                 *data_port = (w >> 16);
100                 *data_port = w;
101                 count -= 2;
102         }
103         ps = (const u16 *)pi;
104         if(count)
105                 *data_port = *ps;
106
107         /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
108 }
109
110 #endif /* __KERNEL__ */
111
112 #endif /* _SPARC_IDE_H */