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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [block/] [umc8672.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  linux/drivers/block/umc8672.c       Version 0.05  Jul 31, 1996
3
 *
4
 *  Copyright (C) 1995-1996  Linus Torvalds & author (see below)
5
 */
6
 
7
/*
8
 *  Principal Author/Maintainer:  PODIEN@hml2.atlas.de (Wolfram Podien)
9
 *
10
 *  This file provides support for the advanced features
11
 *  of the UMC 8672 IDE interface.
12
 *
13
 *  Version 0.01        Initial version, hacked out of ide.c,
14
 *                      and #include'd rather than compiled separately.
15
 *                      This will get cleaned up in a subsequent release.
16
 *
17
 *  Version 0.02        now configs/compiles separate from ide.c  -ml
18
 *  Version 0.03        enhanced auto-tune, fix display bug
19
 *  Version 0.05        replace sti() with restore_flags()  -ml
20
 *                      add detection of possible race condition  -ml
21
 */
22
 
23
/*
24
 * VLB Controller Support from
25
 * Wolfram Podien
26
 * Rohoefe 3
27
 * D28832 Achim
28
 * Germany
29
 *
30
 * To enable UMC8672 support there must a lilo line like
31
 * append="ide0=umc8672"...
32
 * To set the speed according to the abilities of the hardware there must be a
33
 * line like
34
 * #define UMC_DRIVE0 11
35
 * in the beginning of the driver, which sets the speed of drive 0 to 11 (there
36
 * are some lines present). 0 - 11 are allowed speed values. These values are
37
 * the results from the DOS speed test program supplied from UMC. 11 is the
38
 * highest speed (about PIO mode 3)
39
 */
40
#define REALLY_SLOW_IO          /* some systems can safely undef this */
41
 
42
#include <linux/types.h>
43
#include <linux/kernel.h>
44
#include <linux/delay.h>
45
#include <linux/timer.h>
46
#include <linux/mm.h>
47
#include <linux/ioport.h>
48
#include <linux/blkdev.h>
49
#include <linux/hdreg.h>
50
#include <asm/io.h>
51
#include "ide.h"
52
#include "ide_modes.h"
53
 
54
/*
55
 * Default speeds.  These can be changed with "auto-tune" and/or hdparm.
56
 */
57
#define UMC_DRIVE0      1              /* DOS measured drive speeds */
58
#define UMC_DRIVE1      1              /* 0 to 11 allowed */
59
#define UMC_DRIVE2      1              /* 11 = Fastest Speed */
60
#define UMC_DRIVE3      1              /* In case of crash reduce speed */
61
 
62
static byte current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3};
63
static const byte pio_to_umc [5] = {0,3,7,10,11};        /* rough guesses */
64
 
65
/*       0    1    2    3    4    5    6    7    8    9    10   11      */
66
static const byte speedtab [3][12] = {
67
        {0xf, 0xb, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 },
68
        {0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 },
69
        {0xff,0xcb,0xc0,0x58,0x36,0x33,0x23,0x22,0x21,0x11,0x10,0x0}};
70
 
71
static void out_umc (char port,char wert)
72
{
73
        outb_p (port,0x108);
74
        outb_p (wert,0x109);
75
}
76
 
77
static byte in_umc (char port)
78
{
79
        outb_p (port,0x108);
80
        return inb_p (0x109);
81
}
82
 
83
static void umc_set_speeds (byte speeds[])
84
{
85
        int i, tmp;
86
 
87
        outb_p (0x5A,0x108); /* enable umc */
88
 
89
        out_umc (0xd7,(speedtab[0][speeds[2]] | (speedtab[0][speeds[3]]<<4)));
90
        out_umc (0xd6,(speedtab[0][speeds[0]] | (speedtab[0][speeds[1]]<<4)));
91
        tmp = 0;
92
        for (i = 3; i >= 0; i--)
93
        {
94
                tmp = (tmp << 2) | speedtab[1][speeds[i]];
95
        }
96
        out_umc (0xdc,tmp);
97
        for (i = 0;i < 4; i++)
98
        {
99
                out_umc (0xd0+i,speedtab[2][speeds[i]]);
100
                out_umc (0xd8+i,speedtab[2][speeds[i]]);
101
        }
102
        outb_p (0xa5,0x108); /* disable umc */
103
 
104
        printk ("umc8672: drive speeds [0 to 11]: %d %d %d %d\n",
105
                speeds[0], speeds[1], speeds[2], speeds[3]);
106
}
107
 
108
static void tune_umc (ide_drive_t *drive, byte pio)
109
{
110
        unsigned long flags;
111
        ide_hwgroup_t *hwgroup = ide_hwifs[HWIF(drive)->index^1].hwgroup;
112
 
113
        pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
114
        printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", drive->name, pio, pio_to_umc[pio]);
115
        save_flags(flags);
116
        cli();
117
        if (hwgroup && hwgroup->handler != NULL) {
118
                printk("umc8672: other interface is busy: exiting tune_umc()\n");
119
        } else {
120
                current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio];
121
                umc_set_speeds (current_speeds);
122
        }
123
        restore_flags(flags);
124
}
125
 
126
void init_umc8672 (void)        /* called from ide.c */
127
{
128
        unsigned long flags;
129
 
130
        save_flags(flags);
131
        cli ();
132
        if (check_region(0x108, 2)) {
133
                restore_flags(flags);
134
                printk("\numc8672: PORTS 0x108-0x109 ALREADY IN USE\n");
135
                return;
136
        }
137
        outb_p (0x5A,0x108); /* enable umc */
138
        if (in_umc (0xd5) != 0xa0)
139
        {
140
                restore_flags(flags);
141
                printk ("umc8672: not found\n");
142
                return;
143
        }
144
        outb_p (0xa5,0x108); /* disable umc */
145
 
146
        umc_set_speeds (current_speeds);
147
        restore_flags(flags);
148
 
149
        request_region(0x108, 2, "umc8672");
150
        ide_hwifs[0].chipset = ide_umc8672;
151
        ide_hwifs[1].chipset = ide_umc8672;
152
        ide_hwifs[0].tuneproc = &tune_umc;
153
        ide_hwifs[1].tuneproc = &tune_umc;
154
 
155
}

powered by: WebSVN 2.1.0

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