hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/gpio/gpio-f7188x.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * GPIO driver for Fintek Super-I/O F71869, F71869A, F71882, F71889 and F81866
34 *
45 * Copyright (C) 2010-2013 LaCie
56 *
67 * Author: Simon Guinot <simon.guinot@sequanux.org>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
128 */
139
1410 #include <linux/module.h>
....@@ -39,8 +35,20 @@
3935 #define SIO_F71889_ID 0x0909 /* F71889 chipset ID */
4036 #define SIO_F71889A_ID 0x1005 /* F71889A chipset ID */
4137 #define SIO_F81866_ID 0x1010 /* F81866 chipset ID */
38
+#define SIO_F81804_ID 0x1502 /* F81804 chipset ID, same for f81966 */
39
+#define SIO_F81865_ID 0x0704 /* F81865 chipset ID */
4240
43
-enum chips { f71869, f71869a, f71882fg, f71889a, f71889f, f81866 };
41
+
42
+enum chips {
43
+ f71869,
44
+ f71869a,
45
+ f71882fg,
46
+ f71889a,
47
+ f71889f,
48
+ f81866,
49
+ f81804,
50
+ f81865,
51
+};
4452
4553 static const char * const f7188x_names[] = {
4654 "f71869",
....@@ -49,6 +57,8 @@
4957 "f71889a",
5058 "f71889f",
5159 "f81866",
60
+ "f81804",
61
+ "f81865",
5262 };
5363
5464 struct f7188x_sio {
....@@ -223,6 +233,27 @@
223233 F7188X_GPIO_BANK(80, 8, 0x88),
224234 };
225235
236
+
237
+static struct f7188x_gpio_bank f81804_gpio_bank[] = {
238
+ F7188X_GPIO_BANK(0, 8, 0xF0),
239
+ F7188X_GPIO_BANK(10, 8, 0xE0),
240
+ F7188X_GPIO_BANK(20, 8, 0xD0),
241
+ F7188X_GPIO_BANK(50, 8, 0xA0),
242
+ F7188X_GPIO_BANK(60, 8, 0x90),
243
+ F7188X_GPIO_BANK(70, 8, 0x80),
244
+ F7188X_GPIO_BANK(90, 8, 0x98),
245
+};
246
+
247
+static struct f7188x_gpio_bank f81865_gpio_bank[] = {
248
+ F7188X_GPIO_BANK(0, 8, 0xF0),
249
+ F7188X_GPIO_BANK(10, 8, 0xE0),
250
+ F7188X_GPIO_BANK(20, 8, 0xD0),
251
+ F7188X_GPIO_BANK(30, 8, 0xC0),
252
+ F7188X_GPIO_BANK(40, 8, 0xB0),
253
+ F7188X_GPIO_BANK(50, 8, 0xA0),
254
+ F7188X_GPIO_BANK(60, 5, 0x90),
255
+};
256
+
226257 static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
227258 {
228259 int err;
....@@ -239,7 +270,10 @@
239270
240271 superio_exit(sio->addr);
241272
242
- return !(dir & 1 << offset);
273
+ if (dir & 1 << offset)
274
+ return GPIO_LINE_DIRECTION_OUT;
275
+
276
+ return GPIO_LINE_DIRECTION_IN;
243277 }
244278
245279 static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
....@@ -407,6 +441,14 @@
407441 data->nr_bank = ARRAY_SIZE(f81866_gpio_bank);
408442 data->bank = f81866_gpio_bank;
409443 break;
444
+ case f81804:
445
+ data->nr_bank = ARRAY_SIZE(f81804_gpio_bank);
446
+ data->bank = f81804_gpio_bank;
447
+ break;
448
+ case f81865:
449
+ data->nr_bank = ARRAY_SIZE(f81865_gpio_bank);
450
+ data->bank = f81865_gpio_bank;
451
+ break;
410452 default:
411453 return -ENODEV;
412454 }
....@@ -469,6 +511,12 @@
469511 case SIO_F81866_ID:
470512 sio->type = f81866;
471513 break;
514
+ case SIO_F81804_ID:
515
+ sio->type = f81804;
516
+ break;
517
+ case SIO_F81865_ID:
518
+ sio->type = f81865;
519
+ break;
472520 default:
473521 pr_info(DRVNAME ": Unsupported Fintek device 0x%04x\n", devid);
474522 goto err;