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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [ide_modes.h] - Blame information for rev 1626

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
#ifndef _IDE_MODES_H
2
#define _IDE_MODES_H
3
/*
4
 *  linux/drivers/block/ide_modes.h
5
 *
6
 *  Copyright (C) 1996  Linus Torvalds, Igor Abramov, and Mark Lord
7
 */
8
 
9
#include <linux/config.h>
10
 
11
/*
12
 * Shared data/functions for determining best PIO mode for an IDE drive.
13
 * Most of this stuff originally lived in cmd640.c, and changes to the
14
 * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
15
 * breaking the fragile cmd640.c support.
16
 */
17
 
18
#if defined(CONFIG_BLK_DEV_CMD640) || defined(CONFIG_IDE_CHIPSETS)
19
 
20
/*
21
 * Standard (generic) timings for PIO modes, from ATA2 specification.
22
 * These timings are for access to the IDE data port register *only*.
23
 * Some drives may specify a mode, while also specifying a different
24
 * value for cycle_time (from drive identification data).
25
 */
26
typedef struct ide_pio_timings_s {
27
        int     setup_time;     /* Address setup (ns) minimum */
28
        int     active_time;    /* Active pulse (ns) minimum */
29
        int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
30
} ide_pio_timings_t;
31
 
32
typedef struct ide_pio_data_s {
33
        byte pio_mode;
34
        byte use_iordy;
35
        byte overridden;
36
        byte blacklisted;
37
        unsigned int cycle_time;
38
} ide_pio_data_t;
39
 
40
#ifndef _IDE_C
41
 
42
int ide_scan_pio_blacklist (char *model);
43
byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d);
44
extern const ide_pio_timings_t ide_pio_timings[6];
45
 
46
#else /* _IDE_C */
47
 
48
const ide_pio_timings_t ide_pio_timings[6] = {
49
        { 70,   165,    600 },  /* PIO Mode 0 */
50
        { 50,   125,    383 },  /* PIO Mode 1 */
51
        { 30,   100,    240 },  /* PIO Mode 2 */
52
        { 30,   80,     180 },  /* PIO Mode 3 with IORDY */
53
        { 25,   70,     120 },  /* PIO Mode 4 with IORDY */
54
        { 20,   50,     100 }   /* PIO Mode 5 with IORDY (nonstandard) */
55
};
56
 
57
/*
58
 * Black list. Some drives incorrectly report their maximal PIO mode,
59
 * at least in respect to CMD640. Here we keep info on some known drives.
60
 */
61
static struct ide_pio_info {
62
        const char      *name;
63
        int             pio;
64
} ide_pio_blacklist [] = {
65
/*      { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
66
        { "Conner Peripherals 540MB - CFS540A", 3 },
67
 
68
        { "WDC AC2700",  3 },
69
        { "WDC AC2540",  3 },
70
        { "WDC AC2420",  3 },
71
        { "WDC AC2340",  3 },
72
        { "WDC AC2250",  0 },
73
        { "WDC AC2200",  0 },
74
        { "WDC AC21200", 4 },
75
        { "WDC AC2120",  0 },
76
        { "WDC AC2850",  3 },
77
        { "WDC AC1270",  3 },
78
        { "WDC AC1170",  1 },
79
        { "WDC AC1210",  1 },
80
        { "WDC AC280",   0 },
81
/*      { "WDC AC21000", 4 }, */
82
        { "WDC AC31000", 3 },
83
        { "WDC AC31200", 3 },
84
/*      { "WDC AC31600", 4 }, */
85
 
86
        { "Maxtor 7131 AT", 1 },
87
        { "Maxtor 7171 AT", 1 },
88
        { "Maxtor 7213 AT", 1 },
89
        { "Maxtor 7245 AT", 1 },
90
        { "Maxtor 7345 AT", 1 },
91
        { "Maxtor 7546 AT", 3 },
92
        { "Maxtor 7540 AV", 3 },
93
 
94
        { "SAMSUNG SHD-3121A", 1 },
95
        { "SAMSUNG SHD-3122A", 1 },
96
        { "SAMSUNG SHD-3172A", 1 },
97
 
98
/*      { "ST51080A", 4 },
99
 *      { "ST51270A", 4 },
100
 *      { "ST31220A", 4 },
101
 *      { "ST31640A", 4 },
102
 *      { "ST32140A", 4 },
103
 *      { "ST3780A",  4 },
104
 */
105
        { "ST5660A",  3 },
106
        { "ST3660A",  3 },
107
        { "ST3630A",  3 },
108
        { "ST3655A",  3 },
109
        { "ST3391A",  3 },
110
        { "ST3390A",  1 },
111
        { "ST3600A",  1 },
112
        { "ST3290A",  0 },
113
        { "ST3144A",  0 },
114
 
115
        { "QUANTUM ELS127A", 0 },
116
        { "QUANTUM ELS170A", 0 },
117
        { "QUANTUM LPS240A", 0 },
118
        { "QUANTUM LPS210A", 3 },
119
        { "QUANTUM LPS270A", 3 },
120
        { "QUANTUM LPS365A", 3 },
121
        { "QUANTUM LPS540A", 3 },
122
        { "QUANTUM LIGHTNING 540A", 3 },
123
        { "QUANTUM LIGHTNING 730A", 3 },
124
        { "QUANTUM FIREBALL", 3 }, /* For models 540/640/1080/1280 */
125
                                   /* 1080A works fine in mode4 with triton */
126
        { NULL, 0 }
127
};
128
 
