Project

General

Profile

MT6235 DSP » History » Version 3

Anonymous, 02/19/2016 10:48 PM

1 1
== Introduction ==
2
MT6235 SoC features two DSP processors (master and slave).[[BR]]
3
Most probably these processors are ADSP-2181.[[BR]]
4 3
DSP code is executed from ROM but seems that there is possiblity to upload code over IDMA.
5
So far we're not able to read Code Memory using IDMA interface. Only uploading is possible.
6 1
Below is outcome from analyzing of original Sciphone G2 firmware which uses DSP processor.
7
8
== Base addresses of DSP related peripherals. ==
9
Connected via APB:
10
 * '''0x820A0000''' - MCU - DSP1 (master) Shared Registers
11
 * '''0x820C0000''' - MCU - DSP2 (slave) Shared Registers
12
Conected via AHB:
13
 * '''0xA0000000''' - CPU - DSP1 (master) Share RAM
14
 * '''0xA1000000''' - CPU - DSP2 (slave) Share RAM
15
 * '''0xA2000000''' - CPU - DSP1 (master) IDMA port base address
16
  * '''0xA2000000''' - DSP1 Code Memory
17
   * 0xA2000000 - DSP1 Code Memory Page 0
18
   * 0xA2010000 - DSP1 Code Memory Page 1
19
   * ...
20
   * 0xA20F0000 - DSP1 Code Memory Page 15
21
  * '''0xA2100000''' - DSP1 Program Memory
22
   * 0xA2100000 - DSP1 Program Memory Page 0
23
   * 0xA2110000 - DSP1 Program Memory Page 1
24
   * ...
25
   * 0xA21F0000 - DSP1 Program Memory Page 15
26
  * '''0xA2200000''' - DSP1 Data Memory
27
   * 0xA2100000 - DSP1 Data Memory Page 0
28
   * 0xA2110000 - DSP1 Data Memory Page 1
29
   * ...
30
   * 0xA21F0000 - DSP1 Data Memory Page 15
31
  * '''0xA2310000''' - DSP1 DDMA Short Read/Write Register
32
33
== DSP Patch Unit registers (not documented in datasheet) ==
34
35
 DPUB - DSP Patch Unit Base address (0x820E0000)[[BR]]
36
 n - instruction number
37
38
 * DPUB + n*16 + 0x0 - page number
39
 * DPUB + n*16 + 0x4 - address
40
 * DPUB + n*16 + 0x8 - low 16 bits of instruction
41
 * DPUB + n*16 - 0xC - high 8 bits of instruction
42
 * DPUB + 0x100 - patch enable register
43
44
 It seems that DSP Patch Unit is able to patch only 4 instructions of DSP code memory.[[BR]]
45 3
 After writing 0xFF to DSP Patch Enable Register, value 0x303 appears (mask 0x300 enables master DSP, second mask 0x3 enables slave?).[[BR]]
46 1
 Below analysis shows that MTK firmware loads only 4 instructions over DSP Patch Unit and the rest of patch is loaded via MCU-DSP shared memory, which also proves above assumption.[[BR]]
47
 Hard to say if DSP Patch Unit is able to load patches to slave DSP, but probably not as there are MTK processors which have 2 DSP Patch Units. 
48
 
49
== Functions which work with DSP processors ==
50
51 2
'''idma_load()''' - called by Reload_DSP_Patch(), Application_Initialize()
52 1
53 2
This function is called at very early startup of platform (from init() function).
54
55 1
This function uses following structure describing DSP patch:
56
{{{
57
  struct dsp_ptch {
58
    char     patch_version[20];
59
    uint16_t patch_enable[48];  /* offset 0x14 */
60
    uint16_t page_number[48];   /* offset 0x74 */
61
    uint16_t address[48];       /* offset 0xD4 */
62
    uint32_t code[48];          /* code loaded using DSP Patch Unit, offset 0x134 */
63
    uint32_t idma_code1[1024];  /* code loaded using IDMA to DSP1 Code Memory, offset 0x1F4 */
64
    uint32_t idma_code2[1024];  /* code loaded using IDMA to DSP2 Code Memory, offset 0x11F4 */
65
  }
66
}}}
67
68
  * reset DSP1
69
  * reset DSP2
70
  * write 0 to DSP Patch Unit Enable register (disable patches?)
71
  * write 16 values from DSP patch table to DSP Patch Unit (using page number and address fields)
72 2
  * calculate value (mask) using patch_enable field as follows (why 32 times if only 16 patches were loaded?):
73 1
74
{{{
75
mask = 0
76
for (i = 0; i < 32; ++i)
77
    mask |= dsp_ptch->patch_enable[i] << i;
78
}}}
79
80
  * nothing is written to DSP Patch Unit Enable register, only mask is calculated and then compared to some other value which triggers if code should be uploaded over IDMA or not
81
  * write 1024 instructions from idma_code[] table over IDMA under address 0xA200F000 (DSP1 Code Memory) - idma_load_cm()
82
  * write 1024 instructions form_idma_code2[] table over IDMA under address 0xA300F000 (DSP2 Code Memory) - idma_load_cm_d2()
83 2
84
'''L1D_DSP_Wakeup()''' - called by L1D_Init(), L1D_Meta_Init()
85
86
  * set DSP clock to 104MHz
87 1
  * call L1D_DSP_WritePatchConfig(1)
88 2
   * write 4 first entries from dsp_ptch[] table to DSP Patch Unit
89 3
   * write 0x303 to DSP Patch Unit Enable register (enable these patches?). This value is calculated as follows:
90 2
91
{{{
92
enable = dsp_ptch->patch_enable[0] << 8;
93
enable |= dsp_ptch->patch_enable[1] << 9;
94
enable |= dsp_ptch->patch_enable[2];
95
enable |= dsp_ptch->patch_enable[3] << 1;
96
}}}
97
98
  * set reset for DSP1
99
  * power up IR (?)
100
  * turn on DSP clock
101
  * wait 64 Qbits
102
  * write 0 to DSP1 shared RAM (0xA0000000)
103
  * release reset for DSP1
Add picture from clipboard (Maximum size: 48.8 MB)