Path: blob/master/arch/arm/mach-pnx4008/include/mach/gpio.h
10820 views
/*1* arch/arm/mach-pnx4008/include/mach/gpio.h2*3* PNX4008 GPIO driver - header file4*5* Author: Dmitry Chigirev <[email protected]>6*7* Based on reference code by Iwo Mergler and Z.Tabaaloute from Philips:8* Copyright (c) 2005 Koninklijke Philips Electronics N.V.9*10* 2005 (c) MontaVista Software, Inc. This file is licensed under11* the terms of the GNU General Public License version 2. This program12* is licensed "as is" without any warranty of any kind, whether express13* or implied.14*/1516#ifndef _PNX4008_GPIO_H_17#define _PNX4008_GPIO_H_181920/* Block numbers */21#define GPIO_IN (0)22#define GPIO_OUT (0x100)23#define GPIO_BID (0x200)24#define GPIO_RAM (0x300)25#define GPIO_MUX (0x400)2627#define GPIO_TYPE_MASK(K) ((K) & 0x700)2829/* INPUT GPIOs */30/* GPI */31#define GPI_00 (GPIO_IN | 0)32#define GPI_01 (GPIO_IN | 1)33#define GPI_02 (GPIO_IN | 2)34#define GPI_03 (GPIO_IN | 3)35#define GPI_04 (GPIO_IN | 4)36#define GPI_05 (GPIO_IN | 5)37#define GPI_06 (GPIO_IN | 6)38#define GPI_07 (GPIO_IN | 7)39#define GPI_08 (GPIO_IN | 8)40#define GPI_09 (GPIO_IN | 9)41#define U1_RX (GPIO_IN | 15)42#define U2_HTCS (GPIO_IN | 16)43#define U2_RX (GPIO_IN | 17)44#define U3_RX (GPIO_IN | 18)45#define U4_RX (GPIO_IN | 19)46#define U5_RX (GPIO_IN | 20)47#define U6_IRRX (GPIO_IN | 21)48#define U7_HCTS (GPIO_IN | 22)49#define U7_RX (GPIO_IN | 23)50/* MISC IN */51#define SPI1_DATIN (GPIO_IN | 25)52#define DISP_SYNC (GPIO_IN | 26)53#define SPI2_DATIN (GPIO_IN | 27)54#define GPI_11 (GPIO_IN | 28)5556#define GPIO_IN_MASK 0x1eff83ff5758/* OUTPUT GPIOs */59/* GPO */60#define GPO_00 (GPIO_OUT | 0)61#define GPO_01 (GPIO_OUT | 1)62#define GPO_02 (GPIO_OUT | 2)63#define GPO_03 (GPIO_OUT | 3)64#define GPO_04 (GPIO_OUT | 4)65#define GPO_05 (GPIO_OUT | 5)66#define GPO_06 (GPIO_OUT | 6)67#define GPO_07 (GPIO_OUT | 7)68#define GPO_08 (GPIO_OUT | 8)69#define GPO_09 (GPIO_OUT | 9)70#define GPO_10 (GPIO_OUT | 10)71#define GPO_11 (GPIO_OUT | 11)72#define GPO_12 (GPIO_OUT | 12)73#define GPO_13 (GPIO_OUT | 13)74#define GPO_14 (GPIO_OUT | 14)75#define GPO_15 (GPIO_OUT | 15)76#define GPO_16 (GPIO_OUT | 16)77#define GPO_17 (GPIO_OUT | 17)78#define GPO_18 (GPIO_OUT | 18)79#define GPO_19 (GPIO_OUT | 19)80#define GPO_20 (GPIO_OUT | 20)81#define GPO_21 (GPIO_OUT | 21)82#define GPO_22 (GPIO_OUT | 22)83#define GPO_23 (GPIO_OUT | 23)8485#define GPIO_OUT_MASK 0xffffff8687/* BIDIRECTIONAL GPIOs */88/* RAM pins */89#define RAM_D19 (GPIO_RAM | 0)90#define RAM_D20 (GPIO_RAM | 1)91#define RAM_D21 (GPIO_RAM | 2)92#define RAM_D22 (GPIO_RAM | 3)93#define RAM_D23 (GPIO_RAM | 4)94#define RAM_D24 (GPIO_RAM | 5)95#define RAM_D25 (GPIO_RAM | 6)96#define RAM_D26 (GPIO_RAM | 7)97#define RAM_D27 (GPIO_RAM | 8)98#define RAM_D28 (GPIO_RAM | 9)99#define RAM_D29 (GPIO_RAM | 10)100#define RAM_D30 (GPIO_RAM | 11)101#define RAM_D31 (GPIO_RAM | 12)102103#define GPIO_RAM_MASK 0x1fff104105/* I/O pins */106#define GPIO_00 (GPIO_BID | 25)107#define GPIO_01 (GPIO_BID | 26)108#define GPIO_02 (GPIO_BID | 27)109#define GPIO_03 (GPIO_BID | 28)110#define GPIO_04 (GPIO_BID | 29)111#define GPIO_05 (GPIO_BID | 30)112113#define GPIO_BID_MASK 0x7e000000114115/* Non-GPIO multiplexed PIOs. For multiplexing with GPIO, please use GPIO macros */116#define GPIO_SDRAM_SEL (GPIO_MUX | 3)117118#define GPIO_MUX_MASK 0x8119120/* Extraction/assembly macros */121#define GPIO_BIT_MASK(K) ((K) & 0x1F)122#define GPIO_BIT(K) (1 << GPIO_BIT_MASK(K))123#define GPIO_ISMUX(K) ((GPIO_TYPE_MASK(K) == GPIO_MUX) && (GPIO_BIT(K) & GPIO_MUX_MASK))124#define GPIO_ISRAM(K) ((GPIO_TYPE_MASK(K) == GPIO_RAM) && (GPIO_BIT(K) & GPIO_RAM_MASK))125#define GPIO_ISBID(K) ((GPIO_TYPE_MASK(K) == GPIO_BID) && (GPIO_BIT(K) & GPIO_BID_MASK))126#define GPIO_ISOUT(K) ((GPIO_TYPE_MASK(K) == GPIO_OUT) && (GPIO_BIT(K) & GPIO_OUT_MASK))127#define GPIO_ISIN(K) ((GPIO_TYPE_MASK(K) == GPIO_IN) && (GPIO_BIT(K) & GPIO_IN_MASK))128129/* Start Enable Pin Interrupts - table 58 page 66 */130131#define SE_PIN_BASE_INT 32132133#define SE_U7_RX_INT 63134#define SE_U7_HCTS_INT 62135#define SE_BT_CLKREQ_INT 61136#define SE_U6_IRRX_INT 60137/*59 unused*/138#define SE_U5_RX_INT 58139#define SE_GPI_11_INT 57140#define SE_U3_RX_INT 56141#define SE_U2_HCTS_INT 55142#define SE_U2_RX_INT 54143#define SE_U1_RX_INT 53144#define SE_DISP_SYNC_INT 52145/*51 unused*/146#define SE_SDIO_INT_N 50147#define SE_MSDIO_START_INT 49148#define SE_GPI_06_INT 48149#define SE_GPI_05_INT 47150#define SE_GPI_04_INT 46151#define SE_GPI_03_INT 45152#define SE_GPI_02_INT 44153#define SE_GPI_01_INT 43154#define SE_GPI_00_INT 42155#define SE_SYSCLKEN_PIN_INT 41156#define SE_SPI1_DATAIN_INT 40157#define SE_GPI_07_INT 39158#define SE_SPI2_DATAIN_INT 38159#define SE_GPI_10_INT 37160#define SE_GPI_09_INT 36161#define SE_GPI_08_INT 35162/*34-32 unused*/163164/* Start Enable Internal Interrupts - table 57 page 65 */165166#define SE_INT_BASE_INT 0167168#define SE_TS_IRQ 31169#define SE_TS_P_INT 30170#define SE_TS_AUX_INT 29171/*27-28 unused*/172#define SE_USB_AHB_NEED_CLK_INT 26173#define SE_MSTIMER_INT 25174#define SE_RTC_INT 24175#define SE_USB_NEED_CLK_INT 23176#define SE_USB_INT 22177#define SE_USB_I2C_INT 21178#define SE_USB_OTG_TIMER_INT 20179#define SE_USB_OTG_ATX_INT_N 19180/*18 unused*/181#define SE_DSP_GPIO4_INT 17182#define SE_KEY_IRQ 16183#define SE_DSP_SLAVEPORT_INT 15184#define SE_DSP_GPIO1_INT 14185#define SE_DSP_GPIO0_INT 13186#define SE_DSP_AHB_INT 12187/*11-6 unused*/188#define SE_GPIO_05_INT 5189#define SE_GPIO_04_INT 4190#define SE_GPIO_03_INT 3191#define SE_GPIO_02_INT 2192#define SE_GPIO_01_INT 1193#define SE_GPIO_00_INT 0194195#define START_INT_REG_BIT(irq) (1<<((irq)&0x1F))196197#define START_INT_ER_REG(irq) IO_ADDRESS((PNX4008_PWRMAN_BASE + 0x20 + (((irq)&(0x1<<5))>>1)))198#define START_INT_RSR_REG(irq) IO_ADDRESS((PNX4008_PWRMAN_BASE + 0x24 + (((irq)&(0x1<<5))>>1)))199#define START_INT_SR_REG(irq) IO_ADDRESS((PNX4008_PWRMAN_BASE + 0x28 + (((irq)&(0x1<<5))>>1)))200#define START_INT_APR_REG(irq) IO_ADDRESS((PNX4008_PWRMAN_BASE + 0x2C + (((irq)&(0x1<<5))>>1)))201202extern int pnx4008_gpio_register_pin(unsigned short pin);203extern int pnx4008_gpio_unregister_pin(unsigned short pin);204extern unsigned long pnx4008_gpio_read_pin(unsigned short pin);205extern int pnx4008_gpio_write_pin(unsigned short pin, int output);206extern int pnx4008_gpio_set_pin_direction(unsigned short pin, int output);207extern int pnx4008_gpio_read_pin_direction(unsigned short pin);208extern int pnx4008_gpio_set_pin_mux(unsigned short pin, int output);209extern int pnx4008_gpio_read_pin_mux(unsigned short pin);210211static inline void start_int_umask(u8 irq)212{213__raw_writel(__raw_readl(START_INT_ER_REG(irq)) |214START_INT_REG_BIT(irq), START_INT_ER_REG(irq));215}216217static inline void start_int_mask(u8 irq)218{219__raw_writel(__raw_readl(START_INT_ER_REG(irq)) &220~START_INT_REG_BIT(irq), START_INT_ER_REG(irq));221}222223static inline void start_int_ack(u8 irq)224{225__raw_writel(START_INT_REG_BIT(irq), START_INT_RSR_REG(irq));226}227228static inline void start_int_set_falling_edge(u8 irq)229{230__raw_writel(__raw_readl(START_INT_APR_REG(irq)) &231~START_INT_REG_BIT(irq), START_INT_APR_REG(irq));232}233234static inline void start_int_set_rising_edge(u8 irq)235{236__raw_writel(__raw_readl(START_INT_APR_REG(irq)) |237START_INT_REG_BIT(irq), START_INT_APR_REG(irq));238}239240#endif /* _PNX4008_GPIO_H_ */241242243