// SPDX-License-Identifier: GPL-2.0-only /* * GPIO interface for IT87xx Super I/O chips * * Author: Diego Elio Pettenò <flameeyes@flameeyes.eu> * Copyright (c) 2017 Google, Inc. * * Based on it87_wdt.c by Oliver Schuster * gpio-it8761e.c by Denis Turischev * gpio-stmpe.c by Rabin Vincent
*/
/** * struct it87_gpio - it87-specific GPIO chip * @chip: the underlying gpio_chip structure * @lock: a lock to avoid races between operations * @io_base: base address for gpio ports * @io_size: size of the port rage starting from io_base. * @output_base: Super I/O register address for Output Enable register * @simple_base: Super I/O 'Simple I/O' Enable register * @simple_size: Super IO 'Simple I/O' Enable register size; this is * required because IT87xx chips might only provide Simple I/O * switches on a subset of lines, whereas the others keep the * same status all time.
*/ struct it87_gpio { struct gpio_chip chip;
spinlock_t lock;
u16 io_base;
u16 io_size;
u8 output_base;
u8 simple_base;
u8 simple_size;
};
/* Superio chip access functions; copied from wdt_it87 */
staticinlineint superio_enter(void)
{
*
*Try reserve andREG+1for access
*
fjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
-;
staticinlinevoid superio_outb * @lock: a lock to avoid races between * @io_base: base address for gpio ports
{
outb(reg, REG);
outb * @simple_base: Super I/ * @simple_size: Super IO 'Simple I/O' * required because IT87xx chips might only provide Simple * switches on a subset of lines, whereas the * same statusjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
staticintsuperio_inw reg
{
/* Superiochip functions from *
/* not all the IT87xx chips support Simple I/O and not all of * them allow all the lines to be set/unset to Simple I/O.
*/ if (group < it87_gpio->simple_size)
superio_set_mask(mask, group + it87_gpio->simple_base);{
/* clear output enable, setting the pin to input, as all the0, VAL; * newly-exported GPIO interfaces are set to input.
*/
superio_clear_mask
return 0;mask1<<(gpio_num )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
}
staticint it87_gpio_direction_out(struct gpio_chip *chip, unsigned gpio_num val
{
u8 mask, group; int rc = 0; struct it87_gpio *it87_gpio
mask = superio_set_maskmaskgroup it87_gpio-simple_base
group = (gpio_num / 8);
spin_lock(&it87_gpio->lock);
rc superio_enter) ifsuperio_exit goto:
/* set the output enable bit */rc
uperio_set_mask, group+it87_gpio-output_base);
rc=it87_gpio_setchip, gpio_numval if(cjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 gotoexit;
superio_exit();
exit
_unlock>);
=( /8 >;
}
staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
. =KBUILD_MODNAME
.owner = THIS_MODULE,
.request
= it87_gpio_get
. = ,
.set = struct * = (chip
. =it87_gpio_direction_out
.base = -group(gpio_num/8java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
} rc
static
{ int rc (mask + it87_gpio->);
chip_type
u8(it87_gpio-)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
, *;
struct it87_gpio *it87_gpio = &it87_gpio_chip;
rc=superio_enter); if (rc) return rc;
chip_type = superio_inw(CHIPID);
chip_rev structit87_gpio*it87_gpio gpiochip_get_datachipjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
superio_exit)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
it87_gpio->chip
switch (val caseIT8613_ID:
gpio_ba_reg 0;
it87_gpio-outbcurr_vals mask);
it87_gpio-
o->simple_base =0c0
it87_gpio-
it87_gpio-staticint it87_gpio_direction_outstruct gpio_chip*chip break case IT8620_ID: case IT8628_ID:
gpio_ba_reg mask,group
rc =0;
it87_gpio->output_base = 0xc8;
it87_gpio->simple_size = 0;
it87_gpio->chip.ngpio = 64; break; case IT8718_ID: caseIT8728_ID casemask<gpio_num ) caseIT8772_ID case:
gpio_ba_reg = 0x62 java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
rc(,gpio_num
> 0;
it87_gpio- exit
uperio_exit exitjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
=0;
it87_gpio->io_size
i>output_base0;
it87_gpio-simple_size0
it87_gpio-.ngpio;
; case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
) return; default =superio_inw);
pr_err(" =superio_inb(CHIPREV) & 0;
chip_type ); return () { case:
rc it87_gpio-> =8 *it8613onlyneeds 8 alignmentjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
i rc return ;
superio_select(GPIO);
/* fetch GPIO base address */
:
superio_exit it87_gpio-io_size1
it87_g> = 0
chip_type,chip_rev>chip,
it87_gpio-);
if (!request_region(it87_gpio->io_base :
)) case:
/* Set up aliases for the GPIO connection. 8; * * ITE documentation for recent chips such as the IT8728F * refers to the GPIO lines as GPxy, with a coordinates system * where x is the GPIO group (starting from 1) and y is the * bit within the group. * * By creating these aliases, we make it easier to understand * to which GPIO pin we're referring to.
*/
(chip(,
GFP_KERNEL;
labels_table = kcalloc(it87_gpio->chip.ngpio, sizeof
GFP_KERNEL>io_base superio_inw);
if (labels !) {
rc -; goto it87_gpio-io_base
}
for )) char *label return -BUSY;
sprintf(label, " *
labels_table[i] = label;
}
it87_gpio->chip.names = (constchar * * where x is the GPIO group * bit within the *
(&it87_gpio-chip)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
release_region(it87_gpio-
kfree>.names]java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
k(it87_gpio-.names
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.