patch-2_6_7-vs1_9_1_12
[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 #define IDE_ARCH_OBSOLETE_INIT
28 #define ide_default_io_ctl(base)        ((base) + 0x206) /* obsolete */
29
30 #define __ide_insl(data_reg, buffer, wcount) \
31         __ide_insw(data_reg, buffer, (wcount)<<1)
32 #define __ide_outsl(data_reg, buffer, wcount) \
33         __ide_outsw(data_reg, buffer, (wcount)<<1)
34
35 /* On sparc64, I/O ports and MMIO registers are accessed identically.  */
36 #define __ide_mm_insw   __ide_insw
37 #define __ide_mm_insl   __ide_insl
38 #define __ide_mm_outsw  __ide_outsw
39 #define __ide_mm_outsl  __ide_outsl
40
41 static __inline__ unsigned int inw_be(unsigned long addr)
42 {
43         unsigned int ret;
44
45         __asm__ __volatile__("lduha [%1] %2, %0"
46                              : "=r" (ret)
47                              : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
48
49         return ret;
50 }
51
52 static __inline__ void __ide_insw(unsigned long port,
53                                   void *dst,
54                                   u32 count)
55 {
56 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
57         unsigned long end = (unsigned long)dst + (count << 1);
58 #endif
59         u16 *ps = dst;
60         u32 *pi;
61
62         if(((u64)ps) & 0x2) {
63                 *ps++ = inw_be(port);
64                 count--;
65         }
66         pi = (u32 *)ps;
67         while(count >= 2) {
68                 u32 w;
69
70                 w  = inw_be(port) << 16;
71                 w |= inw_be(port);
72                 *pi++ = w;
73                 count -= 2;
74         }
75         ps = (u16 *)pi;
76         if(count)
77                 *ps++ = inw_be(port);
78
79 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
80         __flush_dcache_range((unsigned long)dst, end);
81 #endif
82 }
83
84 static __inline__ void outw_be(unsigned short w, unsigned long addr)
85 {
86         __asm__ __volatile__("stha %0, [%1] %2"
87                              : /* no outputs */
88                              : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
89 }
90
91 static __inline__ void __ide_outsw(unsigned long port,
92                                    void *src,
93                                    u32 count)
94 {
95 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
96         unsigned long end = (unsigned long)src + (count << 1);
97 #endif
98         const u16 *ps = src;
99         const u32 *pi;
100
101         if(((u64)src) & 0x2) {
102                 outw_be(*ps++, port);
103                 count--;
104         }
105         pi = (const u32 *)ps;
106         while(count >= 2) {
107                 u32 w;
108
109                 w = *pi++;
110                 outw_be((w >> 16), port);
111                 outw_be(w, port);
112                 count -= 2;
113         }
114         ps = (const u16 *)pi;
115         if(count)
116                 outw_be(*ps, port);
117
118 #if (L1DCACHE_SIZE > PAGE_SIZE)         /* is there D$ aliasing problem */
119         __flush_dcache_range((unsigned long)src, end);
120 #endif
121 }
122
123 #endif /* __KERNEL__ */
124
125 #endif /* _SPARC64_IDE_H */