gpio-f7188x.c (4f2c0a4acffbec01079c28f839422e64ddeff004) gpio-f7188x.c (3002b8642f016d7fe3ff56240dacea1075f6b877)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * GPIO driver for Fintek and Nuvoton Super-I/O chips
4 *
5 * Copyright (C) 2010-2013 LaCie
6 *
7 * Author: Simon Guinot <simon.guinot@sequanux.org>
8 */

--- 34 unchanged lines hidden (view full) ---

43#define SIO_F81804_ID 0x1502 /* F81804 chipset ID, same for F81966 */
44#define SIO_F81865_ID 0x0704 /* F81865 chipset ID */
45
46#define SIO_LD_GPIO_FINTEK 0x06 /* GPIO logical device */
47
48/*
49 * Nuvoton devices.
50 */
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * GPIO driver for Fintek and Nuvoton Super-I/O chips
4 *
5 * Copyright (C) 2010-2013 LaCie
6 *
7 * Author: Simon Guinot <simon.guinot@sequanux.org>
8 */

--- 34 unchanged lines hidden (view full) ---

43#define SIO_F81804_ID 0x1502 /* F81804 chipset ID, same for F81966 */
44#define SIO_F81865_ID 0x0704 /* F81865 chipset ID */
45
46#define SIO_LD_GPIO_FINTEK 0x06 /* GPIO logical device */
47
48/*
49 * Nuvoton devices.
50 */
51#define SIO_NCT6116D_ID 0xD283 /* NCT6116D chipset ID */
51#define SIO_NCT6126D_ID 0xD283 /* NCT6126D chipset ID */
52
53#define SIO_LD_GPIO_NUVOTON 0x07 /* GPIO logical device */
54
55
56enum chips {
57 f71869,
58 f71869a,
59 f71882fg,
60 f71889a,
61 f71889f,
62 f81866,
63 f81804,
64 f81865,
52
53#define SIO_LD_GPIO_NUVOTON 0x07 /* GPIO logical device */
54
55
56enum chips {
57 f71869,
58 f71869a,
59 f71882fg,
60 f71889a,
61 f71889f,
62 f81866,
63 f81804,
64 f81865,
65 nct6116d,
65 nct6126d,
66};
67
68static const char * const f7188x_names[] = {
69 "f71869",
70 "f71869a",
71 "f71882fg",
72 "f71889a",
73 "f71889f",
74 "f81866",
75 "f81804",
76 "f81865",
66};
67
68static const char * const f7188x_names[] = {
69 "f71869",
70 "f71869a",
71 "f71882fg",
72 "f71889a",
73 "f71889f",
74 "f81866",
75 "f81804",
76 "f81865",
77 "nct6116d",
77 "nct6126d",
78};
79
80struct f7188x_sio {
81 int addr;
82 int device;
83 enum chips type;
84};
85

--- 96 unchanged lines hidden (view full) ---

182 }
183
184#define f7188x_gpio_dir(base) ((base) + 0)
185#define f7188x_gpio_data_out(base) ((base) + 1)
186#define f7188x_gpio_data_in(base) ((base) + 2)
187/* Output mode register (0:open drain 1:push-pull). */
188#define f7188x_gpio_out_mode(base) ((base) + 3)
189
78};
79
80struct f7188x_sio {
81 int addr;
82 int device;
83 enum chips type;
84};
85

--- 96 unchanged lines hidden (view full) ---

