Path: blob/master/arch/unicore32/include/asm/gpio.h
10818 views
/*1* linux/arch/unicore32/include/asm/gpio.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/1112#ifndef __UNICORE_GPIO_H__13#define __UNICORE_GPIO_H__1415#include <linux/io.h>16#include <asm/irq.h>17#include <mach/hardware.h>18#include <asm-generic/gpio.h>1920#define GPI_OTP_INT 021#define GPI_PCI_INTA 122#define GPI_PCI_INTB 223#define GPI_PCI_INTC 324#define GPI_PCI_INTD 425#define GPI_BAT_DET 526#define GPI_SD_CD 627#define GPI_SOFF_REQ 728#define GPI_SD_WP 829#define GPI_LCD_CASE_OFF 930#define GPO_WIFI_EN 1031#define GPO_HDD_LED 1132#define GPO_VGA_EN 1233#define GPO_LCD_EN 1334#define GPO_LED_DATA 1435#define GPO_LED_CLK 1536#define GPO_CAM_PWR_EN 1637#define GPO_LCD_VCC_EN 1738#define GPO_SOFT_OFF 1839#define GPO_BT_EN 1940#define GPO_FAN_ON 2041#define GPO_SPKR 2142#define GPO_SET_V1 2343#define GPO_SET_V2 2444#define GPO_CPU_HEALTH 2545#define GPO_LAN_SEL 264647#ifdef CONFIG_PUV3_NB091648#define GPI_BTN_TOUCH 1449#define GPIO_IN 0x000043ff /* 1 for input */50#define GPIO_OUT 0x0fffbc00 /* 1 for output */51#endif /* CONFIG_PUV3_NB0916 */5253#ifdef CONFIG_PUV3_SMW091954#define GPIO_IN 0x000003ff /* 1 for input */55#define GPIO_OUT 0x0ffffc00 /* 1 for output */56#endif /* CONFIG_PUV3_SMW0919 */5758#ifdef CONFIG_PUV3_DB091359#define GPIO_IN 0x000001df /* 1 for input */60#define GPIO_OUT 0x03fee800 /* 1 for output */61#endif /* CONFIG_PUV3_DB0913 */6263#define GPIO_DIR (~((GPIO_IN) | 0xf0000000))64/* 0 input, 1 output */6566static inline int gpio_get_value(unsigned gpio)67{68if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))69return readl(GPIO_GPLR) & GPIO_GPIO(gpio);70else71return __gpio_get_value(gpio);72}7374static inline void gpio_set_value(unsigned gpio, int value)75{76if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))77if (value)78writel(GPIO_GPIO(gpio), GPIO_GPSR);79else80writel(GPIO_GPIO(gpio), GPIO_GPCR);81else82__gpio_set_value(gpio, value);83}8485#define gpio_cansleep __gpio_cansleep8687static inline unsigned gpio_to_irq(unsigned gpio)88{89if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR)))90return IRQ_GPIOLOW0 + gpio;91else92return IRQ_GPIO0 + gpio;93}9495static inline unsigned irq_to_gpio(unsigned irq)96{97if (irq < IRQ_GPIOHIGH)98return irq - IRQ_GPIOLOW0;99else100return irq - IRQ_GPIO0;101}102103#endif /* __UNICORE_GPIO_H__ */104105106