summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/fiiom3k
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-04-15 03:00:04 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-04-17 20:24:07 +0000
commit01d1eb425874813864d12d72c93e6e74ab92ac1f (patch)
treee4bc6171342e1ef4160b2e32653f5668f9be3d69 /firmware/target/mips/ingenic_x1000/fiiom3k
parente123c5d2f27e9efbef8b4264f1576e4e10ba7b82 (diff)
downloadrockbox-01d1eb425874813864d12d72c93e6e74ab92ac1f.tar.gz
rockbox-01d1eb425874813864d12d72c93e6e74ab92ac1f.zip
FiiO M3K/X1000: Do system clock initialization in the SPL
Initializing the clocks in the SPL brings Rockbox in line with how the FiiO M3K's original SPL works. It's likely other X1000 devices do this too. There was a logic error in the previous setup: the code falsely assumed that DDR memory would always be running from MPLL, but it would be switched to APLL by the bootloader. Rockbox would then try to re-init APLL, albeit with the same parameters. Maybe this was the cause of the boot hang on some units. Change-Id: I64064585e491bbdf1e95fe9428c91a9314f2a917
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/fiiom3k')
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/spl-fiiom3k.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/spl-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/spl-fiiom3k.c
index 0ebe11e24d..7f4441c109 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/spl-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/spl-fiiom3k.c
@@ -21,7 +21,7 @@
21 21
22#include "spl-x1000.h" 22#include "spl-x1000.h"
23#include "gpio-x1000.h" 23#include "gpio-x1000.h"
24#include "nand-x1000.h" 24#include "clk-x1000.h"
25#include "system.h" 25#include "system.h"
26#include <string.h> 26#include <string.h>
27 27
@@ -130,3 +130,36 @@ int spl_get_boot_option(void)
130 /* Default is to boot Rockbox */ 130 /* Default is to boot Rockbox */
131 return SPL_BOOTOPT_ROCKBOX; 131 return SPL_BOOTOPT_ROCKBOX;
132} 132}
133
134void spl_handle_pre_boot(int bootopt)
135{
136 /* Move system to EXCLK so we can manipulate the PLLs */
137 clk_set_ccr_mux(CLKMUX_SCLK_A(EXCLK) | CLKMUX_CPU(SCLK_A) |
138 CLKMUX_AHB0(SCLK_A) | CLKMUX_AHB2(SCLK_A));
139 clk_set_ccr_div(1, 1, 1, 1, 1);
140
141 /* Enable APLL @ 1008 MHz (24 MHz EXCLK * 42 = 1008 MHz) */
142 jz_writef(CPM_APCR, BS(1), PLLM(41), PLLN(0), PLLOD(0), ENABLE(1));
143 while(jz_readf(CPM_APCR, ON) == 0);
144
145 /* System clock setup -- common to Rockbox and FiiO firmware
146 * ----
147 * CPU at 1 GHz, L2 cache at 500 MHz
148 * AHB0 and AHB2 and 200 MHz
149 * PCLK at 100 MHz
150 * DDR at 200 MHz
151 */
152 clk_set_ccr_div(1, 2, 5, 5, 10);
153 clk_set_ccr_mux(CLKMUX_SCLK_A(APLL) | CLKMUX_CPU(SCLK_A) |
154 CLKMUX_AHB0(SCLK_A) | CLKMUX_AHB2(SCLK_A));
155
156 if(bootopt == SPL_BOOTOPT_ROCKBOX) {
157 /* We don't use MPLL in Rockbox, so switch DDR memory to APLL */
158 clk_set_ddr(X1000_CLK_SCLK_A, 5);
159
160 /* Turn off MPLL */
161 jz_writef(CPM_MPCR, ENABLE(0));
162 } else {
163 /* TODO: Original firmware needs a lot of other clocks turned on */
164 }
165}