tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / soc / sprd / gpio.h
1 /*
2  * Copyright (C) 2012 Spreadtrum Communications Inc.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13
14 #ifndef __ASM_ARM_ARCH_GPIO_H
15 #define __ASM_ARM_ARCH_GPIO_H
16
17 /*
18  * SC8825 GPIO&EIC bank and number summary:
19  *
20  * Bank   From    To    NR      Type
21  * 1      0   ~   15            16      EIC
22  * 2      16  ~   271   256     GPIO
23  * 3      272 ~   287   16      ANA EIC
24  * 4      288 ~   319   32      ANA GPIO
25  */
26
27 #ifdef CONFIG_ARCH_SCX35
28 #define D_GPIO_START    0
29 #define D_GPIO_NR               256
30
31 #define A_GPIO_START    ( D_GPIO_START + D_GPIO_NR )
32 #if defined(CONFIG_ARCH_SCX15)
33 #define A_GPIO_NR               0
34 #else
35 #define A_GPIO_NR               32
36 #endif
37
38 #define D_EIC_START             ( A_GPIO_START + A_GPIO_NR)
39 #define D_EIC_NR                16
40
41 #define A_EIC_START             ( D_EIC_START + D_EIC_NR )
42 #define A_EIC_NR                16
43 #else
44 #define D_EIC_START             0
45 #define D_EIC_NR                16
46
47 #define D_GPIO_START    ( D_EIC_START + D_EIC_NR )
48 #define D_GPIO_NR               256
49
50 #define A_EIC_START             ( D_GPIO_START + D_GPIO_NR )
51 #define A_EIC_NR                16
52
53 #define A_GPIO_START    ( A_EIC_START + A_EIC_NR )
54 #define A_GPIO_NR               32
55 #endif
56
57 #define ARCH_NR_GPIOS   ( D_EIC_NR + D_GPIO_NR + A_EIC_NR + A_GPIO_NR )
58
59 #ifdef CONFIG_64BIT
60 #include <asm-generic/gpio.h>
61 #include <soc/sprd/irqs.h>
62 #else
63 #include <asm-generic/gpio.h>
64 #include <mach/irqs.h>
65 #endif
66
67 #define gpio_get_value  __gpio_get_value
68 #define gpio_set_value  __gpio_set_value
69 #define gpio_cansleep   __gpio_cansleep
70 #define gpio_to_irq     __gpio_to_irq
71
72
73 /* Digital GPIO/EIC base address */
74 #define CTL_GPIO_BASE          (SPRD_GPIO_BASE)
75 #define CTL_EIC_BASE           (SPRD_EIC_BASE)
76
77 /* Analog GPIO/EIC base address */
78
79 #if defined(CONFIG_ARCH_SCX35)
80 #define ANA_CTL_EIC_BASE           (ANA_EIC_BASE)
81 #define ANA_CTL_GPIO_BASE      (ANA_GPIO_INT_BASE)
82 #else
83 #define ANA_CTL_EIC_BASE       (SPRD_MISC_BASE + 0x0100)
84 #define ANA_CTL_GPIO_BASE      (SPRD_MISC_BASE + 0x0480)
85 #endif
86
87
88 enum {
89        ENUM_ID_D_GPIO = 0,
90        ENUM_ID_D_EIC,
91        ENUM_ID_A_GPIO,
92        ENUM_ID_A_EIC,
93
94        ENUM_ID_END_NR,
95 };
96
97 struct eic_gpio_resource {
98        int irq;
99        int base_addr;
100        int chip_base;
101        int chip_ngpio;
102 };
103
104 static inline int irq_to_gpio(int irq)
105 {
106         return irq - GPIO_IRQ_START;
107 }
108
109 #endif