| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * GPIO driver for Fintek Super-I/O F71869, F71869A, F71882, F71889 and F81866 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2010-2013 LaCie |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * 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. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | 10 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 39 | 35 | #define SIO_F71889_ID 0x0909 /* F71889 chipset ID */ |
|---|
| 40 | 36 | #define SIO_F71889A_ID 0x1005 /* F71889A chipset ID */ |
|---|
| 41 | 37 | #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 */ |
|---|
| 42 | 40 | |
|---|
| 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 | +}; |
|---|
| 44 | 52 | |
|---|
| 45 | 53 | static const char * const f7188x_names[] = { |
|---|
| 46 | 54 | "f71869", |
|---|
| .. | .. |
|---|
| 49 | 57 | "f71889a", |
|---|
| 50 | 58 | "f71889f", |
|---|
| 51 | 59 | "f81866", |
|---|
| 60 | + "f81804", |
|---|
| 61 | + "f81865", |
|---|
| 52 | 62 | }; |
|---|
| 53 | 63 | |
|---|
| 54 | 64 | struct f7188x_sio { |
|---|
| .. | .. |
|---|
| 223 | 233 | F7188X_GPIO_BANK(80, 8, 0x88), |
|---|
| 224 | 234 | }; |
|---|
| 225 | 235 | |
|---|
| 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 | + |
|---|
| 226 | 257 | static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) |
|---|
| 227 | 258 | { |
|---|
| 228 | 259 | int err; |
|---|
| .. | .. |
|---|
| 239 | 270 | |
|---|
| 240 | 271 | superio_exit(sio->addr); |
|---|
| 241 | 272 | |
|---|
| 242 | | - return !(dir & 1 << offset); |
|---|
| 273 | + if (dir & 1 << offset) |
|---|
| 274 | + return GPIO_LINE_DIRECTION_OUT; |
|---|
| 275 | + |
|---|
| 276 | + return GPIO_LINE_DIRECTION_IN; |
|---|
| 243 | 277 | } |
|---|
| 244 | 278 | |
|---|
| 245 | 279 | static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) |
|---|
| .. | .. |
|---|
| 407 | 441 | data->nr_bank = ARRAY_SIZE(f81866_gpio_bank); |
|---|
| 408 | 442 | data->bank = f81866_gpio_bank; |
|---|
| 409 | 443 | 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; |
|---|
| 410 | 452 | default: |
|---|
| 411 | 453 | return -ENODEV; |
|---|
| 412 | 454 | } |
|---|
| .. | .. |
|---|
| 469 | 511 | case SIO_F81866_ID: |
|---|
| 470 | 512 | sio->type = f81866; |
|---|
| 471 | 513 | break; |
|---|
| 514 | + case SIO_F81804_ID: |
|---|
| 515 | + sio->type = f81804; |
|---|
| 516 | + break; |
|---|
| 517 | + case SIO_F81865_ID: |
|---|
| 518 | + sio->type = f81865; |
|---|
| 519 | + break; |
|---|
| 472 | 520 | default: |
|---|
| 473 | 521 | pr_info(DRVNAME ": Unsupported Fintek device 0x%04x\n", devid); |
|---|
| 474 | 522 | goto err; |
|---|