129
/*
130
 * This routine searches the ide_pio_blacklist for an entry
131
 * matching the start/whole of the supplied model name.
132
 *
133
 * Returns -1 if no match found.
134
 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
135
 */
136
int ide_scan_pio_blacklist (char *model)
137
{
138
        struct ide_pio_info *p;
139
 
140
        for (p = ide_pio_blacklist; p->name != NULL; p++) {
141
                if (strncmp(p->name, model, strlen(p->name)) == 0)
142
                        return p->pio;
143
        }
144
        return -1;
145
}
146
 
147
/*
148
 * This routine returns the recommended PIO settings for a given drive,
149
 * based on the drive->id information and the ide_pio_blacklist[].
150
 * This is used by most chipset support modules when "auto-tuning".
151
 */
152
 
153
/*
154
 * Drive PIO mode auto selection
155
 */
156
byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d)
157
{
158
        int pio_mode;
159
        int cycle_time = 0;
160
        int use_iordy = 0;
161
        struct hd_driveid* id = drive->id;
162
        int overridden  = 0;
163
        int blacklisted = 0;
164
 
165
        if (mode_wanted != 255) {
166
                pio_mode = mode_wanted;
167
        } else if (!drive->id) {
168
                pio_mode = 0;
169
        } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
170
                overridden = 1;
171
                blacklisted = 1;
172
                use_iordy = (pio_mode > 2);
173
        } else {
174
                pio_mode = id->tPIO;
175
                if (pio_mode > 2) {     /* 2 is maximum allowed tPIO value */
176
                        pio_mode = 2;
177
                        overridden = 1;
178
                }
179
                if (id->field_valid & 2) {        /* drive implements ATA2? */
180
                        if (id->capability & 8) { /* drive supports use_iordy? */
181
                                use_iordy = 1;
182
                                cycle_time = id->eide_pio_iordy;
183
                                if (id->eide_pio_modes & 7) {
184
                                        overridden = 0;
185
                                        if (id->eide_pio_modes & 4)
186
                                                pio_mode = 5;
187
                                        else if (id->eide_pio_modes & 2)
188
                                                pio_mode = 4;
189
                                        else
190
                                                pio_mode = 3;
191
                                }
192
                        } else {
193
                                cycle_time = id->eide_pio;
194
                        }
195
                }
196
 
197
                /*
198
                 * Conservative "downgrade" for all pre-ATA2 drives
199
                 */
200
                if (pio_mode && pio_mode < 4) {
201
                        pio_mode--;
202
                        overridden = 1;
203
#if 0
204
                        use_iordy = (pio_mode > 2);
205
#endif
206
                        if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
207
                                cycle_time = 0; /* use standard timing */
208
                }
209
        }
210
        if (pio_mode > max_mode) {
211
                pio_mode = max_mode;
212
                cycle_time = 0;
213
        }
214
        if (d) {
215
                d->pio_mode = pio_mode;
216
                d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
217
                d->use_iordy = use_iordy;
218
                d->overridden = overridden;
219
                d->blacklisted = blacklisted;
220
        }
221
        return pio_mode;
222
}
223
 
224
#endif /* _IDE_C */
225
#endif /* defined(CONFIG_BLK_DEV_CMD640) || defined(CONFIG_IDE_CHIPSETS) */
226
#endif /* _IDE_MODES_H */

powered by: WebSVN 2.1.0

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