找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 482|回复: 0
打印 上一主题 下一主题

初识GEL

[复制链接]

1

主题

12

帖子

283

积分

三级会员(30)

Rank: 3Rank: 3Rank: 3

积分
283
跳转到指定楼层
1#
发表于 2015-3-10 16:17 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

EDA365欢迎您!

您需要 登录 才可以下载或查看,没有帐号?注册

x
和大多数电子小白一样,都是先学51然后cm3 ,现在转战TI C6000,开发DSP最大的不同就是就开发流程来讲 可能就是要编写GEL和CMD这时开发单片机 所没有的在下也是初知乍练还望赐教:
GEL文件中主要是对芯片的初始化
下面我们来看下广州创龙的C6748 gel文件源码
在下抛砖引玉,望老鸟赐教,和大家一起学习C6000
/****************************************************************************/, o; L# a9 y7 S4 w; a
/* */) e. n( H/ }. A
/* General Extension Language */
; v0 V( U7 B% L6 V" i/ F" [/* 通用扩展语言文件 */
4 Z3 G/ c' u1 z3 q! a/* */
, X+ E* A' r' N  a/* 2014年08月26日 */
# F( j& n$ {  Y4 L% I/* */
* R4 n- P( X" _! v9 w9 d/****************************************************************************/
& [6 `$ Q3 W# l' Q4 }3 Z#define PLL0_BASE 0x01C11000 /*SYSTEM PLL BASE ADDRESS*/
7 C, T; u( Q/ j1 H#define PLL0_PID *(unsigned int*) (PLL0_BASE + 0x00) /*PID*/1 A2 d, H) s8 Q: }0 o
#define PLL0_RSTYPE *(unsigned int*) (PLL0_BASE + 0xE4) /*Reset Type status Reg*/7 L* A% V* N  r. w
#define PLL0_PLLCTL *(unsigned int*) (PLL0_BASE + 0x100) /*PLL Control Register*/
  a0 ^* D5 a4 i' U#define PLL0_OCSEL *(unsigned int*) (PLL0_BASE + 0x104) /*OBSCLK Select Register*/7 J7 F3 U& H8 T3 ~( k' ~* S* T
#define PLL0_SECCTL *(unsigned int*) (PLL0_BASE + 0x108) /*PLL Secondary Control Register*/
# v2 c; H  z' D, q: Y* g#define PLL0_PLLM *(unsigned int*) (PLL0_BASE + 0x110) /*PLL Multiplier*/
1 l: ~9 O: P8 r; S$ I' K6 k+ v# t#define PLL0_PREDIV *(unsigned int*) (PLL0_BASE + 0x114) /*Pre divider*/
. H, c4 R  f& ~$ U+ t' k#define PLL0_PLLDIV1 *(unsigned int*) (PLL0_BASE + 0x118) /*Divider-1*/8 k- t& r1 V- T! g$ @
#define PLL0_PLLDIV2 *(unsigned int*) (PLL0_BASE + 0x11C) /*Divider-2*/. [9 ?0 B& n0 Y
#define PLL0_PLLDIV3 *(unsigned int*) (PLL0_BASE + 0x120) /*Divider-3*/& B1 ^( }& a$ O1 r  @0 h
#define PLL0_OSCDIV1 *(unsigned int*) (PLL0_BASE + 0x124) /*Oscilator Divider*/  c# y3 {; `5 {7 p
#define PLL0_POSTDIV *(unsigned int*) (PLL0_BASE + 0x128) /*Post Divider*/; [* g# }% C! x5 F( o
#define PLL0_BPDIV *(unsigned int*) (PLL0_BASE + 0x12C) /*Bypass Divider*/
8 _. }) Q8 S( ^# s0 V#define PLL0_WAKEUP *(unsigned int*) (PLL0_BASE + 0x130) /*Wakeup Reg*/
7 U8 }! D4 t  U6 }2 N7 x  Q' P#define PLL0_PLLCMD *(unsigned int*) (PLL0_BASE + 0x138) /*Command Reg*/
% @* g  @2 N: c#define PLL0_PLLSTAT *(unsigned int*) (PLL0_BASE + 0x13C) /*Status Reg*/: h" L2 `. `4 x2 k- d* _3 B5 X) X! Z
#define PLL0_ALNCTL *(unsigned int*) (PLL0_BASE + 0x140) /*Clock Align Control Reg*/
& }* @6 d( |* P6 G, g#define PLL0_DCHANGE *(unsigned int*) (PLL0_BASE + 0x144) /*PLLDIV Ratio Chnage status*/
. S  q) w& e" U. ]4 L4 C#define PLL0_CKEN *(unsigned int*) (PLL0_BASE + 0x148) /*Clock Enable Reg*/
  f% Q& H* a4 H2 Y0 i+ x* E#define PLL0_CKSTAT *(unsigned int*) (PLL0_BASE + 0x14C) /*Clock Status Reg*/
' u7 K' _0 g0 h#define PLL0_SYSTAT *(unsigned int*) (PLL0_BASE + 0x150) /*Sysclk status reg*/
' s; f0 L7 @9 M8 L* D) r#define PLL0_PLLDIV4 *(unsigned int*) (PLL0_BASE + 0x160) /*Divider 4*/+ w# e' |7 @8 ?# r9 }  m3 N
#define PLL0_PLLDIV5 *(unsigned int*) (PLL0_BASE + 0x164) /*Divider 5*/' v; R2 N  v8 l! m% \( R  Y6 k
#define PLL0_PLLDIV6 *(unsigned int*) (PLL0_BASE + 0x168) /*Divider 6*// b% F* A& D/ J( M/ y& t
#define PLL0_PLLDIV7 *(unsigned int*) (PLL0_BASE + 0x16C) /*Divider 7*/" l: f( l5 B- H! i+ n
#define PLL0_PLLDIV8 *(unsigned int*) (PLL0_BASE + 0x170) /*Divider 8*/
* _* E8 R7 f. @2 R#define PLL0_PLLDIV9 *(unsigned int*) (PLL0_BASE + 0x174) /*Divider 9*/
& Y5 u( X" a3 h7 I# N#define PLL0_PLLDIV10 *(unsigned int*) (PLL0_BASE + 0x178) /*Divider 10*/& C& Z8 W4 k8 ~+ I
#define PLL0_PLLDIV11 *(unsigned int*) (PLL0_BASE + 0x17C) /*Divider 11*/9 b* Y: ?9 z/ x1 A3 K: {
#define PLL0_PLLDIV12 *(unsigned int*) (PLL0_BASE + 0x180) /*Divider 12*/
' ?: H$ Z4 |* T/ z$ q9 K#define PLL0_PLLDIV13 *(unsigned int*) (PLL0_BASE + 0x184) /*Divider 13*/
, t/ p" R( p: k- D* b  w% B#define PLL0_PLLDIV14 *(unsigned int*) (PLL0_BASE + 0x188) /*Divider 14*/6 N/ z$ h9 X0 {
#define PLL0_PLLDIV15 *(unsigned int*) (PLL0_BASE + 0x18C) /*Divider 15*/
2 o. G; {5 L3 d: ^' S, w  y#define PLL0_PLLDIV16 *(unsigned int*) (PLL0_BASE + 0x190) /*Divider 16*/
#define PLL1_BASE 0x01E1A000 /*SYSTEM PLL1 BASE ADDRESS*/0 w* t& g7 _) n2 p
#define PLL1_PID *(unsigned int*) (PLL1_BASE + 0x00) /*PID*/
4 z1 [4 e$ H) U6 x* I#define PLL1_RSTYPE *(unsigned int*) (PLL1_BASE + 0xE4) /*Reset Type status Reg*/1 \/ z  D! Q  ?
#define PLL1_PLLCTL *(unsigned int*) (PLL1_BASE + 0x100) /*PLL Control Register*/
3 X; P8 V( @! L$ }( M% }0 X#define PLL1_OCSEL *(unsigned int*) (PLL1_BASE + 0x104) /*OBSCLK Select Register*/
" U+ e# b8 }" n+ _# q: H#define PLL1_SECCTL *(unsigned int*) (PLL1_BASE + 0x108) /*PLL Secondary Control Register*/3 O( H) a# o8 m* q4 g
#define PLL1_PLLM *(unsigned int*) (PLL1_BASE + 0x110) /*PLL Multiplier*/$ J: O9 z7 W2 g8 r( C9 X- N
#define PLL1_PREDIV *(unsigned int*) (PLL1_BASE + 0x114) /*Pre divider*/0 ?9 `- ?+ c1 O6 N% M9 ]
#define PLL1_PLLDIV1 *(unsigned int*) (PLL1_BASE + 0x118) /*Divider-1*/6 }. Q1 Q4 @1 ^  \4 X; i0 W
#define PLL1_PLLDIV2 *(unsigned int*) (PLL1_BASE + 0x11C) /*Divider-2*/* I0 k2 v7 ^0 B3 o1 _; I
#define PLL1_PLLDIV3 *(unsigned int*) (PLL1_BASE + 0x120) /*Divider-3*/5 D# }% C' [! ?& }7 B9 R1 b
#define PLL1_OSCDIV1 *(unsigned int*) (PLL1_BASE + 0x124) /*Oscilator Divider*/
; t( e' V+ P$ x" j" |' \1 r#define PLL1_POSTDIV *(unsigned int*) (PLL1_BASE + 0x128) /*Post Divider*/0 J0 C9 m9 i# p, t; p
#define PLL1_BPDIV *(unsigned int*) (PLL1_BASE + 0x12C) /*Bypass Divider*/, B$ A4 L0 B* Q, H; r
#define PLL1_WAKEUP *(unsigned int*) (PLL1_BASE + 0x130) /*Wakeup Reg*/% T" F& G3 J% Z9 `/ F  y9 A
#define PLL1_PLLCMD *(unsigned int*) (PLL1_BASE + 0x138) /*Command Reg*/
9 |( _, Y( j5 }" \9 _( s# Q: a#define PLL1_PLLSTAT *(unsigned int*) (PLL1_BASE + 0x13C) /*Status Reg*/  E9 h. s0 o8 Q0 i" d
#define PLL1_ALNCTL *(unsigned int*) (PLL1_BASE + 0x140) /*Clock Align Control Reg*/
3 D  i4 @/ X8 r2 o3 N8 g2 v#define PLL1_DCHANGE *(unsigned int*) (PLL1_BASE + 0x144) /*PLLDIV Ratio Chnage status*/
& ?9 C3 b  G+ L/ O& q#define PLL1_CKEN *(unsigned int*) (PLL1_BASE + 0x148) /*Clock Enable Reg*/
' a& K+ ?# P+ |* E3 c! V8 \& i+ k#define PLL1_CKSTAT *(unsigned int*) (PLL1_BASE + 0x14C) /*Clock Status Reg*/( ~: D, i0 y# F
#define PLL1_SYSTAT *(unsigned int*) (PLL1_BASE + 0x150) /*Sysclk status reg*/- v* i3 {6 m+ a+ M
#define PLL1_PLLDIV4 *(unsigned int*) (PLL1_BASE + 0x160) /*Divider 4*/
1 q5 W  c$ n5 E; `* k" n8 H#define PLL1_PLLDIV5 *(unsigned int*) (PLL1_BASE + 0x164) /*Divider 5*/9 C# l0 `& [3 o6 T1 ^
#define PLL1_PLLDIV6 *(unsigned int*) (PLL1_BASE + 0x168) /*Divider 6*/* N5 x* g* q4 [
#define PLL1_PLLDIV7 *(unsigned int*) (PLL1_BASE + 0x16C) /*Divider 7*/5 J" t  B8 M- b1 O( Z6 h, T5 ?
#define PLL1_PLLDIV8 *(unsigned int*) (PLL1_BASE + 0x170) /*Divider 8*/
, D( t9 J3 }- V#define PLL1_PLLDIV9 *(unsigned int*) (PLL1_BASE + 0x174) /*Divider 9*/- H8 j5 Y# J* N: ^& D# K" O
#define PLL1_PLLDIV10 *(unsigned int*) (PLL1_BASE + 0x178) /*Divider 10*/& u9 {9 g1 N3 p% c1 E: l9 t
#define PLL1_PLLDIV11 *(unsigned int*) (PLL1_BASE + 0x17C) /*Divider 11*/
8 d  m: A; X& c2 [/ z9 a7 `( ~#define PLL1_PLLDIV12 *(unsigned int*) (PLL1_BASE + 0x180) /*Divider 12*/: r# y; \4 h/ u; w+ n
#define PLL1_PLLDIV13 *(unsigned int*) (PLL1_BASE + 0x184) /*Divider 13*/8 t; H: S- X$ M' k4 N! L  E
#define PLL1_PLLDIV14 *(unsigned int*) (PLL1_BASE + 0x188) /*Divider 14*/' O  Y- i$ X5 d. b
#define PLL1_PLLDIV15 *(unsigned int*) (PLL1_BASE + 0x18C) /*Divider 15*/
2 E# z- L% \+ C- r* r  K' N$ a#define PLL1_PLLDIV16 *(unsigned int*) (PLL1_BASE + 0x190) /*Divider 16*/
/*PSC Module Related Registers*/# U1 _$ c8 K) Z' k/ }4 T
#define PSC0_BASE 0x01C10000: j6 V" X2 [( O- Q7 H& J* E2 j
#define PSC1_BASE 0x01E27000
#define PSC0_MDCTL (PSC0_BASE+0xA00)/ G$ b. w+ w" {4 T$ _. g
#define PSC0_MDSTAT (PSC0_BASE+0x800)
4 C6 L8 g; {7 S" _! s3 ~#define PSC0_PTCMD *(unsigned int*) (PSC0_BASE + 0x120): M! v: ~% B% P3 Q
#define PSC0_PTSTAT *(unsigned int*) (PSC0_BASE + 0x128)
#define PSC1_MDCTL (PSC1_BASE+0xA00)
0 X/ E% ^8 R1 I9 i! K% r* J#define PSC1_MDSTAT (PSC1_BASE+0x800)
% n) n$ j& g( P% b0 ]: G0 b#define PSC1_PTCMD *(unsigned int*) (PSC1_BASE + 0x120)
+ C& f' U1 C6 c' g" d! V$ E5 [#define PSC1_PTSTAT *(unsigned int*) (PSC1_BASE + 0x128)
#define PSC_TIMEOUT 200 // This value can be optimized by the user
#define LPSC_EDMA_CC0 0+ w. `" d+ W( _/ q: ^+ W
#define LPSC_EDMA_TC0 1
. H% `! ]( @6 s5 K% C#define LPSC_EDMA_TC1 2
3 N- v( M; f( C  R; D#define LPSC_EMIFA 3 /*PSC0*/
0 g# s& W8 Z! A2 g6 Y#define LPSC_SPI0 4 /*PSC0*/
3 p! `* R3 }% J! g#define LPSC_MMCSD0 5 /*PSC0*/
) ]+ k; f& ]6 V% T/ `#define LPSC_ARM_AINTC 68 C4 q8 |' O( g: G4 A8 z& U( w
#define LPSC_ARM_RAMROM 7 /*PSC0*/
. T+ a8 @; S7 z' n" Q. {: ^2 x// LPSC #8 not used& ?# f3 c' U4 ?& F) M1 l
#define LPSC_UART0 9 /*PSC0*/
* j5 p4 S( G. A# k#define LPSC_SCR0 10
, E! j1 E6 `  E#define LPSC_SCR1 11) ?: Y& C% E  {3 K
#define LPSC_SCR2 127 B- H! Y/ c- V, f* Y; a" Q
#define LPSC_PRU 13 /*PSC0*// L' I0 K/ K. x  H8 F" X
#define LPSC_ARM 14 /*PSC0*/( U" z1 f* }. h& Z; A! D
#define LPSC_DSP 15 /*PSC0*/
#define LPSC_EDMA_CC1 0
0 U" w+ M2 a9 i* [2 W; S7 ?! c#define LPSC_USB20 1 /*PSC1*/
+ R& V$ B! m( t! \  ^#define LPSC_USB11 2 /*PSC1*/" j1 V0 K+ `: z2 T' w; T
#define LPSC_GPIO 3 /*PSC1*/
( U: L' v+ b! }* f#define LPSC_UHPI 4 /*PSC1*/- c( ]! s5 o. n/ a
#define LPSC_EMAC 5 /*PSC1*/) n: Y: G; Z8 s. V4 S' |
#define LPSC_DDR 6 /*PSC1*/# q' E4 s! P. }+ P, d  r
#define LPSC_MCASP0 7 /*PSC1*/  L# c. v) F, `% s1 j! D% N' ^
#define LPSC_SATA 8 /*PSC1*/9 ?. f+ d! A7 Q( y/ n
#define LPSC_VPIF 9 /*PSC1*/
+ p) V5 g, b% j0 g' Z#define LPSC_SPI1 10 /*PSC1*/0 m% R$ q$ l, G9 Z
#define LPSC_I2C1 11 /*PSC1*/' s8 \5 }8 d# m1 M: E
#define LPSC_UART1 12 /*PSC1*/$ B. c: M& j+ f& X; q/ L) @
#define LPSC_UART2 13 /*PSC1*/1 j/ D$ [5 R. R9 ]. w
#define LPSC_MCBSP0 14 /*PSC1*/- f" x4 O9 A# u) K' N- E+ n
#define LPSC_MCBSP1 15 /*PSC1*/2 z/ ]8 I* z* {: H, j
#define LPSC_LCDC 16 /*PSC1*/
$ H/ X3 A6 j+ V#define LPSC_EPWM 17 /*PSC1*/
2 K) \) I, O6 N/ |: W  u3 ^7 z#define LPSC_MMCSD1 18
! N1 P, N" N  e" K& P  Q' t0 ?5 g: ?  D#define LPSC_UPP 19
# L( o3 d' Q8 f#define LPSC_ECAP 20
! y% M% P3 ?+ T#define LPSC_EDMA_TC2 21/ _, D- m1 k1 p; r' N3 b, T# H3 X% _$ i
// LPSC #22-23 not used
. a% Q3 k0 n7 z* V# P#define LPSC_SCR_F0 24
% \6 g7 r+ o! j% u' ]#define LPSC_SCR_F1 25
! l7 }, Z3 z# F: Q0 ]#define LPSC_SCR_F2 264 l& `5 c5 C5 Y/ p
#define LPSC_SCR_F6 27
2 g$ a. i  X% V#define LPSC_SCR_F7 28' i$ a- ~2 j- a
#define LPSC_SCR_F8 29, h1 q1 y5 l$ p' M9 F
#define LPSC_BR_F7 30& [1 F0 p2 s7 I
#define LPSC_SHARED_RAM 31
/*DDR MMR Declaration*/
4 Q+ K/ ]: n# [) t' _' b#define VTPIO_CTL *(unsigned int*)(0x01E2C000) // VTPIO_CTL Register
. m/ I$ h2 Z  V1 E! g  A#define EMIFDDR_SDRAM_CFG 0xB0000000
" A5 k8 _) Z, E  S& S& R6 _#define EMIFDDR_REVID *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x00) //EMIF Module ID and Revision Register
# }% f* x5 ?- p: K) l#define EMIFDDR_SDRSTAT *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x04) //SDRAM Status Register
8 [0 H9 @2 n3 _4 u#define EMIFDDR_SDCR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x08) //SDRAM Bank Config Register
) S/ S8 H0 S& S# a  E#define EMIFDDR_SDRCR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x0C) //SDRAM Refresh Control Register" r6 ~8 p3 F) Y, p$ ~
#define EMIFDDR_SDTIMR1 *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x10) //SDRAM Timing Register1
; ^1 }+ u' ^- X9 [#define EMIFDDR_SDTIMR2 *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x14) //SDRAM Timing Register2
2 P5 d6 c7 M, J#define EMIFDDR_SDCR2 *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x1C) //SDRAM Config Register2$ Q6 t5 V% N0 v7 y7 k$ |
#define EMIFDDR_PBBPR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x20) //VBUSM Burst Priority Register
+ r* [' R% Z: p3 L0 m#define EMIFDDR_VBUSMCFG1 *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x28) //VBUSM config Value1 Register
9 Q% M. C. c: H, C6 |! h2 l6 q- i" l4 S#define EMIFDDR_VBUSMCFG2 *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x2C) //VBUSM config Value2 Register2 V8 y( L* J5 C$ b& `
#define EMIFDDR_IRR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC0) //Interrupt Raw Register: Z- [9 |6 p. R, e8 `! }( K" p7 M. Z
#define EMIFDDR_IMR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC4) //Interrupt Masked Register
8 e- T; v- Z$ t3 w9 A7 {#define EMIFDDR_IMSR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC8) //Interrupt Mask Set Register
) x) }& ~( R' T& o9 s' j# r# i#define EMIFDDR_IMCR *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xCC) //Interrupt Mask Clear Register- X6 Z" O1 N+ O( S2 @' k
#define DDRPHYREV *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xE0) //DDR PHY ID and Revision Register' d) j5 W1 G. K7 j: a
#define DRPYC1R *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xE4) //DDR PHY Control 1 Register
#define DDR2 0 // Do not change this value
; @0 e. X+ S5 @3 [1 y  y  i8 A( ^5 u#define MDDR 1 // Do not change this value
8 [1 _6 f1 Q* ?7 U#define VTP_TIMEOUT 200 // This value can be optimized by the user
3 s/ |8 f. e" _/ W#define DDR_DEBUG 0 // Set this to "1" to program DDR with more timing slack
#define EMIFDDR_BASE_ADDR 0xC00000009 ~5 q1 a! m3 s( R- q# g0 J" B. l; H
#define EMIFA_BASE_ADDR 0x40000000
' k6 ~  o6 a$ `* y#define EMIFA_CS2_BASE_ADDR 0x60000000! n, v1 B! I4 M! }) G8 h
#define EMIFA_CS3_BASE_ADDR 0x620000005 Q  j! n7 P" ~- R, c: e0 h7 q$ v
#define EMIFA_CS4_BASE_ADDR 0x64000000
$ t) n" n3 l. L3 @#define EMIFA_CS5_BASE_ADDR 0x66000000
/*EMIF2.5 MMR Declaration*/
# e9 c/ A" L; _+ }, N#define EMIFA 0x68000000
#define EMIFA_AWAITCFG *(unsigned int*)(EMIFA + 0x04)2 p7 L$ `' B9 I( {, c; ~8 x
#define EMIFA_SDCFG *(unsigned int*)(EMIFA + 0x08)5 \! z9 c5 k: U6 H7 F
#define EMIFA_SDREF *(unsigned int*)(EMIFA + 0x0C)% Y9 h! ^7 n! a7 I8 g/ A
#define EMIFA_ACFG2 *(unsigned int*)(EMIFA + 0x10) //Async Bank1 Config Register, m( k0 x. G; L9 Z* w! Z1 e
#define EMIFA_ACFG3 *(unsigned int*)(EMIFA + 0x14) //Async Bank2 Config Register
  A# B( V$ n9 @4 k8 ^, t! s% {#define EMIFA_ACFG4 *(unsigned int*)(EMIFA + 0x18) //Async Bank3 Config Register, \% A. j9 I6 {  \$ C# B
#define EMIFA_ACFG5 *(unsigned int*)(EMIFA + 0x1C) //Async Bank4 Config Register
, L& }# F/ H% U/ `( d, ]#define EMIFA_SDTIM *(unsigned int*)(EMIFA + 0x20) //SDRAM Timing Register: X# }5 L' y' |6 U9 b
#define EMIFA_SRPD *(unsigned int*)(EMIFA + 0x3C)7 b' j' s+ S- _* L; z
#define EMIFA_NANDFCR *(unsigned int*)(EMIFA + 0x60)
/*GPIO MMR*/0 c; M4 P1 b9 v
#define GPIO_REG_BASE (0x01E26000)/ O0 H; y! q7 Z9 ^. z# V$ k7 S: f$ m
#define GPIO_BANK_OFFSET (0x28)# q# j( X- Y0 v% S
#define GPIO_DAT_OFFSET (0x04)) J. O; r' i9 |: u1 o4 a5 F
#define GPIO_SET_OFFSET (0x08)! ?8 c9 J4 f; K6 L: Z+ [0 u5 W+ k9 w
#define GPIO_CLR_OFFSET (0x0C)- o" z2 a* Q" i, \! g
#define GPIO_BINTEN *(unsigned int*)(GPIO_REG_BASE + 0x08)4 k' G/ R5 W# t- e
#define GPIO_BANK01_BASE (GPIO_REG_BASE + 0x10)" M$ ]0 ?. f. |, n1 h4 `, x7 X) j
#define GPIO_BANK23_BASE (GPIO_BANK01_BASE + GPIO_BANK_OFFSET)) w6 p; V; L; y- N0 v
#define GPIO_BANK45_BASE (GPIO_BANK23_BASE + GPIO_BANK_OFFSET)5 W- ~: b( A. ~  l  w( z
#define GPIO_BANK67_BASE (GPIO_BANK45_BASE + GPIO_BANK_OFFSET): [) D! @6 n! D
#define GPIO_BANK8_BASE (GPIO_BANK67_BASE + GPIO_BANK_OFFSET)
) J$ L% h0 v/ _#define GPIO_BANK23_DIR *(unsigned int*)(GPIO_BANK23_BASE)
$ g( D. X' ]+ y* J. m#define GPIO_BANK23_DAT *(unsigned int*)(GPIO_BANK23_BASE + GPIO_DAT_OFFSET)9 ]1 N/ f) ?9 F2 B2 L& V8 I2 {
#define GPIO_BANK23_SET *(unsigned int*)(GPIO_BANK23_BASE + GPIO_SET_OFFSET)
( f) v7 x% c( F$ F% }" f+ v* Y  b#define GPIO_BANK23_CLR *(unsigned int*)(GPIO_BANK23_BASE + GPIO_CLR_OFFSET)
/*System MMR Declaration*/& t+ S1 r$ k. h# A: p
#define SYS_BASE 0x01C14000
8 ]2 q8 o( F% x) {2 O4 Y/ B, Y#define HOST0CFG *(unsigned int*)(SYS_BASE + 0x040) //ARM HOST0CFG
6 t2 F/ l5 W1 O8 z1 T& y#define KICK0R *(unsigned int*)(SYS_BASE + 0x038)
  \, M/ v& Y0 {; N4 E# G2 T#define KICK1R *(unsigned int*)(SYS_BASE + 0x03c)
1 g; S$ d- ^; Y6 F) @4 P#define PINMUX0 *(unsigned int*)(SYS_BASE + 0x120) //PINMUX0( C- \; e: L0 n6 v% {- B5 ~# F3 i
#define PINMUX1 *(unsigned int*)(SYS_BASE + 0x124) //PINMUX1" ^, z& _% G% a! l& t9 P
#define PINMUX2 *(unsigned int*)(SYS_BASE + 0x128) //PINMUX2
0 _5 g- ]( |' I9 w. G#define PINMUX3 *(unsigned int*)(SYS_BASE + 0x12C) //PINMUX3
1 V" h2 U5 d* |8 Z# f9 e#define PINMUX4 *(unsigned int*)(SYS_BASE + 0x130) //PINMUX47 Z0 Y/ o# F# K3 n8 K4 `& d$ r
#define PINMUX5 *(unsigned int*)(SYS_BASE + 0x134) //PINMUX5) i% g0 h% n# z* a* E
#define PINMUX6 *(unsigned int*)(SYS_BASE + 0x138) //PINMUX6' J- W: h" n! o" H- ^7 V+ q9 _
#define PINMUX7 *(unsigned int*)(SYS_BASE + 0x13C) //PINMUX73 R6 J: q3 m' J6 u& N! @
#define PINMUX8 *(unsigned int*)(SYS_BASE + 0x140) //PINMUX8
& m+ R: \' m& @) T#define PINMUX9 *(unsigned int*)(SYS_BASE + 0x144) //PINMUX9
0 r2 s+ H. c9 Y8 g& y- ^#define PINMUX10 *(unsigned int*)(SYS_BASE + 0x148) //PINMUX10; D. u) w& U  C2 `
#define PINMUX11 *(unsigned int*)(SYS_BASE + 0x14C) //PINMUX11$ G- Z; x+ X) G1 c5 p4 J5 Z
#define PINMUX12 *(unsigned int*)(SYS_BASE + 0x150) //PINMUX12
1 W/ s5 m0 a4 V# K9 {. K) V: Z#define PINMUX13 *(unsigned int*)(SYS_BASE + 0x154) //PINMUX13% c  |% p" z$ j- l- }& f! a
#define PINMUX14 *(unsigned int*)(SYS_BASE + 0x158) //PINMUX14
. K' c* ~0 A8 w! Z/ J#define PINMUX15 *(unsigned int*)(SYS_BASE + 0x15C) //PINMUX15
: `7 v2 Q9 L' o* ^# X0 Y0 H#define PINMUX16 *(unsigned int*)(SYS_BASE + 0x160) //PINMUX16
) b7 h# a, g% I5 \#define PINMUX17 *(unsigned int*)(SYS_BASE + 0x164) //PINMUX17. l  p  n  C: H! b4 P3 Z
#define PINMUX18 *(unsigned int*)(SYS_BASE + 0x168) //PINMUX18. v. I( E: o6 V9 O6 V: u8 i
#define PINMUX19 *(unsigned int*)(SYS_BASE + 0x16C) //PINMUX197 O: p$ P8 F. o7 }
#define CFGCHIP0 *(unsigned int*)(SYS_BASE + 0x17C)' l9 ^' U( ]4 C  s, `  D/ O! b
#define CFGCHIP2 *(unsigned int*)(SYS_BASE + 0x184). J2 E2 @* {6 o% ]* R5 o; h
#define CFGCHIP3 *(unsigned int*)(SYS_BASE + 0x188)
5 h9 R/ S# D6 I  P' [% U9 w0 b* v3 _#define PD0 0 /*Power Domain-0*/3 Z3 g/ x: a. I6 z+ o
#define PD1 1 /*Power Domain-1*/
#define PLLEN_MUX_SWITCH 44 A' O5 ~) [! m
#define PLL_LOCK_TIME_CNT 2400
4 P+ m6 ^2 ~  U$ U) E% D#define PLL_STABILIZATION_TIME 2000; g* E6 Z+ g8 j, d7 O4 r6 [* h
#define PLL_RESET_TIME_CNT 200
OnTargetConnect( )
- `' V: L! B% j- e8 I; K{
2 I* t- Q- [7 K! rGEL_TextOut("\tTarget Connected.\n","Output",1,1,1);
3 O  J2 s- W' \+ m4 ]2 j6 C" OGEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
0 ?; f- D  m) j) N% d' w# J, j# V
CPU_PLL_PSC_DDR_Init();! K# ]% F$ f& h- F% @
}. G0 ]2 v# l, {( u
//建立 菜单 Initiation 子菜单4 ?# o& G( x- a" }( d  c1 e) I
//CPU_PLL_PSC_DDR_Init
) N8 k7 I3 m( ]! C" d; B; Fmenuitem "Initiation"& ?" y9 v/ w+ M2 z
hotmenu CPU_PLL_PSC_DDR_Init()
; Q/ g, z5 _. @{4 l0 V, e$ j7 _. l: g: R
Clear_Memory_Map();
% j4 t1 m+ p, i9 w9 I& W1 M& p5 zSetup_Memory_Map();! w! V0 L1 ^( D3 j; p- O
9 ~1 O; c% B1 h  _4 E+ b) [  @0 Q
PSC_All_On();
: [1 J6 j# E4 RCore_456MHz_DDR2_156MHz();3 V" I& o5 ^" v' \! Z3 i4 J
PINMUX();
3 P- ^8 q% K4 {9 }Wake_DSP(); //只在OMAP下才有效 在使能ARM核之后需要使能DSP才可以调用DSP核
+ V0 n$ V* a0 c$ S0 u, j; ZWake_PRU();8 }' b( c) u# f& f
}
Wake_DSP()
5 n; d- W/ {# `! m{7 \4 l3 ?8 M. W# D; r
PSC0_LPSC_enableCore(1, LPSC_DSP);
GEL_TextOut("\tDSP Wake Complete.(Only For OMAPL138)\n","Output",1,1,1);# Y: v) p- O$ d
GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
% @* S0 R' [" U" p' L}
Wake_PRU()5 r6 P3 S4 s5 N( q" }4 @* q
{
/ S& B: ^/ a& J$ Z/ U* aPSC0_LPSC_enableCore(1, LPSC_PRU);
GEL_TextOut("\tPRU Wake Complete.(Only For OMAPL138)\n","Output",1,1,1);
; A% S4 l1 H: C9 CGEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);% B( |8 a* l. R; t5 L2 {$ m* M
}
PINMUX()+ c1 E% N5 B8 g  b0 K" I
{
& N& J+ ?3 m. e5 P/ sPINMUX0 = 0x88888888;* X9 D* F4 T- v/ P
PINMUX1 = 0x82828288;
! c  [. d$ P1 u4 i; E# aPINMUX2 = 0x88888888;
1 A! O6 t7 _/ TPINMUX3 = 0x88888888;3 V/ X" y' _& T2 B& j' X" w
PINMUX4 = 0x22222288;0 ~  g+ K! P9 @2 M0 R% I# r  _
PINMUX5 = 0x11118102;
- M5 A% B0 r( X0 A. L* |PINMUX6 = 0x11111111;
+ z' [  s* C2 T- [4 l; ePINMUX7 = 0x11111111;
1 V) i: {' ~2 w0 b8 _6 tPINMUX8 = 0x11111111;
% n0 K# f( O! o: S  `* r; {PINMUX9 = 0x11111111;+ I8 D& Z. r7 X
PINMUX10 = 0x11118888;
% k+ N0 t$ X' t  t5 C2 `% f. qPINMUX11 = 0x11111111;
) o( c2 ?$ j. p6 A/ J5 a9 [PINMUX12 = 0x11111111;
+ w$ F, M6 r! `9 W1 RPINMUX13 = 0x44448888;  g% L( {9 e; `8 F5 X! n7 ~
PINMUX14 = 0x44444488;; @2 n( P; y( J, F3 U5 R* K: u8 q8 p
PINMUX15 = 0x44444444;( o# r: Y: p# R- M
PINMUX16 = 0x88888844;
- n0 |/ B. w$ p7 W% o7 P& ^PINMUX17 = 0x88888888;  O* b5 `6 V& W: b. _2 r1 v
PINMUX18 = 0x88888888;
/ r- D3 f3 w9 x* M5 {8 }$ iPINMUX19 = 0x18888888;
! x* W! E' i/ z: G: mGEL_TextOut("\tPINMUX Enable Complete.\n","Output",1,1,1);
9 Q' o* `; F, L/ y# F) ~GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
* f0 @  d/ \: \}
Clear_Memory_Map()
3 g; a- k' a. i3 C2 C& D) d' J{
( z" J; ~, {6 b9 Q# y( q* q! EGEL_MapOff( );
) K. x1 Q" k; P3 zGEL_MapReset( );
( S1 B4 n" ^/ G- FGEL_TextOut("\tMemory Map Cleared.\n","Output",1,1,1);: S# b- e7 V2 ^. S
GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);- |( [5 U, x- e( p9 ^
}
Setup_Memory_Map()# X! W) q. o3 ]3 `! O
{' [3 u) `$ m1 w/ Y5 ?
GEL_MapOn( );1 [! X/ }! A5 _1 l
GEL_MapReset( );
/* PRU */
6 ]8 {3 X( P, e, |2 cGEL_MapAddStr( 0x00000000, 0, 0x00000FFF, "R|W|AS4", 0 ); // PRUSS Local Address Space3 j- J6 z6 y( o  \( u- m5 _
GEL_MapAddStr( 0x01C30000, 0, 0x01C301FF, "R|W|AS4", 0 ); // Data RAM 0
! @7 Q$ [" P$ N  RGEL_MapAddStr( 0x01C32000, 0, 0x01C321FF, "R|W|AS4", 0 ); // Data RAM 1
! m5 ?# t. M* MGEL_MapAddStr( 0x01C34000, 0, 0x01C36FFF, "R|W|AS4", 0 ); // INTC Registers- f& b6 W5 x' y0 R# A* T% t
GEL_MapAddStr( 0x01C37000, 0, 0x01C377FF, "R|W|AS4", 0 ); // PRU0 Registers 4 `8 K. m$ C7 \' U/ @" A3 N
GEL_MapAddStr( 0x01C37800, 0, 0x01C37FFF, "R|W|AS4", 0 ); // PRU1 Registers : r: \5 X8 ~& Q$ L2 b7 s
GEL_MapAddStr( 0x01C38000, 0, 0x01C38FFF, "R|W|AS4", 0 ); // PRU0 Instruction RAM7 u% C1 L7 R3 W% g6 X6 r' C
GEL_MapAddStr( 0x01C3C000, 0, 0x01C3CFFF, "R|W|AS4", 0 ); // PRU1 Instruction RAM) l# _' V& Q/ K* s7 D* Q9 `

- v+ T0 i9 U( g: Y3 j/* ARM */% F, B" H3 V' c" T5 o) D
GEL_MapAddStr( 0xFFFD0000, 0, 0x00010000, "R|W|AS4", 0 ); // ARM Local ROM
/ F' ^" n2 K! ?2 Y6 D9 O  YGEL_MapAddStr( 0xFFFEE000, 0, 0x00001000, "R|W|AS4", 0 ); // ARM INTC
! n! i0 t3 j3 \9 hGEL_MapAddStr( 0xFFFF0000, 0, 0x00002000, "R|W|AS4", 0 ); // ARM Local RAM
# Z* Y$ D; O0 g! nGEL_MapAddStr( 0x01BC0000, 0, 0x00001000, "R|W|AS4", 0 ); // ARM ETB Memory& @1 o  D9 Q! h. z9 c: a; W
GEL_MapAddStr( 0x01BC1000, 0, 0x00000800, "R|W|AS4", 0 ); // ARM ETB Regs
$ R) v1 |, H- ?4 o- xGEL_MapAddStr( 0x01BC1800, 0, 0x00000100, "R|W|AS4", 0 ); // ARM Ice Crusher
/* DSP */
7 h* o- n9 H5 _, o3 ]: r6 XGEL_MapAddStr( 0x00700000, 0, 0x00100000, "R|W|AS4", 0 ); // DSP L2 ROM
' ~# ?0 l0 q. T# iGEL_MapAddStr( 0x00800000, 0, 0x00040000, "R|W|AS4", 0 ); // DSP l2 RAM
4 U) |7 g# @; U7 M' R" l9 o' CGEL_MapAddStr( 0x00E00000, 0, 0x00008000, "R|W|AS4", 0 ); // DSP L1P RAM4 s1 |$ A" Q. \; v
GEL_MapAddStr( 0x00F00000, 0, 0x00008000, "R|W|AS4", 0 ); // DSP L1D RAM2 T1 O  D1 R: @( o' I4 Q4 ~
GEL_MapAddStr( 0x01800000, 0, 0x00010000, "R|W|AS4", 0 ); // DSP Interrupt Controller* d4 m# r* {9 X2 ~% m
GEL_MapAddStr( 0x01810000, 0, 0x00001000, "R|W|AS4", 0 ); // DSP Powerdown Controller
8 k# |' S5 {' V( x: s, Y- RGEL_MapAddStr( 0x01811000, 0, 0x00001000, "R|W|AS4", 0 ); // DSP Security ID* k3 z! I" P& \6 `: B* F& N- s& M
GEL_MapAddStr( 0x01812000, 0, 0x00008000, "R|W|AS4", 0 ); // DSP Revision ID9 J& |8 H, `5 k# p
GEL_MapAddStr( 0x01820000, 0, 0x00010000, "R|W|AS4", 0 ); // DSP EMC
( N+ D* v( M& H' V7 h3 k4 wGEL_MapAddStr( 0x01830000, 0, 0x00010000, "R|W|AS4", 0 ); // DSP Internal Reserved
3 J; f' d7 D& U/ R6 |0 }# gGEL_MapAddStr( 0x01840000, 0, 0x00010000, "R|W|AS4", 0 ); // DSP Memory System
GEL_MapAddStr( 0x11700000, 0, 0x00100000, "R|W|AS4", 0 ); // DSP L2 ROM (mirror)- P$ G2 ~- m7 U# R* N
GEL_MapAddStr( 0x11800000, 0, 0x00040000, "R|W|AS4", 0 ); // DSP l2 RAM (mirror)
% N; _- W' z3 k1 A. @6 A, u: vGEL_MapAddStr( 0x11E00000, 0, 0x00008000, "R|W|AS4", 0 ); // DSP L1P RAM (mirror)0 D! G: O, |5 K8 r$ l- @
GEL_MapAddStr( 0x11F00000, 0, 0x00008000, "R|W|AS4", 0 ); // DSP L1D RAM (mirror)
. ^9 h, o9 L9 I5 B+ r+ X
9 x4 H2 @9 A- w$ z/* Shared RAM */
( ^# A( H0 \* v7 a# EGEL_MapAddStr( 0x80000000, 0, 0x00020000, "R|W|AS4", 0 ); // Shared RAM
/* EMIFA */
9 P2 L) F, B# k$ u" eGEL_MapAddStr( 0x40000000, 0, 0x20000000, "R|W|AS4", 0 ); // EMIFA SDRAM Data
8 Z, e  t& Z, q$ b: ZGEL_MapAddStr( 0x60000000, 0, 0x02000000, "R|W|AS4", 0 ); // EMIFA CS2; E6 f8 {5 i. d6 Q: O9 A8 C+ N; x
GEL_MapAddStr( 0x62000000, 0, 0x02000000, "R|W|AS4", 0 ); // EMIFA CS3$ I% M" K7 P* S& _& o0 t
GEL_MapAddStr( 0x64000000, 0, 0x02000000, "R|W|AS4", 0 ); // EMIFA CS4
1 v& O4 ?! w0 Q* lGEL_MapAddStr( 0x66000000, 0, 0x02000000, "R|W|AS4", 0 ); // EMIFA CS5. m+ u$ r' n# X; _  @
GEL_MapAddStr( 0x68000000, 0, 0x00008000, "R|W|AS4", 0 ); // EMIFA Control
/* DDR */
* B7 p# ?9 V/ `$ Q& {6 M7 p* L: I( B. QGEL_MapAddStr( 0xB0000000, 0, 0x00008000, "R|W|AS4", 0 ); // DDR Control
" v: g% ^$ P# j; sGEL_MapAddStr( 0xC0000000, 0, 0x20000000, "R|W|AS4", 0 ); // DDR Data
/* Peripherals */# P" Q+ c4 m8 w2 t& |) |
GEL_MapAddStr( 0x01C00000, 0, 0x00008000, "R|W|AS4", 0 ); // TPCC0
1 v" M9 k; E+ `( k" NGEL_MapAddStr( 0x01C08000, 0, 0x00000400, "R|W|AS4", 0 ); // TPTC0; X6 f' s, |  z( ^+ D
GEL_MapAddStr( 0x01C08400, 0, 0x00000400, "R|W|AS4", 0 ); // TPTC1. D8 I! d. ^1 ]( S+ b6 }
GEL_MapAddStr( 0x01C10000, 0, 0x00001000, "R|W|AS4", 0 ); // PSC 0
6 ]  ~! c! K( B9 F# s2 o2 j$ ?GEL_MapAddStr( 0x01C11000, 0, 0x00001000, "R|W|AS4", 0 ); // PLL Controller 0# k! D& Q; A9 O0 ^
GEL_MapAddStr( 0x01C12000, 0, 0x00001000, "R|W|AS4", 0 ); // Key Manager
: N* |2 B4 e, }; B* S! p: ZGEL_MapAddStr( 0x01C13000, 0, 0x00001000, "R|W|AS4", 0 ); // SecCo
  h# ^7 Q" a9 K8 G3 S0 }4 ~' {  mGEL_MapAddStr( 0x01C14000, 0, 0x00001000, "R|W|AS4", 0 ); // SysConfig
0 y. W; X1 \& n/ e/ q9 ]" hGEL_MapAddStr( 0x01C16000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 0. b0 w- C+ I. M
GEL_MapAddStr( 0x01C17000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 25 V  O/ i/ _9 C' [5 ~: _+ U
GEL_MapAddStr( 0x01C20000, 0, 0x00001000, "R|W|AS4", 0 ); // Timer64P 0
+ G$ o' k7 b* L! K5 R! sGEL_MapAddStr( 0x01C21000, 0, 0x00001000, "R|W|AS4", 0 ); // Timer64P 1
" N6 j& v! s& H4 d' ^GEL_MapAddStr( 0x01C22000, 0, 0x00001000, "R|W|AS4", 0 ); // I2C 0
6 }& g3 i0 |$ F) oGEL_MapAddStr( 0x01C23000, 0, 0x00001000, "R|W|AS4", 0 ); // RTC; ]+ T) f1 o$ i/ F. O" r
GEL_MapAddStr( 0x01C24000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 1* N, [0 t4 `. n- V. b; F0 G  F# Q
GEL_MapAddStr( 0x01C30000, 0, 0x00000200, "R|W|AS4", 0 ); // PRU Data RAM 0$ Q4 A0 K1 _  T. \5 {
GEL_MapAddStr( 0x01C32000, 0, 0x00000200, "R|W|AS4", 0 ); // PRU Data RAM 1
. _. g9 x+ @. U+ a' L  j2 `GEL_MapAddStr( 0x01C34000, 0, 0x00004000, "R|W|AS4", 0 ); // PRU Control Registers
1 x, D  [2 z& Z$ c1 m% xGEL_MapAddStr( 0x01C38000, 0, 0x00001000, "R|W|AS4", 0 ); // PRU 0 Config Memory! c) H8 k/ [- y( V+ l# O
GEL_MapAddStr( 0x01C3C000, 0, 0x00001000, "R|W|AS4", 0 ); // PRU 1 Config Memory% \. n  `* }) i# Z' ]
GEL_MapAddStr( 0x01C40000, 0, 0x00001000, "R|W|AS4", 0 ); // MMC/SD 0
0 f( F. U& C8 h# b" kGEL_MapAddStr( 0x01C41000, 0, 0x00001000, "R|W|AS4", 0 ); // SPI 0
" U6 P5 _  i! b( T( P' R9 ^/ gGEL_MapAddStr( 0x01C42000, 0, 0x00001000, "R|W|AS4", 0 ); // UART 0
8 D! i& b) p- N0 a! _GEL_MapAddStr( 0x01C43000, 0, 0x00001000, "R|W|AS4", 0 ); // MPU 0
1 N# @& S) f1 l/ ?5 U- T! i9 ~- vGEL_MapAddStr( 0x01D00000, 0, 0x00001000, "R|W|AS4", 0 ); // McASP 0 Control
+ Y2 a, m0 [! U4 _  tGEL_MapAddStr( 0x01D01000, 0, 0x00001000, "R|W|AS4", 0 ); // McASP 0 FIFO Ctrl
3 X7 |1 Y1 J  z8 b/ fGEL_MapAddStr( 0x01D02000, 0, 0x00001000, "R|W|AS4", 0 ); // McASP 0 Data
% r+ M7 K8 X2 m( _1 f9 B3 N6 CGEL_MapAddStr( 0x01D0C000, 0, 0x00001000, "R|W|AS4", 0 ); // UART 1
2 M8 m7 H3 C+ k1 w, {GEL_MapAddStr( 0x01D0D000, 0, 0x00001000, "R|W|AS4", 0 ); // UART 2
+ n% N; ~* F$ d( C0 o, KGEL_MapAddStr( 0x01D0E000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 41 [4 R5 E, Q+ `5 [2 ?7 @
GEL_MapAddStr( 0x01D10000, 0, 0x00000800, "R|W|AS4", 0 ); // McBSP 0 Control% q6 T2 b/ U8 n6 j6 W
GEL_MapAddStr( 0x01D10800, 0, 0x00000200, "R|W|AS4", 0 ); // McBSP 0 FIFO Ctrl/ u# }, s( P* M3 j5 f$ E
GEL_MapAddStr( 0x01D11000, 0, 0x00000800, "R|W|AS4", 0 ); // McBSP 1 Control: T; B- d2 f+ p* Z& o! }
GEL_MapAddStr( 0x01D11800, 0, 0x00000200, "R|W|AS4", 0 ); // McBSP 1 FIFO Ctrl" I3 T  n* T! {/ n; j
GEL_MapAddStr( 0x01E00000, 0, 0x00010000, "R|W|AS4", 0 ); // USB0 (USB HS) Cfg
8 }9 y  G" v4 ?1 T. G# p8 ~* EGEL_MapAddStr( 0x01E10000, 0, 0x00001000, "R|W|AS4", 0 ); // UHPI Cfg& A- R% q. G* \0 |  ?
GEL_MapAddStr( 0x01E11000, 0, 0x00001000, "R|W|AS4", 0 ); // UHPI (IODFT)2 H; O5 a  r, @
GEL_MapAddStr( 0x01E13000, 0, 0x00001000, "R|W|AS4", 0 ); // LCD Controller3 l& a. O8 V1 L" ]" v& A4 m4 V, p7 h& d
GEL_MapAddStr( 0x01E14000, 0, 0x00001000, "R|W|AS4", 0 ); // MPU 13 w4 M" X0 P' V2 U: e
GEL_MapAddStr( 0x01E15000, 0, 0x00001000, "R|W|AS4", 0 ); // MPU 2
* H+ K4 m9 ?% ]9 }) NGEL_MapAddStr( 0x01E16000, 0, 0x00001000, "R|W|AS4", 0 ); // UPP4 {# A& [" @, Q( w1 C6 t
GEL_MapAddStr( 0x01E17000, 0, 0x00001000, "R|W|AS4", 0 ); // VPIF
/ S  t! V: _; oGEL_MapAddStr( 0x01E18000, 0, 0x00002000, "R|W|AS4", 0 ); // SATA
& S: _9 W, j; k- x  p; X) m& h% jGEL_MapAddStr( 0x01E1A000, 0, 0x00001000, "R|W|AS4", 0 ); // PLL Controller 1% V" l0 e% c: q! w7 J( G( R* {
GEL_MapAddStr( 0x01E1B000, 0, 0x00001000, "R|W|AS4", 0 ); // MMC/SD 1$ D- c  C+ h/ y  x
GEL_MapAddStr( 0x01E20000, 0, 0x00002000, "R|W|AS4", 0 ); // EMAC CPPI
! i8 W8 N& W; v) pGEL_MapAddStr( 0x01E22000, 0, 0x00001000, "R|W|AS4", 0 ); // EMAC CONTROL registers6 _1 }$ o5 X' K; h: N5 D
GEL_MapAddStr( 0x01E23000, 0, 0x00001000, "R|W|AS4", 0 ); // EMAC registers
& D  t+ ^( m$ g& t" S6 e( K/ XGEL_MapAddStr( 0x01E24000, 0, 0x00001000, "R|W|AS4", 0 ); // EMAC MDIO port
" N% M; V3 }; h) Q, }- m7 ^GEL_MapAddStr( 0x01E25000, 0, 0x00001000, "R|W|AS4", 0 ); // USB1 (USB FS)3 ~, }5 n1 o! j
GEL_MapAddStr( 0x01E26000, 0, 0x00001000, "R|W|AS4", 0 ); // GPIO
# X" h% J5 p: L/ h1 KGEL_MapAddStr( 0x01E27000, 0, 0x00001000, "R|W|AS4", 0 ); // PSC 1# h$ |3 |; g' |& G
GEL_MapAddStr( 0x01E28000, 0, 0x00001000, "R|W|AS4", 0 ); // I2C 1% u  p2 q% }8 ~, {& f: e* ?' a
GEL_MapAddStr( 0x01E29000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 3/ u1 g6 o7 P7 O5 M- p3 |* l, Q+ ?
GEL_MapAddStr( 0x01E2A000, 0, 0x00001000, "R|W|AS4", 0 ); // PBIST Controller; X% D! V, c/ ~% L
GEL_MapAddStr( 0x01E2B000, 0, 0x00001000, "R|W|AS4", 0 ); // PBIST Combiner
1 F* R7 u9 h& W6 q- SGEL_MapAddStr( 0x01E2C000, 0, 0x00001000, "R|W|AS4", 0 ); // System Config
GEL_MapAddStr( 0x01E30000, 0, 0x00008000, "R|W|AS4", 0 ); // TPCC1
, z4 K+ K+ O5 [8 OGEL_MapAddStr( 0x01E38000, 0, 0x00000400, "R|W|AS4", 0 ); // TPTC22 S  ~3 {% x/ |2 |7 ~4 ^
GEL_MapAddStr( 0x01F00000, 0, 0x00001000, "R|W|AS4", 0 ); // EPWM 03 [% G' a9 T2 g  A3 X
GEL_MapAddStr( 0x01F01000, 0, 0x00001000, "R|W|AS4", 0 ); // HRPWM 0
2 n/ ?% _, c: x4 {GEL_MapAddStr( 0x01F02000, 0, 0x00001000, "R|W|AS4", 0 ); // EPWM 17 X! K, Z: q' o2 {0 d
GEL_MapAddStr( 0x01F03000, 0, 0x00001000, "R|W|AS4", 0 ); // HRPWM 15 n6 R( B' u* X5 X2 {
GEL_MapAddStr( 0x01F06000, 0, 0x00001000, "R|W|AS4", 0 ); // ECAP 0/ T" z* E$ i: b) p, w* c2 m
GEL_MapAddStr( 0x01F07000, 0, 0x00001000, "R|W|AS4", 0 ); // ECAP 1
  {' }  u  _! fGEL_MapAddStr( 0x01F08000, 0, 0x00001000, "R|W|AS4", 0 ); // ECAP 2
, z; A/ {1 I  Q  I: y8 }GEL_MapAddStr( 0x01F0B000, 0, 0x00001000, "R|W|AS4", 0 ); // IOPU 50 \$ K$ S( O1 t/ @" S$ E2 j
GEL_MapAddStr( 0x01F0C000, 0, 0x00001000, "R|W|AS4", 0 ); // Timer64P 21 P+ E1 Y. p4 V; \- w. Y
GEL_MapAddStr( 0x01F0D000, 0, 0x00001000, "R|W|AS4", 0 ); // Timer64P 3
) t* m. R. ~4 D1 ~- s" V0 mGEL_MapAddStr( 0x01F0E000, 0, 0x00001000, "R|W|AS4", 0 ); // SPI1$ @+ x3 T- i: y$ c1 K! T; g
GEL_MapAddStr( 0x01F10000, 0, 0x00001000, "R|W|AS4", 0 ); // McBSP 0 FIFO Data; T0 |( M7 ^* ]) B6 W8 l, I
GEL_MapAddStr( 0x01F11000, 0, 0x00001000, "R|W|AS4", 0 ); // McBSP 1 FIFO Data' Y, o6 I6 I; P3 W
GEL_TextOut("\tMemory Map Setup Complete.\n","Output",1,1,1);* K# M" T5 \, \, b# y
GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
6 H" u, ~) G* S) t}
Set_Core_456MHz() {  Q6 K0 B0 {+ k; ?
device_PLL0(0,18,0,0,1,3,9);
- t8 G! T: q3 RGEL_TextOut("\tPLL0 init done for Core:456MHz, EMIFA:114MHz\n","Output",1,1,1);  w1 A+ ^9 }! D! p; i
}
Set_DDRPLL_156MHz() {
4 N3 N9 h- [0 [% f5 Y! L- S+ r9 Odevice_PLL1(12,0,0,1,2);
; r$ m: x& d: p* ]GEL_TextOut("\tPLL1 init done for DDR:156MHz\n","Output",1,1,1);
7 R# H6 I, H' d( A* z! Z0 X}
Set_DDR2_156MHz() {% c' @* g0 r* ]- E* y5 r
GEL_TextOut("\tDDR initialization is in progress....\n","Output",1,1,1);
1 u% c& Q( ^' o  o, d! xSet_DDRPLL_156MHz();
' `( b; `# c* H- ?) L! k% O( QDEVICE_DDRConfig();) Y9 K) H0 y3 k
GEL_TextOut("\tDDR2 init for 156 MHz is done\n","Output",1,1,1);2 F+ M8 n- t5 z( A
}
Core_456MHz_DDR2_156MHz() {" Z5 I8 J6 u8 U0 f5 w# P, X" G
Set_Core_456MHz();$ J4 z- I' Q8 ?' {$ F1 @
Set_DDR2_156MHz();3 T* ?# Q, n+ z6 `
GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);' T8 V/ w0 {# H7 B2 U) U) F3 n  u
}
PSC_All_On() {
. X  [) i$ k( _// PSC0
: `) ]6 D/ w% d. S% Z* X6 ]* K% sPSC0_LPSC_enable(0, LPSC_EDMA_CC0);2 k' R' h, l3 p7 m+ i+ C
PSC0_LPSC_enable(0, LPSC_EDMA_TC0);
' l0 j+ ?0 q* Y8 e+ h! ZPSC0_LPSC_enable(0, LPSC_EDMA_TC1);
; w# s$ w) ~, }7 \+ sPSC0_LPSC_enable(0, LPSC_EMIFA);) B, t$ s. Z; e+ M) Q2 Q
PSC0_LPSC_enable(0, LPSC_SPI0);, I/ J3 }1 R0 `0 ]9 I
PSC0_LPSC_enable(0, LPSC_MMCSD0);
: L9 s; A6 T) U* N! vPSC0_LPSC_enable(0, LPSC_ARM_AINTC);" j0 A( b2 V5 c& O$ F
PSC0_LPSC_enable(0, LPSC_ARM_RAMROM);& V% g# ?: i: [  S) X( D. S) B
PSC0_LPSC_enable(0, LPSC_UART0);
4 s8 G2 l* _$ [1 V% s6 X- VPSC0_LPSC_enable(0, LPSC_SCR0);1 ^4 U. b3 \" p+ W! e  p$ l* I
PSC0_LPSC_enable(0, LPSC_SCR1);8 O5 E" r  W) ?
PSC0_LPSC_enable(0, LPSC_SCR2);
// PSC1
% u! P2 {! M% T0 TPSC1_LPSC_enable(0, LPSC_EDMA_CC1);
6 C6 A  b* q  m) JPSC1_LPSC_enable(0, LPSC_USB20);
2 s, U5 s7 U' N$ t2 v# U7 J; TPSC1_LPSC_enable(0, LPSC_USB11);
0 L! I! n# P  I9 E7 |3 ICFGCHIP2 = 0x09F2; //Enable USB clock, PHY_PLLON, glue logic mux(USB2 ref clk input)5 r. |+ g8 F, l/ G" h% W
PSC1_LPSC_enable(0, LPSC_GPIO);. \; y' b* P( M' j1 R9 m( V8 S$ m
PSC1_LPSC_enable(0, LPSC_UHPI);
! T3 |$ |+ p, C9 G8 N0 b- YPSC1_LPSC_enable(0, LPSC_EMAC);9 z: n* g" _9 I
PSC1_LPSC_enable(0, LPSC_MCASP0);0 W% V% y: H% Q: M4 k
PSC1_LPSC_force(LPSC_SATA);
! E' b  _0 D! rPSC1_LPSC_enable(0, LPSC_SATA);/ |& n) P# L- @! d
PSC1_LPSC_enable(0, LPSC_VPIF);
) s# F' E# T& k- ?. }3 s* bPSC1_LPSC_enable(0, LPSC_SPI1);. f: D* N  y: {/ @
PSC1_LPSC_enable(0, LPSC_I2C1);
/ ~$ w0 g8 R' Z6 @6 l0 _$ A8 OPSC1_LPSC_enable(0, LPSC_UART1);' b% f5 F: W2 v: I7 d7 G6 ^/ _
PSC1_LPSC_enable(0, LPSC_UART2);
& W+ \0 }# {/ o, t2 m* @PSC1_LPSC_enable(0, LPSC_MCBSP0);' D, J5 Z4 a4 W  ]8 a
PSC1_LPSC_enable(0, LPSC_MCBSP1);1 e/ x2 C* U$ F7 M, r
PSC1_LPSC_enable(0, LPSC_LCDC);5 [' M4 x  y* r' D' `% X: x
PSC1_LPSC_enable(0, LPSC_EPWM);
. m& O) O/ X0 K5 k- v0 YPSC1_LPSC_enable(0, LPSC_MMCSD1);
( Z% {( ?, c$ I. DPSC1_LPSC_enable(0, LPSC_UPP);
9 R! k3 i  m7 BPSC1_LPSC_enable(0, LPSC_ECAP);
: {- Y5 u+ O* {9 e6 A. oPSC1_LPSC_enable(0, LPSC_EDMA_TC2);
6 h2 _) p. _4 o$ {/ }; zPSC1_LPSC_enable(0, LPSC_SCR_F0);1 Y( o0 G2 p  F: \
PSC1_LPSC_enable(0, LPSC_SCR_F1);& X$ `; d  Q; v4 a& n4 f
PSC1_LPSC_enable(0, LPSC_SCR_F2);$ y! X" C  b. b9 w  u# J
PSC1_LPSC_enable(0, LPSC_SCR_F6);
4 j5 Q# C6 i* j4 I; {, WPSC1_LPSC_enable(0, LPSC_SCR_F7);. `* R& C" ?' S; m/ V
PSC1_LPSC_enable(0, LPSC_SCR_F8);
. j! ?& s; k4 R: E9 R! CPSC1_LPSC_enable(0, LPSC_BR_F7);+ ?7 k9 u/ _# ^  U
PSC1_LPSC_enable(0, LPSC_SHARED_RAM);
GEL_TextOut("\tPSC Enable Complete.\n","Output",1,1,1);, d* N* W. x( e( u: I  _
GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);4 d: d1 h8 G5 u
}
/**************************************************************************************************************************************************" Z' m  p/ s3 x( U* \6 @2 m4 P
Device_PLL0 init:
CLKMODE - 0---->On Chip Oscilator 1---->External Oscilator7 O: a7 y" n/ ^/ |' ^
PLL0_SYSCLK1 - Fixed ratio /1
- q- f& W2 k! L3 _( g5 F& p, y  xPLL0_SYSCLK2 - Fixed ratio /29 S+ N2 G/ ^% A2 N. ?, J
PLL0_SYSCLK3 - Variable Divider (EMIFA)
+ s& V$ {  G/ }( q9 @PLL0_SYSCLK4 - Fixed ratio /4" k' k0 G) W/ N! n9 T2 ^
PLL0_SYSCLK5 - Not used -- do nothing, K3 ]! e& V3 {: D" Y3 e
PLL0_SYSCLK6 - Fixed ratio /1
" i8 g5 H) L+ ?$ qPLL0_SYSCLK7 - Variable Divider (RMII)
5 y2 d- g$ u4 x7 }* q7 D! u( Y8 S( Y) R******************************************************************************************************************************************************/, g, V5 O9 ^$ x+ ^- }- k: R
device_PLL0(unsigned int CLKMODE, unsigned int PLLM, unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3, unsigned int PLLDIV7 ) {
unsigned int i=0;
/* Clear PLL lock bit */. e7 G3 u$ d8 z! |0 D- ~
CFGCHIP0 &= ~(0x00000010);
/* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
+ t% k" H6 [5 J. |3 d9 uPLL0_PLLCTL &= ~(0x00000020);
/* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */8 q# i1 I0 @) P* h  Y- c$ p' ?; p
PLL0_PLLCTL &= ~(0x00000200);
/* Set PLLEN=0 to put in bypass mode*/
  \( V% E" k* ePLL0_PLLCTL &= ~(0x00000001);
/*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
: T% w6 v! P$ P& _for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
/* Select the Clock Mode bit 8 as External Clock or On Chip Oscilator*/
& V$ w7 G' i2 C' SPLL0_PLLCTL &= 0xFFFFFEFF;3 ]9 B9 F7 L; N! M/ H. I
PLL0_PLLCTL |= (CLKMODE << 8);
/*Clear PLLRST bit to reset the PLL */' n- E" Q+ X3 s7 M' I6 E. o( R9 i" c
PLL0_PLLCTL &= ~(0x00000008);
/* Disable the PLL output*/* D% p1 v( e4 R# L/ ]
PLL0_PLLCTL |= (0x00000010);
/* PLL initialization sequence
% v; k- T% h! d! l9 S" @Power up the PLL by setting PWRDN bit set to 0 */
" U7 n; o5 M6 Y) P/ Q* gPLL0_PLLCTL &= ~(0x00000002);
/* Enable the PLL output*/
: b2 a8 f- D. ^2 h: C3 JPLL0_PLLCTL &= ~(0x00000010);
/*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/4 ]7 J, u' ?& V' P! e: H4 r: \
for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
/*Program the required multiplier value in PLLM*/# v2 C7 i8 {; X/ O, P% Y5 e( i
PLL0_PLLM = PLLM;
/*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
) j" _1 o8 F" m* sPLL0_POSTDIV = 0x8000 | POSTDIV;
/*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/2 o7 q( a7 l& s" B) m6 |" d+ q
while(PLL0_PLLSTAT & 0x1==1){}
/*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
. b4 k( P8 \7 G, j* D! APLL0_PLLDIV1 = 0x8000 | PLLDIV1; // Fixed Ratio /1& ~8 @3 |8 W3 ^" P$ j
PLL0_PLLDIV2 = 0x8000 | PLLDIV2; // Fixed Ratio /23 G2 i0 Q, [5 b% @
PLL0_PLLDIV4 = 0x8000 | (((PLLDIV1+1)*4)-1); // Fixed Ratio /48 g" g7 n2 }* m7 q
PLL0_PLLDIV6 = 0x8000 | PLLDIV1; // Fixed Ratio /1
0 B; W/ k8 E. I+ ~0 f* sPLL0_PLLDIV3 = 0x8000 | PLLDIV3; // Variable Ratio (EMIF)
5 R  e+ V: W3 qPLL0_PLLDIV7 = 0x8000 | PLLDIV7; // Variable Ratio (RMII)

6 a2 l, F0 |9 p  W/*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/) H* N1 v9 L. Z0 y
PLL0_PLLCMD |= 0x1;
/*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
8 B! X6 m- a# s2 qwhile(PLL0_PLLSTAT & 0x1==1) { }
/*Wait for PLL to reset properly.*/  i: [' z& A& ~8 N
for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}
/*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
0 }0 j, F* h1 }9 u5 QPLL0_PLLCTL |= 0x8;
/*Wait for PLL to lock.*/9 X" G1 @& O: H2 }
for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}
/*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/. ]) U2 j+ I* b4 m% @7 a6 \- ^
PLL0_PLLCTL |= 0x1;1 r+ K, h# b( p
}
/**********************************************************************************# W" [- k/ u0 Q3 n
DDR PLL1 init:
***********************************************************************************/4 }2 \% C4 L* i- T0 T
device_PLL1(unsigned int PLLM,unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3 ) {
unsigned int i=0;
/* Clear PLL lock bit */
: {( a1 k/ |5 R7 w$ ]& I9 PCFGCHIP3 &= ~(0x00000020);
/* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */* U5 w) M& J/ G
PLL1_PLLCTL &= ~(0x00000020);
/* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
! u; g" q* r- Q5 _  A- K. I, A. _PLL1_PLLCTL &= ~(0x00000200);
/* Set PLLEN=0 to put in bypass mode*/
! q; V8 W4 A" l$ ~5 rPLL1_PLLCTL &= ~(0x00000001);
/*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
7 i# ~  [2 F5 i6 }% @1 J9 xfor(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
/*Clear PLLRST bit to reset the PLL */  T! U2 H9 e4 }  D9 \
PLL1_PLLCTL &= ~(0x00000008);
/* Disable the PLL output*/+ I# U, `& @0 f6 N6 h. z( x
PLL1_PLLCTL |= (0x00000010);
/* PLL initialization sequence
* q/ C& F( J5 S; wPower up the PLL by setting PWRDN bit set to 0 */) [8 e% E' @/ T' F8 [' s
PLL1_PLLCTL &= ~(0x00000002);
/* Enable the PLL output*/
4 s& s4 T7 w# T) k) iPLL1_PLLCTL &= ~(0x00000010);
/*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
& W$ S' q( s, F- e) ^- Ufor(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
/*Program the required multiplier value in PLLM*/
- k' A* v( O3 F9 ~! e3 x8 A" r: hPLL1_PLLM = PLLM;
/*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
. N1 }+ j8 t& g9 u/ j; kPLL1_POSTDIV = 0x8000 | POSTDIV;
/*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
: u, t' e6 i% }* S9 H, t3 nwhile(PLL1_PLLSTAT & 0x1==1){}
/*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
2 O; D; y) i# WPLL1_PLLDIV1 = 0x8000 | PLLDIV1; // DDR frequency (aka 2X_CLK)$ h) k8 h  m9 n3 n: p
PLL1_PLLDIV2 = 0x8000 | PLLDIV2; // Optional CFGCHIP3[ASYNC3_CLKSRC] clock source
6 f, B# J3 x, {  I' xPLL1_PLLDIV3 = 0x8000 | PLLDIV3; // Optional PLL0 clock source
/*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
: _$ u! [* E+ j2 g; C" p- |PLL1_PLLCMD |= 0x1;
/*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/* q: u6 o& H5 r
while(PLL1_PLLSTAT & 0x1==1) { }
/*Wait for PLL to reset properly */! a2 @4 M8 {4 G# Y; E8 D) G
for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}
/*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/' u$ P' t  {& q) \5 i
PLL1_PLLCTL |= 0x8;
/*Wait for PLL to lock. See PLL spec for PLL lock time*/6 p# E9 v8 ~0 B
for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}
/*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
# w* |0 M% J& `8 {9 m4 i4 ~PLL1_PLLCTL |= 0x1;: N% C  |- d8 w/ J5 `
}
/*********************************************************************************** ?2 ~5 S4 {( y
PSC Common functions :
***********************************************************************************/
8 p2 \$ C8 u: R! s* P/*Force module state without handshaking */
6 z2 ~' ?) k  d. rPSC1_LPSC_force(unsigned int LPSC_num) {5 m& a- j5 y6 w  p7 S. X- `
*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) | 0x80000000);: K4 q7 E! [( S4 w- ?9 M
}
/*SyncReset Function for PSC1*/
' E, J9 E' ~3 w& M2 E# q+ ]PSC1_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {0 p$ p+ R- Q1 O& |( s
unsigned int j;
if( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {4 I7 m. R  f$ k5 v
*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
  e7 u0 j: [& W) W( q" rPSC1_PTCMD = 0x1<<PD;
j = 0;& h" A" x  T3 r' _2 T* e$ v: e
/*Wait for power state transition to finish*/2 ~- t' p( X5 H. ?: k& K: D( j
while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) {
3 b% W! L$ G5 Qif( j++ > PSC_TIMEOUT ) {
' X" W$ e8 z- f4 G4 v3 G. D" xGEL_TextOut("\tPSC1 Sync Reset Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
. A1 d# J' K0 y" t, P" A' Wbreak;$ A" k* g6 D8 G( u! M- ~
}* Z% l: s. \7 X* o: f3 E
}
j = 0;: J( U7 S6 T/ |4 {8 h
while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1) {
; }5 k. a1 Z. e; |0 Aif( j++ > PSC_TIMEOUT ) {6 ~7 m7 {0 V( b  F. F
GEL_TextOut("\tPSC1 Sync Reset Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);7 j$ U( v! q2 P9 Q* m* d
break;5 E1 o* E# ]! g7 g
}
/ Q$ ^% w# f% x$ Z) r' I! g; ~7 w; J}
) y" G# o/ }3 {; J$ L0 D}
4 w% ^3 K( T* t7 s* a, R1 b}
/*Enable Function for PSC1*/8 P5 f6 I# E: O4 @1 Z' U$ [
PSC1_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {
' C3 C. i# I# z, W. Xunsigned int j;
: O" C3 V5 d' X$ p- |/ v
# E3 {6 J' Q) G8 m9 Q/ rif( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {& ^7 a4 _3 c+ F, |4 U4 k- [2 q
*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
( p. v3 E0 _  k' o0 r) Z9 DPSC1_PTCMD = 0x1<<PD;
j = 0;
  j: j5 o, A# z! ]$ m/*Wait for power state transition to finish*/
* R* c( d- I+ W* w/ ~6 R  h, rwhile( (PSC1_PTSTAT & (0x1<<PD) ) !=0) {4 J$ M1 I! n* i
if( j++ > PSC_TIMEOUT ) {
- R$ q2 u( q3 f  Q5 CGEL_TextOut("\tPSC1 Enable Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);! [( Z. N! r0 H$ @! v
break;& }0 m8 ^: n$ X1 ?0 z1 b( C
}
! ^- F  o$ Z# j* v}
j = 0;
6 `  r5 U' ?" n9 A4 n8 w% uwhile( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3) {8 b3 `+ g3 b/ c2 `$ {
if( j++ > PSC_TIMEOUT ) {
" d3 O! M6 s1 |2 H$ `* C: AGEL_TextOut("\tPSC1 Enable Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
3 h& f0 ^5 B% z3 ~" u! Mbreak;
( m8 x) {7 T, |}( [, ?2 B! N8 d7 j
}
# K9 T! M: \; ~}
! W& |6 S. C/ N; ~2 T" d8 k2 F}
/*LPSC Enable Function for ARM or DSP*/( ^$ w5 Z" P. x5 e
PSC0_LPSC_enableCore(unsigned int PD, unsigned int LPSC_num) {/ r% e& ]: k  A; j. T) j
unsigned int j;
6 G! ?# p$ D9 n3 u' C8 E
' e/ e* j/ e9 X) nif( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) != 0x103 ) {
& X0 B% @3 M+ T5 {6 N*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFEE0) | 0x0103;: L* W- L8 C7 ]; A
PSC0_PTCMD = 0x1<<PD;
j = 0;# S  c# m+ }6 c, D
/*Wait for power state transition to finish*/& Q( D2 f% h- d( \" v
while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {7 v; M, Y4 k. N( D0 q/ z% f
if( j++ > PSC_TIMEOUT ) {7 t, y# f, Q, ^7 c
GEL_TextOut("\tPSC0 Enable Core Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
5 K/ j+ I7 D& Pbreak;) W% c2 N9 ^6 @0 q5 y+ v- G) R
}
2 a1 M7 [5 I+ y4 n; s}- t5 ]4 w, `3 a) P3 e9 w
: b) ?8 b$ s3 _5 B/ g# q; ]
j = 0;5 t& ^+ I' W, Y- p+ j% \, q
while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) !=0x103) {
0 h! E: k$ g9 z$ }  Y0 |/ M- m- zif( j++ > PSC_TIMEOUT ) {
5 ~1 \! r( h% |7 P9 ^7 ^GEL_TextOut("\tPSC0 Enable Core Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);2 O! Y* ?& m7 ]
break;' K- g9 M8 e- L8 o
}
; h! j% v& X( p9 y6 M) v" W; m2 f! T}
0 L1 v! v; j' I; \% G}2 c5 W6 I5 |* O  f: S- ?
}
/*SyncReset Function for PSC0*/
# K+ j- f$ F# pPSC0_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {' j2 y% `" }  W, L' Q) e, }
unsigned int j;
" A2 u8 c5 }' O; V' B% R
* A  d; s0 ^1 s& q+ V0 oif( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {7 V- f3 C! t: P; c  I$ N2 {
*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
4 c& K0 H4 M: {: ~- L, L# L7 dPSC0_PTCMD = 0x1<<PD;
j = 0;
' \6 d6 b5 K* S) n0 |/*Wait for power state transition to finish*/0 K( S( V5 h' m! t  X! m
while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {+ c  A9 F9 X: m# l, E3 ^
if( j++ > PSC_TIMEOUT ) {
3 C" I# m$ s' kGEL_TextOut("\tPSC0 Sync Reset Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
& ?) O) G' Y, y3 }6 b1 r5 w4 hbreak;
# z' T1 J. A0 @* p9 {( k3 k' q}
) G6 J# z9 l. P}
j = 0;
# e+ g3 r$ T  j0 L; ]2 K" O6 owhile( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1) {3 d2 \$ X) i. M
if( j++ > PSC_TIMEOUT ) {" E  G0 x, T9 a% V0 @( t; f; C
GEL_TextOut("\tPSC0 Sync Reset Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
: m. W  L9 ~, S) D2 _: Abreak;
% K* S. ^6 @' c  V  E* v0 \}2 U, F" t  ~; J5 x
}
* i/ j& E5 `" S5 w}/ n: ^$ C, v+ J- w+ n
}
/*Enable Function for PSC0*/
/ k* `" [- n1 ^* T8 pPSC0_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {+ X3 w4 `# s8 T
unsigned int j;
if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
. o2 m0 Y8 g; M6 N3 D& h*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;4 B! p& u" W" ?! @# k
PSC0_PTCMD = 0x1<<PD;
j = 0;
4 u# z; L6 M% ]8 y8 h/*Wait for power state transition to finish*/
" c! {2 W* d8 T8 `' A/ D4 C, Gwhile( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {, r. n: C0 s6 N" |
if( j++ > PSC_TIMEOUT ) {% T4 F3 g# z) j: d. X
GEL_TextOut("\tPSC0 Enable Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);$ [; Y; b3 G: R1 G9 ~, b  O8 x
break;
, }9 E4 G! i) _" G/ ^}
  |, o. `! ]2 D}
j = 0;
' p5 v9 m9 |+ e" X; Dwhile( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3) {  O9 m( r2 z1 f- ?) D! B
if( j++ > PSC_TIMEOUT ) {
( i. L9 ^  @2 G2 C. h% FGEL_TextOut("\tPSC0 Enable Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
$ j* _" d& P6 K5 B6 p' M9 Kbreak;
- S2 R' r" u1 x# W. m# K1 F* D( j# L}, w! J' k, `# C/ r" E) z, H+ W6 \
}' N  r: S3 K5 \9 Z2 r6 S* r
}
5 ~$ [( M5 T. [& |8 z}
+ f+ u% d, u" F8 A7 ?
/**********************************************************************************
" C- B) q, T7 I' k7 Z4 dDDR Configuration routine:3 `. E; K* W3 f. S
1. DDR Enable+ M; n; I2 _5 S- \! G" }7 t: ]
2. VTP calibration
: N' r3 O& y3 W( L2 A- c+ z3. Configure DDR
# I) y) l0 [( d# _4. Set to self-refresh, enable mclkstop and DDR Sync Reset2 @8 f) ^% @5 j  z
5. Enable DDR and disable self-refresh
int freq is MHz
DDR2 = 0
6 D) g7 a! w  I" P. u2 K5 S* W( DMDDR = 1
A DDR configuration spreadsheet tool is located here:
- J& ~- K  E3 c  `7 s5 Ehttp://processors.wiki.ti.com/in ... F_on_OMAP-L1x/C674x
***********************************************************************************/# Q1 a5 m  A: d
// 0xB000 0008 SDCR 0x00134632/ {% o, t, K2 }) S
// 0xB000 000C SDRCR 0xC0000260$ q2 I  _5 O% L4 R0 D' ~& T
// 0xB000 0010 SDTIMR1 0x264A2A095 Y- p6 O9 S; r* Z6 x0 m+ M, e
// 0xB000 0014 SDTIMR2 0x4412C722
3 }& V# N( k0 D+ L// 0xB000 001C SDCR2 0x00000000; d$ E; I' @0 M
// 0xB000 00E4 DRPYC1R 0x000000C3
/ c, e" U+ g8 GDEVICE_DDRConfig()
0 X6 H  n1 i1 O( S{5 ~  r+ i: n7 ]8 p9 \" D
unsigned int j;
  I: j6 l1 T* m) K3 U1 qunsigned int tmp_SDCR;
- k5 [9 R8 |# c# k+ X5 n- D+ K. |' S% O5 n( G3 g3 w5 Q- i
// Enable the Clock to EMIFDDR SDRAM
4 d$ F  e8 x9 U; v+ }1 \1 _! b& YPSC1_LPSC_enable(PD0, LPSC_DDR);
// Begin VTP Calibration/ d, v& U7 e5 S+ `, Z$ m, q; E
VTPIO_CTL &= ~0x00000040; // Clear POWERDN6 n  |0 {6 E' k0 q: r& y
VTPIO_CTL &= ~0x00000080; // Clear LOCK
: k0 U# r1 p/ ]1 D" N: K% jVTPIO_CTL |= 0x00002000; // Set CLKRZ in case it was cleared before (VTP looks for CLKRZ edge transition)
3 [* \8 F- k+ @( VVTPIO_CTL &= ~0x00002000; // Clear CLKRZ (Use read-modify-write to ensure 1 VTP cycle wait for previous instruction)
5 i- l3 a: l3 V" a: x) f8 ^VTPIO_CTL |= 0x00002000; // Set CLKRZ (Use read-modify-write to ensure 1 VTP cycle wait for previous instruction)
j = 0;
3 Q3 i: ?* h, E9 E3 f6 m( P// Polling READY bit to see when VTP calibration is done, ?/ |- A6 R: U, B  \
while((VTPIO_CTL & 0x00008000) == 0) {
5 V& u3 v, S5 t) E2 `! N! ]4 ~if( j++ > VTP_TIMEOUT ) {
( w% ]" T) k+ c; N+ i" Q$ mGEL_TextOut("\tVTP Ready timeout\n","Output",1,1,1); - o5 I) j' J: m# y
break;
6 }* E. n$ Z- j$ u. g! b}
" {+ H/ g1 |4 A}
VTPIO_CTL |= 0x00000080; // Set LOCK bit for static calibration mode
0 H+ V! D/ K5 p2 O0 i+ e9 g7 jVTPIO_CTL |= 0x00000040; // Set POWERDN bit to power down VTP module
; }9 g: [3 |8 E/ q  ?, M4 N) y// End VTP Calibration
VTPIO_CTL |= 0x00004000; // Set IOPWRDN to allow powerdown of input receivers when PWRDNEN is set
// **********************************************************************************************
% _% c0 M! O, b) H) K9 T' q8 v// Setting based 1Gb DDR2 Samsung K4T1G164QF-BCF8
) t- Q& h% P7 `+ L$ ?) A' m9 o// Config DDR timings- z% l$ y  L. e1 _
DRPYC1R = (0x0 << 8) | // Reserved
1 f: M& b" V8 B7 i4 Y' s" C1 u. O(0x1 << 7) | // EXT_STRBEN
9 x5 I/ e1 h9 l(0x1 << 6) | // PWRDNEN
# |5 X7 k8 p$ O- k2 L6 Q5 n(0x0 << 3) | // Reserved
1 a) D5 r6 G- w0 @(0x3 << 0); // RL: X; ?# b" G% \, v0 L6 Q
// DRPYC1R Value = 0x000000C3
if( DDR_DEBUG ) {
+ [  |( N2 v5 u! v4 {5 g: f# j// Configure EMIF with max timings for more slack
; C( g6 J. s- D, L/ C" F/ E// Try this if memory is not stable2 J! L& e0 D# l- j
DRPYC1R |= 0x7; // RL, A& r# f4 p+ ]; }! I7 ^6 \0 ?: g% p
}
EMIFDDR_SDCR |= 0x00800000; // Set BOOTUNLOCK
// Settings depending on DDR2
4 J2 H: w( x$ p$ Ttmp_SDCR = (0x0 << 25) | // MSDRAMEN
3 g* f& L' @+ V& h(0x1 << 20); // DDR2EN$ ^: b8 p& X7 D- `  p" c1 Q) L, }
GEL_TextOut("\tUsing DDR2 settings\n","Output",1,1,1);
EMIFDDR_SDCR = tmp_SDCR | // Settings that change depending on DDR2 or MDDR
, [+ L; @0 Y/ v(EMIFDDR_SDCR & 0xF0000000) | // Reserved/ P! `0 ~; u+ q8 x( P* h# r; ]
(0x0 << 27) | // DDR2TERM1
) M  B+ p9 A8 H! m(0x0 << 26) | // IBANK_POS+ v6 N, \# p; Q+ R
(0x0 << 24) | // DDRDRIVE1
; u( X0 h& R5 ~+ j5 f3 C(0x0 << 23) | // BOOTUNLOCK, l% V: m( s& l
(0x0 << 22) | // DDR2DDQS& S) j; c0 U& _- Z/ \% R. f5 H7 Z% a
(0x0 << 21) | // DDR2TERM0+ O* `: T& Z' \6 r0 B8 d( Y$ ~
(0x0 << 19) | // DDRDLL_DIS  V- c5 k" Q$ {# e7 Z
(0x0 << 18) | // DDRDRIVE0& W7 g3 u, v0 w' Z5 s* T
(0x1 << 17) | // DDREN
% L! U: I3 q0 m) S" R) m$ H$ P$ B(0x1 << 16) | // SDRAMEN
$ ]( E! {9 |0 [+ B! v4 U4 Y(0x1 << 15) | // TIMUNLOCK8 a& E0 C, e: K( a0 X. S+ r& U
(0x1 << 14) | // NM
! A5 p$ q, T0 F& M* g) j6 [( o" u(0x0 << 12) | // Reserved; I" J7 h' z, @2 |8 Y& Q/ s" W
(0x3 << 9) | // CL
7 o7 M# [6 G3 r(0x0 << 7) | // Reserved- O0 ]% \! {4 ]% P
(0x3 << 4) | // IBANK
7 N2 [& d$ n9 J$ [% b% G* Q(0x0 << 3) | // Reserved
( c8 v9 @0 t4 y8 {(0x2 << 0); // PAGESIZE. Q8 o/ }) u$ ]# a

. ?, d+ }& L4 `7 R% t, I# REMIFDDR_SDCR2 = 0x00000000; // IBANK_POS set to 0 so this register does not apply
if( DDR_DEBUG ) {
+ m+ e4 M2 R4 D& f3 ^* b// Configure EMIF with max timings for more slack
* e' M9 A# I2 }: D// Try this if memory is not stable
EMIFDDR_SDTIMR1 = (0x7F << 25) | // tRFC
) \  p0 R& ^: z9 L1 P0 {) @(0x07 << 22) | // tRP
2 `& u5 x* F: l3 B(0x07 << 19) | // tRCD
6 m+ \% D8 A9 i7 U(0x07 << 16) | // tWR: `+ r" F4 G5 s; _0 b; k, V7 z
(0x1F << 11) | // tRAS8 z/ y% Y) o/ H* V2 l4 ?! E( Q
(0x1F << 6) | // tRC6 ?9 G9 u1 f7 v, A3 D' v  \
(0x07 << 3) | // tRRD
  l. t- c" }9 o7 h* s5 ~& Y% Z(EMIFDDR_SDTIMR1 & 0x4) | // Reserved
0 [0 t- z+ b$ q% f: H+ w6 s(0x03 << 0); // tWTR
) z( b. l% z  s2 R8 A& i; @- H; |: [# L. C8 T/ Z# Z
EMIFDDR_SDTIMR2 = (EMIFDDR_SDTIMR2 & 0x80000000) | // Reserved
0 R: R/ ?# m( W- D! |3 s(((unsigned int) ((70000 / 3400) - 0.5)) << 27) | // tRASMAX (original 7812.5)
! \7 V9 B) A9 S- F; V(0x3 << 25) | // tXP
# q' s3 c) I# |(0x0 << 23) | // tODT (Not supported)
/ Y8 w3 ^, @9 Q0 u. [: a(0x7F << 16) | // tXSNR
1 T: Z8 N" M! |8 R/ u2 T9 T$ L(0xFF << 8) | // tXSRD
/ [/ _7 f! d+ o: \* x6 _(0x07 << 5) | // tRTP (1 Cycle)( \/ @. Q! U: Z- w6 |
(0x1F << 0); // tCKE
GEL_TextOut("\tDDR Timings Configured for Debug\n","Output",1,1,1);3 T% }/ ]& M& b6 @# t/ g
}
4 a8 o+ ^" Y; {0 V% ]7 g& B$ eelse {
' C8 a3 F. |1 t; B* n0 |" F// Let float -> integer truncate handle minus 1; Safer to round up for timings% X) |2 P' D* o/ X  G; q/ V. Y
EMIFDDR_SDTIMR1 = (19 << 25) | // tRFC
4 t0 e2 u; J0 j+ ]) S3 v$ |(1 << 22) | // tRP
/ L& }7 b' ~# N3 M4 K(1 << 19) | // tRCD
" ?/ c, J) C, n7 l6 C% e3 X% \7 l(2 << 16) | // tWR" V* c( d0 o: g, @( x
(5 << 11) | // tRAS0 k. p) P" N. c: ]
(8 << 6) | // tRC" K& [" Q; x2 L8 K' A3 S  \
(1 << 3) | // tRRD* P; F( K. g6 J1 g0 a) o' w
(0 << 2) | // Reserved! Y  m/ J$ E8 ?$ i: Z. Q; L; j
(1 << 0); // tWTR
; u( }4 A: }7 |8 x1 c9 ]( h
, M4 H) \# s' T- H* AEMIFDDR_SDTIMR2 = (EMIFDDR_SDTIMR2 & 0x80000000) | // Reserved- n/ e/ U0 T. ]/ U$ d
(8 << 27) | // tRASMAX
! l( Y$ \& j1 A2 i1 {+ A(2 << 25) | // tXP
+ t; Z4 e9 J. j" M, F. _% V(0 << 23) | // tODT (Not supported)
) ]% ]8 _- e& g0 a$ M9 O(18 << 16) | // tXSNR (tXSR for mDDR)& X4 b8 Y8 o( J7 d
(199 << 8) | // tXSRD (tXSR for mDDR)$ M: a; ]2 O- a" `' T
(1 << 5) | // tRTP0 |# ]" T; q: n5 y
(2 << 0); // tCKE! r) l6 k- e  N+ U9 r2 C
}
. f% D. D, x4 \4 b' I) y% a, o  d
EMIFDDR_SDCR &= ~0x00008000; // Clear TIMUNLOCK
// Let float -> integer truncate handle RR round-down; Safer to round down for refresh rate1 Y2 ], Z. G3 `7 G% _" v& D
EMIFDDR_SDRCR = (0x1 << 31) | // LPMODEN (Required for LPSC SyncReset/Enable)1 D0 A. A8 L- J, L8 q$ b
(0x1 << 30) | // MCLKSTOPEN (Required for LPSC SyncReset/Enable)
  L, i" F4 H) N$ L7 |  ^$ a(0x0 << 24) | // Reserved
; s% b" k" }5 Q5 F(0x0 << 23) | // SR_PD
3 k) j* P6 z" t(0x0 << 16) | // Reserved; {9 |, c5 D+ G" |
(0x260 << 0); // RR
// SyncReset the Clock to EMIFDDR SDRAM
+ n: P* f8 ?8 OPSC1_LPSC_SyncReset(PD0, LPSC_DDR);
// Enable the Clock to EMIFDDR SDRAM
! q3 z! m) k* s; _* yPSC1_LPSC_enable(PD0, LPSC_DDR);
// Disable self-refresh
9 ?% Q0 j' [2 O- i# L; JEMIFDDR_SDRCR &= ~0xC0000000;
  i5 I7 F- d  U! Z6 W2 h
- z4 O" M, g! H$ _4 jEMIFDDR_PBBPR = 0x10;
# o, W: |- Z! p}
// Input clock to device in MHz
' T; x5 s/ \/ A: F8 _#define OSCIN_FREQ 24
#define ARM_ROM_ID *(unsigned int*) 0xFFFD000c
2 |0 K; B9 V: \2 j#define DSP_ROM_ID *(unsigned int*) 0x1170000c
#define ARM_BLCfgStruct *(unsigned int*)0xFFFF0700
! K6 W( f4 e1 P0 E$ `2 l$ U#define DSP_BLCfgStruct *(unsigned int*)0x11F00700
#define SYS_BASE 0x01C14000# G' j: P" Y" B4 C8 J" x% ?$ t
#define DEV_INFO_24 *(unsigned int*)(SYS_BASE + 0x008)
& K% ~' l+ u- j  h2 X) K! q, @#define DEV_INFO_25 *(unsigned int*)(SYS_BASE + 0x00C)
) _& a' {% t1 h# W  k3 o#define DEV_INFO_06 *(unsigned int*)(SYS_BASE + 0x010): f1 ?2 ~  j9 Y# i4 N
#define DEV_INFO_26 *(unsigned int*)(SYS_BASE + 0x014)
: t) ]* b/ E/ c) U#define DEV_INFO_00 *(unsigned int*)(SYS_BASE + 0x018)( _9 |2 D8 c4 ~0 q5 U! P+ _' |
#define DEV_INFO_01 *(unsigned int*)(SYS_BASE + 0x01C)  W, `/ S4 ^) u- `* B& E7 m
#define DEV_INFO_02 *(unsigned int*)(SYS_BASE + 0x020)% M' [0 ?- Q6 ?
#define DEV_INFO_03 *(unsigned int*)(SYS_BASE + 0x024)
! K" J& {$ A% O. i% |; F: I" q$ a#define DEV_INFO_04 *(unsigned int*)(SYS_BASE + 0x028)
+ r5 Y. \) i* J. @- {4 q0 u#define DEV_INFO_05 *(unsigned int*)(SYS_BASE + 0x02C)
8 h8 i) X9 a; H* \% g#define DEV_INFO_11 ((DEV_INFO_24>>0) & 0xFFF)- {6 X" o0 |+ a* G9 f: [
#define DEV_INFO_12 ((DEV_INFO_24>>12) & 0xFFF)
# v4 c* |5 Z$ t! M#define DEV_INFO_10 ((DEV_INFO_24>>24) & 0x3F)
) d. N+ b# D2 E" k9 ~#define DEV_INFO_09 ((DEV_INFO_25>>0) & 0xFFFFFF)
- ?7 H! C+ J) c#define DEV_INFO_07 ((DEV_INFO_25>>24) & 0x1F)
' }1 ?- t) l8 j4 ^) ~1 e0 U#define DEV_INFO_08 ((DEV_INFO_25>>29) & 0x7)
. Z+ i* b7 M$ y3 ?2 T6 p: K( V) g( n#define DEV_INFO_13 ((DEV_INFO_26>>0) & 0x1F)) y. A* l8 O1 w1 K1 A
#define DEV_INFO_14 ((DEV_INFO_26>>5) & 0x1)
# A+ s1 k' j5 @6 A+ `% y: u#define DEV_INFO_15 ((DEV_INFO_26>>6) & 0x7FF)
$ m. X8 {  g) \0 q/ {6 e, ^; F: M) W#define DEV_INFO_16 ((DEV_INFO_26>>17) & 0x3FFF)
7 P5 _+ l# q7 Q  `#define KEY_BASE 0x01C12000
( e$ o: ?' v0 D- A$ o" N" y#define DEV_INFO_17 *(unsigned int*)(KEY_BASE + 0x004)
6 u7 J0 I( i8 V$ N0 p8 X#define DEV_INFO_18 *(unsigned int*)(KEY_BASE + 0x008)
4 F" k3 ~# h0 U" d% j% {#define DEV_INFO_19 ((DEV_INFO_17>>8) & 0x1F)$ v) l3 H6 }* n0 z4 _& A$ k8 N
#define DEV_INFO_20 *(unsigned int*)(0x11700008)2 @- z/ `" _' F* w% N; h2 t8 ?; L
#define DEV_INFO_21 *(unsigned int*)(0x1170000C)- E  q7 e: o- V( |4 |+ E) q
#define DEV_INFO_22 *(unsigned int*)(0xFFFD0008)
) e% B; k. S/ T# `3 {#define DEV_INFO_23 *(unsigned int*)(0xFFFD000C)$ {8 v0 u" K  L2 d& P. w9 ^
#define BOOTCFG *(unsigned int*)(SYS_BASE + 0x020) //BOOTCFG
#define PLLC0_BASE_ADDRESS 0x01C11000
( Q6 r5 L! C! {. W: ?+ o9 ^) P#define PLLC1_BASE_ADDRESS 0x01E1A000. p! [0 A: \( X! p
#define PLLCTL_OFFSET 0x1004 g, J4 E1 g8 g: [+ u. k
#define OCSEL_OFFSET 0x104. O/ V2 _+ `: C6 s/ c
#define PLLM_OFFSET 0x110
. x! W- C- E1 E# W/ a  t: I#define PREDIV_OFFSET 0x114
6 M+ }: T: H. \: V#define PLLDIV1_OFFSET 0x118
( X" Z6 X+ T- S* h#define PLLDIV2_OFFSET 0x11C8 X3 {8 x; v! e- K. x/ {
#define PLLDIV3_OFFSET 0x120
0 Y$ `0 B7 _: ], {! g3 }#define OSCDIV_OFFSET 0x124
' g$ o4 R% e% ]1 s  \# n#define POSTDIV_OFFSET 0x128
% A: `! k6 Q) W! n#define PLLDIV4_OFFSET 0x160% @/ y6 D8 G7 E# G5 o7 K' A. ?
#define PLLDIV5_OFFSET 0x164
) W+ g" K7 K" }8 s( }0 {6 R0 G#define PLLDIV6_OFFSET 0x168! _+ H) e, K1 t* ]& W0 m8 O/ b
#define PLLDIV7_OFFSET 0x16C
#define CFGCHIP3 *(unsigned int*)(0x01C14188)
menuitem "Diagnostics" 7 K3 I4 |8 N  A1 P* a; L+ M) [
hotmenu Run_All()
+ g3 x% c/ f7 e4 N$ b& \; M{7 A4 Z+ b( o* `+ t- I5 a5 O+ o
GEL_MapOff( );
7 H! b- D% C& ?+ E9 j7 a9 QPrint_Device_Info();
9 n& {0 B; `  n) k5 EPrint_ROM_Info();
% A+ t* z. R+ {0 ]+ r8 g& ~Print_PLL_Configuration();, d3 z$ [* L' [3 ?) q: p" j1 E
Print_PSC_Status();9 F' k7 S* \  B: ]& c
}

; a8 m& N3 e* h1 _% d/ \! tmenuitem "Diagnostics"
* R- j% E* P, w, a" ehotmenu Print_ROM_Info(); b" b7 K) N' Z8 }
{! q7 p3 K. ~7 x3 M4 J
int errorCode;
  `3 F) C, i3 Z! H9 _" Rint boot_config;) p& ?! a8 A1 v. g- A
int revision2, revision1, revision0;
) w1 [$ {( v* M7 s5 L  [int arm_dsp;
  ?  C0 m/ m: D! k' `$ |9 a* |* nint rom_id;
0 `, L" S) f0 z& H2 u6 Vunsigned int BLCfgStruct;
GEL_TextOut("---------------------------------------------\n",,,,);
" p' g& n. K& qGEL_TextOut("| BOOTROM Info |\n",,,,);
5 b; [- G8 }# c" A0 D+ sGEL_TextOut("---------------------------------------------\n",,,,);
' P' T3 G' X, f+ ?. s9 S( _: Z5 X9 c+ e# R' O
arm_dsp = ((ARM_ROM_ID & 0xFF) == 0x6B) ? 1 : 0;
rom_id = (arm_dsp) ? ARM_ROM_ID : DSP_ROM_ID;
revision0 = ((rom_id & 0xFF000000) >>24) - 48; 9 N* i5 L# x2 o9 d6 ]2 z7 ]
revision1 = ((rom_id & 0xFF0000) >>16) - 48; ( l; M7 S, j1 B
revision2 = ((rom_id & 0xFF00) >>8) - 48;
GEL_TextOut("ROM ID: d800k%d%d%d \n",,,,, revision2, revision1, revision0);
if(revision0 == 1) GEL_TextOut("Silicon Revision 1.0\n",,,,);
: {2 f) f( ?" G3 t* U+ F0 Velse if(revision0 == 2) GEL_TextOut("Silicon Revision 1.0\n",,,,);6 q/ {% K* F- _6 Q9 d1 p3 A' v# r3 g
else if(revision0 == 3) GEL_TextOut("Silicon Revision 2.0\n",,,,);
) i2 ?/ e# I) B& J( u. y/ Jelse if(revision0 == 4) GEL_TextOut("Silicon Revision 1.1\n",,,,);
3 R. W  j5 T( Nelse if(revision0 == 5) GEL_TextOut("Silicon Revision 2.1\n",,,,); # j/ M( |" ^. B8 e: @. N7 ~
else if(revision0 == 6) GEL_TextOut("Silicon Revision 2.0\n",,,,);
9 H! I9 q1 R5 j5 S7 R8 t& _) Yelse if(revision0 == 8) GEL_TextOut("Silicon Revision 2.1\n",,,,);
. Y" h. ]+ i$ ielse GEL_TextOut("Silicon Revision UNKNOWN\n",,,,);

6 w0 T3 h4 ~/ R. i* I( @boot_config = BOOTCFG;2 I( Q1 o: V' y  F
GEL_TextOut("Boot pins: %d\n",,,,, boot_config);
  E6 N8 P  p3 y% h0 Y) e7 Pif((revision0 % 2) == 1) {" G& h- `8 f8 Q7 i1 s2 i, l0 p
if((boot_config & 0x87) == 0x01) GEL_TextOut("Boot Mode: NOR (%x)\n",,,,,boot_config);' w4 `( P1 I$ ?8 V2 x
else if((boot_config & 0x87) == 0x02) GEL_TextOut("Boot Mode: HPI (%x)\n",,,,,boot_config);
* K* u6 C# m5 s8 g& S0 |else if((boot_config & 0x87) == 0x05) GEL_TextOut("Boot Mode: SPI0 Flash (%x)\n",,,,,boot_config);
1 n, ~" p9 _% n+ L, h4 Delse if((boot_config & 0x87) == 0x06) GEL_TextOut("Boot Mode: SPI1 Flash (%x)\n",,,,,boot_config);
/ s, L( U$ e8 B2 J3 Z- d# D2 relse if((boot_config & 0x87) == 0x07) GEL_TextOut("Boot Mode: NAND 8 (%x)\n",,,,,boot_config);4 U0 u" g# G0 m/ |, e0 e
else if((boot_config & 0x8F) == 0x80) GEL_TextOut("Boot Mode: NAND 16 (%x)\n",,,,,boot_config);
3 ]1 A; |2 m7 o0 c! ~2 ^else if((boot_config & 0x8F) == 0x00) GEL_TextOut("Boot Mode: I2C0 Master (%x)\n",,,,,boot_config);
3 l' y4 q1 p9 R1 selse if((boot_config & 0x8F) == 0x08) GEL_TextOut("Boot Mode: I2C0 Slave (%x)\n",,,,,boot_config);7 r5 j5 D, R# U. d' @
else if((boot_config & 0x8F) == 0x03) GEL_TextOut("Boot Mode: I2C1 Master (%x)\n",,,,,boot_config);
: L2 Q5 C' W7 s* pelse if((boot_config & 0x8F) == 0x0B) GEL_TextOut("Boot Mode: I2C1 Slave (%x)\n",,,,,boot_config);  c. d" V* T* Y6 O
else if((boot_config & 0x8F) == 0x04) GEL_TextOut("Boot Mode: SPI0 EEPROM (%x)\n",,,,,boot_config);& L! h- W% S& H
else if((boot_config & 0x8F) == 0x0C) GEL_TextOut("Boot Mode: SPI1 EEPROM (%x)\n",,,,,boot_config);: }4 j7 X. B6 G; }4 d
else if((boot_config & 0x8F) == 0x81) GEL_TextOut("Boot Mode: SPI0 Slave (%x)\n",,,,,boot_config);
' e% L! s* V: S- L6 Uelse if((boot_config & 0x8F) == 0x89) GEL_TextOut("Boot Mode: SPI1 Slave (%x)\n",,,,,boot_config);
6 ~  C9 Q# X8 X4 t" m' h3 {else if((boot_config & 0x8F) == 0x83) GEL_TextOut("Boot Mode: UART0 (%x)\n",,,,,boot_config);
$ p; M! f, n% g3 {1 `  O% }else if((boot_config & 0x8F) == 0x8B) GEL_TextOut("Boot Mode: UART1 (%x)\n",,,,,boot_config);9 R  j! i$ G8 H5 Q8 X
else if((boot_config & 0x8F) == 0x82) GEL_TextOut("Boot Mode: UART2 (%x)\n",,,,,boot_config);) h; f# Y  Z; h! o
else if((boot_config & 0x8F) == 0x87) GEL_TextOut("Boot Mode: Emulation Debug (%x)\n",,,,,boot_config);# f) ^( N. K# k1 ]  U
else GEL_TextOut("Boot Mode: INVALID (%x)\n",,,,,boot_config);- i& W$ r2 n# {  J
}
' b# v. X& o4 }0 x' J4 {( b6 eelse{
/ t/ c; @2 R  Y- Zif(boot_config == 0x02) GEL_TextOut("Boot Mode: NOR\n",,,,);# ?; _& o0 U1 F8 {  Q) d
else if(boot_config == 0x0E) GEL_TextOut("Boot Mode: NAND 8\n",,,,);( t" ~% C, D6 b& V* I4 A
else if(boot_config == 0x10) GEL_TextOut("Boot Mode: NAND 16\n",,,,); * n0 x; W- f9 F/ k( `
else if(boot_config == 0x00) GEL_TextOut("Boot Mode: I2C0 EEPROM\n",,,,);
% G& O1 h6 }3 R- T# M! m9 Nelse if(boot_config == 0x06) GEL_TextOut("Boot Mode: I2C1 EEPROM\n",,,,);
( N1 C: R" |$ N0 U) W: Gelse if(boot_config == 0x01) GEL_TextOut("Boot Mode: I2C0 Slave\n",,,,);
2 F  ^8 |* Q6 Y0 belse if(boot_config == 0x07) GEL_TextOut("Boot Mode: I2C1 Slave\n",,,,);. g- F0 q6 u* o" L+ {
else if(boot_config == 0x08) GEL_TextOut("Boot Mode: SPI0 EEPROM\n",,,,);* I5 b; B- K0 f: {* s1 Q9 n$ C
else if(boot_config == 0x09) GEL_TextOut("Boot Mode: SPI1 EEPROM\n",,,,);
+ b4 f$ q& w  C1 selse if(boot_config == 0x0A) GEL_TextOut("Boot Mode: SPI0 Flash\n",,,,);
4 G3 v5 T5 N8 T& C( Y5 Nelse if(boot_config == 0x0C) GEL_TextOut("Boot Mode: SPI1 Flash\n",,,,);& [# n) p6 L% Y. c
else if(boot_config == 0x12) GEL_TextOut("Boot Mode: SPI0 Slave\n",,,,);7 c" s' j8 W; h4 N7 x" i" [
else if(boot_config == 0x13) GEL_TextOut("Boot Mode: SPI1 Slave\n",,,,);
% d- v5 T  Y2 [" D7 ?) kelse if((boot_config & 0x3F) == 0x1C) GEL_TextOut("Boot Mode: SDMMC0\n",,,,);. p& C6 S. @$ ^. g. {& i
else if((boot_config & 0x3F) == 0x3C) GEL_TextOut("Boot Mode: SDMMC0, MMC mode\n",,,,);
5 v3 P0 o$ E. x8 ?) ^else if((boot_config & 0x1F) == 0x16) GEL_TextOut("Boot Mode: UART0\n",,,,);  I! ~" ^0 @) y; F* j) y
else if((boot_config & 0x1F) == 0x17) GEL_TextOut("Boot Mode: UART1\n",,,,);
+ T  w& t7 ?1 }" f& r7 n$ nelse if((boot_config & 0x1F) == 0x14) GEL_TextOut("Boot Mode: UART2\n",,,,);
# h+ i6 u6 |/ D( k; |2 kelse if(boot_config == 0x04) GEL_TextOut("Boot Mode: HPI\n",,,,);
# N+ t4 Q; {' [5 H' R1 `/ D" m+ ielse if(boot_config == 0x1E) GEL_TextOut("Boot Mode: Emulation Debug\n",,,,);
$ c! ]$ \+ x& N. [/ g: j7 Telse if(boot_config == 0x1C && revision0 > 6) GEL_TextOut("Boot Mode: MMCSD0\n",,,,);
% M2 o0 h5 D! B% \" x% S, nelse GEL_TextOut("Boot Mode: INVALID (%x)\n",,,,,boot_config);
# ~5 F7 G2 z- M* z8 u/ w
! r: I$ p0 }1 y7 B; Cif((boot_config & 0x1F) == 0x16 || (boot_config & 0x1F) == 0x17 || (boot_config & 0x1F) == 0x14) {7 f2 t+ V0 y/ ?; a1 H  m# ?
if(((boot_config & 0xE0) >> 5) == 0) GEL_TextOut("24 MHz or 12 MHz input clock\n",,,,);
" J5 U/ N' I2 L; k% s9 fif(((boot_config & 0xE0) >> 5) == 1) GEL_TextOut("27 MHz or 13.5 MHz input clock\n",,,,);
' q5 E+ Y: ?- L+ eif(((boot_config & 0xE0) >> 5) == 2) GEL_TextOut("30 MHz or 15 MHz input clock\n",,,,);, t, I% r8 ~+ {
if(((boot_config & 0xE0) >> 5) == 3) GEL_TextOut("16.8 MHz input clock\n",,,,);
, ?: c; z0 f2 G3 y8 E* b  Mif(((boot_config & 0xE0) >> 5) == 4) GEL_TextOut("19.2 MHz input clock\n",,,,);5 @- f+ m+ I7 N1 ?1 o& ]
if(((boot_config & 0xE0) >> 5) == 5) GEL_TextOut("24.576 MHz or 12.288 MHz input clock\n",,,,);  D2 S9 U' P) ]" U4 i1 e% j5 u
if(((boot_config & 0xE0) >> 5) == 6) GEL_TextOut("25 MHz input clock\n",,,,);- [7 [# p  T. \/ P6 s4 ?
if(((boot_config & 0xE0) >> 5) == 7) GEL_TextOut("26 MHz or 13 MHz input clock\n",,,,);
2 ^1 V3 ]: h& m6 f; x
5 q1 B- _1 Q; A}7 M5 U4 Z% J2 g, V1 _
}
$ d8 B  ]# e  F2 N/ G( B
0 h5 {" A; T0 k- ^  L. j: d: ]( _if((revision0 % 2) == 1) {6 Z' ?, K6 Q6 ^" L( a6 s" R' M& y: P
BLCfgStruct = arm_dsp ? ARM_BLCfgStruct : DSP_BLCfgStruct;
: ~5 v" k3 _! g0 O. N& p# A8 S5 K}
5 L& ]. C; T" a" Zelse {
) v% \! ^  \7 E1 p  ~! yBLCfgStruct = arm_dsp ? ARM_BLCfgStruct : DSP_BLCfgStruct;
7 [2 }" m* m! T( J$ D8 l- r9 B}
errorCode = (BLCfgStruct >> 8) & 0xFF;
6 j5 l& T4 R- n' vGEL_TextOut("ROM Status Code: %x\n",,,,, errorCode);
if(revision0 == 1) {; a1 e+ `/ ?* ~! ~* G# G
if(errorCode == 0) GEL_TextOut("No error\n",,,,);
+ [4 V5 @1 d, g- X& m3 `9 relse if(errorCode == 1) GEL_TextOut("Unknown error\n",,,,);0 {4 P9 z  W' ^0 j% f% g
else if(errorCode == 2) GEL_TextOut("Invalid (or no action) boot mode\n",,,,);
/ b/ D- B, a3 w# t2 Yelse if(errorCode == 3) GEL_TextOut("Function not allowed\n",,,,);
. S0 u; f2 x7 o# q! W- k8 Pelse if(errorCode == 4) GEL_TextOut("This code should not execute\n",,,,);
& ~: @+ Q: Q0 R/ w' Y! }. ~8 a' _else if(errorCode == 5) GEL_TextOut("Waiting to get reset\n",,,,);2 B4 w+ m& r( E9 S- y( U4 `: d! ?
else if(errorCode == 6) GEL_TextOut("Invalid bits for device\n",,,,);4 j( x# ?  k8 u% m3 j
else if(errorCode == 7) GEL_TextOut("Invalid device type\n",,,,);
* F3 T( u' `$ j+ A* Z2 }" telse if(errorCode == 8) GEL_TextOut("Invalid device number\n",,,,);( h- t! P5 v' V+ o# O0 `/ T$ H
else if(errorCode == 9) GEL_TextOut("Invalid address range\n",,,,,);
+ P- U% N. ?1 ~else if(errorCode == 10) GEL_TextOut("Not supported for non-secure device\n",,,,);
( y/ `0 X9 {: K: N- Uelse if(errorCode == 11) GEL_TextOut("Invalid password\n",,,,);& I! x$ l7 N. Q, U
else if(errorCode == 12) GEL_TextOut("Not supported for secure device\n",,,,);
# u9 k/ X9 p' G- v3 P$ X5 c! F7 ielse if(errorCode == 13) GEL_TextOut("Secure ROM checksum failed\n",,,,);# \( r% Z8 H- Y" ]8 i7 }: k( i! z7 n
else if(errorCode == 14) GEL_TextOut("Invalid RPK\n",,,,);8 N6 W1 Y: l  w, H, I9 O: c5 t
else if(errorCode == 15) GEL_TextOut("Invalid signature\n",,,,);
5 N0 E* j# d5 |1 W; H; N7 Belse if(errorCode == 16) GEL_TextOut("Buffer overflow\n",,,,);. O7 }2 S% v6 Z1 T% G6 b
else if(errorCode == 17) GEL_TextOut("Invalid AIS keyword\n",,,,);( A: Y% p- A7 S- f0 S/ c" c
else if(errorCode == 18) GEL_TextOut("Invalid AIS sync opcode\n",,,,);
/ d: I7 C/ l/ q% P  Z: h) m7 _else if(errorCode == 19) GEL_TextOut("Error parsing AIS opcode\n",,,,);
( o' T0 b0 _" [2 |; Celse if(errorCode == 20) GEL_TextOut("Invalid AIS format\n",,,,);
# x% A! |3 P6 J+ t* E3 {* melse if(errorCode == 21) GEL_TextOut("Invalid AIS state\n",,,,);
, `7 R( z# p" o# f6 pelse if(errorCode == 22) GEL_TextOut("Invalid type in AIS boot table command\n",,,,);
! ?+ Y& Z; X: U( w/ M( H8 welse if(errorCode == 23) GEL_TextOut("Invalid type in AIS section fill command\n",,,,);  @* M+ G" y- ^/ _" F2 B! b# D
else if(errorCode == 24) GEL_TextOut("Invalid function index\n",,,,);0 P9 L; ?! v- L# o1 {6 i$ N
else if(errorCode == 25) GEL_TextOut("Invalid argument count\n",,,,);1 A, Y8 g6 y! I0 U2 r" X  `  k
else if(errorCode == 26) GEL_TextOut("Too many CRC errors\n",,,,);
' M" B3 h$ O5 S+ E9 z/ {else if(errorCode == 27) GEL_TextOut("Invalid NOR configuration word\n",,,,);. s5 w9 p/ q  k; y
else if(errorCode == 28) GEL_TextOut("SPI bit error\n",,,,);" E. W, B$ |, v& h: j
else if(errorCode == 29) GEL_TextOut("Invalid character received by UART\n",,,,);6 \5 ?9 u3 [( W( u( M, ?
else if(errorCode == 30) GEL_TextOut("UART Overrun Error\n",,,,);
! c2 Z* J0 U! c* r  [else if(errorCode == 31) GEL_TextOut("UART Parity Error\n",,,,);
6 G$ `# V0 A. _$ x, _! ~else if(errorCode == 32) GEL_TextOut("UART Frame Error\n",,,,);
8 q; L* h- A! j% {* t: J2 Nelse if(errorCode == 33) GEL_TextOut("UART Break Indicator\n",,,,);- P( P  s9 O% M# K  Y
else GEL_TextOut("Error code not recognized\n",,,,);' n! c- g+ ?# M8 g
}/ X8 V  ~6 ~. k; K
else {8 p; i( [+ B2 U, e) t% t: ?  J2 S; n
if(errorCode == 0) GEL_TextOut("No error\n",,,,);% [% D$ s4 j* [) i) v# \; U) r9 m
else if(errorCode == 1) GEL_TextOut("DSP was put to sleep\n",,,,);& ^' ?6 L6 L. {* [
else if(errorCode == 2) GEL_TextOut("Unknown error\n",,,,);
3 z! g/ s+ w" k$ s2 p+ _! a6 h( ]& p0 Jelse if(errorCode == 3) GEL_TextOut("One-time Device Init failed\n",,,,);  \6 j9 d$ n/ w7 r& g% x* u' C
else if(errorCode == 4) GEL_TextOut("One-time Device finalize failed\n",,,,);% q8 U& Z  @; W$ }. z
else if(errorCode == 5) GEL_TextOut("Peripheral Open Failed\n",,,,);) G; N& j* u- c  E- y" S  w
else if(errorCode == 6) GEL_TextOut("Peripheral Close Failed\n",,,,);/ d( _7 U% `8 r1 ]6 u4 B- n" m
else if(errorCode == 7) GEL_TextOut("Invalid (or no action) boot mode\n",,,,);
  m, e0 f( ]8 E  V: |+ I) Oelse if(errorCode == 8) GEL_TextOut("Invalid peripheral number\n",,,,);
8 x' d0 m# U& e6 \! `8 \- ^else if(errorCode == 9) GEL_TextOut("Invalid AIS keyword\n",,,,,);( S9 c3 D  `& v& J4 X* D
else if(errorCode == 10) GEL_TextOut("Invalid AIS sync opcode\n",,,,);
: g8 y, [7 M& V( W- Eelse if(errorCode == 11) GEL_TextOut("Error parsing AIS opcode\n",,,,);' ~, L! ]2 ~% e, u
else if(errorCode == 12) GEL_TextOut("Invalid AIS state\n",,,,);2 X% Z" |- u5 _2 c
else if(errorCode == 13) GEL_TextOut("Invalid type in AIS boot table command\n",,,,);. N+ e  ^( ^( H
else if(errorCode == 14) GEL_TextOut("Invalid type in AIS section fill command\n",,,,);
9 t6 t8 W. B3 _5 {8 [' ]' Xelse if(errorCode == 15) GEL_TextOut("Invalid function index\n",,,,);
7 E9 _& p( t; f! A1 ielse if(errorCode == 16) GEL_TextOut("Invalid argument count\n",,,,);
0 ?# v3 [  g" E# S/ welse if(errorCode == 17) GEL_TextOut("Function execute command failed\n",,,,);1 ?$ k" ~- d, s, @. b
else if(errorCode == 18) GEL_TextOut("Too many CRC errors\n",,,,);
* D% W9 ~5 q, V1 J4 p/ Lelse if(errorCode == 19) GEL_TextOut("Invalid NOR configuration word\n",,,,);
6 h: ]5 B1 B3 A& Y( G7 G7 _else if(errorCode == 20) GEL_TextOut("SPI bit error\n",,,,);
5 A& ?3 {) m& e2 Eelse if(errorCode == 21) GEL_TextOut("Invalid character received by UART\n",,,,);
( [5 A- [! t% n  x  i. }else if(errorCode == 22) GEL_TextOut("UART Overrun Error\n",,,,);
! |5 W4 X4 P$ F- @" L0 m+ Delse if(errorCode == 23) GEL_TextOut("UART Parity Error\n",,,,);" L1 h- E6 z5 o2 n7 B* b
else if(errorCode == 24) GEL_TextOut("UART Frame Error\n",,,,);& v+ b$ n/ Z) S! W9 u
else if(errorCode == 25) GEL_TextOut("UART Break Indicator\n",,,,);
1 u) s4 X5 G$ h" @" H: X( Q6 u  yelse if(errorCode == 26) GEL_TextOut("NAND read page failed\n",,,,);
3 A5 x& h/ ~6 Nelse if(errorCode == 27) GEL_TextOut("SDMMC read error\n",,,,);
% ]: N! X7 n1 P; D+ ^, E6 welse if(errorCode == 128+1) GEL_TextOut("Secure key has not been installed\n",,,,);
) q+ ~, _, Q. {# I, o* Jelse if(errorCode == 128+2) GEL_TextOut("Invalid Boot exit type\n",,,,);" \; E" S6 W' s! \
else if(errorCode == 128+3) GEL_TextOut("Waiting to get reset\n",,,,);
& z8 P3 g( y" Ielse if(errorCode == 128+4) GEL_TextOut("Invalid type of device\n",,,,);( X/ ~. A% R. a4 f
else if(errorCode == 128+5) GEL_TextOut("Invalid address range\n",,,,);3 o2 m! z8 t  I* p  X2 @
else if(errorCode == 128+6) GEL_TextOut("Not supported for non-secure device\n",,,,);( a* U0 f* c3 I* Q+ \1 M2 m
else if(errorCode == 128+7) GEL_TextOut("Invalid password\n",,,,);
7 u+ i. b: f3 B. H% kelse if(errorCode == 128+8) GEL_TextOut("Not supported for secure device\n",,,,);
- Y+ C* ]' V2 v$ ^else if(errorCode == 128+9) GEL_TextOut("Secure ROM checksum failed\n",,,,);0 a9 w$ q! c, g( v; x
else if(errorCode == 128+10) GEL_TextOut("Invalid RPK\n",,,,);
, @% @* [$ M; s1 p: w* Z$ delse if(errorCode == 128+11) GEL_TextOut("Invalid signature\n",,,,);/ r+ G  M" t  Z
else if(errorCode == 128+12) GEL_TextOut("AIS command not allowed for this device type\n",,,,);+ @$ V- n5 h1 c4 [8 }! i
else if(errorCode == 128+13) GEL_TextOut("Secure Loading failure\n",,,,);
/ i! P" g& @0 {else if(errorCode == 128+14) GEL_TextOut("Function not allowed\n",,,,);+ g- E; G' f" m6 O, e& Q1 ?' B5 t
else if(errorCode == 128+15) GEL_TextOut("JTAG Read failed\n",,,,);
/ o$ F% i- g+ ^/ selse GEL_TextOut("Error code not recognized\n",,,,);
8 \8 i( D1 F+ n# n}
' d" s. ?4 [6 [* R2 ?% ?- {  kGEL_TextOut("Program Counter (PC) = %x\n",,,,,PC);; i5 A- K4 y) @. v  @
}
menuitem "Diagnostics" 1 S9 l; n0 B! r
hotmenu Print_Device_Info(); w4 F9 n" Q( E! S
{4 g5 h) K) p) ?
int j;& a/ g0 v! ]7 T
char k = 65;
GEL_TextOut("---------------------------------------------\n",,,,);
* \$ T9 f, a; X) ^GEL_TextOut("| Device Information |\n",,,,);
4 X! i9 d5 H4 _( cGEL_TextOut("---------------------------------------------\n",,,,);2 B5 c+ J4 e- P$ ~, u1 N
GEL_TextOut("DEV_INFO_00 = %x\n",,,,,DEV_INFO_00);
" X* ?+ F5 U8 Y( f% M; G; vGEL_TextOut("DEV_INFO_01 = %x\n",,,,,DEV_INFO_01);, i- f3 e6 x  ^
GEL_TextOut("DEV_INFO_02 = %x\n",,,,,DEV_INFO_02);
! d7 Q; |7 @( W2 |1 j/ |# IGEL_TextOut("DEV_INFO_03 = %x\n",,,,,DEV_INFO_03);7 A3 Y! M, L. a# q( H
GEL_TextOut("DEV_INFO_04 = %x\n",,,,,DEV_INFO_04);! J5 G- {9 m  n
GEL_TextOut("DEV_INFO_05 = %x\n",,,,,DEV_INFO_05);
/ J( {) K3 G/ u5 _# W1 l3 y$ wGEL_TextOut("DEV_INFO_06 = %x\n",,,,,DEV_INFO_06);
0 N. D  {* j6 d0 }9 CGEL_TextOut("DEV_INFO_07-DEV_INFO_08-DEV_INFO_09-DEV_INFO_10-DEV_INFO_11-DEV_INFO_12 = %d-%d-%d-%d-%d-%d\n",,,,,DEV_INFO_07,DEV_INFO_08,DEV_INFO_09,DEV_INFO_10,DEV_INFO_11,DEV_INFO_12);
6 \- V% r" [* Q5 v. x( A+ HGEL_TextOut("DEV_INFO_13,DEV_INFO_14,DEV_INFO_15,DEV_INFO_16 = %d,%d,%d,%d\n",,,,,DEV_INFO_13,DEV_INFO_14,DEV_INFO_15,DEV_INFO_16);9 H" l7 ^+ i8 D" A+ \
GEL_TextOut("-----\n",,,,);
* }: r4 A; W4 {8 a+ WGEL_TextOut("DEV_INFO_17 = %x\n",,,,,DEV_INFO_17);
6 E6 B. V4 g( U1 R6 wGEL_TextOut("DEV_INFO_18 = %x\n",,,,,DEV_INFO_18);
5 E8 k+ l0 V9 R2 Y' a. ~GEL_TextOut("DEV_INFO_19 = %x\n",,,,,DEV_INFO_19);
8 v" t5 O5 T$ R( VGEL_TextOut("-----\n",,,,);
4 u8 {2 q* a; W) N, q6 k# q; j0 UGEL_TextOut("DEV_INFO_20 = %x\n",,,,,DEV_INFO_20);" R6 h0 B. t9 o3 L  w: u7 e; ~
GEL_TextOut("DEV_INFO_21 = %x\n",,,,,DEV_INFO_21);- d: T- m; W+ U
GEL_TextOut("DEV_INFO_22 = %x\n",,,,,DEV_INFO_22);7 x5 B. I# y* {- U/ v( o" P% o7 k2 P
GEL_TextOut("DEV_INFO_23 = %x\n",,,,,DEV_INFO_23);6 f4 F# ~  v4 ~1 \# `
GEL_TextOut("-----\n",,,,);
/ [' x9 r/ [9 d$ Y1 H0 T4 G1 qGEL_TextOut("DEV_INFO_24 = %x\n",,,,,DEV_INFO_24);
7 m% C, L& D' D% ?/ @' C6 TGEL_TextOut("DEV_INFO_25 = %x\n",,,,,DEV_INFO_25);( Y/ x: x. |: ]* E% W% z0 c
GEL_TextOut("DEV_INFO_06 = %x\n",,,,,DEV_INFO_06);+ g- ^1 T, A- v2 m- Y
GEL_TextOut("DEV_INFO_26 = %x\n",,,,,DEV_INFO_26);1 E7 [$ E! e' l3 q
GEL_TextOut("\n\n",,,,);. Z5 M% A# L6 }' X! x! K0 g; C' a
}

; w( H6 g  v+ q1 |) \menuitem "Diagnostics"- s+ B4 k: D& m
hotmenu Print_PLL_Configuration()- l5 H7 r6 h: u! a" r% k0 P; [
{
2 r' Q) s. R; v3 v. ^' I2 V- ~// PLL0 registers
; {( D/ k. a4 {8 K" V  Runsigned int pll0_ocsel, pll0_pllm, pll0_prediv, pll0_postdiv;! d6 |, j7 k3 j' M
unsigned int pll0_plldiv1, pll0_plldiv2, pll0_plldiv3, pll0_plldiv4;
" A: _( g& l" N! p; Runsigned int pll0_plldiv5, pll0_plldiv6, pll0_plldiv7, pll0_pllctl;
// PLL0 clocks
2 H& b0 {: d$ l$ Ounsigned int pll0clk_prediv, pll0clk_pllen;$ K. g" c" d7 F3 F) X
unsigned int pll0clk_pllout, pll0clk_pllout_postdiv, pll0clk_sysclk1;
5 W8 v/ A0 m+ u- _' ~unsigned int pll0clk_sysclk2, pll0clk_sysclk3, pll0clk_sysclk4, pll0clk_sysclk5;+ `$ }8 |. Z1 q2 L+ t
unsigned int pll0clk_sysclk6, pll0clk_sysclk7;
// PLL1 registers
; q" J! S- q9 P! l9 x2 T+ Z4 o1 Bunsigned int pll1_pllctl, pll1_ocsel, pll1_pllm, pll1_postdiv;
$ a6 w% y4 X% g7 ]( Q6 Dunsigned int pll1_plldiv1, pll1_plldiv2, pll1_plldiv3;
// PLL1 clocks
8 c9 c1 x) S6 V: \unsigned int pll1clk_pllout, pll1clk_pllout_postdiv, pll1clk_pllen;
5 |( z( _$ _8 a6 Kunsigned int pll1clk_sysclk1, pll1clk_sysclk2, pll1clk_sysclk3;
// Device in use
& A: Z$ }. M) h1 A/ s7 _unsigned int arm_dsp, rom_id, revision0;
' B# N# R5 A; S3 Earm_dsp = ((ARM_ROM_ID & 0xFF) == 0x6B) ? 1 : 0;$ h5 E' ]2 Y7 n5 G1 D
rom_id = (arm_dsp) ? ARM_ROM_ID : DSP_ROM_ID;) \. |' l2 b  |. A3 e7 M: S) X1 x: S, `
revision0 = ((rom_id & 0xFF000000) >>24) - 48;
/***** Calculate PLL1 clock values first since PLL1 can be input to PLL0 */
if ((revision0%2) == 0) //PLL1 exists only on OMAP-L138 and pin-for-pin compatible
# ?- v  j4 O) S" u4 h% N{
; g- v' {& p1 Y( g. a$ m3 fpll1_pllctl = *(unsigned int*)(PLLC1_BASE_ADDRESS + PLLCTL_OFFSET);  r/ B# p$ H5 A- N% K# \
pll1_pllm = *(unsigned int*)(PLLC1_BASE_ADDRESS + PLLM_OFFSET);
7 W7 M( e5 |" V) L$ }  V, {# ypll1_postdiv = *(unsigned int*)(PLLC1_BASE_ADDRESS + POSTDIV_OFFSET);
  Y7 L' M) J! w$ x. C# M7 `pll1_plldiv1 = *(unsigned int*)(PLLC1_BASE_ADDRESS + PLLDIV1_OFFSET);: A5 t/ I7 T; |
pll1_plldiv2 = *(unsigned int*)(PLLC1_BASE_ADDRESS + PLLDIV2_OFFSET);
8 p: @4 T9 S. t( V$ Y3 u6 D  V# @pll1_plldiv3 = *(unsigned int*)(PLLC1_BASE_ADDRESS + PLLDIV3_OFFSET);! k# `% c7 F  N$ u. V! j3 J
: i9 l' V! }1 e: `
pll1clk_pllout = OSCIN_FREQ * ((pll1_pllm & 0x1F) + 1);
* X1 R4 W% \3 A- a; I
2 \, q- B4 ~  v$ {if ((pll1_postdiv & 0x8000) == 0x8000)# d2 ~/ o2 E' f  [2 j) }
{, W& ?5 p) ]. ^( W$ p- [8 E* Y
pll1clk_pllout_postdiv = pll1clk_pllout / ((pll1_postdiv & 0x1F) + 1);* f: ?$ |3 n3 G! c( ?5 h
}
2 \% b# e' x. O' w2 K7 @0 selse! o( B# E) M! `% Q
{' X! d& R8 }# g2 d5 h; N7 c
pll1clk_pllout_postdiv = pll1clk_pllout;
5 v  L& `7 ~, i  l4 ~. w}
9 \( K6 a" S/ U2 U- s4 ]
; A: u2 K9 [7 `' ]' a4 q" f' }if ((pll1_pllctl & 1) == 1)4 j) X$ T; K3 c8 l
{6 i' L+ J5 ^3 [% u* I! m/ K
pll1clk_pllen = pll1clk_pllout_postdiv;
' W2 B  P, g( }+ k2 {* Y, Q}
: O' `6 ^; p: p2 v& r4 M: [else
9 R% E' D' K/ W{
  o/ v; q% `) Mpll1clk_pllen = OSCIN_FREQ;
8 G: h- ]+ r7 E; @+ T, V$ z}% g' ~9 @+ M4 Z1 L  g
$ s/ S1 q( d- j
if ((pll1_plldiv1 & 0x8000) == 0x8000)
8 \& |& G" o( A+ t& D6 t" C- V{
* R- Y- `$ k1 hpll1clk_sysclk1 = pll1clk_pllen / ((pll1_plldiv1 & 0x1F) + 1);
6 W# \9 x5 Z% K7 M/ c}
4 o$ r5 s! `. \" I# K4 U4 b2 s/ Celse- ~! W& O" ]* y2 C
{' L) x2 y, Q4 C1 |
pll1clk_sysclk1 = pll1clk_pllen;3 a1 P7 N( |* a* {( \
}
0 G  ~0 m% r2 {# ^' u' ]* G+ G5 s- w2 v: Z% @) {( i+ C! [
if ((pll1_plldiv2 & 0x8000) == 0x8000). a% a) B( K8 s" J) M2 s& R
{/ I9 A: s7 D. O+ z! u" }! R* I
pll1clk_sysclk2 = pll1clk_pllen / ((pll1_plldiv2 & 0x1F) + 1);
: B# N1 k& {& ~, _} 2 B9 P5 p8 _2 S- A
else
  z5 q+ ?% N1 H{  Z1 n8 B: z2 ?8 C- t$ T& {
pll1clk_sysclk2 = pll1clk_pllen;
# r5 G) y) H8 d, T}& n& F) e0 \  y/ c- a

) m* ~$ l4 |# F! f3 I& Tif ((pll1_plldiv3 & 0x8000) == 0x8000)
7 V4 c" d, A: f{  r0 ^' o, e  u$ o3 R9 ^8 ^  v
pll1clk_sysclk3 = pll1clk_pllen / ((pll1_plldiv3 & 0x1F) + 1);
  `0 [( P5 j9 C5 t& v/ H! e}
) P' x1 a5 V1 gelse
3 Q; r7 m' t, O% D2 T{
) Y# r  P7 B$ ]* a7 G! Kpll1clk_sysclk3 = pll1clk_pllen;  r9 Q/ k$ \1 [* F, f# U5 E2 `7 d
}
' y% }( ?. ^7 y4 z& x}; i) B0 [( j5 I: w. H, H
/ J* Q; T. e" n3 `
/***** Calculate PLL0 clock values *****/
  ~* }7 x5 S7 n$ R3 B# D' m
7 G" v- z8 E6 M+ B/ {) ]5 @- ~pll0_pllctl = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLCTL_OFFSET);
6 H% P5 q, T2 s( Z. h& m' O1 C0 Dpll0_prediv = *(unsigned int*)(PLLC0_BASE_ADDRESS + PREDIV_OFFSET);
- Z2 C1 y6 ~5 |$ upll0_pllm = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLM_OFFSET);
! r% \: V4 g, }: b! npll0_postdiv = *(unsigned int*)(PLLC0_BASE_ADDRESS + POSTDIV_OFFSET);  O& b# b" w) G3 q- J/ \$ ~: H
pll0_plldiv1 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV1_OFFSET);
0 z4 h, f9 q: Q- qpll0_plldiv2 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV2_OFFSET);& G6 |: o# y  N: [
pll0_plldiv3 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV3_OFFSET);4 x* B; B2 e, s4 r+ ~+ Y9 R
pll0_plldiv4 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV4_OFFSET);
6 ]8 u0 E% o9 O4 c9 Cpll0_plldiv5 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV5_OFFSET);" @$ u8 G' w$ }7 U; A: s1 |
pll0_plldiv6 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV6_OFFSET);
( i' o8 S9 ?6 L1 Apll0_plldiv7 = *(unsigned int*)(PLLC0_BASE_ADDRESS + PLLDIV7_OFFSET);
if ((pll0_prediv & 0x8000) == 0x8000)
6 M1 {9 ]" \, ]; k+ M9 }$ L) |{
" B5 o5 L# d, T: rpll0clk_prediv = OSCIN_FREQ / ((pll0_prediv & 0x1F) + 1);
( T- w" d$ v4 r5 F}
' W" T; A8 r1 \" E' }4 U5 o! Kelse7 ^' Q$ v' r! `% s) \8 c' |% p
{& w( C$ h; _9 `+ E( n( |
pll0clk_prediv = OSCIN_FREQ;
! t: Q8 S+ y; G% A4 a: @$ J}) o! N1 H4 m' U2 ?
! P0 n# }( ]; L+ ]3 H
pll0clk_pllout = pll0clk_prediv * ((pll0_pllm & 0x1F) + 1);
if ((pll0_postdiv & 0x8000) == 0x8000): c0 ^- S% H3 v
{
% r4 Z1 G& |' e7 E7 ^  }" Rpll0clk_pllout_postdiv = pll0clk_pllout / ((pll0_postdiv & 0x1F) + 1);
$ A# S) c1 t8 f9 O5 S$ a9 V}  J# @7 i3 P; X7 |2 m1 V. ^1 Q
else
/ E3 r6 R0 b$ j+ _* z5 {9 P3 y5 f{
( q% U* Y7 }+ Z; i* o# l' I4 Zpll0clk_pllout_postdiv = pll0clk_pllout;! W+ c% V/ m9 {
}
) K. ]; E- o% u$ ]
8 G) x+ M, A& Z  j  }* a  L// Check PLLCTL[PLLEN]
# ~$ t. t' S/ j8 d  J( J( pif ((pll0_pllctl & 1) == 1)& `! c% x" @8 l1 `- H' p: D
{# C9 L, ^9 G* A; k  T% T+ R8 t' ^
pll0clk_pllen = pll0clk_pllout_postdiv;
9 ]- t, q' d- P4 e  |}7 S( V: q0 N" P' Z. y4 B7 c" B2 P1 |0 z6 W
else
! _1 w* k9 V4 j{/ L; h. j" I, b, W+ {: \0 S
// Check PLLCTL[EXTCLKSRC]
9 P) w/ Z- x4 \5 bif ( (pll0_pllctl & (1<<9)) == (1<<9) )
- n* F; Q, R0 X* L. [{9 V0 |2 I: D# S( B! J  j
pll0clk_pllen = pll1clk_sysclk3;- {2 {3 J8 W* y$ O
}  N6 D. @) t1 \9 Y2 l4 ~) |! }
else
2 c# n- _; J* i9 r! b% p{
+ Q; Y& s+ w8 u: c/ w2 spll0clk_pllen = OSCIN_FREQ;4 ~5 Y) r( D  ~- o$ f7 n) `
}
/ J: _0 u( S2 A! a; N9 ?}/ v' o, x3 L5 b3 N* _

0 H! C0 [- F* R3 ~if ((pll0_plldiv1 & 0x8000) == 0x8000)0 e' y% i' E# N/ Z
{
& B8 z- I: Z0 L) H; G) bpll0clk_sysclk1 = pll0clk_pllen / ((pll0_plldiv1 & 0x1F) + 1);
3 d0 F) ^2 F" l7 a# ^}
, N- X9 T3 z4 m1 h0 ], x3 v( x, Celse
: x6 a% w9 T6 N/ z" m{
1 s7 d4 v! \% D. O' Y. A6 vpll0clk_sysclk1 = pll0clk_pllen;
) \- M+ R: d( F3 ?. z}
- c6 ?% R8 c' j# p/ S# ^- C! }# K5 b# Q, }0 e) R& `
if ((pll0_plldiv2 & 0x8000) == 0x8000)8 J* n+ ~3 I: |+ X  S5 X
{
) x0 t) N; W0 E9 fpll0clk_sysclk2 = pll0clk_pllen / ((pll0_plldiv2 & 0x1F) + 1);
2 p- ^( I; Q" s, g}
; T& P" j1 h7 e% b, Kelse
( h4 J% I) g0 u# N{1 O0 a/ Z7 q8 i5 q0 e# Z
pll0clk_sysclk2 = pll0clk_pllen;2 k# w% L/ [* L6 Z0 ^% u
}
if ((pll0_plldiv3 & 0x8000) == 0x8000)! b" K8 p' z$ j5 b
{
- C0 K) ^8 c6 z0 D* vpll0clk_sysclk3 = pll0clk_pllen / ((pll0_plldiv3 & 0x1F) + 1);
4 r% i1 u8 D2 {5 M( Q; V: q}
% Z. ?% L- v4 h1 K: U6 W" n$ W; ?else
8 ], X# E$ ?8 O  H0 o# h. I{
% L$ k0 D+ s) X; g' ?" {pll0clk_sysclk3 = pll0clk_pllen;
9 @, M4 @9 ]2 V1 r}
2 d9 H0 X$ C. v/ q- G
  @8 j- z# k7 k% g5 s5 Kif ((pll0_plldiv4 & 0x8000) == 0x8000)* B; l" t; z5 b0 r" p
{! s$ f1 o4 p$ R2 }
pll0clk_sysclk4 = pll0clk_pllen / ((pll0_plldiv4 & 0x1F) + 1);7 F" d: ~+ G; B5 t! K+ M
} 1 r" }8 Y  B+ ]( K
else  E' P; O2 y! v, e6 N% u8 V
{
$ U+ y. U% B2 \- P$ C0 z9 hpll0clk_sysclk4 = pll0clk_pllen;6 w0 z8 H+ B  m. @1 X5 Z' j
}. U6 n, X+ P( c
! o8 J9 D" ?# z1 E
if ((pll0_plldiv5 & 0x8000) == 0x8000)
' h, Q# A( S+ Z. c! g{
( x# W9 F/ X4 m, ypll0clk_sysclk5 = pll0clk_pllen / ((pll0_plldiv5 & 0x1F) + 1);7 C2 s1 _9 H0 Q+ O2 A" {9 ~
}
7 v" w  U8 Y( ?, W* Helse
) Q9 b6 U5 j4 @3 e! x) f0 z{; d4 E- ^' |9 \( W
pll0clk_sysclk5 = pll0clk_pllen;
* D# {5 t  M" `/ |# i}
if ((pll0_plldiv6 & 0x8000) == 0x8000)
, C/ \" I3 B1 F) {: _{
/ B+ O' m+ b; H+ l. [3 {9 Apll0clk_sysclk6 = pll0clk_pllen / ((pll0_plldiv6 & 0x1F) + 1);- t' R, f- |: b' `6 d8 p
}
9 ]: C$ K" n) Belse' F& t1 q- b# \- T% a6 t$ C
{
7 y& b/ r* y+ g* zpll0clk_sysclk6 = pll0clk_pllen;- y, ]( P* I. ~* a% y
}
if ((pll0_plldiv7 & 0x8000) == 0x8000)
& O5 o: b. z; N: P{
1 ]7 f- P3 U( r8 ]0 O8 G; qpll0clk_sysclk7 = pll0clk_pllen / ((pll0_plldiv7 & 0x1F) + 1);
! e6 ^+ S# s8 E}   M* C! `" H. N4 J( F( p" ~# c
else) c0 \6 \* b8 p! H. [4 B( R
{
# o8 u) P$ W  e* ~pll0clk_sysclk7 = pll0clk_pllen;
8 ~! C1 N1 I0 g( n7 y}
GEL_TextOut("\n");
2 A! A. w8 W* x/ R# zGEL_TextOut("---------------------------------------------\n");; O3 x! T2 b" w! z; u+ j, o2 n
GEL_TextOut("| Clock Information |\n");+ j! W1 `& u9 q# n! y
GEL_TextOut("---------------------------------------------\n"); 8 l* B  Z# B2 ~8 L) K4 t6 C
GEL_TextOut("\n");
// if PLLCTL[CLKMODE] == 1, A0 l" m( z) @5 X& o4 V- |0 H+ u9 H4 ?
if ( (pll0_pllctl & (1<<8)) == (1<<8) )
( p( j/ L3 W! U/ ~0 k, y{3 s; M) Y9 t6 w% j
GEL_TextOut("PLLs configured to utilize 1.2V square wave input.\n");
0 B3 }; q0 }7 F4 i9 E}2 ^1 m) L& K+ ^& m
else- }1 J. O) @) H8 |! R
{
: M- F& E" z& [3 kGEL_TextOut("PLLs configured to utilize crystal.\n");8 c: L+ L6 C5 A  K8 [6 T5 F, N
}
// if CFGCHIP3[ASYNC3_CLKSRC] == 1" k( \/ z4 j: z4 e5 G2 M# a
if ( (CFGCHIP3 & (1<<4)) == 0 )" v" D' _8 e' r
{
- R7 A& \/ r; h; QGEL_TextOut("ASYNC3 = PLL0_SYSCLK2\n");
% A! x, {8 {4 H7 ^( J3 R. X9 J}' n# y' a0 M1 _) f7 c6 p
else
+ m/ C* J2 Z; u& G3 M{ ) r3 r) _* ]2 \, H' r. H
GEL_TextOut("ASYNC3 = PLL1_SYSCLK2\n");
4 C8 F; K" v6 ~' c9 T}
' ]- p4 S; k8 L9 G3 P% X/ }% ~2 l( A- L# ~3 b% I# T, C( l1 K
GEL_TextOut("\n");. r& Y5 W0 C9 }4 t8 d2 Z
GEL_TextOut("NOTE: All clock frequencies in following PLL sections are based\n");
# F! c7 r8 O% g% IGEL_TextOut("off OSCIN = %d MHz. If that value does not match your hardware\n",,,,, OSCIN_FREQ);
, R9 p1 W5 M1 J5 h, _GEL_TextOut("you should change the #define in the top of the gel file, save it,\n");
$ F# I, i& ?* c$ |% P' e2 e. \GEL_TextOut("and then reload.\n");
GEL_TextOut("\n");
7 h: j) H7 \: w0 C* xGEL_TextOut("---------------------------------------------\n");1 Q4 Z/ Z$ e4 {4 C$ c
GEL_TextOut("| PLL0 Information |\n");1 q6 ~1 [% R1 U3 H9 e" `! W
GEL_TextOut("---------------------------------------------\n");
1 n/ A. `; U2 x7 k; b2 _: DGEL_TextOut("\n");
  I. n/ f' }# t/ q0 f
# M1 I/ S6 Y7 c8 h// Uncomment to see intermediate clock calculations
1 J2 ~+ {1 o  i5 K5 a$ R//GEL_TextOut("PLL0_PREDIV = %d MHz\n",,,,, pll0clk_prediv);/ f* j: T- i9 P6 i. V$ K
//GEL_TextOut("PLL0_PLLOUT = %d MHz\n",,,,, pll0clk_pllout);
/ p% L8 U  q9 {& g  w0 M- S3 g//GEL_TextOut("PLL0_PLLOUT_POSTDIV = %d MHz\n",,,,, pll0clk_pllout_postdiv);! D8 v+ y& ^9 Q! X
//GEL_TextOut("PLL0_PLLEN = %d MHz\n",,,,, pll0clk_pllen);
, O" g6 @# S( Q5 b( t5 q
, N1 u6 ^) r  D" }0 g+ w9 x2 H# MGEL_TextOut("PLL0_SYSCLK1 DSP = %d MHz\n",,,,, pll0clk_sysclk1);
3 t$ X; s! r; X8 v9 x% hGEL_TextOut("PLL0_SYSCLK2 ASYNC3 = %d MHz\n",,,,, pll0clk_sysclk2);
5 J# c. Q- Z+ F* q) wGEL_TextOut("PLL0_SYSCLK3 EMIFA = %d MHz\n",,,,, pll0clk_sysclk3);- U9 X  p# [* y/ B5 t0 U
GEL_TextOut("PLL0_SYSCLK4 = %d MHz\n",,,,, pll0clk_sysclk4);6 H6 ^% P0 T0 i- @; X" ~' `
GEL_TextOut("PLL0_SYSCLK5 Not used = %d MHz\n",,,,, pll0clk_sysclk5);* X$ R- k# k& D+ x3 Y
GEL_TextOut("PLL0_SYSCLK6 ARM(OMAPL138) = %d MHz\n",,,,, pll0clk_sysclk6);. v' I- E# J' E2 {
GEL_TextOut("PLL0_SYSCLK7 EMAC = %d MHz\n",,,,, pll0clk_sysclk7);
( c) \3 t6 m' T& r, Q1 U4 _* P# C% V/ q/ k$ \
if ( (pll0clk_sysclk1 / pll0clk_sysclk2) != 2 )$ s. K5 c7 f% l
{
  r/ U0 m# ]' R) S/ oGEL_TextOut("Error: PLL0_SYSCLK2 must equal PLL0_SYSCLK1 / 2\n");! i$ C1 k) y/ {. i6 x
}
if ( (pll0clk_sysclk1 / pll0clk_sysclk4) != 4 )
, |2 q6 ]3 @6 {7 d, `; _$ A7 ?{" {$ z; G' j  }
GEL_TextOut("Error: PLL0_SYSCLK4 must equal PLL0_SYSCLK1 / 4\n");
# h7 I* p& D' N}
if ( (pll0clk_sysclk1 / pll0clk_sysclk6) != 1 )& `# ?  R; s* Q9 G" K0 }+ w! v
{' L% S# M$ T' y/ l7 z
GEL_TextOut("Error: PLL0_SYSCLK6 must equal PLL0_SYSCLK1 / 1\n");
3 f' D/ S7 d9 t9 V; A# K}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only% B) v) `+ G' ]
{
- L3 }$ k  V0 WGEL_TextOut("\n");$ x/ L% X  e  K- o
GEL_TextOut("---------------------------------------------\n");
( B, }( b( J0 T# p2 SGEL_TextOut("| PLL1 Information |\n");
5 K$ G" `, G8 I5 u9 N( fGEL_TextOut("---------------------------------------------\n");
  `- c2 J% t( K  N2 i) U" j0 vGEL_TextOut("\n");/ J* S/ q9 T+ o. u

5 z  n4 ~- }9 E! o// Uncomment to see intermediate clock calculations$ K- r$ u4 s2 A: y0 ^
//GEL_TextOut("PLL1_PLLOUT = %d MHz\n",,,,, pll1clk_pllout);: U  i" _8 D6 Q" n- x" O
//GEL_TextOut("PLL1_PLLOUT_POSTDIV = %d MHz\n",,,,, pll1clk_pllout_postdiv);/ v( ^/ [8 e) x' x! g% A  S
//GEL_TextOut("PLL1_PLLEN = %d MHz\n",,,,, pll1clk_pllen);
9 q' Y, W& m# ?7 k2 X6 x
! V. B  C3 M" h5 q3 `1 wGEL_TextOut("PLL1_SYSCLK1 DDR2 = %d MHz\n",,,,, pll1clk_sysclk1);+ B, [$ k$ q. N! T; w& [( b
GEL_TextOut("PLL1_SYSCLK2 ASYNC3 = %d MHz\n",,,,, pll1clk_sysclk2);
- b; A; p. V' {5 mGEL_TextOut("PLL1_SYSCLK3 = %d MHz\n",,,,, pll1clk_sysclk3);# K0 z  Q& p- r$ b
}
  q8 h- q- S4 x2 W( S. ]- Q- G}
menuitem "Diagnostics"
" T# B* u' U; k- b* J6 r# qhotmenu Print_PSC_Status()+ a% m2 k' Z1 m. z. T4 `2 h
{- d8 ^0 s# \0 s; T
unsigned int *pPSC0_MDSTAT = (unsigned int*)0x01C10800;
) J- e' h( `; O. z% e! i) a0 Junsigned int *pPSC1_MDSTAT = (unsigned int*)0x01E27800;) V% e1 b4 i7 O: u0 K3 A4 B

% k, l" _! ^5 U! {8 g// Device in use
! k, Q0 N0 s! w  v' }9 ~8 P5 `. e( gunsigned int arm_dsp, rom_id, revision0;
arm_dsp = ((ARM_ROM_ID & 0xFF) == 0x6B) ? 1 : 0;5 J$ G7 K1 _  R4 ]: g
rom_id = (arm_dsp) ? ARM_ROM_ID : DSP_ROM_ID;
4 Z9 h* j- M/ `6 L2 I0 a7 `revision0 = ((rom_id & 0xFF000000) >>24) - 48;
GEL_TextOut("\n");! m& v  ]: k. m* x- z3 D& E  M
GEL_TextOut("---------------------------------------------\n");& ^1 y. g% z1 m7 w0 q7 @( |
GEL_TextOut("| PSC0 Information |\n");& ~4 J$ z  P3 o0 ?6 v! s
GEL_TextOut("---------------------------------------------\n");
; K% C  Y1 T- x* w4 Q. C& aGEL_TextOut("\n");
GEL_TextOut("State Decoder:\n");
% r% a, f6 V4 F3 @& OGEL_TextOut(" 0 = SwRstDisable (reset asserted, clock off)\n");5 ~+ `% y% A3 [4 G! V) r' l
GEL_TextOut(" 1 = SyncReset (reset assered, clock on)\n");/ s( X# R+ b. T
GEL_TextOut(" 2 = Disable (reset de-asserted, clock off)\n");! Q+ k" J8 n3 r2 X
GEL_TextOut(" 3 = Enable (reset de-asserted, clock on)\n");
- @' X: Q2 M: e$ Q5 Y7 X- `, {GEL_TextOut(">3 = Transition in progress\n");( S' e' n5 v( f; i0 z4 C
GEL_TextOut("\n");
4 X) K7 K! n& ?0 ]7 J) v& M
' q/ U9 r/ d2 V9 J1 W& iGEL_TextOut("Module 0: EDMA3CC (0) STATE = %d\n",,,,, (pPSC0_MDSTAT[0] & 0x3F));
6 a- o" s- {* k) o/ B/ OGEL_TextOut("Module 1: EDMA3 TC0 STATE = %d\n",,,,, (pPSC0_MDSTAT[1] & 0x3F));
; f6 c/ J2 \1 r3 g7 q% y( P+ wGEL_TextOut("Module 2: EDMA3 TC1 STATE = %d\n",,,,, (pPSC0_MDSTAT[2] & 0x3F));
/ T+ s9 b, \% @& VGEL_TextOut("Module 3: EMIFA (BR7) STATE = %d\n",,,,, (pPSC0_MDSTAT[3] & 0x3F));
- k8 y* A. k' Q' W7 K; lGEL_TextOut("Module 4: SPI 0 STATE = %d\n",,,,, (pPSC0_MDSTAT[4] & 0x3F));9 W* F5 t' X/ |. m5 D5 x! t2 G) N% Q
GEL_TextOut("Module 5: MMC/SD 0 STATE = %d\n",,,,, (pPSC0_MDSTAT[5] & 0x3F));
9 c% G  \1 f2 u3 x. w& }GEL_TextOut("Module 6: AINTC STATE = %d\n",,,,, (pPSC0_MDSTAT[6] & 0x3F));4 n: B" w' o- R6 W/ f
GEL_TextOut("Module 7: ARM RAM/ROM STATE = %d\n",,,,, (pPSC0_MDSTAT[7] & 0x3F));
/ |1 m, L* t: W- M( yGEL_TextOut("Module 9: UART 0 STATE = %d\n",,,,, (pPSC0_MDSTAT[9] & 0x3F));" v6 v% E% L* I/ j/ H7 z
GEL_TextOut("Module 10: SCR 0 (BR0/1/2/8) STATE = %d\n",,,,, (pPSC0_MDSTAT[10] & 0x3F));, s! s- k0 F5 t* W5 B& X7 F3 T( T
GEL_TextOut("Module 11: SCR 1 (BR4) STATE = %d\n",,,,, (pPSC0_MDSTAT[11] & 0x3F));( g0 g7 M/ ^# O' l; d( _( f/ M( d
GEL_TextOut("Module 12: SCR 2 (BR3/5/6) STATE = %d\n",,,,, (pPSC0_MDSTAT[12] & 0x3F));
& W7 _0 ?5 G6 i; fGEL_TextOut("Module 13: PRUSS STATE = %d\n",,,,, (pPSC0_MDSTAT[13] & 0x3F));: J+ g6 Q! O  j; Q
GEL_TextOut("Module 14: ARM(OMAPL138) STATE = %d\n",,,,, (pPSC0_MDSTAT[14] & 0x3F));8 o( C3 J+ J, _& o2 P' I
GEL_TextOut("Module 15: DSP STATE = %d\n",,,,, (pPSC0_MDSTAT[15] & 0x3F)); 5 f" s1 S! q8 L$ h: u9 C2 M' g( R9 D4 _
' y% h, n. f- w& i+ }5 W0 s
GEL_TextOut("\n");
; U, b" f( ~9 ]3 b6 C& `5 MGEL_TextOut("---------------------------------------------\n");, @3 o5 q, ~! \4 K* ?- y9 h2 ?: |$ ]
GEL_TextOut("| PSC1 Information |\n");6 p4 x9 F3 r' l5 n( q; ]% c
GEL_TextOut("---------------------------------------------\n"); + o& O$ X* X0 {6 `7 [
GEL_TextOut("\n"); & Q5 l: h( C! C  y

; X9 K2 v0 x3 G* D/ ?, UGEL_TextOut("State Decoder:\n");
$ N# h8 V) w* u. I- Y' ?GEL_TextOut(" 0 = SwRstDisable (reset asserted, clock off)\n");' J* U$ J( j/ G! u2 `) W
GEL_TextOut(" 1 = SyncReset (reset assered, clock on)\n");
/ C! n* f& }' v' [GEL_TextOut(" 2 = Disable (reset de-asserted, clock off)\n");0 l1 m( m9 H% d# k/ L
GEL_TextOut(" 3 = Enable (reset de-asserted, clock on)\n");
) L  s" F3 H- s* E9 H' h9 lGEL_TextOut(">3 = Transition in progress\n");, x; e( Z# d$ b/ y
GEL_TextOut("\n");
" K! [$ g: C) W8 {8 g5 Y% A7 o" P: C! l% [7 @8 V! _1 N
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
/ n0 C1 l. A* _" e/ Q- `" b{
! J0 e6 T; g9 {3 _+ C; FGEL_TextOut("Module 0: EDMA3CC (1) STATE = %d\n",,,,, (pPSC1_MDSTAT[0] & 0x3F));
/ Y& ?3 O5 j2 I" P) w4 ]$ M}
3 a* y( r8 N  R8 y3 t
/ Q. f6 W4 C! MGEL_TextOut("Module 1: USB0 (2.0) STATE = %d\n",,,,, (pPSC1_MDSTAT[1] & 0x3F));
# }: d; l* i2 K7 y% K* P% p3 M0 w, tGEL_TextOut("Module 2: USB1 (1.1) STATE = %d\n",,,,, (pPSC1_MDSTAT[2] & 0x3F));
, [: r& c- W1 @/ U# iGEL_TextOut("Module 3: GPIO STATE = %d\n",,,,, (pPSC1_MDSTAT[3] & 0x3F));  T& Y: I3 Y( @; Z# z
GEL_TextOut("Module 4: UHPI STATE = %d\n",,,,, (pPSC1_MDSTAT[4] & 0x3F));
% q/ O4 I  b7 w* y# |  iGEL_TextOut("Module 5: EMAC STATE = %d\n",,,,, (pPSC1_MDSTAT[5] & 0x3F));' t9 u$ I: R. d) a0 F" l9 w' e# p

  z& `& E2 [1 a( u2 G  x' iif ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only( p: M5 @2 z0 j4 A8 O  Z) F( [
{
; I# [0 G3 h% o$ @: ^! b3 BGEL_TextOut("Module 6: DDR2 and SCR F3 STATE = %d\n",,,,, (pPSC1_MDSTAT[6] & 0x3F));0 ?2 Q7 r$ e0 @: G+ d1 ~$ h: S
}
# D; t& z2 W7 P1 j8 K5 \' I- @else
# Z3 u, `9 i8 O{ // OMAP-L137 and variants$ b: W& H1 {) U% d( x
GEL_TextOut("Module 6: EMIFB (BR20) STATE = %d\n",,,,, (pPSC1_MDSTAT[6] & 0x3F));9 h! x3 ~" H; u. c. O6 w; T4 J
}
GEL_TextOut("Module 7: MCASP0 + FIFO STATE = %d\n",,,,, (pPSC1_MDSTAT[7] & 0x3F));
! Z1 F/ U% n  I4 `0 M2 n2 O' }) s7 x* ]+ B+ U5 P/ T2 {  w
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
# f3 y' ]4 q7 ~. m{
) k' [2 P+ K' b* _  i  W4 |6 x7 b" gGEL_TextOut("Module 8: SATA STATE = %d\n",,,,, (pPSC1_MDSTAT[8] & 0x3F));
6 ]$ z$ s  o0 i2 ~. g/ S}
6 b- [- ?# z* ^- @! velse
0 T+ Q0 h. o; W4 t{ // OMAP-L137 and variants
2 x  ]. v' E# p1 _GEL_TextOut("Module 8: MCASP1 + FIFO STATE = %d\n",,,,, (pPSC1_MDSTAT[8] & 0x3F));0 N( m: }2 n# ]* A
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
! D  {% P# d/ O/ B0 E{ $ P( K  `  v% l* A
GEL_TextOut("Module 9: VPIF STATE = %d\n",,,,, (pPSC1_MDSTAT[9] & 0x3F));  {  `: g' [; F
}, x: ^% m. S. @$ r$ r
else" V# B$ d* y7 n- y/ p8 e
{ // OMAP-L137 and variants
0 l8 H5 A8 n# ~GEL_TextOut("Module 9: MCASP2 + FIFO STATE = %d\n",,,,, (pPSC1_MDSTAT[9] & 0x3F));2 R" e8 E& F! P$ s  G
}/ q4 A; j+ b0 |) C4 W6 ]. ^

* F/ }0 P: u4 lGEL_TextOut("Module 10: SPI 1 STATE = %d\n",,,,, (pPSC1_MDSTAT[10] & 0x3F));
0 h+ W/ ~/ A1 V; d3 D. {! QGEL_TextOut("Module 11: I2C 1 STATE = %d\n",,,,, (pPSC1_MDSTAT[11] & 0x3F));
8 q9 L2 j: ^& {$ G! q  N; l+ {GEL_TextOut("Module 12: UART 1 STATE = %d\n",,,,, (pPSC1_MDSTAT[12] & 0x3F));
9 r- v* |7 O6 `; ^  _# PGEL_TextOut("Module 13: UART 2 STATE = %d\n",,,,, (pPSC1_MDSTAT[13] & 0x3F));
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only* F3 G0 h# q, p4 I; |
{
+ J$ F6 V1 j% _% [: S8 t# eGEL_TextOut("Module 14: MCBSP0 + FIFO STATE = %d\n",,,,, (pPSC1_MDSTAT[14] & 0x3F));( }& e$ T  a$ N1 v
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
8 s# ~7 y/ m4 ~9 f/ |% y{
3 N6 V- O- H1 R! d8 X+ K6 ~GEL_TextOut("Module 15: MCBSP1 + FIFO STATE = %d\n",,,,, (pPSC1_MDSTAT[15] & 0x3F));4 n, E; ]* Y  M& `$ y
}1 H0 u9 l3 I0 j+ ]/ X
4 }! [8 O% N7 v% Z+ S- J
GEL_TextOut("Module 16: LCDC STATE = %d\n",,,,, (pPSC1_MDSTAT[16] & 0x3F));
% A. N: Y1 c) m& q/ lGEL_TextOut("Module 17: eHRPWM (all) STATE = %d\n",,,,, (pPSC1_MDSTAT[17] & 0x3F));- R% W+ x7 C/ U) L- \

& ?% t- p8 D* ~/ k/ R9 mif ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only1 m! U* X1 M9 J  L' G
{
( [* J: X8 [% w3 f8 uGEL_TextOut("Module 18: MMC/SD 1 STATE = %d\n",,,,, (pPSC1_MDSTAT[18] & 0x3F));# |3 s0 S9 R, Q
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only9 _6 ~% r& t9 j
{
8 G% }* n% o& O3 ^6 tGEL_TextOut("Module 19: UPP STATE = %d\n",,,,, (pPSC1_MDSTAT[19] & 0x3F));. X! A# A/ P9 z- M/ v# M( o' C
}
GEL_TextOut("Module 20: eCAP (all) STATE = %d\n",,,,, (pPSC1_MDSTAT[20] & 0x3F));
- M7 Z1 ^# C3 w' y9 y, G! S: O; T5 h1 i/ C) s
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
) D' K1 `. i9 D{
# X: i2 H  r( Y8 N& hGEL_TextOut("Module 21: EDMA3 TC2 STATE = %d\n",,,,, (pPSC1_MDSTAT[21] & 0x3F));8 S4 _0 x8 K8 F4 B) B+ M8 S
}/ w& W$ [( g0 U. j+ Z9 w3 _
else9 S. {3 N  ~1 ?
{ // OMAP-L137 and variants& Y" [, H6 a, y, |9 L
GEL_TextOut("Module 21: eQEP 0/1 STATE = %d\n",,,,, (pPSC1_MDSTAT[21] & 0x3F));9 g8 ?" I4 T2 s0 k1 c8 R
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
6 ?1 N: }6 @$ c# H' I{   U( v1 I' K8 _+ h2 e1 F) C; [3 U- {4 d
GEL_TextOut("Module 24: SCR-F0 Br-F0 STATE = %d\n",,,,, (pPSC1_MDSTAT[24] & 0x3F));! I( _8 u, w4 H% L  G$ y
}# Q3 I7 A4 G( |' {
else: {; t. v7 W3 t3 J# u! d
{ // OMAP-L137 and variants
4 n1 J: y$ A. s7 }  WGEL_TextOut("Module 24: SCR8 (Br15) STATE = %d\n",,,,, (pPSC1_MDSTAT[24] & 0x3F));* J6 Q. W+ F6 Y* V
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
# \4 C  [. h! r! p{
6 s7 M, d! @# G- A: k7 wGEL_TextOut("Module 25: SCR-F1 Br-F1 STATE = %d\n",,,,, (pPSC1_MDSTAT[25] & 0x3F));
) H4 A6 b- `: B$ \+ l}2 y0 _- z5 S$ i7 q/ {$ [9 d& ]
else
5 k8 h# r$ Z' y{ // OMAP-L137 and variants, W! L6 K) W0 c" O' o
GEL_TextOut("Module 25: SCR7 (Br12) STATE = %d\n",,,,, (pPSC1_MDSTAT[25] & 0x3F));6 Q! @- v& s  U5 C; x. }2 {& v- h
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
9 ~, T0 R% n6 ~7 u2 ~/ ]; @( k{
6 ?! ~6 i) T4 XGEL_TextOut("Module 26: SCR-F2 Br-F2 STATE = %d\n",,,,, (pPSC1_MDSTAT[26] & 0x3F));; F: }4 b. |! _: \5 z$ @, f
}
& P+ X- g5 b! l( [else4 q) R# Q& D% g6 P; h
{ // OMAP-L137 and variants
' N. I* |. V# l" y" y- P; f- O. G% x3 NGEL_TextOut("Module 26: SCR12 (Br18) STATE = %d\n",,,,, (pPSC1_MDSTAT[26] & 0x3F));+ a4 r; g/ V4 S; U" k) \
}$ x0 n" d7 l8 w, G8 l. e
0 n/ M" ?( f+ X' k5 N0 ]
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
- G+ R( i$ H5 p8 m# m{ / |  Y$ Y" |# m2 Z& v* y' Q1 S
GEL_TextOut("Module 27: SCR-F6 Br-F3 STATE = %d\n",,,,, (pPSC1_MDSTAT[27] & 0x3F));
8 [" R" s8 w! k% T8 zGEL_TextOut("Module 28: SCR-F7 Br-F4 STATE = %d\n",,,,, (pPSC1_MDSTAT[28] & 0x3F));8 s0 M: Q1 O, _' N
GEL_TextOut("Module 29: SCR-F8 Br-F5 STATE = %d\n",,,,, (pPSC1_MDSTAT[29] & 0x3F));! f/ q5 T- m2 i( q- l
GEL_TextOut("Module 30: Br-F7 (DDR Contr) STATE = %d\n",,,,, (pPSC1_MDSTAT[30] & 0x3F));+ g  F  e* y4 S0 i2 L% S# D
}
if ((revision0 % 2) == 0) // OMAP-L138 and pin-for-pin variants only
* n3 x) S+ W2 s- i% [; C{
+ ]+ a" \' n+ r+ `GEL_TextOut("Module 31: L3 RAM, SCR-F4, Br-F6 STATE = %d\n",,,,, (pPSC1_MDSTAT[31] & 0x3F));
: F9 k# A# u' S2 C) K  q# k}
9 n2 ^* W5 i5 eelse
- y; z" u, R3 ?+ V2 p8 k{ // OMAP-L137 and variants1 x0 d8 P7 j- S$ S0 I
GEL_TextOut("Module 31: L3 RAM (Br13) STATE = %d\n",,,,, (pPSC1_MDSTAT[31] & 0x3F));
( O- E: R1 h7 T}
1 O5 I4 A0 y' \& l0 h1 y
- X  H( w5 \& ^% }+ X! _3 c; o& ]* t}
其中回调函数可以在CCS help文档中找到
比如GEL_MapOff()
这个函数描述是这样的
This function disables memory mapping. Note that disabling memory mapping can cause bus fault problems in the target because the Code Composer Studio debugger may attempt to access nonexistent memory. On power up, the memory map is turned off by default.
该函数会禁止内存映射,注意禁止的内存映射可能会引起目标的总线故障 ,因为CCS 调试器会尝试访问不存在的内存。在上电后,内存映射默认关闭。
参考创龙TL138_1808_6748-EVM 参考资料
多多指教

( t. ^. y* y% h- D1 m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 支持!支持! 反对!反对!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

巢课

技术风云榜

关于我们|手机版|EDA365 ( 粤ICP备18020198号 )

GMT+8, 2025-4-6 06:42 , Processed in 0.079629 second(s), 34 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表