1 /******************************************************************************
2 ** File Name: sc8810_gpio_cfg.h *
3 ** Author: Steve.Zhan *
5 ** Copyright: 2010 Spreatrum, Incoporated. All Rights Reserved. *
7 ******************************************************************************/
8 /******************************************************************************
10 **---------------------------------------------------------------------------*
11 ** DATE NAME DESCRIPTION *
12 ** 06/05/2010 Steve.Zhan Create. *
13 ******************************************************************************/
14 #ifndef _SC8810_GPIO_CFG_H_
15 #define _SC8810_GPIO_CFG_H_
16 #include "adi_reg_v3.h"
17 #include "sc8810_reg_base.h"
18 #include "chip_drv_common_io.h"
19 #include "adi_hal_internal.h"
20 #include "sc8810_reg_base.h"
21 /*----------------------------------------------------------------------------*
23 **------------------------------------------------------------------------- */
25 /**---------------------------------------------------------------------------*
27 **--------------------------------------------------------------------------*/
33 /**---------------------------------------------------------------------------*
35 **---------------------------------------------------------------------------*/
38 GPIO_SECTION_GPI = 0x0,
48 uint32 gpxx_pagex_base;
49 uint32 gpxx_pagex_size;
50 GPIO_SECTION_E gpxx_section_type;
52 #define ADI_GPIO_ADDR_MASK 0x08000000
63 #define GPIO_DRV_DEBUG
64 //#define GPIO_ASSERT_IF_WRONG_SECTION //is only using for debug mode
66 #define MIN_DESHAKING_INTERVAL 10
67 #define GPI_DEBOUNCE_PERIED 255
68 #define GPI_MAX_DEBOUCE_INTERVAL (GPI_DEBOUNCE_PERIED+ MIN_DESHAKING_INTERVAL*4) /*255+ 40(ignore)*/
72 static __inline uint32 GpioCfg_GetBaseAddr (uint32 gpio_id)
76 return ( (gpio_id - 160) >>4) * 0x80 + (unsigned int) 0x82000600;
79 return (gpio_id>>4) * 0x80 + (uint32) GPIO_BASE;
82 static __inline uint32 GpioCfg_GetBitNum (uint32 gpio_id)
84 return (gpio_id & 0xF);
86 static __inline void gpio_chip_reg_set (uint32 reg_addr, uint32 value)
88 if (reg_addr & ADI_GPIO_ADDR_MASK)
90 CHIP_REG_SET (reg_addr,value);
94 ANA_REG_SET (reg_addr,value);
100 static __inline uint32 gpio_chip_reg32 (uint32 reg_addr)
102 if (reg_addr & ADI_GPIO_ADDR_MASK)
104 return REG32 (reg_addr);
108 return ANA_REG_GET (reg_addr);
111 static __inline void gpio_chip_reg_and (uint32 reg_addr, uint32 value)
113 if (reg_addr & ADI_GPIO_ADDR_MASK)
115 CHIP_REG_AND (reg_addr,value);
119 ANA_REG_AND (reg_addr,value);
122 static __inline void gpio_chip_reg_or (uint32 reg_addr, uint32 value)
124 if (reg_addr & ADI_GPIO_ADDR_MASK)
126 CHIP_REG_OR (reg_addr,value);
130 ANA_REG_OR (reg_addr,value);
134 #define GPIO_REG_SET(x,y) gpio_chip_reg_set(x,y)
135 #define GPIO_REG32(x) gpio_chip_reg32(x)
136 #define GPIO_REG_AND(reg_addr, value) gpio_chip_reg_and(reg_addr, value)
137 #define GPIO_REG_OR(reg_addr, value) gpio_chip_reg_or(reg_addr, value)
139 /*****************************************************************************/
140 // Description: This function should be called at the gpio module, to get
141 // the info(the gpio Pin register addr, section size, gpio type).
142 // Dependency: s_gpio_section_table
143 // Author: Steve.Zhan
145 /*****************************************************************************/
146 PUBLIC GPIO_SECTION_T *Gpio_GetCfgSectionTable (uint32 *size);
149 /**----------------------------------------------------------------------------*
150 ** Function Prototype **
151 **----------------------------------------------------------------------------*/
152 /*****************************************************************************/
153 // Description: This function get the gpio type that have debounce function.
155 // Dependency: s_gpio_section_table
156 // Author: Steve.Zhan
158 /*****************************************************************************/
159 GPIO_SECTION_E *Gpio_GetCfgDebounceGpioTable (uint32 *pSize);
161 /**----------------------------------------------------------------------------*
162 ** Local Function Prototype **
163 **----------------------------------------------------------------------------*/
165 /**---------------------------------------------------------------------------*
166 ** Function Definitions *
167 **---------------------------------------------------------------------------*/
168 // Description: This function be called by interrupt handler when is
170 // Author: Xueliang.Wang
172 /*****************************************************************************/
173 PUBLIC void GPIO_Handler (uint32 int_num);
176 PUBLIC GPIO_INT_T *Gpio_GetCfgGpioIntTable (uint32 *pSize);
178 /**----------------------------------------------------------------------------*
179 ** Function Prototype **
180 **----------------------------------------------------------------------------*/
183 /**----------------------------------------------------------------------------*
185 **----------------------------------------------------------------------------*/
186 #endif // end of if 0
190 /**---------------------------------------------------------------------------*/