0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "omap24xx.h"
0016 #include "omap34xx.h"
0017 #include "omap44xx.h"
0018 #include "ti81xx.h"
0019 #include "am33xx.h"
0020 #include "omap54xx.h"
0021
0022 #ifndef __ASSEMBLY__
0023
0024 #include <linux/bitops.h>
0025 #include <linux/of.h>
0026
0027
0028
0029
0030 #undef MULTI_OMAP2
0031 #define MULTI_OMAP2
0032
0033
0034
0035
0036 #define OMAP2_DEVICE_TYPE_TEST 0
0037 #define OMAP2_DEVICE_TYPE_EMU 1
0038 #define OMAP2_DEVICE_TYPE_SEC 2
0039 #define OMAP2_DEVICE_TYPE_GP 3
0040 #define OMAP2_DEVICE_TYPE_BAD 4
0041
0042 int omap_type(void);
0043
0044
0045
0046
0047
0048
0049
0050 unsigned int omap_rev(void);
0051
0052 static inline int soc_is_omap(void)
0053 {
0054 return omap_rev() != 0;
0055 }
0056
0057
0058
0059
0060 #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 #define GET_OMAP_CLASS (omap_rev() & 0xff)
0075
0076 #define IS_OMAP_CLASS(class, id) \
0077 static inline int is_omap ##class (void) \
0078 { \
0079 return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
0080 }
0081
0082 #define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
0083
0084 #define IS_AM_CLASS(class, id) \
0085 static inline int is_am ##class (void) \
0086 { \
0087 return (GET_AM_CLASS == (id)) ? 1 : 0; \
0088 }
0089
0090 #define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
0091
0092 #define IS_TI_CLASS(class, id) \
0093 static inline int is_ti ##class (void) \
0094 { \
0095 return (GET_TI_CLASS == (id)) ? 1 : 0; \
0096 }
0097
0098 #define GET_DRA_CLASS ((omap_rev() >> 24) & 0xff)
0099
0100 #define IS_DRA_CLASS(class, id) \
0101 static inline int is_dra ##class (void) \
0102 { \
0103 return (GET_DRA_CLASS == (id)) ? 1 : 0; \
0104 }
0105
0106 #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
0107
0108 #define IS_OMAP_SUBCLASS(subclass, id) \
0109 static inline int is_omap ##subclass (void) \
0110 { \
0111 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
0112 }
0113
0114 #define IS_TI_SUBCLASS(subclass, id) \
0115 static inline int is_ti ##subclass (void) \
0116 { \
0117 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
0118 }
0119
0120 #define IS_AM_SUBCLASS(subclass, id) \
0121 static inline int is_am ##subclass (void) \
0122 { \
0123 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
0124 }
0125
0126 #define IS_DRA_SUBCLASS(subclass, id) \
0127 static inline int is_dra ##subclass (void) \
0128 { \
0129 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
0130 }
0131
0132 #define GET_DRA_PACKAGE (omap_rev() & 0xff)
0133
0134 #define IS_DRA_SUBCLASS_PACKAGE(subclass, package, id) \
0135 static inline int is_dra ##subclass ##_ ##package (void) \
0136 { \
0137 return (is_dra ##subclass () && GET_DRA_PACKAGE == id) ? 1 : 0; \
0138 }
0139
0140 IS_OMAP_CLASS(24xx, 0x24)
0141 IS_OMAP_CLASS(34xx, 0x34)
0142 IS_OMAP_CLASS(44xx, 0x44)
0143 IS_AM_CLASS(35xx, 0x35)
0144 IS_OMAP_CLASS(54xx, 0x54)
0145 IS_AM_CLASS(33xx, 0x33)
0146 IS_AM_CLASS(43xx, 0x43)
0147
0148 IS_TI_CLASS(81xx, 0x81)
0149 IS_DRA_CLASS(7xx, 0x7)
0150
0151 IS_OMAP_SUBCLASS(242x, 0x242)
0152 IS_OMAP_SUBCLASS(243x, 0x243)
0153 IS_OMAP_SUBCLASS(343x, 0x343)
0154 IS_OMAP_SUBCLASS(363x, 0x363)
0155 IS_OMAP_SUBCLASS(443x, 0x443)
0156 IS_OMAP_SUBCLASS(446x, 0x446)
0157 IS_OMAP_SUBCLASS(447x, 0x447)
0158 IS_OMAP_SUBCLASS(543x, 0x543)
0159
0160 IS_TI_SUBCLASS(816x, 0x816)
0161 IS_TI_SUBCLASS(814x, 0x814)
0162 IS_AM_SUBCLASS(335x, 0x335)
0163 IS_AM_SUBCLASS(437x, 0x437)
0164 IS_DRA_SUBCLASS(76x, 0x76)
0165 IS_DRA_SUBCLASS_PACKAGE(76x, abz, 2)
0166 IS_DRA_SUBCLASS_PACKAGE(76x, acd, 3)
0167 IS_DRA_SUBCLASS(75x, 0x75)
0168 IS_DRA_SUBCLASS(72x, 0x72)
0169
0170 #define soc_is_ti81xx() 0
0171 #define soc_is_ti816x() 0
0172 #define soc_is_ti814x() 0
0173 #define soc_is_am35xx() 0
0174 #define soc_is_am33xx() 0
0175 #define soc_is_am335x() 0
0176 #define soc_is_am43xx() 0
0177 #define soc_is_am437x() 0
0178 #define soc_is_omap44xx() 0
0179 #define soc_is_omap443x() 0
0180 #define soc_is_omap446x() 0
0181 #define soc_is_omap447x() 0
0182 #define soc_is_omap54xx() 0
0183 #define soc_is_omap543x() 0
0184 #define soc_is_dra7xx() 0
0185 #define soc_is_dra76x() 0
0186 #define soc_is_dra74x() 0
0187 #define soc_is_dra72x() 0
0188
0189 #if defined(CONFIG_ARCH_OMAP2)
0190 # define soc_is_omap24xx() is_omap24xx()
0191 #else
0192 # define soc_is_omap24xx() 0
0193 #endif
0194 #if defined(CONFIG_SOC_OMAP2420)
0195 # define soc_is_omap242x() is_omap242x()
0196 #else
0197 # define soc_is_omap242x() 0
0198 #endif
0199 #if defined(CONFIG_SOC_OMAP2430)
0200 # define soc_is_omap243x() is_omap243x()
0201 #else
0202 # define soc_is_omap243x() 0
0203 #endif
0204 #if defined(CONFIG_ARCH_OMAP3)
0205 # define soc_is_omap34xx() is_omap34xx()
0206 # define soc_is_omap343x() is_omap343x()
0207 #else
0208 # define soc_is_omap34xx() 0
0209 # define soc_is_omap343x() 0
0210 #endif
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221 #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
0222
0223 #define IS_OMAP_TYPE(type, id) \
0224 static inline int is_omap ##type (void) \
0225 { \
0226 return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
0227 }
0228
0229 IS_OMAP_TYPE(2420, 0x2420)
0230 IS_OMAP_TYPE(2422, 0x2422)
0231 IS_OMAP_TYPE(2423, 0x2423)
0232 IS_OMAP_TYPE(2430, 0x2430)
0233 IS_OMAP_TYPE(3430, 0x3430)
0234
0235 #define soc_is_omap2420() 0
0236 #define soc_is_omap2422() 0
0237 #define soc_is_omap2423() 0
0238 #define soc_is_omap2430() 0
0239 #define soc_is_omap3430() 0
0240 #define soc_is_omap3630() 0
0241 #define soc_is_omap5430() 0
0242
0243
0244 #define soc_is_omap7xx() 0
0245 #define soc_is_omap15xx() 0
0246 #define soc_is_omap16xx() 0
0247 #define soc_is_omap1510() 0
0248 #define soc_is_omap1610() 0
0249 #define soc_is_omap1611() 0
0250 #define soc_is_omap1621() 0
0251 #define soc_is_omap1710() 0
0252 #define cpu_class_is_omap1() 0
0253 #define cpu_class_is_omap2() 1
0254
0255 #if defined(CONFIG_ARCH_OMAP2)
0256 # undef soc_is_omap2420
0257 # undef soc_is_omap2422
0258 # undef soc_is_omap2423
0259 # undef soc_is_omap2430
0260 # define soc_is_omap2420() is_omap2420()
0261 # define soc_is_omap2422() is_omap2422()
0262 # define soc_is_omap2423() is_omap2423()
0263 # define soc_is_omap2430() is_omap2430()
0264 #endif
0265
0266 #if defined(CONFIG_ARCH_OMAP3)
0267 # undef soc_is_omap3430
0268 # undef soc_is_ti81xx
0269 # undef soc_is_ti816x
0270 # undef soc_is_ti814x
0271 # undef soc_is_am35xx
0272 # define soc_is_omap3430() is_omap3430()
0273 # undef soc_is_omap3630
0274 # define soc_is_omap3630() is_omap363x()
0275 # define soc_is_ti81xx() is_ti81xx()
0276 # define soc_is_ti816x() is_ti816x()
0277 # define soc_is_ti814x() is_ti814x()
0278 # define soc_is_am35xx() is_am35xx()
0279 #endif
0280
0281 # if defined(CONFIG_SOC_AM33XX)
0282 # undef soc_is_am33xx
0283 # undef soc_is_am335x
0284 # define soc_is_am33xx() is_am33xx()
0285 # define soc_is_am335x() is_am335x()
0286 #endif
0287
0288 #ifdef CONFIG_SOC_AM43XX
0289 # undef soc_is_am43xx
0290 # undef soc_is_am437x
0291 # define soc_is_am43xx() is_am43xx()
0292 # define soc_is_am437x() is_am437x()
0293 #endif
0294
0295 # if defined(CONFIG_ARCH_OMAP4)
0296 # undef soc_is_omap44xx
0297 # undef soc_is_omap443x
0298 # undef soc_is_omap446x
0299 # undef soc_is_omap447x
0300 # define soc_is_omap44xx() is_omap44xx()
0301 # define soc_is_omap443x() is_omap443x()
0302 # define soc_is_omap446x() is_omap446x()
0303 # define soc_is_omap447x() is_omap447x()
0304 # endif
0305
0306 # if defined(CONFIG_SOC_OMAP5)
0307 # undef soc_is_omap54xx
0308 # undef soc_is_omap543x
0309 # define soc_is_omap54xx() is_omap54xx()
0310 # define soc_is_omap543x() is_omap543x()
0311 #endif
0312
0313 #if defined(CONFIG_SOC_DRA7XX)
0314 #undef soc_is_dra7xx
0315 #undef soc_is_dra76x
0316 #undef soc_is_dra76x_abz
0317 #undef soc_is_dra76x_acd
0318 #undef soc_is_dra74x
0319 #undef soc_is_dra72x
0320 #define soc_is_dra7xx() is_dra7xx()
0321 #define soc_is_dra76x() is_dra76x()
0322 #define soc_is_dra76x_abz() is_dra76x_abz()
0323 #define soc_is_dra76x_acd() is_dra76x_acd()
0324 #define soc_is_dra74x() is_dra75x()
0325 #define soc_is_dra72x() is_dra72x()
0326 #endif
0327
0328
0329 #define OMAP242X_CLASS 0x24200024
0330 #define OMAP2420_REV_ES1_0 OMAP242X_CLASS
0331 #define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
0332
0333 #define OMAP243X_CLASS 0x24300024
0334 #define OMAP2430_REV_ES1_0 OMAP243X_CLASS
0335
0336 #define OMAP343X_CLASS 0x34300034
0337 #define OMAP3430_REV_ES1_0 OMAP343X_CLASS
0338 #define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
0339 #define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
0340 #define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
0341 #define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
0342 #define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
0343
0344 #define OMAP363X_CLASS 0x36300034
0345 #define OMAP3630_REV_ES1_0 OMAP363X_CLASS
0346 #define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
0347 #define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
0348
0349 #define TI816X_CLASS 0x81600081
0350 #define TI8168_REV_ES1_0 TI816X_CLASS
0351 #define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
0352 #define TI8168_REV_ES2_0 (TI816X_CLASS | (0x2 << 8))
0353 #define TI8168_REV_ES2_1 (TI816X_CLASS | (0x3 << 8))
0354
0355 #define TI814X_CLASS 0x81400081
0356 #define TI8148_REV_ES1_0 TI814X_CLASS
0357 #define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
0358 #define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
0359
0360 #define AM35XX_CLASS 0x35170034
0361 #define AM35XX_REV_ES1_0 AM35XX_CLASS
0362 #define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
0363
0364 #define AM335X_CLASS 0x33500033
0365 #define AM335X_REV_ES1_0 AM335X_CLASS
0366 #define AM335X_REV_ES2_0 (AM335X_CLASS | (0x1 << 8))
0367 #define AM335X_REV_ES2_1 (AM335X_CLASS | (0x2 << 8))
0368
0369 #define AM437X_CLASS 0x43700000
0370 #define AM437X_REV_ES1_0 (AM437X_CLASS | (0x10 << 8))
0371 #define AM437X_REV_ES1_1 (AM437X_CLASS | (0x11 << 8))
0372 #define AM437X_REV_ES1_2 (AM437X_CLASS | (0x12 << 8))
0373
0374 #define OMAP443X_CLASS 0x44300044
0375 #define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
0376 #define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
0377 #define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
0378 #define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
0379 #define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
0380
0381 #define OMAP446X_CLASS 0x44600044
0382 #define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
0383 #define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
0384
0385 #define OMAP447X_CLASS 0x44700044
0386 #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
0387
0388 #define OMAP54XX_CLASS 0x54000054
0389 #define OMAP5430_REV_ES2_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
0390 #define OMAP5432_REV_ES2_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
0391
0392 #define DRA7XX_CLASS 0x07000000
0393 #define DRA762_REV_ES1_0 (DRA7XX_CLASS | (0x62 << 16) | (0x10 << 8))
0394 #define DRA762_ABZ_REV_ES1_0 (DRA762_REV_ES1_0 | (2 << 0))
0395 #define DRA762_ACD_REV_ES1_0 (DRA762_REV_ES1_0 | (3 << 0))
0396 #define DRA752_REV_ES1_0 (DRA7XX_CLASS | (0x52 << 16) | (0x10 << 8))
0397 #define DRA752_REV_ES1_1 (DRA7XX_CLASS | (0x52 << 16) | (0x11 << 8))
0398 #define DRA752_REV_ES2_0 (DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8))
0399 #define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
0400 #define DRA722_REV_ES2_0 (DRA7XX_CLASS | (0x22 << 16) | (0x20 << 8))
0401 #define DRA722_REV_ES2_1 (DRA7XX_CLASS | (0x22 << 16) | (0x21 << 8))
0402
0403 void omap2xxx_check_revision(void);
0404 void omap3xxx_check_revision(void);
0405 void omap4xxx_check_revision(void);
0406 void omap5xxx_check_revision(void);
0407 void dra7xxx_check_revision(void);
0408 void omap3xxx_check_features(void);
0409 void ti81xx_check_features(void);
0410 void am33xx_check_features(void);
0411 void omap4xxx_check_features(void);
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423 extern u32 omap_features;
0424
0425 #define OMAP3_HAS_L2CACHE BIT(0)
0426 #define OMAP3_HAS_IVA BIT(1)
0427 #define OMAP3_HAS_SGX BIT(2)
0428 #define OMAP3_HAS_NEON BIT(3)
0429 #define OMAP3_HAS_ISP BIT(4)
0430 #define OMAP3_HAS_192MHZ_CLK BIT(5)
0431 #define OMAP3_HAS_IO_WAKEUP BIT(6)
0432 #define OMAP3_HAS_SDRC BIT(7)
0433 #define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
0434 #define OMAP4_HAS_PERF_SILICON BIT(9)
0435
0436
0437 #define OMAP3_HAS_FEATURE(feat,flag) \
0438 static inline unsigned int omap3_has_ ##feat(void) \
0439 { \
0440 return omap_features & OMAP3_HAS_ ##flag; \
0441 } \
0442
0443 OMAP3_HAS_FEATURE(l2cache, L2CACHE)
0444 OMAP3_HAS_FEATURE(sgx, SGX)
0445 OMAP3_HAS_FEATURE(iva, IVA)
0446 OMAP3_HAS_FEATURE(neon, NEON)
0447 OMAP3_HAS_FEATURE(isp, ISP)
0448 OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
0449 OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
0450 OMAP3_HAS_FEATURE(sdrc, SDRC)
0451 OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
0452
0453
0454
0455
0456 #define OMAP4_HAS_FEATURE(feat, flag) \
0457 static inline unsigned int omap4_has_ ##feat(void) \
0458 { \
0459 return omap_features & OMAP4_HAS_ ##flag; \
0460 } \
0461
0462 OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
0463
0464
0465
0466
0467
0468 #define omap_initcall(level, fn) \
0469 static int __init __used __##fn(void) \
0470 { \
0471 if (!soc_is_omap()) \
0472 return 0; \
0473 return fn(); \
0474 } \
0475 level(__##fn);
0476
0477 #define omap_early_initcall(fn) omap_initcall(early_initcall, fn)
0478 #define omap_core_initcall(fn) omap_initcall(core_initcall, fn)
0479 #define omap_postcore_initcall(fn) omap_initcall(postcore_initcall, fn)
0480 #define omap_arch_initcall(fn) omap_initcall(arch_initcall, fn)
0481 #define omap_subsys_initcall(fn) omap_initcall(subsys_initcall, fn)
0482 #define omap_device_initcall(fn) omap_initcall(device_initcall, fn)
0483 #define omap_late_initcall(fn) omap_initcall(late_initcall, fn)
0484 #define omap_late_initcall_sync(fn) omap_initcall(late_initcall_sync, fn)
0485
0486
0487 #define cpu_is_omap2420() soc_is_omap2420()
0488 #define cpu_is_omap2422() soc_is_omap2422()
0489 #define cpu_is_omap242x() soc_is_omap242x()
0490 #define cpu_is_omap2430() soc_is_omap2430()
0491 #define cpu_is_omap243x() soc_is_omap243x()
0492 #define cpu_is_omap24xx() soc_is_omap24xx()
0493 #define cpu_is_omap3430() soc_is_omap3430()
0494 #define cpu_is_omap343x() soc_is_omap343x()
0495 #define cpu_is_omap34xx() soc_is_omap34xx()
0496 #define cpu_is_omap3630() soc_is_omap3630()
0497 #define cpu_is_omap443x() soc_is_omap443x()
0498 #define cpu_is_omap446x() soc_is_omap446x()
0499 #define cpu_is_omap44xx() soc_is_omap44xx()
0500 #define cpu_is_ti814x() soc_is_ti814x()
0501 #define cpu_is_ti816x() soc_is_ti816x()
0502 #define cpu_is_ti81xx() soc_is_ti81xx()
0503
0504 #endif