This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / include / asm-sparc64 / ide.h
1 /* $Id: ide.h,v 1.21 2001/09/25 20:21:48 kanoj Exp $
2  * ide.h: Ultra/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  */
7
8 #ifndef _SPARC64_IDE_H
9 #define _SPARC64_IDE_H
10
11 #ifdef __KERNEL__
12
13 #include <linux/config.h>
14 #include <asm/pgalloc.h>
15 #include <asm/io.h>
16 #include <asm/page.h>
17 #include <asm/spitfire.h>
18
19 #ifndef MAX_HWIFS
20 # ifdef CONFIG_BLK_DEV_IDEPCI
21 #define MAX_HWIFS       10
22 # else
23 #define MAX_HWIFS       2
24 # endif
25 #endif
26
27 static __inline__ int ide_default_irq(unsigned long base)
28 {
29         return 0;
30 }
31
32 static __inline__ unsigned long ide_default_io_base(int index)
33 {
34         return 0;
35 }
36
37 #define IDE_ARCH_OBSOLETE_INIT
38 #define ide_default_io_ctl(base)        ((base) + 0x206) /* obsolete */
39
40 #define ide_init_default_irq(base)      (0)
41
42 #define __ide_insl(data_reg, buffer, wcount) \
43         __ide_insw(data_reg, buffer, (wcount)<<1)
44 #define __ide_outsl(data_reg, buffer, wcount) \
45         __ide_outsw(data_reg, buffer, (wcount)<<1)
46
47 /* On sparc64, I/O ports and MMIO registers are accessed identically.  */
48 #define __ide_mm_insw   __ide_insw
49 #define __ide_mm_insl   __ide_insl
50 #define __ide_mm_outsw  __ide_outsw
51 #define __ide_mm_outsl  __ide_outsl
52
53 static __inline__ unsigned int inw_be(unsigned long addr)
54 {
55         unsigned int ret;
56
57         __asm__ __volatile__("lduha [%1] %2, %0"
58                              : "=r" (ret)
59                              : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
60
61         return ret;
62 }
63
64 static __inline__ void __ide_insw(unsigned long port,
65                                   void *dst,
66                                   u32 count)
67 {
68 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
69         unsigned long end = (unsigned long)dst + (count << 1);
70 #endif
71         u16 *ps = dst;
72         u32 *pi;
73
74         if(((u64)ps) & 0x2) {
75                 *ps++ = inw_be(port);
76                 count--;
77         }
78         pi = (u32 *)ps;
79         while(count >= 2) {
80                 u32 w;
81
82                 w  = inw_be(port) << 16;
83                 w |= inw_be(port);
84                 *pi++ = w;
85                 count -= 2;
86         }
87         ps = (u16 *)pi;
88         if(count)
89                 *ps++ = inw_be(port);
90
91 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
92         __flush_dcache_range((unsigned long)dst, end);
93 #endif
94 }
95
96 static __inline__ void outw_be(unsigned short w, unsigned long addr)
97 {
98         __asm__ __volatile__("stha %0, [%1] %2"
99                              : /* no outputs */
100                              : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
101 }
102
103 static __inline__ void __ide_outsw(unsigned long port,
104                                    void *src,
105                                    u32 count)
106 {
107 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
108         unsigned long end = (unsigned long)src + (count << 1);
109 #endif
110         const u16 *ps = src;
111         const u32 *pi;
112
113         if(((u64)src) & 0x2) {
114                 outw_be(*ps++, port);
115                 count--;
116         }
117         pi = (const u32 *)ps;
118         while(count >= 2) {
119                 u32 w;
120
121                 w = *pi++;
122                 outw_be((w >> 16), port);
123                 outw_be(w, port);
124                 count -= 2;
125         }
126         ps = (const u16 *)pi;
127         if(count)
128                 outw_be(*ps, port);
129
130 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
131         __flush_dcache_range((unsigned long)src, end);
132 #endif
133 }
134
135 #endif /* __KERNEL__ */
136
137 #endif /* _SPARC64_IDE_H */