Lines Matching +full:data +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * GPIO driver for Fintek Super-I/O F71869, F71869A, F71882, F71889 and F81866
5 * Copyright (C) 2010-2013 LaCie
17 #define DRVNAME "gpio-f7188x"
20 * Super-I/O registers
28 #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */
29 #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */
65 int addr; member
72 struct f7188x_gpio_data *data; member
82 * Super-I/O functions.
114 return -EBUSY; in superio_enter()
170 /* Output mode register (0:open drain 1:push-pull). */
261 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_get_direction()
264 err = superio_enter(sio->addr); in f7188x_gpio_get_direction()
267 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_get_direction()
269 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); in f7188x_gpio_get_direction()
271 superio_exit(sio->addr); in f7188x_gpio_get_direction()
283 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_direction_in()
286 err = superio_enter(sio->addr); in f7188x_gpio_direction_in()
289 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_direction_in()
291 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); in f7188x_gpio_direction_in()
293 superio_outb(sio->addr, gpio_dir(bank->regbase), dir); in f7188x_gpio_direction_in()
295 superio_exit(sio->addr); in f7188x_gpio_direction_in()
304 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_get()
305 u8 dir, data; in f7188x_gpio_get() local
307 err = superio_enter(sio->addr); in f7188x_gpio_get()
310 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_get()
312 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); in f7188x_gpio_get()
315 data = superio_inb(sio->addr, gpio_data_out(bank->regbase)); in f7188x_gpio_get()
317 data = superio_inb(sio->addr, gpio_data_in(bank->regbase)); in f7188x_gpio_get()
319 superio_exit(sio->addr); in f7188x_gpio_get()
321 return !!(data & BIT(offset)); in f7188x_gpio_get()
329 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_direction_out()
332 err = superio_enter(sio->addr); in f7188x_gpio_direction_out()
335 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_direction_out()
337 data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); in f7188x_gpio_direction_out()
342 superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); in f7188x_gpio_direction_out()
344 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); in f7188x_gpio_direction_out()
346 superio_outb(sio->addr, gpio_dir(bank->regbase), dir); in f7188x_gpio_direction_out()
348 superio_exit(sio->addr); in f7188x_gpio_direction_out()
357 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_set()
360 err = superio_enter(sio->addr); in f7188x_gpio_set()
363 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_set()
365 data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); in f7188x_gpio_set()
370 superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); in f7188x_gpio_set()
372 superio_exit(sio->addr); in f7188x_gpio_set()
381 struct f7188x_sio *sio = bank->data->sio; in f7188x_gpio_set_config()
382 u8 data; in f7188x_gpio_set_config() local
386 return -ENOTSUPP; in f7188x_gpio_set_config()
388 err = superio_enter(sio->addr); in f7188x_gpio_set_config()
391 superio_select(sio->addr, SIO_LD_GPIO); in f7188x_gpio_set_config()
393 data = superio_inb(sio->addr, gpio_out_mode(bank->regbase)); in f7188x_gpio_set_config()
395 data &= ~BIT(offset); in f7188x_gpio_set_config()
397 data |= BIT(offset); in f7188x_gpio_set_config()
398 superio_outb(sio->addr, gpio_out_mode(bank->regbase), data); in f7188x_gpio_set_config()
400 superio_exit(sio->addr); in f7188x_gpio_set_config()
412 struct f7188x_sio *sio = dev_get_platdata(&pdev->dev); in f7188x_gpio_probe()
413 struct f7188x_gpio_data *data; in f7188x_gpio_probe() local
415 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in f7188x_gpio_probe()
416 if (!data) in f7188x_gpio_probe()
417 return -ENOMEM; in f7188x_gpio_probe()
419 switch (sio->type) { in f7188x_gpio_probe()
421 data->nr_bank = ARRAY_SIZE(f71869_gpio_bank); in f7188x_gpio_probe()
422 data->bank = f71869_gpio_bank; in f7188x_gpio_probe()
425 data->nr_bank = ARRAY_SIZE(f71869a_gpio_bank); in f7188x_gpio_probe()
426 data->bank = f71869a_gpio_bank; in f7188x_gpio_probe()
429 data->nr_bank = ARRAY_SIZE(f71882_gpio_bank); in f7188x_gpio_probe()
430 data->bank = f71882_gpio_bank; in f7188x_gpio_probe()
433 data->nr_bank = ARRAY_SIZE(f71889a_gpio_bank); in f7188x_gpio_probe()
434 data->bank = f71889a_gpio_bank; in f7188x_gpio_probe()
437 data->nr_bank = ARRAY_SIZE(f71889_gpio_bank); in f7188x_gpio_probe()
438 data->bank = f71889_gpio_bank; in f7188x_gpio_probe()
441 data->nr_bank = ARRAY_SIZE(f81866_gpio_bank); in f7188x_gpio_probe()
442 data->bank = f81866_gpio_bank; in f7188x_gpio_probe()
445 data->nr_bank = ARRAY_SIZE(f81804_gpio_bank); in f7188x_gpio_probe()
446 data->bank = f81804_gpio_bank; in f7188x_gpio_probe()
449 data->nr_bank = ARRAY_SIZE(f81865_gpio_bank); in f7188x_gpio_probe()
450 data->bank = f81865_gpio_bank; in f7188x_gpio_probe()
453 return -ENODEV; in f7188x_gpio_probe()
455 data->sio = sio; in f7188x_gpio_probe()
457 platform_set_drvdata(pdev, data); in f7188x_gpio_probe()
460 for (i = 0; i < data->nr_bank; i++) { in f7188x_gpio_probe()
461 struct f7188x_gpio_bank *bank = &data->bank[i]; in f7188x_gpio_probe()
463 bank->chip.parent = &pdev->dev; in f7188x_gpio_probe()
464 bank->data = data; in f7188x_gpio_probe()
466 err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank); in f7188x_gpio_probe()
468 dev_err(&pdev->dev, in f7188x_gpio_probe()
478 static int __init f7188x_find(int addr, struct f7188x_sio *sio) in f7188x_find() argument
483 err = superio_enter(addr); in f7188x_find()
487 err = -ENODEV; in f7188x_find()
488 devid = superio_inw(addr, SIO_MANID); in f7188x_find()
490 pr_debug(DRVNAME ": Not a Fintek device at 0x%08x\n", addr); in f7188x_find()
494 devid = superio_inw(addr, SIO_DEVID); in f7188x_find()
497 sio->type = f71869; in f7188x_find()
500 sio->type = f71869a; in f7188x_find()
503 sio->type = f71882fg; in f7188x_find()
506 sio->type = f71889a; in f7188x_find()
509 sio->type = f71889f; in f7188x_find()
512 sio->type = f81866; in f7188x_find()
515 sio->type = f81804; in f7188x_find()
518 sio->type = f81865; in f7188x_find()
524 sio->addr = addr; in f7188x_find()
528 f7188x_names[sio->type], in f7188x_find()
529 (unsigned int) addr, in f7188x_find()
530 (int) superio_inb(addr, SIO_DEVREV)); in f7188x_find()
533 superio_exit(addr); in f7188x_find()
544 f7188x_gpio_pdev = platform_device_alloc(DRVNAME, -1); in f7188x_gpio_device_add()
546 return -ENOMEM; in f7188x_gpio_device_add()
551 pr_err(DRVNAME "Platform data allocation failed\n"); in f7188x_gpio_device_add()
570 * Try to match a supported Fintek device by reading the (hard-wired)
589 return -ENODEV; in f7188x_gpio_init()
609 MODULE_DESCRIPTION("GPIO driver for Super-I/O chips F71869, F71869A, F71882FG, F71889A, F71889F and…