1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # the DBGU and USARTs are 'almost' indentical'
4 set DBGU_CR [expr {$AT91C_BASE_DBGU + 0x00000000}]
5 set DBGU_MR [expr {$AT91C_BASE_DBGU + 0x00000004}]
6 set DBGU_IER [expr {$AT91C_BASE_DBGU + 0x00000008}]
7 set DBGU_IDR [expr {$AT91C_BASE_DBGU + 0x0000000C}]
8 set DBGU_IMR [expr {$AT91C_BASE_DBGU + 0x00000010}]
9 set DBGU_CSR [expr {$AT91C_BASE_DBGU + 0x00000014}]
10 set DBGU_RHR [expr {$AT91C_BASE_DBGU + 0x00000018}]
11 set DBGU_THR [expr {$AT91C_BASE_DBGU + 0x0000001C}]
12 set DBGU_BRGR [expr {$AT91C_BASE_DBGU + 0x00000020}]
17 set DBGU_CIDR [expr {$AT91C_BASE_DBGU + 0x00000040}]
18 set DBGU_EXID [expr {$AT91C_BASE_DBGU + 0x00000044}]
19 set DBGU_FNTR [expr {$AT91C_BASE_DBGU + 0x00000048}]
24 set USx_IER 0x00000008
25 set USx_IDR 0x0000000C
26 set USx_IMR 0x00000010
27 set USx_CSR 0x00000014
28 set USx_RHR 0x00000018
29 set USx_THR 0x0000001C
30 set USx_BRGR 0x00000020
31 set USx_RTOR 0x00000024
32 set USx_TTGR 0x00000028
33 set USx_FIDI 0x00000040
34 set USx_NER 0x00000044
37 # Create all the uarts that exist..
38 # we blow up if there are >9
41 proc show_mmr_USx_MR_helper { NAME ADDR VAL } {
42 # First - just print it
44 set x [show_normalize_bitfield $VAL 3 0]
46 echo "\tNormal operation"
48 echo [format "\tNon Normal operation mode: 0x%02x" $x]
51 set x [show_normalize_bitfield $VAL 11 9]
59 set $x [expr {$x & 6}]
62 6 { set s "Multidrop Mode" }
66 echo [format "\tParity: %s " $s]
68 set x [expr {5 + [show_normalize_bitfield $VAL 7 6]}]
69 echo [format "\tDatabits: %d" $x]
71 set x [show_normalize_bitfield $VAL 13 12]
73 0 { echo "\tStop bits: 1" }
74 1 { echo "\tStop bits: 1.5" }
75 2 { echo "\tStop bits: 2" }
76 3 { echo "\tStop bits: Illegal/Reserved" }
80 # For every possbile usart...
81 foreach WHO { US0 US1 US2 US3 US4 US5 US6 US7 US8 US9 } {
82 set n AT91C_BASE_[set WHO]
85 # Only if it exists on the chip
86 if [ info exists $n ] {
87 # Hence: $n - is like AT91C_BASE_USx
88 # For every sub-register
89 foreach REG {CR MR IER IDR IMR CSR RHR THR BRGR RTOR TTGR FIDI NER IF} {
91 set vn [set WHO]_[set REG]
94 set vv [expr "$$n + [set USx_[set REG]]"]
95 # And VV is the address in memory of that register
98 # make that VN a GLOBAL so others can find it
102 # Create a command for this specific register.
103 proc show_$vn { } "show_mmr32_reg $vn"
105 # Add this command to the Device(as a whole) command
106 set str "$str\nshow_$vn"
108 # Now - create the DEVICE(as a whole) command
114 # The Debug Uart is special..
118 # For every sub-register
119 foreach REG {DBGU_CR DBGU_MR DBGU_IER DBGU_IDR DBGU_IMR
120 DBGU_CSR DBGU_RHR DBGU_THR DBGU_BRGR DBGU_CIDR DBGU_EXID DBGU_FNTR} {
122 # Create a command for this specific register.
123 proc show_$REG { } "show_mmr32_reg $REG"
125 # Add this command to the Device(as a whole) command
126 set str "$str\nshow_$REG"
129 # Now - create the DEVICE(as a whole) command
130 proc show_DBGU { } $str
134 proc show_DBGU_MR_helper { NAME ADDR VAL } { show_mmr_USx_MR_helper $NAME $ADDR $VAL }