merge with master
[kernel/u-boot.git] / arch / arm / include / asm / arch-exynos / cpu.h
1 /*
2  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
3  * Minkyu Kang <mk7.kang@samsung.com>
4  * Sanghee Kim <sh0130.kim@samsung.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA
20  */
21
22 #ifndef __ASM_ARCH_CPU_H
23 #define __ASM_ARCH_CPU_H
24
25 #define EXYNOS4_ADDR_BASE       0x10000000
26
27 /* EXYNOS4 */
28 #define EXYNOS4_GPIO_PART3_BASE 0x03860000
29 #define EXYNOS4_PRO_ID          0x10000000
30 #define EXYNOS4_SYSREG_BASE     0x10010000
31 #define EXYNOS4_POWER_BASE      0x10020000
32 #define EXYNOS4_INFORM_BASE     0x10020800
33 #define EXYNOS4_CLOCK_BASE      0x10030000
34 #define EXYNOS4_MCT_BASE        0x10050000
35 #define EXYNOS4_WDT_BASE        0x10060000
36 #define EXYNOS4_SECKEY_BASE     0x10100000
37 #if defined(CONFIG_EXYNOS4210)
38 #define EXYNOS4_DMC0_BASE       0x10400000
39 #define EXYNOS4_DMC1_BASE       0x10410000
40 #else
41 #define EXYNOS4_DMC0_BASE       0x10600000
42 #define EXYNOS4_DMC1_BASE       0x10610000
43 #endif
44 #define EXYNOS4_GPIO_PART2_BASE 0x11000000
45 #define EXYNOS4_GPIO_PART1_BASE 0x11400000
46 #define EXYNOS4_FIMD_BASE       0x11C00000
47 #define EXYNOS4_MIPI_DSIM_BASE  0x11C80000
48 #define EXYNOS4_USBOTG_BASE     0x12480000
49 #define EXYNOS4_MMC_BASE        0x12510000
50 #define EXYNOS4_SROMC_BASE      0x12570000
51 #define EXYNOS4_USBPHY_BASE     0x125B0000
52 #define EXYNOS4_UART_BASE       0x13800000
53 #if defined(CONFIG_EXYNOS4210)
54 #define EXYNOS4_ADC_BASE                0x13910000
55 #else
56 #define EXYNOS4_ADC_BASE        0x12150000
57 #endif
58 #define EXYNOS4_PWMTIMER_BASE   0x139D0000
59
60 /*
61  * SYSREG
62  */
63
64 #define EXYNOS4_LCDBLK_CFG      (EXYNOS4_SYSREG_BASE + 0x0210)
65
66 /*
67  * POWER
68  */
69
70 #define EXYNOS4_SWRESET         (EXYNOS4_POWER_BASE + 0x400)
71 #define EXYNOS4_RST_STAT        (EXYNOS4_POWER_BASE + 0x404)
72
73 #define S5P_SWRESET             EXYNOS4_SWRESET
74 #define S5P_RST_STAT            EXYNOS4_RST_STAT
75
76 #ifndef __ASSEMBLY__
77 #include <asm/io.h>
78
79 /* CPU detection macros */
80 extern unsigned int s5p_cpu_id;
81 extern unsigned int s5p_cpu_rev;
82
83 static inline int s5p_get_cpu_rev(void)
84 {
85         return s5p_cpu_rev;
86 }
87
88 static inline void s5p_set_cpu_rev(unsigned int rev)
89 {
90         s5p_cpu_rev = rev;
91 }
92
93 static inline void s5p_set_cpu_id(void)
94 {
95         /*
96          * PRO_ID[31:16] = Product ID
97          * 0x4320: EXYNOS4210 EVT0
98          * 0x4321: EXYNOS4210 EVT1
99          * 0x4322: EXYNOS4212
100          * 0xE441: EXYNOS4412
101          */
102         s5p_cpu_id = readl(EXYNOS4_PRO_ID) >> 16;
103
104         switch (s5p_cpu_id) {
105         case 0x4320:
106                 s5p_cpu_id |= 0x1;
107                 s5p_set_cpu_rev(0);
108                 break;
109         case 0x4321:
110                 s5p_set_cpu_rev(1);
111                 break;
112         case 0x4322:
113         case 0xE441:
114         default:
115                 /* PRO_ID[7:0] = MainRev + SubRev */
116                 s5p_set_cpu_rev(readl(EXYNOS4_PRO_ID) & 0xff);
117         }
118 }
119
120 static inline int cpu_is_exynos4(void)
121 {
122         switch (s5p_cpu_id) {
123         case 0x4321:
124         case 0x4322:
125         case 0xE441:
126                 return 1;
127         default:
128                 return 0;
129         }
130 }
131
132 #define IS_SAMSUNG_TYPE(type, id)                       \
133 static inline int cpu_is_##type(void)                   \
134 {                                                       \
135         return s5p_cpu_id == id ? 1 : 0;                \
136 }
137
138 IS_SAMSUNG_TYPE(exynos4210, 0x4321)
139 IS_SAMSUNG_TYPE(exynos4212, 0x4322)
140 IS_SAMSUNG_TYPE(exynos4412, 0xE441)
141
142 #define SAMSUNG_BASE(device, base)                              \
143 static inline unsigned int samsung_get_base_##device(void)      \
144 {                                                               \
145         if (cpu_is_exynos4())                                   \
146                 return EXYNOS4_##base;                          \
147         else                                                    \
148                 return 0;                                       \
149 }
150
151 SAMSUNG_BASE(power, POWER_BASE)
152 SAMSUNG_BASE(adc, ADC_BASE)
153 SAMSUNG_BASE(clock, CLOCK_BASE)
154 SAMSUNG_BASE(fimd, FIMD_BASE)
155 SAMSUNG_BASE(mipi_dsim, MIPI_DSIM_BASE)
156 SAMSUNG_BASE(gpio_part1, GPIO_PART1_BASE)
157 SAMSUNG_BASE(gpio_part2, GPIO_PART2_BASE)
158 SAMSUNG_BASE(gpio_part3, GPIO_PART3_BASE)
159 SAMSUNG_BASE(pro_id, PRO_ID)
160 SAMSUNG_BASE(mmc, MMC_BASE)
161 SAMSUNG_BASE(sromc, SROMC_BASE)
162 SAMSUNG_BASE(swreset, SWRESET)
163 SAMSUNG_BASE(timer, PWMTIMER_BASE)
164 SAMSUNG_BASE(uart, UART_BASE)
165 SAMSUNG_BASE(usb_phy, USBPHY_BASE)
166 SAMSUNG_BASE(usb_otg, USBOTG_BASE)
167 SAMSUNG_BASE(systimer, MCT_BASE)
168 SAMSUNG_BASE(watchdog, WDT_BASE)
169 #endif
170
171 #endif  /* __ASM_ARCH_CPU_H */