1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * on20.c is a low-level protocol driver for the
6 * Onspec 90c20 parallel to IDE adapter.
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/delay.h>
12 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/wait.h>
16 #include "pata_parport.h"
20 w2(4); w0(f); w2(5); w2(0xd); \
21 w2(5); w2(0xd); w2(5); w2(4); \
26 w2(4); w0(v); w2(5); \
27 w2(7); w2(5); w2(4); \
30 #define j44(a, b) (((a >> 4) & 0x0f) | (b & 0xf0))
33 * cont = 0 - access the IDE register file
34 * cont = 1 - access the IDE command set
37 static int on20_read_regr(struct pi_adapter *pi, int cont, int regr)
41 r = (regr << 2) + 1 + cont;
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);
52 w2(4); w2(0x26); r = r0();
53 w2(4); w2(0x26); w2(4);
60 static void on20_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
62 int r = (regr << 2) + 1 + cont;
69 static void on20_connect(struct pi_adapter *pi)
74 w2(4); w0(0); w2(0xc); w2(4); w2(6); w2(4); w2(6); w2(4);
76 op(2); vl(8); op(2); vl(9);
78 op(2); vl(0); op(2); vl(8);
82 static void on20_disconnect(struct pi_adapter *pi)
84 w2(4); w0(7); w2(4); w2(0xc); w2(4);
89 static void on20_read_block(struct pi_adapter *pi, char *buf, int count)
95 for (k = 0; k < count; k++) {
97 w2(4); w2(0x26); buf[k] = r0();
99 w2(6); l = r1(); w2(4);
100 w2(6); h = r1(); w2(4);
107 static void on20_write_block(struct pi_adapter *pi, char *buf, int count)
113 for (k = 0; k < count; k++) {
114 w2(5); w0(buf[k]); w2(7);
119 static void on20_log_adapter(struct pi_adapter *pi)
121 char *mode_string[2] = { "4-bit", "8-bit" };
124 "OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n",
125 pi->port, pi->mode, mode_string[pi->mode], pi->delay);
128 static struct pi_protocol on20 = {
129 .owner = THIS_MODULE,
135 .write_regr = on20_write_regr,
136 .read_regr = on20_read_regr,
137 .write_block = on20_write_block,
138 .read_block = on20_read_block,
139 .connect = on20_connect,
140 .disconnect = on20_disconnect,
141 .log_adapter = on20_log_adapter,
144 MODULE_LICENSE("GPL");
146 MODULE_DESCRIPTION("Onspec 90c20 parallel port IDE adapter protocol driver");
147 module_pata_parport_driver(on20);