OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-m68k/] [ide.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _M68K_IDE_H
2
#define _M68K_IDE_H
3
 
4
/* Copyright(c) 1996 Kars de Jong */
5
/* Based on the ide driver from 1.2.13pl8 */
6
 
7
#include <linux/config.h>
8
 
9
#ifdef CONFIG_AMIGA
10
#include <asm/amigahw.h>
11
#include <asm/amihdreg.h>
12
#include <asm/amigaints.h>
13
#endif /* CONFIG_AMIGA */
14
 
15
#ifdef CONFIG_ATARI
16
#include <asm/atarihw.h>
17
#include <asm/atarihdreg.h>
18
#include <asm/atariints.h>
19
#include <asm/atari_stdma.h>
20
#endif /* CONFIG_ATARI */
21
 
22
#include <asm/bootinfo.h>
23
 
24
struct hd_regs_struct {
25
  unsigned int hd_error,
26
  hd_nsector,
27
  hd_sector,
28
  hd_lcyl,
29
  hd_hcyl,
30
  hd_select,
31
  hd_status;
32
};
33
 
34
static struct hd_regs_struct hd_regs;
35
static void probe_m68k_ide (void);
36
 
37
/* Undefine these again, they were defined for the PC. */
38
#undef IDE_ERROR_OFFSET
39
#undef IDE_NSECTOR_OFFSET
40
#undef IDE_SECTOR_OFFSET
41
#undef IDE_LCYL_OFFSET
42
#undef IDE_HCYL_OFFSET
43
#undef IDE_SELECT_OFFSET
44
#undef IDE_STATUS_OFFSET
45
#undef IDE_FEATURE_OFFSET
46
#undef IDE_COMMAND_OFFSET
47
#undef SELECT_DRIVE
48
 
49
#define IDE_ERROR_OFFSET        hd_regs.hd_error
50
#define IDE_NSECTOR_OFFSET      hd_regs.hd_nsector
51
#define IDE_SECTOR_OFFSET       hd_regs.hd_sector
52
#define IDE_LCYL_OFFSET         hd_regs.hd_lcyl
53
#define IDE_HCYL_OFFSET         hd_regs.hd_hcyl
54
#define IDE_SELECT_OFFSET       hd_regs.hd_select
55
#define IDE_STATUS_OFFSET       hd_regs.hd_status
56
#define IDE_FEATURE_OFFSET      IDE_ERROR_OFFSET
57
#define IDE_COMMAND_OFFSET      IDE_STATUS_OFFSET
58
 
59
#undef SUPPORT_VLB_SYNC
60
#define SUPPORT_VLB_SYNC 0
61
 
62
#undef HD_DATA
63
#define HD_DATA NULL
64
 
65
/* MSch: changed sti() to STI() wherever possible in ide.c; moved STI() def.
66
 * to asm/ide.h
67
 */
68
/* The Atari interrupt structure strictly requires that the IPL isn't lowered
69
 * uncontrolled in an interrupt handler. In the concrete case, the IDE
70
 * interrupt is already a slow int, so the irq is already disabled at the time
71
 * the handler is called, and the IPL has been lowered to the minimum value
72
 * possible. To avoid going below that, STI() checks for being called inside
73
 * an interrupt, and in that case it does nothing. Hope that is reasonable and
74
 * works. (Roman)
75
 */
76
#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA)
77
#define STI()                                   \
78
    do {                                        \
79
        if (!intr_count) sti();                 \
80
    } while(0)
81
#elif defined(CONFIG_ATARI)
82
#define STI()                                           \
83
    do {                                                \
84
        if (!MACH_IS_ATARI || !intr_count) sti();       \
85
    } while(0)
86
#else /* !defined(CONFIG_ATARI) */
87
#define STI()   sti()
88
#endif
89
 
90
#define SELECT_DRIVE(hwif,drive)  OUT_BYTE((drive)->select.all, hwif->io_base+IDE_SELECT_OFFSET);
91
 
92
#define insl(data_reg, buffer, wcount) insw(data_reg, buffer, wcount<<1)
93
#define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, wcount<<1)
94
 
95
#define insw(port, buf, nr) \
96
    if (nr % 16) \
97
        __asm__ __volatile__ \
98
               ("movel %0,%/a0; \
99
                 movel %1,%/a1; \
100
                 movel %2,%/d6; \
101
                 subql #1,%/d6; \
102
               1:movew %/a0@,%/a1@+; \
103
                 dbra %/d6,1b" : \
104
                : "g" (port), "g" (buf), "g" (nr) \
105
                : "a0", "a1", "d6"); \
106
    else \
107
        __asm__ __volatile__ \
108
               ("movel %0,%/a0; \
109
                 movel %1,%/a1; \
110
                 movel %2,%/d6; \
111
                 lsrl  #4,%/d6; \
112
                 subql #1,%/d6; \
113
               1:movew %/a0@,%/a1@+; \
114
                 movew %/a0@,%/a1@+; \
115
                 movew %/a0@,%/a1@+; \
116
                 movew %/a0@,%/a1@+; \
117
                 movew %/a0@,%/a1@+; \
118
                 movew %/a0@,%/a1@+; \
119
                 movew %/a0@,%/a1@+; \
120
                 movew %/a0@,%/a1@+; \
121
                 movew %/a0@,%/a1@+; \
122
                 movew %/a0@,%/a1@+; \
123
                 movew %/a0@,%/a1@+; \
124
                 movew %/a0@,%/a1@+; \
125
                 movew %/a0@,%/a1@+; \
126
                 movew %/a0@,%/a1@+; \
127
                 movew %/a0@,%/a1@+; \
128
                 movew %/a0@,%/a1@+; \
129
                 dbra %/d6,1b" : \
130
                : "g" (port), "g" (buf), "g" (nr) \
131
                : "a0", "a1", "d6");
132
 
133
#define outsw(port, buf, nr) \
134
    if (nr % 16) \
135
        __asm__ __volatile__ \
136
               ("movel %0,%/a0; \
137
                 movel %1,%/a1; \
138
                 movel %2,%/d6; \
139
                 subql #1,%/d6; \
140
               1:movew %/a1@+,%/a0@; \
141
                 dbra %/d6,1b" : \
142
                : "g" (port), "g" (buf), "g" (nr) \
143
                : "a0", "a1", "d6"); \
144
    else \
145
        __asm__ __volatile__ \
146
               ("movel %0,%/a0; \
147
                 movel %1,%/a1; \
148
                 movel %2,%/d6; \
149
                 lsrl  #4,%/d6; \
150
                 subql #1,%/d6; \
151
               1:movew %/a1@+,%/a0@; \
152
                 movew %/a1@+,%/a0@; \
153
                 movew %/a1@+,%/a0@; \
154
                 movew %/a1@+,%/a0@; \
155
                 movew %/a1@+,%/a0@; \
156
                 movew %/a1@+,%/a0@; \
157
                 movew %/a1@+,%/a0@; \
158
                 movew %/a1@+,%/a0@; \
159
                 movew %/a1@+,%/a0@; \
160
                 movew %/a1@+,%/a0@; \
161
                 movew %/a1@+,%/a0@; \
162
                 movew %/a1@+,%/a0@; \
163
                 movew %/a1@+,%/a0@; \
164
                 movew %/a1@+,%/a0@; \
165
                 movew %/a1@+,%/a0@; \
166
                 movew %/a1@+,%/a0@; \
167
                 dbra %/d6,1b" : \
168
                : "g" (port), "g" (buf), "g" (nr) \
169
                : "a0", "a1", "d6");
170
 
171
#define T_CHAR          (0x0000)        /* char:  don't touch  */
172
#define T_SHORT         (0x4000)        /* short: 12 -> 21     */
173
#define T_INT           (0x8000)        /* int:   1234 -> 4321 */
174
#define T_TEXT          (0xc000)        /* text:  12 -> 21     */
175
 
176
#define T_MASK_TYPE     (0xc000)
177
#define T_MASK_COUNT    (0x3fff)
178
 
179
#define D_CHAR(cnt)     (T_CHAR  | (cnt))
180
#define D_SHORT(cnt)    (T_SHORT | (cnt))
181
#define D_INT(cnt)      (T_INT   | (cnt))
182
#define D_TEXT(cnt)     (T_TEXT  | (cnt))
183
 
184
static u_short driveid_types[] = {
185
        D_SHORT(10),    /* config - vendor2 */
186
        D_TEXT(20),     /* serial_no */
187
        D_SHORT(3),     /* buf_type - ecc_bytes */
188
        D_TEXT(48),     /* fw_rev - model */
189
        D_CHAR(2),      /* max_multsect - vendor3 */
190
        D_SHORT(1),     /* dword_io */
191
        D_CHAR(2),      /* vendor4 - capability */
192
        D_SHORT(1),     /* reserved50 */
193
        D_CHAR(4),      /* vendor5 - tDMA */
194
        D_SHORT(4),     /* field_valid - cur_sectors */
195
        D_INT(1),       /* cur_capacity */
196
        D_CHAR(2),      /* multsect - multsect_valid */
197
        D_INT(1),       /* lba_capacity */
198
        D_SHORT(194)    /* dma_1word - reservedyy */
199
};
200
 
201
#define num_driveid_types       (sizeof(driveid_types)/sizeof(*driveid_types))
202
 
203
static __inline__ void big_endianize_driveid(struct hd_driveid *id)
204
{
205
   u_char *p = (u_char *)id;
206
   int i, j, cnt;
207
   u_char t;
208
 
209
   for (i = 0; i < num_driveid_types; i++) {
210
      cnt = driveid_types[i] & T_MASK_COUNT;
211
      switch (driveid_types[i] & T_MASK_TYPE) {
212
         case T_CHAR:
213
            p += cnt;
214
            break;
215
         case T_SHORT:
216
            for (j = 0; j < cnt; j++) {
217
               t = p[0];
218
               p[0] = p[1];
219
               p[1] = t;
220
               p += 2;
221
            }
222
            break;
223
         case T_INT:
224
            for (j = 0; j < cnt; j++) {
225
               t = p[0];
226
               p[0] = p[3];
227
               p[3] = t;
228
               t = p[1];
229
               p[1] = p[2];
230
               p[2] = t;
231
               p += 4;
232
            }
233
            break;
234
         case T_TEXT:
235
            for (j = 0; j < cnt; j += 2) {
236
               t = p[0];
237
               p[0] = p[1];
238
               p[1] = t;
239
               p += 2;
240
            }
241
            break;
242
      }
243
   }
244
}
245
 
246
#endif /* _M68K_IDE_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.