|
1 | | -/* |
2 | | - ktti.c (c) 1998 Grant R. Guenther <grant@torque.net> |
3 | | - Under the terms of the GNU General Public License. |
4 | | -
|
5 | | - ktti.c is a low-level protocol driver for the KT Technology |
6 | | - parallel port adapter. This adapter is used in the "PHd" |
7 | | - portable hard-drives. As far as I can tell, this device |
8 | | - supports 4-bit mode _only_. |
9 | | -
|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | +/* |
| 3 | + * (c) 1998 Grant R. Guenther <grant@torque.net> |
| 4 | + * |
| 5 | + * ktti.c is a low-level protocol driver for the KT Technology |
| 6 | + * parallel port adapter. This adapter is used in the "PHd" |
| 7 | + * portable hard-drives. As far as I can tell, this device |
| 8 | + * supports 4-bit mode _only_. |
10 | 9 | */ |
11 | 10 |
|
12 | 11 | #include <linux/module.h> |
|
18 | 17 | #include <asm/io.h> |
19 | 18 | #include "pata_parport.h" |
20 | 19 |
|
21 | | -#define j44(a,b) (((a>>4)&0x0f)|(b&0xf0)) |
| 20 | +#define j44(a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) |
22 | 21 |
|
23 | | -/* cont = 0 - access the IDE register file |
24 | | - cont = 1 - access the IDE command set |
25 | | -*/ |
26 | | - |
27 | | -static int cont_map[2] = { 0x10, 0x08 }; |
| 22 | +/* |
| 23 | + * cont = 0 - access the IDE register file |
| 24 | + * cont = 1 - access the IDE command set |
| 25 | + */ |
| 26 | +static int cont_map[2] = { 0x10, 0x08 }; |
28 | 27 |
|
29 | 28 | static void ktti_write_regr(struct pi_adapter *pi, int cont, int regr, int val) |
| 29 | +{ |
| 30 | + int r = regr + cont_map[cont]; |
30 | 31 |
|
31 | | -{ int r; |
32 | | - |
33 | | - r = regr + cont_map[cont]; |
34 | | - |
35 | | - w0(r); w2(0xb); w2(0xa); w2(3); w2(6); |
| 32 | + w0(r); w2(0xb); w2(0xa); w2(3); w2(6); |
36 | 33 | w0(val); w2(3); w0(0); w2(6); w2(0xb); |
37 | 34 | } |
38 | 35 |
|
39 | 36 | static int ktti_read_regr(struct pi_adapter *pi, int cont, int regr) |
40 | | - |
41 | | -{ int a, b, r; |
| 37 | +{ |
| 38 | + int a, b, r; |
42 | 39 |
|
43 | 40 | r = regr + cont_map[cont]; |
44 | 41 |
|
45 | | - w0(r); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9); |
| 42 | + w0(r); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9); |
46 | 43 | a = r1(); w2(0xc); b = r1(); w2(9); w2(0xc); w2(9); |
47 | | - return j44(a,b); |
48 | | - |
| 44 | + return j44(a, b); |
49 | 45 | } |
50 | 46 |
|
51 | 47 | static void ktti_read_block(struct pi_adapter *pi, char *buf, int count) |
| 48 | +{ |
| 49 | + int k, a, b; |
52 | 50 |
|
53 | | -{ int k, a, b; |
54 | | - |
55 | | - for (k=0;k<count/2;k++) { |
| 51 | + for (k = 0; k < count / 2; k++) { |
56 | 52 | w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9); |
57 | 53 | a = r1(); w2(0xc); b = r1(); w2(9); |
58 | | - buf[2*k] = j44(a,b); |
| 54 | + buf[2*k] = j44(a, b); |
59 | 55 | a = r1(); w2(0xc); b = r1(); w2(9); |
60 | | - buf[2*k+1] = j44(a,b); |
| 56 | + buf[2*k+1] = j44(a, b); |
61 | 57 | } |
62 | 58 | } |
63 | 59 |
|
64 | 60 | static void ktti_write_block(struct pi_adapter *pi, char *buf, int count) |
| 61 | +{ |
| 62 | + int k; |
65 | 63 |
|
66 | | -{ int k; |
67 | | - |
68 | | - for (k=0;k<count/2;k++) { |
| 64 | + for (k = 0; k < count / 2; k++) { |
69 | 65 | w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6); |
70 | | - w0(buf[2*k]); w2(3); |
71 | | - w0(buf[2*k+1]); w2(6); |
| 66 | + w0(buf[2 * k]); w2(3); |
| 67 | + w0(buf[2 * k + 1]); w2(6); |
72 | 68 | w2(0xb); |
73 | 69 | } |
74 | 70 | } |
75 | 71 |
|
76 | 72 | static void ktti_connect(struct pi_adapter *pi) |
77 | | - |
78 | | -{ pi->saved_r0 = r0(); |
79 | | - pi->saved_r2 = r2(); |
80 | | - w2(0xb); w2(0xa); w0(0); w2(3); w2(6); |
| 73 | +{ |
| 74 | + pi->saved_r0 = r0(); |
| 75 | + pi->saved_r2 = r2(); |
| 76 | + w2(0xb); w2(0xa); w0(0); w2(3); w2(6); |
81 | 77 | } |
82 | 78 |
|
83 | 79 | static void ktti_disconnect(struct pi_adapter *pi) |
84 | | - |
85 | | -{ w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4); |
| 80 | +{ |
| 81 | + w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4); |
86 | 82 | w0(pi->saved_r0); |
87 | | - w2(pi->saved_r2); |
88 | | -} |
| 83 | + w2(pi->saved_r2); |
| 84 | +} |
89 | 85 |
|
90 | 86 | static void ktti_log_adapter(struct pi_adapter *pi) |
91 | | - |
92 | 87 | { |
93 | 88 | dev_info(&pi->dev, "KT adapter at 0x%x, delay %d\n", |
94 | | - pi->port, pi->delay); |
| 89 | + pi->port, pi->delay); |
95 | 90 | } |
96 | 91 |
|
97 | 92 | static struct pi_protocol ktti = { |
|
0 commit comments