|
1 |
| -/* |
2 |
| - on20.c (c) 1996-8 Grant R. Guenther <[email protected]> |
3 |
| - Under the terms of the GNU General Public License. |
4 |
| -
|
5 |
| - on20.c is a low-level protocol driver for the |
6 |
| - Onspec 90c20 parallel to IDE adapter. |
7 |
| -*/ |
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | +/* |
| 3 | + * (c) 1996-1998 Grant R. Guenther <[email protected]> |
| 4 | + * |
| 5 | + * on20.c is a low-level protocol driver for the |
| 6 | + * Onspec 90c20 parallel to IDE adapter. |
| 7 | + */ |
8 | 8 |
|
9 | 9 | #include <linux/module.h>
|
10 | 10 | #include <linux/init.h>
|
|
15 | 15 | #include <asm/io.h>
|
16 | 16 | #include "pata_parport.h"
|
17 | 17 |
|
18 |
| -#define op(f) w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4); |
19 |
| -#define vl(v) w2(4);w0(v);w2(5);w2(7);w2(5);w2(4); |
20 |
| - |
21 |
| -#define j44(a,b) (((a>>4)&0x0f)|(b&0xf0)) |
22 |
| - |
23 |
| -/* cont = 0 - access the IDE register file |
24 |
| - cont = 1 - access the IDE command set |
25 |
| -*/ |
26 |
| - |
27 |
| -static int on20_read_regr(struct pi_adapter *pi, int cont, int regr) |
28 |
| - |
29 |
| -{ int h,l, r ; |
| 18 | +#define op(f) \ |
| 19 | + do { \ |
| 20 | + w2(4); w0(f); w2(5); w2(0xd); \ |
| 21 | + w2(5); w2(0xd); w2(5); w2(4); \ |
| 22 | + } while (0) |
30 | 23 |
|
31 |
| - r = (regr<<2) + 1 + cont; |
| 24 | +#define vl(v) \ |
| 25 | + do { \ |
| 26 | + w2(4); w0(v); w2(5); \ |
| 27 | + w2(7); w2(5); w2(4); \ |
| 28 | + } while (0) |
32 | 29 |
|
33 |
| - op(1); vl(r); op(0); |
| 30 | +#define j44(a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) |
34 | 31 |
|
35 |
| - switch (pi->mode) { |
36 |
| - |
37 |
| - case 0: w2(4); w2(6); l = r1(); |
38 |
| - w2(4); w2(6); h = r1(); |
39 |
| - w2(4); w2(6); w2(4); w2(6); w2(4); |
40 |
| - return j44(l,h); |
41 |
| - |
42 |
| - case 1: w2(4); w2(0x26); r = r0(); |
43 |
| - w2(4); w2(0x26); w2(4); |
44 |
| - return r; |
| 32 | +/* |
| 33 | + * cont = 0 - access the IDE register file |
| 34 | + * cont = 1 - access the IDE command set |
| 35 | + */ |
45 | 36 |
|
| 37 | +static int on20_read_regr(struct pi_adapter *pi, int cont, int regr) |
| 38 | +{ |
| 39 | + int h, l, r; |
| 40 | + |
| 41 | + r = (regr << 2) + 1 + cont; |
| 42 | + |
| 43 | + op(1); vl(r); op(0); |
| 44 | + |
| 45 | + switch (pi->mode) { |
| 46 | + case 0: |
| 47 | + w2(4); w2(6); l = r1(); |
| 48 | + w2(4); w2(6); h = r1(); |
| 49 | + w2(4); w2(6); w2(4); w2(6); w2(4); |
| 50 | + return j44(l, h); |
| 51 | + case 1: |
| 52 | + w2(4); w2(0x26); r = r0(); |
| 53 | + w2(4); w2(0x26); w2(4); |
| 54 | + return r; |
46 | 55 | }
|
| 56 | + |
47 | 57 | return -1;
|
48 |
| -} |
| 58 | +} |
49 | 59 |
|
50 | 60 | static void on20_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
|
| 61 | +{ |
| 62 | + int r = (regr << 2) + 1 + cont; |
51 | 63 |
|
52 |
| -{ int r; |
53 |
| - |
54 |
| - r = (regr<<2) + 1 + cont; |
55 |
| - |
56 |
| - op(1); vl(r); |
57 |
| - op(0); vl(val); |
| 64 | + op(1); vl(r); |
| 65 | + op(0); vl(val); |
58 | 66 | op(0); vl(val);
|
59 | 67 | }
|
60 | 68 |
|
61 | 69 | static void on20_connect(struct pi_adapter *pi)
|
62 |
| - |
63 |
| -{ pi->saved_r0 = r0(); |
64 |
| - pi->saved_r2 = r2(); |
65 |
| - |
66 |
| - w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4); |
67 |
| - if (pi->mode) { op(2); vl(8); op(2); vl(9); } |
68 |
| - else { op(2); vl(0); op(2); vl(8); } |
| 70 | +{ |
| 71 | + pi->saved_r0 = r0(); |
| 72 | + pi->saved_r2 = r2(); |
| 73 | + |
| 74 | + w2(4); w0(0); w2(0xc); w2(4); w2(6); w2(4); w2(6); w2(4); |
| 75 | + if (pi->mode) { |
| 76 | + op(2); vl(8); op(2); vl(9); |
| 77 | + } else { |
| 78 | + op(2); vl(0); op(2); vl(8); |
| 79 | + } |
69 | 80 | }
|
70 | 81 |
|
71 | 82 | static void on20_disconnect(struct pi_adapter *pi)
|
72 |
| - |
73 |
| -{ w2(4);w0(7);w2(4);w2(0xc);w2(4); |
74 |
| - w0(pi->saved_r0); |
75 |
| - w2(pi->saved_r2); |
76 |
| -} |
| 83 | +{ |
| 84 | + w2(4); w0(7); w2(4); w2(0xc); w2(4); |
| 85 | + w0(pi->saved_r0); |
| 86 | + w2(pi->saved_r2); |
| 87 | +} |
77 | 88 |
|
78 | 89 | static void on20_read_block(struct pi_adapter *pi, char *buf, int count)
|
79 |
| - |
80 |
| -{ int k, l, h; |
| 90 | +{ |
| 91 | + int k, l, h; |
81 | 92 |
|
82 | 93 | op(1); vl(1); op(0);
|
83 | 94 |
|
84 |
| - for (k=0;k<count;k++) |
85 |
| - if (pi->mode) { |
86 |
| - w2(4); w2(0x26); buf[k] = r0(); |
87 |
| - } else { |
88 |
| - w2(6); l = r1(); w2(4); |
89 |
| - w2(6); h = r1(); w2(4); |
90 |
| - buf[k] = j44(l,h); |
91 |
| - } |
| 95 | + for (k = 0; k < count; k++) { |
| 96 | + if (pi->mode) { |
| 97 | + w2(4); w2(0x26); buf[k] = r0(); |
| 98 | + } else { |
| 99 | + w2(6); l = r1(); w2(4); |
| 100 | + w2(6); h = r1(); w2(4); |
| 101 | + buf[k] = j44(l, h); |
| 102 | + } |
| 103 | + } |
92 | 104 | w2(4);
|
93 | 105 | }
|
94 | 106 |
|
95 | 107 | static void on20_write_block(struct pi_adapter *pi, char *buf, int count)
|
96 |
| - |
97 |
| -{ int k; |
| 108 | +{ |
| 109 | + int k; |
98 | 110 |
|
99 | 111 | op(1); vl(1); op(0);
|
100 | 112 |
|
101 |
| - for (k=0;k<count;k++) { w2(5); w0(buf[k]); w2(7); } |
| 113 | + for (k = 0; k < count; k++) { |
| 114 | + w2(5); w0(buf[k]); w2(7); |
| 115 | + } |
102 | 116 | w2(4);
|
103 | 117 | }
|
104 | 118 |
|
105 | 119 | static void on20_log_adapter(struct pi_adapter *pi)
|
| 120 | +{ |
| 121 | + char *mode_string[2] = { "4-bit", "8-bit" }; |
106 | 122 |
|
107 |
| -{ char *mode_string[2] = {"4-bit","8-bit"}; |
108 |
| - |
109 |
| - dev_info(&pi->dev, "OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n", |
110 |
| - pi->port, pi->mode, mode_string[pi->mode], pi->delay); |
| 123 | + dev_info(&pi->dev, |
| 124 | + "OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n", |
| 125 | + pi->port, pi->mode, mode_string[pi->mode], pi->delay); |
111 | 126 | }
|
112 | 127 |
|
113 | 128 | static struct pi_protocol on20 = {
|
|
0 commit comments