182 }
183
184#define f7188x_gpio_dir(base) ((base) + 0)
185#define f7188x_gpio_data_out(base) ((base) + 1)
186#define f7188x_gpio_data_in(base) ((base) + 2)
187/* Output mode register (0:open drain 1:push-pull). */
188#define f7188x_gpio_out_mode(base) ((base) + 3)
189
190#define f7188x_gpio_dir_invert(type) ((type) == nct6116d)
191#define f7188x_gpio_data_single(type) ((type) == nct6116d)
190#define f7188x_gpio_dir_invert(type) ((type) == nct6126d)
191#define f7188x_gpio_data_single(type) ((type) == nct6126d)
192
193static struct f7188x_gpio_bank f71869_gpio_bank[] = {
194 F7188X_GPIO_BANK(0, 6, 0xF0, DRVNAME "-0"),
195 F7188X_GPIO_BANK(10, 8, 0xE0, DRVNAME "-1"),
196 F7188X_GPIO_BANK(20, 8, 0xD0, DRVNAME "-2"),
197 F7188X_GPIO_BANK(30, 8, 0xC0, DRVNAME "-3"),
198 F7188X_GPIO_BANK(40, 8, 0xB0, DRVNAME "-4"),
199 F7188X_GPIO_BANK(50, 5, 0xA0, DRVNAME "-5"),

--- 69 unchanged lines hidden (view full) ---

269 F7188X_GPIO_BANK(10, 8, 0xE0, DRVNAME "-1"),
270 F7188X_GPIO_BANK(20, 8, 0xD0, DRVNAME "-2"),
271 F7188X_GPIO_BANK(30, 8, 0xC0, DRVNAME "-3"),
272 F7188X_GPIO_BANK(40, 8, 0xB0, DRVNAME "-4"),
273 F7188X_GPIO_BANK(50, 8, 0xA0, DRVNAME "-5"),
274 F7188X_GPIO_BANK(60, 5, 0x90, DRVNAME "-6"),
275};
276
192
193static struct f7188x_gpio_bank f71869_gpio_bank[] = {
194 F7188X_GPIO_BANK(0, 6, 0xF0, DRVNAME "-0"),
195 F7188X_GPIO_BANK(10, 8, 0xE0, DRVNAME "-1"),
196 F7188X_GPIO_BANK(20, 8, 0xD0, DRVNAME "-2"),
197 F7188X_GPIO_BANK(30, 8, 0xC0, DRVNAME "-3"),
198 F7188X_GPIO_BANK(40, 8, 0xB0, DRVNAME "-4"),
199 F7188X_GPIO_BANK(50, 5, 0xA0, DRVNAME "-5"),

--- 69 unchanged lines hidden (view full) ---

269 F7188X_GPIO_BANK(10, 8, 0xE0, DRVNAME "-1"),
270 F7188X_GPIO_BANK(20, 8, 0xD0, DRVNAME "-2"),
271 F7188X_GPIO_BANK(30, 8, 0xC0, DRVNAME "-3"),
272 F7188X_GPIO_BANK(40, 8, 0xB0, DRVNAME "-4"),
273 F7188X_GPIO_BANK(50, 8, 0xA0, DRVNAME "-5"),
274 F7188X_GPIO_BANK(60, 5, 0x90, DRVNAME "-6"),
275};
276
277static struct f7188x_gpio_bank nct6116d_gpio_bank[] = {
277static struct f7188x_gpio_bank nct6126d_gpio_bank[] = {
278 F7188X_GPIO_BANK(0, 8, 0xE0, DRVNAME "-0"),
279 F7188X_GPIO_BANK(10, 8, 0xE4, DRVNAME "-1"),
280 F7188X_GPIO_BANK(20, 8, 0xE8, DRVNAME "-2"),
281 F7188X_GPIO_BANK(30, 8, 0xEC, DRVNAME "-3"),
282 F7188X_GPIO_BANK(40, 8, 0xF0, DRVNAME "-4"),
283 F7188X_GPIO_BANK(50, 8, 0xF4, DRVNAME "-5"),
284 F7188X_GPIO_BANK(60, 8, 0xF8, DRVNAME "-6"),
278 F7188X_GPIO_BANK(0, 8, 0xE0, DRVNAME "-0"),
279 F7188X_GPIO_BANK(10, 8, 0xE4, DRVNAME "-1"),
280 F7188X_GPIO_BANK(20, 8, 0xE8, DRVNAME "-2"),
281 F7188X_GPIO_BANK(30, 8, 0xEC, DRVNAME "-3"),
282 F7188X_GPIO_BANK(40, 8, 0xF0, DRVNAME "-4"),
283 F7188X_GPIO_BANK(50, 8, 0xF4, DRVNAME "-5"),
284 F7188X_GPIO_BANK(60, 8, 0xF8, DRVNAME "-6"),
285 F7188X_GPIO_BANK(70, 1, 0xFC, DRVNAME "-7"),
285 F7188X_GPIO_BANK(70, 8, 0xFC, DRVNAME "-7"),
286};
287
288static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
289{
290 int err;
291 struct f7188x_gpio_bank *bank = gpiochip_get_data(chip);
292 struct f7188x_sio *sio = bank->data->sio;
293 u8 dir;

--- 191 unchanged lines hidden (view full) ---

485 case f81804:
486 data->nr_bank = ARRAY_SIZE(f81804_gpio_bank);
487 data->bank = f81804_gpio_bank;
488 break;
489 case f81865:
490 data->nr_bank = ARRAY_SIZE(f81865_gpio_bank);
491 data->bank = f81865_gpio_bank;
492 break;
286};
287
288static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
289{
290 int err;
291 struct f7188x_gpio_bank *bank = gpiochip_get_data(chip);
292 struct f7188x_sio *sio = bank->data->sio;
293 u8 dir;

--- 191 unchanged lines hidden (view full) ---

485 case f81804:
486 data->nr_bank = ARRAY_SIZE(f81804_gpio_bank);
487 data->bank = f81804_gpio_bank;
488 break;
489 case f81865:
490 data->nr_bank = ARRAY_SIZE(f81865_gpio_bank);
491 data->bank = f81865_gpio_bank;
492 break;
493 case nct6116d:
494 data->nr_bank = ARRAY_SIZE(nct6116d_gpio_bank);
495 data->bank = nct6116d_gpio_bank;
493 case nct6126d:
494 data->nr_bank = ARRAY_SIZE(nct6126d_gpio_bank);
495 data->bank = nct6126d_gpio_bank;
496 break;
497 default:
498 return -ENODEV;
499 }
500 data->sio = sio;
501
502 platform_set_drvdata(pdev, data);
503

--- 50 unchanged lines hidden (view full) ---

554 sio->type = f81866;
555 break;
556 case SIO_F81804_ID:
557 sio->type = f81804;
558 break;
559 case SIO_F81865_ID:
560 sio->type = f81865;
561 break;
496 break;
497 default:
498 return -ENODEV;
499 }
500 data->sio = sio;
501
502 platform_set_drvdata(pdev, data);
503

