root/arch/unicore32/include/asm/gpio.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. gpio_get_value
  2. gpio_set_value
  3. gpio_to_irq
  4. irq_to_gpio

   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * linux/arch/unicore32/include/asm/gpio.h
   4  *
   5  * Code specific to PKUnity SoC and UniCore ISA
   6  *
   7  * Copyright (C) 2001-2010 GUAN Xue-tao
   8  */
   9 
  10 #ifndef __UNICORE_GPIO_H__
  11 #define __UNICORE_GPIO_H__
  12 
  13 #include <linux/io.h>
  14 #include <asm/irq.h>
  15 #include <mach/hardware.h>
  16 #include <asm-generic/gpio.h>
  17 
  18 #define GPI_OTP_INT             0
  19 #define GPI_PCI_INTA            1
  20 #define GPI_PCI_INTB            2
  21 #define GPI_PCI_INTC            3
  22 #define GPI_PCI_INTD            4
  23 #define GPI_BAT_DET             5
  24 #define GPI_SD_CD               6
  25 #define GPI_SOFF_REQ            7
  26 #define GPI_SD_WP               8
  27 #define GPI_LCD_CASE_OFF        9
  28 #define GPO_WIFI_EN             10
  29 #define GPO_HDD_LED             11
  30 #define GPO_VGA_EN              12
  31 #define GPO_LCD_EN              13
  32 #define GPO_LED_DATA            14
  33 #define GPO_LED_CLK             15
  34 #define GPO_CAM_PWR_EN          16
  35 #define GPO_LCD_VCC_EN          17
  36 #define GPO_SOFT_OFF            18
  37 #define GPO_BT_EN               19
  38 #define GPO_FAN_ON              20
  39 #define GPO_SPKR                21
  40 #define GPO_SET_V1              23
  41 #define GPO_SET_V2              24
  42 #define GPO_CPU_HEALTH          25
  43 #define GPO_LAN_SEL             26
  44 
  45 #ifdef CONFIG_PUV3_NB0916
  46 #define GPI_BTN_TOUCH           14
  47 #define GPIO_IN                 0x000043ff /* 1 for input */
  48 #define GPIO_OUT                0x0fffbc00 /* 1 for output */
  49 #endif  /* CONFIG_PUV3_NB0916 */
  50 
  51 #ifdef CONFIG_PUV3_SMW0919
  52 #define GPIO_IN                 0x000003ff /* 1 for input */
  53 #define GPIO_OUT                0x0ffffc00 /* 1 for output */
  54 #endif  /* CONFIG_PUV3_SMW0919 */
  55 
  56 #ifdef CONFIG_PUV3_DB0913
  57 #define GPIO_IN                 0x000001df /* 1 for input */
  58 #define GPIO_OUT                0x03fee800 /* 1 for output */
  59 #endif  /* CONFIG_PUV3_DB0913 */
  60 
  61 #define GPIO_DIR                (~((GPIO_IN) | 0xf0000000))
  62                                 /* 0 input, 1 output */
  63 
  64 static inline int gpio_get_value(unsigned gpio)
  65 {
  66         if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
  67                 return readl(GPIO_GPLR) & GPIO_GPIO(gpio);
  68         else
  69                 return __gpio_get_value(gpio);
  70 }
  71 
  72 static inline void gpio_set_value(unsigned gpio, int value)
  73 {
  74         if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
  75                 if (value)
  76                         writel(GPIO_GPIO(gpio), GPIO_GPSR);
  77                 else
  78                         writel(GPIO_GPIO(gpio), GPIO_GPCR);
  79         else
  80                 __gpio_set_value(gpio, value);
  81 }
  82 
  83 #define gpio_cansleep   __gpio_cansleep
  84 
  85 static inline unsigned gpio_to_irq(unsigned gpio)
  86 {
  87         if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR)))
  88                 return IRQ_GPIOLOW0 + gpio;
  89         else
  90                 return IRQ_GPIO0 + gpio;
  91 }
  92 
  93 static inline unsigned irq_to_gpio(unsigned irq)
  94 {
  95         if (irq < IRQ_GPIOHIGH)
  96                 return irq - IRQ_GPIOLOW0;
  97         else
  98                 return irq - IRQ_GPIO0;
  99 }
 100 
 101 #endif /* __UNICORE_GPIO_H__ */

/* [<][>][^][v][top][bottom][index][help] */