annotate MEMIF-wait-states @ 67:ed686a290f2d

FC-handset-spec: LCD and backlight specification changes to ungate Venus board design
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 03 Jul 2021 07:01:39 +0000
parents c01155dec65b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 The Calypso chip's MEMIF (ARM memory interface) block has a few configuration
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 registers; most settings in these registers are quite straightforward, but the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 WS setting (number of wait states to be inserted for external memory access)
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 requires some non-trivial analysis.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 Calypso MEMIF timings are described on pages 7 through 11 of this TI document:
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ftp://ftp.freecalypso.org/pub/GSM/Calypso/cal000_a.pdf
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
25
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
10 as well as this more recently discovered newer version:
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
11
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
12 ftp://ftp.freecalypso.org/pub/GSM/Calypso/cal000_a_v0.8.pdf
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
13
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 When running on a Calypso C035 target, our TCS211 reference fw as well as most
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 vendor firmwares we've examined run the ARM7 core at its maximum clock frequency
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 of 52 MHz. These same firmwares typically configure WS=3 for both flash and
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 XRAM. Most Calypso-based phones and modems have flash and RAM chips with 70 ns
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 access time, and for a long time it seemed that this combination of ARM7 at
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 52 MHz and WS=3 was OK for 70 ns memories: one ARM7 clock cycle at 52 MHz is
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 19.23 ns, WS=3 means 4 cycles total per access (it's an N+1 arrangement),
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 19.23 ns * 4 = 76.92 ns, thus it should be OK for 70 ns memories, right? Not
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 so fast: as shown in the formula on cal000_a.pdf page 11 and can be seen from
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 the timing diagrams, two other timing parameters (tda and tsu) also need to be
25
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
24 factored in. The sum of tda+tsu for 2.8V MEMIF as given in the CAL000/A v0.2
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
25 document is 10.5 ns, thus if we run the ARM7 core at 52 MHz and set WS=3, the
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
26 available safe window for memory access time is only about 66 ns, which is 4 ns
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
27 short of the 70 ns flash and RAM access time specs.
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
28
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
29 The more recently discovered version 0.8 of this same CAL000/A document
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
30 indicates that the tables for 2.8V and 1.8V MEMIF were erroneously swapped in
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
31 the older version, and the new correct tda+tsu number for 2.8V MEMIF now appears
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
32 to be 8.0 ns rather than 10.5 ns. The available safe window for memory access
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
33 time with WS=3 thus becomes 68.92 ns - this new figure is much closer to 70 ns,
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
34 but it is still a negative margin, short by 1.08 ns.
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 TI's reference fw setting of WS=3 in conjuction with ARM7 running at 52 MHz has
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 made its way into the official firmwares of Openmoko devices and several Compal
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 phones, including Mot C11x/12x, Mot C139/140 and Sony Ericsson J100. At least
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 in the case of Openmoko we know that the hardware features a flash chip with
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 70 ns access time (the combined flash+RAM chip is K5A3281CTM-D755, with the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 suffix meaning 70 ns access time for flash and 55 ns for RAM), and in the case
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 of Compal phones it is highly unlikely that they used flash chips faster than
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 70 ns, thus we have strong evidence that the access time spec is being violated
25
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
44 by about 1.1 ns. It works in practice because the official specs are guaranteed
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
45 worst-case numbers and the shortcoming is very small, but it is still wrong in
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
46 the strict sense.
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 We have strong evidence that this WS=3 setting comes from TI's mainline
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 reference fw, as opposed to being customized by or for Openmoko or Compal.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 The evidence is in the following instruction sequence which appears verbatim-
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 identical across Openmoko's, Mot C11x/12x and C139/140 firmware versions:
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 ldr r1, =0xFFFFFB00
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 mov r0, #0xA3
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 strh r0, [r1, #0]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 strh r0, [r1, #2]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 mov r2, #0xA5
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 strh r2, [r1, #4]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 strh r0, [r1, #6]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 mov r0, #0x80
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 strh r0, [r1, #0xA]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 mov r0, #0xC0
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 strh r0, [r1, #0xC]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 mov r0, #0x40
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 strh r0, [r1, #8]
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 (The SE J100 version differs only in the nCS2 configuration; apparently this
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 SE J100 phone has its ringtone melody generator chip hooked up to nCS2, whereas
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 on both OM's modem and Mot C11x/12x/139/140 this chip select is unused and
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 unconnected, meaning that its setting is a dummy just like nCS3 and nCS4.)
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 The above instruction sequence has been reconstructed into the following
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 sequence of C macro calls:
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 MEM_INIT_CS0(3, MEM_DVS_16, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 MEM_INIT_CS1(3, MEM_DVS_16, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 MEM_INIT_CS3(3, MEM_DVS_16, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 MEM_INIT_CS6(0, MEM_DVS_32, MEM_WRITE_EN, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 MEM_INIT_CS7(0, MEM_DVS_32, MEM_WRITE_DIS, 0);
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 (The last two lines setting nCS6 and nCS7 don't need to be considered, as those
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 are internal to the Calypso chip itself.)
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 Thus we see that what appears to be TI's mainline code sets WS=3 for both nCS0
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 and nCS1 (flash and XRAM, respectively), and then sets what appears to be a
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 dummy config for the unused nCS2, nCS3 and nCS4. I say "appears to be" because
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 we have no original source with comments, only a COFF binary object which our
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 reconstructed recompilable C code has been made to match.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 We may never know the truth unless we miraculously find a surviving copy of the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 original (not reconstructed from disassembly) init.c source from TCS211, but my
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 (Mother Mychaela's) current working hypothesis is that the above MEMIF settings
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 were originally made for the D-Sample board and never changed for Leonardo.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 The D-Sample board has flash on nCS0, main XRAM bank on nCS1, an additional
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 XRAM bank (typically unused) on nCS2 and peripherals (principally the LCD) on
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 nCS3. Furthermore, the original D-Sample boards had Calypso C05 chips populated
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 on them, and that chip version has no nCS4, only CS4 which is muxed with ADD22
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 and used for the latter on the D-Sample.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 I further hypothetize that the above MEMIF settings were likely cast into code
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 in the days of Calypso C05, and that the WS=3 setting was computed when the
25
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
105 ARM7 core ran at 39 MHz. The combination of ARM7 at 39 MHz, WS=3 and the more
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
106 generous tda+tsu = 10.5 ns adjustment from the older cal000_a.pdf document
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 (officially corresponding to Calypso C035 F751774) gives an access time of
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 92 ns, which is very sensible. The hypothesis further goes that later TI moved
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 to Calypso C035 silicon and started running the ARM7 core at 52 MHz, but the WS
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 setting was never changed (overlooked), and the 92 ns access time turned into a
25
c01155dec65b MEMIF-wait-states: updates for the newly discovered CAL000/A v0.8 document
Mychaela Falconia <falcon@freecalypso.org>
parents: 17
diff changeset
111 mere 68.92 ns. The latter works with 70 ns memories in practice despite being
17
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 strictly incorrect (negative margin), and so the error escaped notice.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 Solution adopted for FreeCalypso
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 ================================
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 Pirelli's firmware on the DP-L10 sets WS=4 for both flash and XRAM, and we have
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 always used the same setting in FreeCalypso when running on this target. When
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 we made our FCDEV3B hardware using the same Spansion flash+RAM chip copied from
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 the Pirelli DP-L10, we adopted the same WS=4 setting for our own FreeCalypso
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 hardware family on the reasoning that it is needed for this chip. But now we
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 have a better theoretical foundation: the flash+RAM chip in question has 70 ns
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 access time for both flash and pSRAM parts, same as most other flash and RAM
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 chips used in most Calypso devices, and the WS=4 setting should really be used
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 for all Calypso C035 targets (ARM7 at 52 MHz) with 70 ns memories. Thus the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 new FreeCalypso strategy is to treat WS=4 as the generic default for Calypso
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 C035 platforms unless explicitly overridden for specific targets, and to stop
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 treating TI's reconstructed setup with WS=3 as canonical.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 When running on Openmoko GTA01/02, Mot C11x/12x, Mot C139/140 and SE J100
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 targets (this specific list), we are going to keep WS=3 for nCS0 and nCS1 and
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 the dummies for nCS2, nCS3 and nCS4 unchanged for now, i.e., run with exactly
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 the same MEMIF settings as each manufacturer's respective original official fw.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 The reason is political: we are not the product manufacturer of record, and the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 error of negative design margin in the memory access timings is the liability
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 of FIC/Openmoko and Compal/Motorola/SE, not us. If we change from WS=3 to WS=4
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 on these targets, our firmware will necessarily run a little slower, and given
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 that the original official fw "works just fine", we may be accused of needlessly
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 or artificially slowing down our aftermarket fw. But when we market our own
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 handset or modem products under the FreeCalypso trademark, then the full
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 responsibility for the entire product (hw+fw) falls on us, hence we use the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 correct WS=4 setting.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 Interim WS setting during boot
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 ==============================
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 There is one more complication to this picture. The MEMIF settings discussed
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 above for the operational phase with Calypso DPLL producing fast clocks are
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 made in the Init_Target() function, but there is another interim setting
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 established early on in assembly code, used prior to DPLL enabling, when the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 ARM7 core runs at unmultiplied 13 MHz or 26 MHz as fed to the Calypso by the
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 board. This interim setting is first set in bootloader.s, then again in int.s
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 (with the definition residing in the included init.asm file), and the registers
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 are set to 0x2A1, meaning WS=1 and 1 dummy cycle.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 Unlike the situation with the censored init.c source file, we have the original
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 source for the assembly modules in question, and the only preprocessor
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 conditionals found therein are based on BOARD and CHIPSET symbols. Remember
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 that TI's Leonardo board never got its own BOARD number, instead it shares
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 BOARD=41 with D-Sample, yet the two boards have different Calypso clock inputs:
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 13 MHz on the DS, 26 MHz on the Leonardo. The C code in init.c (this part
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 survived in the LoCosto source) uses a preprocessor conditional on the RF_FAM
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 symbol to differentiate between 13 MHz and 26 MHz input clock arrangements, but
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 there is no conditional of any such sort in the assembly code. Thus it is my
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 (Mother Mychaela's) educated guess that the WS=1 setting was chosen assuming a
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 13 MHz clock, and when Leonardo came along with its 26 MHz clock, the problem
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 spot was once again overlooked.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 WS=1 at 13 MHz is equivalent to WS=7 at 52 MHz, thus there is plenty of margin.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 But WS=1 at 26 MHz is equivalent to WS=3 at 52 MHz, once again putting us in
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 the troubled territory of negative margin with 70 ns flash and RAM chips.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 Except that this case is even more difficult for firmware engineers to spot:
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 Pirelli's fw still has the same 0x2A1 setting in its early boot path, i.e.,
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 their fw engineers have changed WS=3 to WS=4 for the main body of the fw, but
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 missed the early boot code.
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 The solution adopted for FreeCalypso is to change the early MEMIF setting from
3d65bdaf00da MEMIF-wait-states article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 0x2A1 to 0x2A2, i.e., set WS=2 for the interim boot phase.