--- 50 unchanged lines hidden (view full) ---

554 sio->type = f81866;
555 break;
556 case SIO_F81804_ID:
557 sio->type = f81804;
558 break;
559 case SIO_F81865_ID:
560 sio->type = f81865;
561 break;
562 case SIO_NCT6116D_ID:
562 case SIO_NCT6126D_ID:
563 sio->device = SIO_LD_GPIO_NUVOTON;
563 sio->device = SIO_LD_GPIO_NUVOTON;
564 sio->type = nct6116d;
564 sio->type = nct6126d;
565 break;
566 default:
567 pr_info("Unsupported Fintek device 0x%04x\n", devid);
568 goto err;
569 }
570
571 /* double check manufacturer where possible */
565 break;
566 default:
567 pr_info("Unsupported Fintek device 0x%04x\n", devid);
568 goto err;
569 }
570
571 /* double check manufacturer where possible */
572 if (sio->type != nct6116d) {
572 if (sio->type != nct6126d) {
573 manid = superio_inw(addr, SIO_FINTEK_MANID);
574 if (manid != SIO_FINTEK_ID) {
575 pr_debug("Not a Fintek device at 0x%08x\n", addr);
576 goto err;
577 }
578 }
579
580 sio->addr = addr;
581 err = 0;
582
583 pr_info("Found %s at %#x\n", f7188x_names[sio->type], (unsigned int)addr);
573 manid = superio_inw(addr, SIO_FINTEK_MANID);
574 if (manid != SIO_FINTEK_ID) {
575 pr_debug("Not a Fintek device at 0x%08x\n", addr);
576 goto err;
577 }
578 }
579
580 sio->addr = addr;
581 err = 0;
582
583 pr_info("Found %s at %#x\n", f7188x_names[sio->type], (unsigned int)addr);
584 if (sio->type != nct6116d)
584 if (sio->type != nct6126d)
585 pr_info(" revision %d\n", superio_inb(addr, SIO_FINTEK_DEVREV));
586
587err:
588 superio_exit(addr);
589 return err;
590}
591
592static struct platform_device *f7188x_gpio_pdev;

--- 74 unchanged lines hidden ---
585 pr_info(" revision %d\n", superio_inb(addr, SIO_FINTEK_DEVREV));
586
587err:
588 superio_exit(addr);
589 return err;
590}
591
592static struct platform_device *f7188x_gpio_pdev;

--- 74 unchanged lines hidden ---