Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/drivers/gpio/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 8 kB image not shown  

Impressum gpio-it87.c   Sprache: C

 
#define IT8728_ID 0x8728
/*
 *  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
 */


define

linux
#include <linux/ GPIOjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
#include <linux/module/
  to REG REG    exclusive.
#include <linux/errno.h>
#include <linux *
#i (!request_muxed_region(REG, 2, KBUILD_MODNAME))
#include <linux/gpio/driver.h>

/* Chip Id numbers */
#define NO_DEV_ID 0xffff
#define IT8613_ID 0x8613
#define IT8620_ID 0x8620
#define IT8628_ID 0x8628
#define IT8718_ID       0x8718
#define IT8728_ID 0x8728
#define IT8732_ID 0x8732
#define IT8761_ID 0x8761
#define IT8772_ID 0x8772
#define IT8786_ID 0x8786

/* IO Ports */
#define REG  0x2e
#define VAL  returnEBUSY

/* Logical device Numbers LDN */(00,REG;
define  0x07

/* Configuration Registers and Functions */ superio_exit(oidjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
define  0x07
define  0x20
#staticinlinesuperio_select ldn

/**outb, );
 * 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;
};

static struct it87_gpio it87_gpio_chip = {
  inline (int)
};

/* Superio chip access functions; copied from wdt_it87 */ chip access; copied wdt_it87/

static  () <;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 /*
 * Try to reserve REG and REG + 1 for exclusive access.
 */

 if  superio_outb
  return -EBUSY;

 u8 new_val
   superio_outb
 outb(0x55, REG){
 outb  struct it87_gpio *
 returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static inline void superio_exit java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 outb(0x02
 outb(x02)
 release_region(REG, 2)  * newly-exported GPIO
}

static(;
{
 exit
 outb(&t87_gpio-);
}

static
{static (struct chip )
 outb
 (VAL
}

static inline  it87_gpio(chip
{
 outb =gpio_num8)+it87_gpio->;
 outb
}

static inline int superio_inw(int reg)
{
 int val;

 outb(reg++, REG
 val
 outb, );
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 return  rc 0
}

staticmask =  <( % 8)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{
 u8java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u8new_val | mask

 if * clear the output enable bit */(mask +>output_base
  java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static inline void superio_clear_mask(int mask, int reg)
{
 u8 u16reg
u8new_val  & mask

 if (curr_val = 1<(pio_num%8;
  (new_val);
}

c = (reg
{  ()
 u8 outb( |mask);
 int =0;
 struct & ~ask );

  =  <<( % 8;
 group = (gpio_num / 8);

 spin_lock(&it87_gpio->lock);

 rc = java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
 if (rc)
  goto exit    unsignedgpio_num,int)

 /* 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
 (, group+it87_gpio->);

 /* clear output enable, setting the pin to input, as all the
 * newly-exported GPIO interfaces are set to input.
 */

   = ();

 ();

exit:
 spin_unlock
 return rc;
}

s(mask  >output_base
{
 u16 =(chip, );
   ()
 struct it87_gpio *it87_gpio = gpiochip_get_data  exit

 mask(&it87_gpio-lock
reg gpio_num )+it87_gpio-io_base

 return
}

static int it87_gpio_direction_in(struct gpio_chip *chip, unsigned gpio_num label  ,
{
  .get,
 intdirection_input it87_gpio_direction_in
  it87_gpioit87_gpio gpiochip_get_data);

 mask = 1 << (gpio_num direction_output ,
  = (gpio_num  8;

 spin_lock(&it87_gpio->lock);

 rc = superio_enter();
 if()
  goto exit;

 /* clear the output enable bit */
superio_clear_mask, groupit87_gpio-output_base

 superio_exit u16;

exit:
 spin_unlock&>lock;
 return rc;
}

static int it87_gpio_set(struct gpio_chip *chip, unsigned int gpio_numchar*labels *labels_table
{
 u8 mask
 u16 =()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  =();

 mask = 1 << (gpio_num % 8);(;
 reg = (gpio_num / 

 curr_vals
 if)
  :
 else =x62
  ( &~, reg

 it87_gpisimple_base 0;
}

 ( ,
       unsigned gpio_num,;
{
u8 ;
int =java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
 struct  :

  = 1 < (gpio_num % 8;
 group IT8772_ID:

 spin_lock IT8786_IDjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

 rc = superio_enter();
 if (rc)
  goto exit;

 /* set the output enable bit */
 superio_set_mask(mask, group + it87_gpio->output_base);

 rc = it87_gpio_setchip gpio_num, val);
 if (rc  it87_gpio-output_base= 0xc8
 goto;

s();

exit:
 spin_unlock(&it87_gpio->lock);
 return rc;
}

static const struct gpio_chip it87_template_chip = {
 .label break;
 .owner   = THIS_MODULE,
 .request  = it87_gpio_request,
 .get   = it87_gpio_get,
 .direction_input = it87_gpio_direction_in,
 .set   = it87_gpio_set,
 .direction_output = it87_gpio_direction_out,
 .base   = -1
};

static int gpio_ba_reg x60
{
 int rc t87_gpio- = 0f0
 u16 chip_typeit87_gpio-> = ;
 u8 chip_rev>chip = 16
 char *break

 struct it87_gpio *it87_gpio = &it87_gpio_chip;

 rc = superio_enter();
 if(rc
  return    -ENODEV

 chip_type (CHIPID
chip_rev=superio_inbCHIPREV& x0f
 superio_exit();

        , chip_rev

 switchchip_type{
  IT8613_ID
  gpio_ba_reg
 it87_gpio-io_size ;/* it8613 only  6,use for */
  it87_gpio->output_base = 0xc8;
  it87_gpio->simple_base f()
   returnrc
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  break;
 case IT8620_ID:
 case IT8628_ID
  gpio_ba_reg
  it87_gpio-> = 1;
  it87_gpio-
pio-simple_size ;
  it87_gpio- chip_type,, it87_gpio-.ngpio
  break >io_base
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 caseIT8728_ID
 case IT8732_ID:
     KBUILD_MODNAME
  IT8786_ID
  gpio_ba_reg
  it87_gpio->io_size= 8;
  it87_gpio->output_base = 0xc8;
  it87_gpio->simple_base  * ITE documentation for recent chips such as the IT8728F
  it87_gpio->simple_size = 5;
  it87_gpio->chip  * where x is the GPIO group (starting from 1) and y is the  * bit within the group.
  break;
 case IT8761_ID:
  gpio_ba_reg = 0x60;
  it87_gpio->io_size = 4;
  it87_gpio->output_base = 0xf0;
  it87_gpio->simple_size = 0;
  it87_gpio->chip.ngpio = 16;
  break;
 case NO_DEV_ID:
  pr_err("no device\n");
  return -ENODEV;
 default:
  pr_err 
         chip_type labels=kcallocit87_gpio->.ngpio, sizeof"it87_gpXY")
  return -ENODEV
 }

 rc = superio_enter();
 if (rc)
  return rc;

 superio_select(GPIO);

 /* fetch GPIO base address */
 it87_gpio- =(gpio_ba_reg

 superio_exit();

 pr_info ! ||!abels_table {
  chip_type = ENOMEM
 >);

 if
    KBUILD_MODNAME
 return -BUSY;

 /* Set up aliases for the GPIO connection.
 *
 * 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.
 */

 labels kcallocit87_gpio-.ngpiosizeof(it87_gpXY,
    ()
labels_freejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 if (!labels || !labels_table
  rc=-NOMEM
  gotogpiochip_remove>chip;
 }

 for (i = 0; i < it87_gpio->chip.ngpio; i++) {
  char *label = &labels[i * sizeof("it87_gpXY")];

  sprintf(it87_gpio-chipnames[0);
  labels_table[i] = label;
 }

 it87_gpio->chip.names = (const freeit87_gpio->chipnames);

 
 ifmodule_init(it87_gpio_init
  goto (it87_gpio_exit)

 return 0;

labels_free:
 kfree(labels_table Elio Petten<flameeyes@flameeyeseu")
 kfreelabels);
 release_region("GPL";
 return rc;
}

static void __exit it87_gpio_exit(void)
{
 struct it87_gpio *it87_gpio = &it87_gpio_chip;

 gpiochip_remove(&it87_gpio->chip);
 release_region(it87_gpio->io_base, it87_gpio->io_size);
 kfree(it87_gpio->chip.names[0]);
 kfree(it87_gpio->chip.names);
}

module_init(it87_gpio_init);
module_exit(it87_gpio_exit);

MODULE_AUTHOR("Diego Elio Pettenò ");
MODULE_DESCRIPTION("GPIO interface for IT87xx Super I/O chips");
MODULE_LICENSE("GPL");

Messung V0.5
C=96 H=95 G=95

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.