hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-parport.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* ------------------------------------------------------------------------ *
23 * i2c-parport.c I2C bus over parallel port *
34 * ------------------------------------------------------------------------ *
....@@ -9,15 +10,6 @@
910 Frodo Looijaard <frodol@dds.nl>
1011 Kyösti Mälkki <kmalkki@cc.hut.fi>
1112
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 2 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
2113 * ------------------------------------------------------------------------ */
2214
2315 #define pr_fmt(fmt) "i2c-parport: " fmt
....@@ -33,7 +25,90 @@
3325 #include <linux/slab.h>
3426 #include <linux/list.h>
3527 #include <linux/mutex.h>
36
-#include "i2c-parport.h"
28
+
29
+#define PORT_DATA 0
30
+#define PORT_STAT 1
31
+#define PORT_CTRL 2
32
+
33
+struct lineop {
34
+ u8 val;
35
+ u8 port;
36
+ u8 inverted;
37
+};
38
+
39
+struct adapter_parm {
40
+ struct lineop setsda;
41
+ struct lineop setscl;
42
+ struct lineop getsda;
43
+ struct lineop getscl;
44
+ struct lineop init;
45
+ unsigned int smbus_alert:1;
46
+};
47
+
48
+static const struct adapter_parm adapter_parm[] = {
49
+ /* type 0: Philips adapter */
50
+ {
51
+ .setsda = { 0x80, PORT_DATA, 1 },
52
+ .setscl = { 0x08, PORT_CTRL, 0 },
53
+ .getsda = { 0x80, PORT_STAT, 0 },
54
+ .getscl = { 0x08, PORT_STAT, 0 },
55
+ },
56
+ /* type 1: home brew teletext adapter */
57
+ {
58
+ .setsda = { 0x02, PORT_DATA, 0 },
59
+ .setscl = { 0x01, PORT_DATA, 0 },
60
+ .getsda = { 0x80, PORT_STAT, 1 },
61
+ },
62
+ /* type 2: Velleman K8000 adapter */
63
+ {
64
+ .setsda = { 0x02, PORT_CTRL, 1 },
65
+ .setscl = { 0x08, PORT_CTRL, 1 },
66
+ .getsda = { 0x10, PORT_STAT, 0 },
67
+ },
68
+ /* type 3: ELV adapter */
69
+ {
70
+ .setsda = { 0x02, PORT_DATA, 1 },
71
+ .setscl = { 0x01, PORT_DATA, 1 },
72
+ .getsda = { 0x40, PORT_STAT, 1 },
73
+ .getscl = { 0x08, PORT_STAT, 1 },
74
+ },
75
+ /* type 4: ADM1032 evaluation board */
76
+ {
77
+ .setsda = { 0x02, PORT_DATA, 1 },
78
+ .setscl = { 0x01, PORT_DATA, 1 },
79
+ .getsda = { 0x10, PORT_STAT, 1 },
80
+ .init = { 0xf0, PORT_DATA, 0 },
81
+ .smbus_alert = 1,
82
+ },
83
+ /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */
84
+ {
85
+ .setsda = { 0x02, PORT_DATA, 1 },
86
+ .setscl = { 0x01, PORT_DATA, 1 },
87
+ .getsda = { 0x10, PORT_STAT, 1 },
88
+ },
89
+ /* type 6: Barco LPT->DVI (K5800236) adapter */
90
+ {
91
+ .setsda = { 0x02, PORT_DATA, 1 },
92
+ .setscl = { 0x01, PORT_DATA, 1 },
93
+ .getsda = { 0x20, PORT_STAT, 0 },
94
+ .getscl = { 0x40, PORT_STAT, 0 },
95
+ .init = { 0xfc, PORT_DATA, 0 },
96
+ },
97
+ /* type 7: One For All JP1 parallel port adapter */
98
+ {
99
+ .setsda = { 0x01, PORT_DATA, 0 },
100
+ .setscl = { 0x02, PORT_DATA, 0 },
101
+ .getsda = { 0x80, PORT_STAT, 1 },
102
+ .init = { 0x04, PORT_DATA, 1 },
103
+ },
104
+ /* type 8: VCT-jig */
105
+ {
106
+ .setsda = { 0x04, PORT_DATA, 1 },
107
+ .setscl = { 0x01, PORT_DATA, 1 },
108
+ .getsda = { 0x40, PORT_STAT, 0 },
109
+ .getscl = { 0x80, PORT_STAT, 1 },
110
+ },
111
+};
37112
38113 /* ----- Device list ------------------------------------------------------ */
39114
....@@ -48,9 +123,30 @@
48123
49124 static LIST_HEAD(adapter_list);
50125 static DEFINE_MUTEX(adapter_list_lock);
126
+
51127 #define MAX_DEVICE 4
52128 static int parport[MAX_DEVICE] = {0, -1, -1, -1};
129
+module_param_array(parport, int, NULL, 0);
130
+MODULE_PARM_DESC(parport,
131
+ "List of parallel ports to bind to, by index.\n"
132
+ " At most " __stringify(MAX_DEVICE) " devices are supported.\n"
133
+ " Default is one device connected to parport0.\n"
134
+);
53135
136
+static int type = -1;
137
+module_param(type, int, 0);
138
+MODULE_PARM_DESC(type,
139
+ "Type of adapter:\n"
140
+ " 0 = Philips adapter\n"
141
+ " 1 = home brew teletext adapter\n"
142
+ " 2 = Velleman K8000 adapter\n"
143
+ " 3 = ELV adapter\n"
144
+ " 4 = ADM1032 evaluation board\n"
145
+ " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"
146
+ " 6 = Barco LPT->DVI (K5800236) adapter\n"
147
+ " 7 = One For All JP1 parallel port adapter\n"
148
+ " 8 = VCT-jig\n"
149
+);
54150
55151 /* ----- Low-level parallel port access ----------------------------------- */
56152
....@@ -237,13 +333,17 @@
237333
238334 /* Setup SMBus alert if supported */
239335 if (adapter_parm[type].smbus_alert) {
240
- adapter->ara = i2c_setup_smbus_alert(&adapter->adapter,
241
- &adapter->alert_data);
242
- if (adapter->ara)
336
+ struct i2c_client *ara;
337
+
338
+ ara = i2c_new_smbus_alert_device(&adapter->adapter,
339
+ &adapter->alert_data);
340
+ if (!IS_ERR(ara)) {
341
+ adapter->ara = ara;
243342 parport_enable_irq(port);
244
- else
343
+ } else {
245344 dev_warn(&adapter->pdev->dev,
246345 "Failed to register ARA client\n");
346
+ }
247347 }
248348
249349 /* Add the new adapter to the list */
....@@ -318,13 +418,6 @@
318418 MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>");
319419 MODULE_DESCRIPTION("I2C bus over parallel port");
320420 MODULE_LICENSE("GPL");
321
-
322
-module_param_array(parport, int, NULL, 0);
323
-MODULE_PARM_DESC(parport,
324
- "List of parallel ports to bind to, by index.\n"
325
- " Atmost " __stringify(MAX_DEVICE) " devices are supported.\n"
326
- " Default is one device connected to parport0.\n"
327
-);
328421
329422 module_init(i2c_parport_init);
330423 module_exit(i2c_parport_exit);