diff --git a/Makefile b/Makefile
index d810cec..0dddc20 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX)
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
-CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall $(CUSTOMDEFINES)
+CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fno-inline -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
################################################################################
diff --git a/source/config/config.c b/source/config/config.c
index 23b516f..5028b08 100644
--- a/source/config/config.c
+++ b/source/config/config.c
@@ -23,14 +23,13 @@
#include "../gfx/tui.h"
#include "../libs/fatfs/ff.h"
#include "../soc/t210.h"
+#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/btn.h"
#include "../utils/list.h"
#include "../utils/util.h"
extern hekate_config h_cfg;
-extern bool sd_mount();
-extern void sd_unmount();
void set_default_configuration()
{
@@ -52,565 +51,3 @@ void set_default_configuration()
sd_power_cycle_time_start = 0;
}
-
-int create_config_entry()
-{
- if (!sd_mount())
- return 1;
-
- char lbuf[32];
- FIL fp;
- bool mainIniFound = false;
-
- LIST_INIT(ini_sections);
-
- if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
- mainIniFound = true;
- else
- {
- u8 res = f_open(&fp, "bootloader/hekate_ipl.ini", FA_READ);
- if (res == FR_NO_FILE || res == FR_NO_PATH)
- {
- f_mkdir("bootloader");
- f_mkdir("bootloader/ini");
- f_mkdir("bootloader/payloads");
- f_mkdir("bootloader/sys");
- }
- else
- {
- if (!res)
- f_close(&fp);
- return 1;
- }
- }
-
- if (f_open(&fp, "bootloader/hekate_ipl.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
- return 1;
- // Add config entry.
- f_puts("[config]\nautoboot=", &fp);
- itoa(h_cfg.autoboot, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nautoboot_list=", &fp);
- itoa(h_cfg.autoboot_list, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nbootwait=", &fp);
- itoa(h_cfg.bootwait, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nbacklight=", &fp);
- itoa(h_cfg.backlight, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nautohosoff=", &fp);
- itoa(h_cfg.autohosoff, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nautonogc=", &fp);
- itoa(h_cfg.autonogc, lbuf, 10);
- f_puts(lbuf, &fp);
- f_puts("\nupdater2p=", &fp);
- itoa(h_cfg.updater2p, lbuf, 10);
- f_puts(lbuf, &fp);
- if (h_cfg.brand)
- {
- f_puts("\nbrand=", &fp);
- f_puts(h_cfg.brand, &fp);
- }
- if (h_cfg.tagline)
- {
- f_puts("\ntagline=", &fp);
- f_puts(h_cfg.tagline, &fp);
- }
- f_puts("\n", &fp);
-
- if (mainIniFound)
- {
- // Re-construct existing entries.
- LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
- {
- if (!strcmp(ini_sec->name, "config"))
- continue;
-
- switch (ini_sec->type)
- {
- case INI_CHOICE: // Re-construct Boot entry [ ].
- f_puts("[", &fp);
- f_puts(ini_sec->name, &fp);
- f_puts("]\n", &fp);
- // Re-construct boot entry's config.
- LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
- {
- f_puts(kv->key, &fp);
- f_puts("=", &fp);
- f_puts(kv->val, &fp);
- f_puts("\n", &fp);
- }
- break;
- case INI_CAPTION: // Re-construct caption entry { }.
- f_puts("{", &fp);
- f_puts(ini_sec->name, &fp);
- f_puts("}\n", &fp);
- break;
- case INI_NEWLINE: // Re-construct cosmetic newline \n.
- f_puts("\n", &fp);
- break;
- case INI_COMMENT: // Re-construct comment entry #.
- f_puts("#", &fp);
- f_puts(ini_sec->name, &fp);
- f_puts("\n", &fp);
- break;
- }
- }
- }
-
- f_close(&fp);
- sd_unmount();
-
- return 0;
-}
-
-#pragma GCC push_options
-#pragma GCC optimize ("Os")
-
-static void _save_config()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- if (!create_config_entry())
- gfx_puts("\nConfiguration was saved!\n");
- else
- EPRINTF("\nConfiguration saving failed!");
- gfx_puts("\nPress any key...");
-}
-
-static void _config_autoboot_list(void *ent)
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- u32 *temp_autoboot = NULL;
-
- LIST_INIT(ini_sections);
-
- u8 max_entries = 30;
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (max_entries + 3));
- u32 *boot_values = (u32 *)malloc(sizeof(u32) * max_entries);
- char *boot_text = (char *)malloc(512 * max_entries);
-
- for (u32 j = 0; j < max_entries; j++)
- boot_values[j] = j;
-
- if (sd_mount())
- {
- if (ini_parse(&ini_sections, "bootloader/ini", true))
- {
- // Build configuration menu.
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- u32 i = 2;
- LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
- {
- // Skip other ini entries for autoboot.
- if (ini_sec->type == INI_CHOICE)
- {
- if (!strcmp(ini_sec->name, "config"))
- continue;
-
- if (strlen(ini_sec->name) > 510)
- ments[i].caption = ini_sec->name;
- else
- {
- if (h_cfg.autoboot != (i - 1) || !h_cfg.autoboot_list)
- boot_text[(i - 1) * 512] = ' ';
-
- else
- boot_text[(i - 1) * 512] = '*';
- strcpy(boot_text + (i - 1) * 512 + 1, ini_sec->name);
- ments[i].caption = &boot_text[(i - 1) * 512];
- }
- ments[i].type = ini_sec->type;
- ments[i].data = &boot_values[i - 1];
- i++;
-
- if ((i - 1) > max_entries)
- break;
- }
- }
-
- memset(&ments[i], 0, sizeof(ment_t));
- menu_t menu = {ments, "Select an entry to auto boot", 0, 0};
- temp_autoboot = (u32 *)tui_do_menu(&menu);
- if (temp_autoboot != NULL)
- {
- h_cfg.autoboot = *(u32 *)temp_autoboot;
- h_cfg.autoboot_list = 1;
- _save_config();
-
- ment_t *tmp = (ment_t *)ent;
- tmp->data = NULL;
- }
- else
- goto out2;
- }
- else
- {
- EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!.");
- goto out;
- }
- }
-
-out:;
- btn_wait();
-out2:;
- free(ments);
- free(boot_values);
- free(boot_text);
-
- sd_unmount();
-}
-
-void config_autoboot()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- u32 *temp_autoboot = NULL;
-
- LIST_INIT(ini_sections);
-
- u8 max_entries = 30;
- u32 boot_text_size = 512;
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (max_entries + 5));
- u32 *boot_values = (u32 *)malloc(sizeof(u32) * max_entries);
- char *boot_text = (char *)malloc(boot_text_size * max_entries);
-
- for (u32 j = 0; j < max_entries; j++)
- boot_values[j] = j;
-
- if (sd_mount())
- {
- if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
- {
- // Build configuration menu.
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- ments[2].type = MENT_DATA;
- if (!h_cfg.autoboot)
- ments[2].caption = "*Disable";
- else
- ments[2].caption = " Disable";
- ments[2].data = &boot_values[0];
-
- ments[3].type = MENT_HDLR_RE;
- if (h_cfg.autoboot_list)
- ments[3].caption = "*More configs...";
- else
- ments[3].caption = " More configs...";
- ments[3].handler = _config_autoboot_list;
- ments[3].data = (void *)0xCAFE;
-
- ments[4].type = MENT_CHGLINE;
-
- u32 i = 5;
- LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
- {
- // Skip other ini entries for autoboot.
- if (ini_sec->type == INI_CHOICE)
- {
- if (!strcmp(ini_sec->name, "config"))
- continue;
-
- if (strlen(ini_sec->name) > 510)
- ments[i].caption = ini_sec->name;
- else
- {
- if (h_cfg.autoboot != (i - 4) || h_cfg.autoboot_list)
- boot_text[(i - 4) * boot_text_size] = ' ';
-
- else
- boot_text[(i - 4) * boot_text_size] = '*';
- strcpy(boot_text + (i - 4) * boot_text_size + 1, ini_sec->name);
- ments[i].caption = &boot_text[(i - 4) * boot_text_size];
- }
- ments[i].type = ini_sec->type;
- ments[i].data = &boot_values[i - 4];
- i++;
-
- if ((i - 4) > max_entries)
- break;
- }
- }
- if (i < 6 && !h_cfg.autoboot_list)
- {
- ments[i].type = MENT_CAPTION;
- ments[i].caption = "No main configurations found...";
- ments[i].color = 0xFFFFDD00;
- i++;
- }
-
- memset(&ments[i], 0, sizeof(ment_t));
- menu_t menu = {ments, "Disable or select entry to auto boot", 0, 0};
- temp_autoboot = (u32 *)tui_do_menu(&menu);
- if (temp_autoboot != NULL)
- {
- h_cfg.autoboot = *(u32 *)temp_autoboot;
- h_cfg.autoboot_list = 0;
- _save_config();
- }
- else
- goto out2;
- }
- else
- {
- EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!.");
- goto out;
- }
- }
-
-out:;
- btn_wait();
-out2:;
- free(ments);
- free(boot_values);
- free(boot_text);
-
- sd_unmount();
-
- if (temp_autoboot == NULL)
- return;
-}
-
-void config_bootdelay()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- u32 delay_entries = 6;
- u32 delay_text_size = 32;
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (delay_entries + 3));
- u32 *delay_values = (u32 *)malloc(sizeof(u32) * delay_entries);
- char *delay_text = (char *)malloc(delay_text_size * delay_entries);
-
- for (u32 j = 0; j < delay_entries; j++)
- delay_values[j] = j;
-
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- ments[2].type = MENT_DATA;
- if (h_cfg.bootwait)
- ments[2].caption = " 0 seconds (Bootlogo disabled)";
- else
- ments[2].caption = "*0 seconds (Bootlogo disabled)";
- ments[2].data = &delay_values[0];
-
- u32 i = 0;
- for (i = 1; i < delay_entries; i++)
- {
- if (h_cfg.bootwait != i)
- delay_text[i * delay_text_size] = ' ';
- else
- delay_text[i * delay_text_size] = '*';
- delay_text[i * delay_text_size + 1] = i + '0';
- strcpy(delay_text + i * delay_text_size + 2, " seconds");
-
- ments[i + 2].type = MENT_DATA;
- ments[i + 2].caption = delay_text + (i * delay_text_size);
- ments[i + 2].data = &delay_values[i];
- }
-
- memset(&ments[i + 2], 0, sizeof(ment_t));
- menu_t menu = {ments, "Time delay for entering bootloader menu", 0, 0};
-
- u32 *temp_bootwait = (u32 *)tui_do_menu(&menu);
- if (temp_bootwait != NULL)
- {
- h_cfg.bootwait = *(u32 *)temp_bootwait;
- _save_config();
- }
-
- free(ments);
- free(delay_values);
- free(delay_text);
-
- if (temp_bootwait == NULL)
- return;
- btn_wait();
-}
-
-void config_backlight()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- u32 bri_text_size = 8;
- u32 bri_entries = 11;
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (bri_entries + 3));
- u32 *bri_values = (u32 *)malloc(sizeof(u32) * bri_entries);
- char *bri_text = (char *)malloc(bri_text_size * bri_entries);
-
- for (u32 j = 1; j < bri_entries; j++)
- bri_values[j] = j * 10;
-
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- u32 i = 0;
- for (i = 1; i < bri_entries; i++)
- {
- if ((h_cfg.backlight / 20) != i)
- bri_text[i * bri_text_size] = ' ';
- else
- bri_text[i * bri_text_size] = '*';
-
- if (i < 10)
- {
- bri_text[i * bri_text_size + 1] = i + '0';
- strcpy(bri_text + i * bri_text_size + 2, "0%");
- }
- else
- strcpy(bri_text + i * bri_text_size + 1, "100%");
-
- ments[i + 1].type = MENT_DATA;
- ments[i + 1].caption = bri_text + (i * bri_text_size);
- ments[i + 1].data = &bri_values[i];
- }
-
- memset(&ments[i + 1], 0, sizeof(ment_t));
- menu_t menu = {ments, "Backlight brightness", 0, 0};
-
- u32 *temp_backlight = (u32 *)tui_do_menu(&menu);
- if (temp_backlight != NULL)
- {
- h_cfg.backlight = (*(u32 *)temp_backlight) * 2;
- _save_config();
- }
-
- free(ments);
- free(bri_values);
- free(bri_text);
-
- if (temp_backlight == NULL)
- return;
- btn_wait();
-}
-
-void config_auto_hos_poweroff()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 6);
- u32 *hp_values = (u32 *)malloc(sizeof(u32) * 3);
-
- for (u32 j = 0; j < 3; j++)
- {
- hp_values[j] = j;
- ments[j + 2].type = MENT_DATA;
- ments[j + 2].data = &hp_values[j];
- }
-
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- if (h_cfg.autohosoff == 1)
- {
- ments[2].caption = " Disable";
- ments[3].caption = "*Enable";
- ments[4].caption = " Enable (No logo)";
- }
- else if (h_cfg.autohosoff >= 2)
- {
- ments[2].caption = " Disable";
- ments[3].caption = " Enable";
- ments[4].caption = "*Enable (No logo)";
- }
- else
- {
- ments[2].caption = "*Disable";
- ments[3].caption = " Enable";
- ments[4].caption = " Enable (No logo)";
- }
-
- memset(&ments[5], 0, sizeof(ment_t));
- menu_t menu = {ments, "Power off if woke up from HOS", 0, 0};
-
- u32 *temp_autohosoff = (u32 *)tui_do_menu(&menu);
- if (temp_autohosoff != NULL)
- {
- h_cfg.autohosoff = *(u32 *)temp_autohosoff;
- _save_config();
- }
-
- free(ments);
- free(hp_values);
-
- if (temp_autohosoff == NULL)
- return;
- btn_wait();
-}
-
-void config_nogc()
-{
- gfx_clear_grey(0x1B);
- gfx_con_setpos(0, 0);
-
- ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 5);
- u32 *cb_values = (u32 *)malloc(sizeof(u32) * 2);
-
- for (u32 j = 0; j < 2; j++)
- {
- cb_values[j] = j;
- ments[j + 2].type = MENT_DATA;
- ments[j + 2].data = &cb_values[j];
- }
-
- ments[0].type = MENT_BACK;
- ments[0].caption = "Back";
-
- ments[1].type = MENT_CHGLINE;
-
- if (h_cfg.autonogc)
- {
- ments[2].caption = " Disable";
- ments[3].caption = "*Auto";
- }
- else
- {
- ments[2].caption = "*Disable";
- ments[3].caption = " Auto";
- }
-
- memset(&ments[4], 0, sizeof(ment_t));
- menu_t menu = {ments, "No Gamecard", 0, 0};
-
- u32 *temp_nogc = (u32 *)tui_do_menu(&menu);
- if (temp_nogc != NULL)
- {
- h_cfg.autonogc = *(u32 *)temp_nogc;
- _save_config();
- }
-
- free(ments);
- free(cb_values);
-
- if (temp_nogc == NULL)
- return;
- btn_wait();
-}
-
-#pragma GCC pop_options
diff --git a/source/config/ini.c b/source/config/ini.c
index 85a19b1..4c200dd 100644
--- a/source/config/ini.c
+++ b/source/config/ini.c
@@ -55,12 +55,9 @@ u32 _find_section_name(char *lbuf, u32 lblen, char schar)
ini_sec_t *_ini_create_section(link_t *dst, ini_sec_t *csec, char *name, u8 type)
{
if (csec)
- {
list_append(dst, &csec->link);
- csec = NULL;
- }
- csec = (ini_sec_t *)malloc(sizeof(ini_sec_t));
+ csec = (ini_sec_t *)calloc(sizeof(ini_sec_t), 1);
csec->name = _strdup(name);
csec->type = type;
@@ -154,7 +151,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
{
u32 i = _find_section_name(lbuf, lblen, '=');
- ini_kv_t *kv = (ini_kv_t *)malloc(sizeof(ini_kv_t));
+ ini_kv_t *kv = (ini_kv_t *)calloc(sizeof(ini_kv_t), 1);
kv->key = _strdup(&lbuf[0]);
kv->val = _strdup(&lbuf[i + 1]);
list_append(&csec->kvs, &kv->link);
diff --git a/source/gfx/di.c b/source/gfx/di.c
index 200d412..3252475 100644
--- a/source/gfx/di.c
+++ b/source/gfx/di.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (c) 2018 CTCaer
+ * Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -31,7 +31,11 @@
#include "di.inl"
-static u32 _display_ver = 0;
+extern volatile nyx_storage_t *nyx_str;
+
+static u32 _display_id = 0;
+
+void display_end();
static void _display_dsi_wait(u32 timeout, u32 off, u32 mask)
{
@@ -41,8 +45,21 @@ static void _display_dsi_wait(u32 timeout, u32 off, u32 mask)
usleep(5);
}
+static void _display_dsi_send_cmd(u8 cmd, u32 param, u32 wait)
+{
+ DSI(_DSIREG(DSI_WR_DATA)) = (param << 8) | cmd;
+ DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+
+ if (wait)
+ usleep(wait);
+}
+
void display_init()
{
+ // Check if display is already initialized.
+ if (CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) & 0x18000000)
+ display_end();
+
// Power on.
max77620_regulator_set_volt_and_flags(REGULATOR_LDO0, 1200000, MAX77620_POWER_MODE_NORMAL); // Configure to 1.2V.
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_GPIO7, MAX77620_CNFG_GPIO_OUTPUT_VAL_HIGH | MAX77620_CNFG_GPIO_DRV_PUSHPULL);
@@ -60,16 +77,16 @@ void display_init()
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_W_SET) = 0x80000; // Set enable clock DSIA_LP.
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_DSIA_LP) = 10; // Set PLLP_OUT and div 6 (68MHz).
- // Disable deap power down.
+ // Disable deep power down.
PMC(APBDEV_PMC_IO_DPD_REQ) = 0x40000000;
PMC(APBDEV_PMC_IO_DPD2_REQ) = 0x40000000;
// Config LCD and Backlight pins.
- PINMUX_AUX(PINMUX_AUX_NFC_EN) &= ~PINMUX_TRISTATE;
- PINMUX_AUX(PINMUX_AUX_NFC_INT) &= ~PINMUX_TRISTATE;
- PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) &= ~PINMUX_TRISTATE;
- PINMUX_AUX(PINMUX_AUX_LCD_BL_EN) &= ~PINMUX_TRISTATE;
- PINMUX_AUX(PINMUX_AUX_LCD_RST) &= ~PINMUX_TRISTATE;
+ PINMUX_AUX(PINMUX_AUX_NFC_EN) &= ~PINMUX_TRISTATE; // PULL_DOWN
+ PINMUX_AUX(PINMUX_AUX_NFC_INT) &= ~PINMUX_TRISTATE; // PULL_DOWN
+ PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) &= ~PINMUX_TRISTATE; // PULL_DOWN | 1
+ PINMUX_AUX(PINMUX_AUX_LCD_BL_EN) &= ~PINMUX_TRISTATE; // PULL_DOWN
+ PINMUX_AUX(PINMUX_AUX_LCD_RST) &= ~PINMUX_TRISTATE; // PULL_DOWN
// Set Backlight +-5V pins mode and direction
gpio_config(GPIO_PORT_I, GPIO_PIN_0 | GPIO_PIN_1, GPIO_MODE_GPIO);
@@ -87,14 +104,18 @@ void display_init()
gpio_write(GPIO_PORT_V, GPIO_PIN_1, GPIO_HIGH); // Enable Backlight EN.
// Power up supply regulator for display interface.
- MIPI_CAL(MIPI_CAL_MIPI_BIAS_PAD_CFG2) = 0;
+ MIPI_CAL(_DSIREG(MIPI_CAL_MIPI_BIAS_PAD_CFG2)) = 0;
- // Set DISP1 clock source and parrent clock.
- exec_cfg((u32 *)CLOCK_BASE, _display_config_1, 4);
+ // Set DISP1 clock source and parent clock.
+ CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_DISP1) = 0x40000000; // PLLD_OUT.
+ u32 plld_div = (3 << 20) | (20 << 11) | 1; // DIVM: 1, DIVN: 20, DIVP: 3. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 96 MHz.
+ CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
+ CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; // PLLD_SETUP.
+ CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2D0AAA; // PLLD_ENABLE_CLK.
// Setup display communication interfaces.
- exec_cfg((u32 *)DISPLAY_A_BASE, _display_config_2, 94);
- exec_cfg((u32 *)DSI_BASE, _display_config_3, 61);
+ exec_cfg((u32 *)DISPLAY_A_BASE, _display_dc_setup_win_config, 94);
+ exec_cfg((u32 *)DSI_BASE, _display_dsi_init_config, 61);
usleep(10000);
// Enable Backlight Reset.
@@ -103,12 +124,10 @@ void display_init()
// Setups DSI packet configuration and request display id.
DSI(_DSIREG(DSI_BTA_TIMING)) = 0x50204;
- DSI(_DSIREG(DSI_WR_DATA)) = 0x337; // MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE
- DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ _display_dsi_send_cmd(MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, 3, 0);
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
- DSI(_DSIREG(DSI_WR_DATA)) = 0x406; // MIPI_DCS_GET_DISPLAY_ID
- DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ _display_dsi_send_cmd(MIPI_DSI_DCS_READ, MIPI_DCS_GET_DISPLAY_ID, 0);
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
DSI(_DSIREG(DSI_HOST_CONTROL)) = DSI_HOST_CONTROL_TX_TRIG_HOST | DSI_HOST_CONTROL_IMM_BTA | DSI_HOST_CONTROL_CS | DSI_HOST_CONTROL_ECC;
@@ -116,37 +135,71 @@ void display_init()
usleep(5000);
- _display_ver = DSI(_DSIREG(DSI_RD_DATA));
- if (_display_ver == 0x10)
- exec_cfg((u32 *)DSI_BASE, _display_config_4, 43);
+ // MIPI_DCS_GET_DISPLAY_ID reply is a long read, size 3 u32.
+ for (u32 i = 0; i < 3; i++)
+ _display_id = DSI(_DSIREG(DSI_RD_DATA)); // Skip ack and msg type info and get the payload (display id).
- DSI(_DSIREG(DSI_WR_DATA)) = 0x1105; // MIPI_DCS_EXIT_SLEEP_MODE
- DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ // Save raw Display ID to Nyx storage.
+ nyx_str->info.disp_id = _display_id;
- usleep(180000);
+ // Decode Display ID.
+ _display_id = ((_display_id >> 8) & 0xFF00) | (_display_id & 0xFF);
- DSI(_DSIREG(DSI_WR_DATA)) = 0x2905; // MIPI_DCS_SET_DISPLAY_ON
- DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ if ((_display_id & 0xFF) == PANEL_JDI_LPM062M)
+ _display_id = PANEL_JDI_LPM062M;
- usleep(20000);
+ // Initialize display panel.
+ switch (_display_id)
+ {
+ case PANEL_JDI_LPM062M:
+ exec_cfg((u32 *)DSI_BASE, _display_init_config_jdi, 43);
+ _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 180000);
+ break;
+ case PANEL_INL_P062CCA_AZ1:
+ case PANEL_AUO_A062TAN01:
+ _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 180000);
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x439; // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x9483FFB9; // Enable extension cmd. (Pass: FF 83 94).
+ DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ usleep(5000);
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x739; // MIPI_DSI_DCS_LONG_WRITE: 7 bytes.
+ if (_display_id == PANEL_INL_P062CCA_AZ1)
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x751548B1; // Set Power control. (Not deep standby, BT5 / XDK, VRH gamma volt adj 53 / x40).
+ else
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x711148B1; // Set Power control. (Not deep standby, BT1 / XDK, VRH gamma volt adj 49 / x40).
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x143209; // (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/32).
+ DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ usleep(5000);
+ break;
+ case PANEL_INL_P062CCA_AZ2:
+ case PANEL_AUO_A062TAN02:
+ default: // Allow spare part displays to work.
+ _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 120000);
+ break;
+ }
+
+ _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_SET_DISPLAY_ON, 20000);
// Configure PLLD for DISP1.
- exec_cfg((u32 *)CLOCK_BASE, _display_config_6, 3);
+ plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 460.8 MHz.
+ CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
+ CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20;
+ CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2DFC00; // Use new PLLD_SDM_DIN.
// Finalize DSI configuration.
- exec_cfg((u32 *)DSI_BASE, _display_config_5, 21);
- DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = 4;
- exec_cfg((u32 *)DSI_BASE, _display_config_7, 10);
+ exec_cfg((u32 *)DSI_BASE, _display_dsi_packet_config, 21);
+ DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = 4; // PCD1 | div3.
+ exec_cfg((u32 *)DSI_BASE, _display_dsi_mode_config, 10);
usleep(10000);
// Calibrate display communication pads.
- exec_cfg((u32 *)MIPI_CAL_BASE, _display_config_8, 6);
- exec_cfg((u32 *)DSI_BASE, _display_config_9, 4);
- exec_cfg((u32 *)MIPI_CAL_BASE, _display_config_10, 16);
+ exec_cfg((u32 *)MIPI_CAL_BASE, _display_mipi_pad_cal_config, 6);
+ exec_cfg((u32 *)DSI_BASE, _display_dsi_pad_cal_config, 4);
+ exec_cfg((u32 *)MIPI_CAL_BASE, _display_mipi_apply_dsi_cal_config, 16);
usleep(10000);
// Enable video display controller.
- exec_cfg((u32 *)DISPLAY_A_BASE, _display_config_11, 113);
+ exec_cfg((u32 *)DISPLAY_A_BASE, _display_video_disp_controller_enable_config, 113);
}
void display_backlight_pwm_init()
@@ -197,25 +250,50 @@ void display_end()
{
display_backlight_brightness(0, 1000);
- DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 1;
+ DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = DSI_CMD_PKT_VID_ENABLE;
DSI(_DSIREG(DSI_WR_DATA)) = 0x2805; // MIPI_DCS_SET_DISPLAY_OFF
DISPLAY_A(_DIREG(DC_CMD_STATE_ACCESS)) = READ_MUX | WRITE_MUX;
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 0; // Disable host cmd packet.
// De-initialize video controller.
- exec_cfg((u32 *)DISPLAY_A_BASE, _display_config_12, 17);
- exec_cfg((u32 *)DSI_BASE, _display_config_13, 16);
+ exec_cfg((u32 *)DISPLAY_A_BASE, _display_video_disp_controller_disable_config, 17);
+ exec_cfg((u32 *)DSI_BASE, _display_dsi_timing_deinit_config, 16);
usleep(10000);
// De-initialize display panel.
- if (_display_ver == 0x10)
- exec_cfg((u32 *)DSI_BASE, _display_config_14, 22);
+ switch (_display_id)
+ {
+ case PANEL_JDI_LPM062M:
+ exec_cfg((u32 *)DSI_BASE, _display_deinit_config_jdi, 22);
+ break;
+ case PANEL_AUO_A062TAN01:
+ exec_cfg((u32 *)DSI_BASE, _display_deinit_config_auo, 37);
+ break;
+ case PANEL_INL_P062CCA_AZ2:
+ case PANEL_AUO_A062TAN02:
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x439; // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x9483FFB9; // Enable extension cmd. (Pass: FF 83 94).
+ DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ usleep(5000);
+ // Set Power.
+ DSI(_DSIREG(DSI_WR_DATA)) = 0xB39; // MIPI_DSI_DCS_LONG_WRITE: 11 bytes.
+ if (_display_id == PANEL_INL_P062CCA_AZ2)
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x751548B1; // Set Power control. (Not deep standby, BT5 / XDK, VRH gamma volt adj 53 / x40).
+ else
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x711148B1; // Set Power control. (Not deep standby, BT1 / XDK, VRH gamma volt adj 49 / x40).
+ // Set Power control. (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/32, Enter standby / PON / VCOMG).
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x71143209;
+ DSI(_DSIREG(DSI_WR_DATA)) = 0x114D31; // Set Power control. (Unknown).
+ DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
+ usleep(5000);
+ break;
+ case PANEL_INL_P062CCA_AZ1:
+ default:
+ break;
+ }
- DSI(_DSIREG(DSI_WR_DATA)) = 0x1005; // MIPI_DCS_ENTER_SLEEP_MODE
- DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
-
- usleep(50000);
+ _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_ENTER_SLEEP_MODE, 50000);
// Disable display and backlight pins.
gpio_write(GPIO_PORT_V, GPIO_PIN_2, GPIO_LOW); //Backlight Reset disable.
diff --git a/source/gfx/di.h b/source/gfx/di.h
index ee796a7..a160eff 100644
--- a/source/gfx/di.h
+++ b/source/gfx/di.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (c) 2018 CTCaer
+ * Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -24,6 +24,21 @@
/*! Display registers. */
#define _DIREG(reg) ((reg) * 4)
+// Display controller scratch registers.
+#define DC_D_WINBUF_DD_SCRATCH_REGISTER_0 0xED
+#define DC_D_WINBUF_DD_SCRATCH_REGISTER_1 0xEE
+#define DC_T_WINBUF_TD_SCRATCH_REGISTER_0 0x16D
+#define DC_T_WINBUF_TD_SCRATCH_REGISTER_1 0x16E
+#define DC_COM_SCRATCH_REGISTER_A 0x325
+#define DC_COM_SCRATCH_REGISTER_B 0x326
+#define DC_A_WINBUF_AD_SCRATCH_REGISTER_0 0xBED
+#define DC_A_WINBUF_AD_SCRATCH_REGISTER_1 0xBEE
+#define DC_B_WINBUF_BD_SCRATCH_REGISTER_0 0xDED
+#define DC_B_WINBUF_BD_SCRATCH_REGISTER_1 0xDEE
+#define DC_C_WINBUF_CD_SCRATCH_REGISTER_0 0xFED
+#define DC_C_WINBUF_CD_SCRATCH_REGISTER_1 0xFEE
+
+// DC_CMD non-shadowed command/sync registers.
#define DC_CMD_GENERAL_INCR_SYNCPT 0x00
#define DC_CMD_GENERAL_INCR_SYNCPT_CNTRL 0x01
@@ -50,6 +65,7 @@
#define PM0_ENABLE (1 << 16)
#define PM1_ENABLE (1 << 18)
+#define DC_CMD_INT_STATUS 0x37
#define DC_CMD_INT_MASK 0x38
#define DC_CMD_INT_ENABLE 0x39
@@ -62,11 +78,13 @@
#define WIN_A_ACT_REQ (1 << 1)
#define WIN_B_ACT_REQ (1 << 2)
#define WIN_C_ACT_REQ (1 << 3)
+#define WIN_D_ACT_REQ (1 << 4)
#define CURSOR_ACT_REQ (1 << 7)
#define GENERAL_UPDATE (1 << 8)
#define WIN_A_UPDATE (1 << 9)
#define WIN_B_UPDATE (1 << 10)
#define WIN_C_UPDATE (1 << 11)
+#define WIN_D_UPDATE (1 << 12)
#define CURSOR_UPDATE (1 << 15)
#define NC_HOST_TRIG (1 << 24)
@@ -74,15 +92,38 @@
#define WINDOW_A_SELECT (1 << 4)
#define WINDOW_B_SELECT (1 << 5)
#define WINDOW_C_SELECT (1 << 6)
+#define WINDOW_D_SELECT (1 << 7)
#define DC_CMD_REG_ACT_CONTROL 0x043
+// DC_D_WIN_DD window D instance of DC_WIN
+#define DC_D_WIN_DD_WIN_OPTIONS 0x80
+#define DC_D_WIN_DD_COLOR_DEPTH 0x83
+#define DC_D_WIN_DD_POSITION 0x84
+#define DC_D_WIN_DD_SIZE 0x85
+#define DC_D_WIN_DD_LINE_STRIDE 0x8A
+#define DC_D_WIN_DD_BLEND_LAYER_CONTROL 0x96
+#define DC_D_WIN_DD_BLEND_MATCH_SELECT 0x97
+#define DC_D_WIN_DD_BLEND_ALPHA_1BIT 0x99
+
+// DC_D_WINBUF_DD window D instance of DC_WINBUF
+#define DC_D_WINBUF_DD_START_ADDR 0xC0
+#define DC_D_WINBUF_DD_ADDR_H_OFFSET 0xC6
+#define DC_D_WINBUF_DD_ADDR_V_OFFSET 0xC8
+#define DC_D_WINBUF_DD_START_ADDR_HI 0xCD
+#define DC_D_WINBUF_DD_MEMFETCH_CONTROL 0xEB
+
+// DC_T_WIN_TD macro for using DD defines.
+#define _DC_T(reg) ((reg) + 0x80)
+
+// DC_COM non-shadowed registers.
#define DC_COM_CRC_CONTROL 0x300
#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
#define DC_COM_DSC_TOP_CTL 0x33E
+// DC_DISP shadowed registers.
#define DC_DISP_DISP_WIN_OPTIONS 0x402
#define HDMI_ENABLE (1 << 30)
#define DSI_ENABLE (1 << 29)
@@ -161,6 +202,32 @@
#define DE_CONTROL_EARLY (3 << 2)
#define DE_CONTROL_ACTIVE_BLANK (4 << 2)
+// Cursor configuration registers.
+#define DC_DISP_CURSOR_FOREGROUND 0x43C
+#define DC_DISP_CURSOR_BACKGROUND 0x43D
+#define CURSOR_COLOR(r,g,b) (((r) & 0xFF) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16))
+
+#define DC_DISP_CURSOR_START_ADDR 0x43E
+#define CURSOR_CLIPPING(w) ((w) << 28)
+#define CURSOR_CLIP_WIN_A 1
+#define CURSOR_CLIP_WIN_B 2
+#define CURSOR_CLIP_WIN_C 3
+#define CURSOR_SIZE_32 (0 << 24)
+#define CURSOR_SIZE_64 (1 << 24)
+#define CURSOR_SIZE_128 (2 << 24)
+#define CURSOR_SIZE_256 (3 << 24)
+#define DC_DISP_CURSOR_POSITION 0x440
+#define DC_DISP_CURSOR_START_ADDR_HI 0x4EC
+#define DC_DISP_BLEND_CURSOR_CONTROL 0x4F1
+#define CURSOR_BLEND_2BIT (0 << 24)
+#define CURSOR_BLEND_R8G8B8A8 (1 << 24)
+#define CURSOR_BLEND_SRC_FACTOR(n) ((n) << 8)
+#define CURSOR_BLEND_DST_FACTOR(n) ((n) << 16)
+#define CURSOR_BLEND_ZRO 0
+#define CURSOR_BLEND_K1 1
+#define CURSOR_BLEND_NK1 2
+// End of cursor cfg regs.
+
#define DC_DISP_DC_MCCIF_FIFOCTRL 0x480
#define DC_DISP_SD_BL_PARAMETERS 0x4D7
#define DC_DISP_SD_BL_CONTROL 0x4DC
@@ -187,6 +254,13 @@
#define CSC_ENABLE (1 << 18)
#define WIN_ENABLE (1 << 30)
+#define DC_WIN_BUFFER_CONTROL 0x702
+#define BUFFER_CONTROL_HOST 0
+#define BUFFER_CONTROL_VI 1
+#define BUFFER_CONTROL_EPP 2
+#define BUFFER_CONTROL_MPEGE 3
+#define BUFFER_CONTROL_SB2D 4
+
#define DC_WIN_COLOR_DEPTH 0x703
#define WIN_COLOR_DEPTH_P1 0x0
#define WIN_COLOR_DEPTH_P2 0x1
@@ -211,8 +285,9 @@
#define WIN_COLOR_DEPTH_YCbCr422RA 0x18
#define WIN_COLOR_DEPTH_YUV422RA 0x19
-#define DC_WIN_BUFFER_CONTROL 0x702
#define DC_WIN_POSITION 0x704
+#define H_POSITION(x) (((x) & 0xFfff) << 0)
+#define V_POSITION(x) (((x) & 0x1fff) << 16)
#define DC_WIN_SIZE 0x705
#define H_SIZE(x) (((x) & 0x1fff) << 0)
@@ -234,6 +309,42 @@
#define UV_LINE_STRIDE(x) (((x) & 0xffff) << 16)
#define DC_WIN_DV_CONTROL 0x70E
+#define DC_WINBUF_BLEND_LAYER_CONTROL 0x716
+#define WIN_K1(x) (((x) & 0xff) << 8)
+#define WIN_K2(x) (((x) & 0xff) << 16)
+#define WIN_BLEND_ENABLE (0 << 24)
+#define WIN_BLEND_BYPASS (1 << 24)
+
+#define DC_WINBUF_BLEND_MATCH_SELECT 0x717
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_ZERO (0 << 0)
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_ONE (1 << 0)
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1 (2 << 0)
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1_TIMES_DST (3 << 0)
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_NEG_K1_TIMES_DST (4 << 0)
+#define WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1_TIMES_SRC (5 << 0)
+
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_ZERO (0 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_ONE (1 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K1 (2 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K2 (3 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K1_TIMES_DST (4 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1_TIMES_DST (5 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1_TIMES_SRC (6 << 4)
+#define WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1 (7 << 4)
+
+#define WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_ZERO (0 << 8)
+#define WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_K1 (1 << 8)
+#define WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_K2 (2 << 8)
+
+#define WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_ZERO (0 << 12)
+#define WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_ONE (1 << 12)
+#define WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_NEG_K1_TIMES_SRC (2 << 12)
+#define WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_K2 (3 << 12)
+
+#define DC_WINBUF_BLEND_ALPHA_1BIT 0x719
+#define WIN_ALPHA_1BIT_WEIGHT0(x) (((x) & 0xff) << 0)
+#define WIN_ALPHA_1BIT_WEIGHT1(x) (((x) & 0xff) << 8)
+
/*! The following registers are A/B/C shadows of the 0xBC0/0xDC0/0xFC0 registers (see DISPLAY_WINDOW_HEADER). */
#define DC_WINBUF_START_ADDR 0x800
#define DC_WINBUF_ADDR_H_OFFSET 0x806
@@ -336,6 +447,7 @@
#define DSI_PAD_CONTROL_CD 0x4C
#define DSI_VIDEO_MODE_CONTROL 0x4E
+#define DSI_CMD_PKT_VID_ENABLE 1
#define DSI_PAD_CONTROL_1 0x4F
#define DSI_PAD_CONTROL_2 0x50
@@ -349,7 +461,57 @@
#define DSI_PAD_CONTROL_4 0x52
#define DSI_INIT_SEQ_DATA_15 0x5F
-#define MIPI_CAL_MIPI_BIAS_PAD_CFG2 0x60
+/*! MIPI registers. */
+#define MIPI_CAL_MIPI_CAL_CTRL (0x00 / 0x4)
+#define MIPI_CAL_CIL_MIPI_CAL_STATUS (0x08 / 0x4)
+#define MIPI_CAL_CILA_MIPI_CAL_CONFIG (0x14 / 0x4)
+#define MIPI_CAL_CILB_MIPI_CAL_CONFIG (0x18 / 0x4)
+#define MIPI_CAL_CILC_MIPI_CAL_CONFIG (0x1C / 0x4)
+#define MIPI_CAL_CILD_MIPI_CAL_CONFIG (0x20 / 0x4)
+#define MIPI_CAL_CILE_MIPI_CAL_CONFIG (0x24 / 0x4)
+#define MIPI_CAL_CILF_MIPI_CAL_CONFIG (0x28 / 0x4)
+#define MIPI_CAL_DSIA_MIPI_CAL_CONFIG (0x38 / 0x4)
+#define MIPI_CAL_DSIB_MIPI_CAL_CONFIG (0x3C / 0x4)
+#define MIPI_CAL_DSIC_MIPI_CAL_CONFIG (0x40 / 0x4)
+#define MIPI_CAL_DSID_MIPI_CAL_CONFIG (0x44 / 0x4)
+#define MIPI_CAL_MIPI_BIAS_PAD_CFG0 (0x58 / 0x4)
+#define MIPI_CAL_MIPI_BIAS_PAD_CFG1 (0x5C / 0x4)
+#define MIPI_CAL_MIPI_BIAS_PAD_CFG2 (0x60 / 0x4)
+#define MIPI_CAL_DSIA_MIPI_CAL_CONFIG_2 (0x64 / 0x4)
+#define MIPI_CAL_DSIB_MIPI_CAL_CONFIG_2 (0x68 / 0x4)
+#define MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2 (0x70 / 0x4)
+#define MIPI_CAL_DSID_MIPI_CAL_CONFIG_2 (0x74 / 0x4)
+
+/*! MIPI CMDs. */
+#define MIPI_DSI_DCS_SHORT_WRITE 0x05
+#define MIPI_DSI_DCS_READ 0x06
+#define MIPI_DSI_DCS_SHORT_WRITE_PARAM 0x15
+#define MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE 0x37
+#define MIPI_DSI_DCS_LONG_WRITE 0x39
+
+/*! MIPI DCS CMDs. */
+#define MIPI_DCS_GET_DISPLAY_ID 0x04
+#define MIPI_DCS_ENTER_SLEEP_MODE 0x10
+#define MIPI_DCS_EXIT_SLEEP_MODE 0x11
+#define MIPI_DCS_SET_DISPLAY_ON 0x29
+
+/* Switch Panels:
+ * [10] 81 [26]: JDI LPM062M326A
+ * [10] 96 [09]: JDI LAM062M109A
+ * [20] 93 [0F]: InnoLux P062CCA-AZ1 (Rev A1)
+ * [20] XX [10]: InnoLux P062CCA-AZ2 [UNCONFIRMED ID]
+ * [30] 94 [0F]: AUO A062TAN01 (59.06A33.001)
+ * [30] XX [10]: AUO A062TAN02 (59.06A33.002) [UNCONFIRMED ID]
+ */
+
+enum
+{
+ PANEL_JDI_LPM062M = 0x10,
+ PANEL_INL_P062CCA_AZ1 = 0x0F20,
+ PANEL_AUO_A062TAN01 = 0x0F30,
+ PANEL_INL_P062CCA_AZ2 = 0x1020,
+ PANEL_AUO_A062TAN02 = 0x1030
+};
void display_init();
void display_backlight_pwm_init();
@@ -364,5 +526,8 @@ void display_backlight_brightness(u32 brightness, u32 step_delay);
/*! Init display in full 1280x720 resolution (B8G8R8A8, line stride 768, framebuffer size = 1280*768*4 bytes). */
u32 *display_init_framebuffer();
+void display_init_cursor(void *crs_fb, u32 size);
+void display_set_pos_cursor(u32 x, u32 y);
+void display_deinit_cursor();
#endif
diff --git a/source/gfx/di.inl b/source/gfx/di.inl
index dd82899..9a275eb 100644
--- a/source/gfx/di.inl
+++ b/source/gfx/di.inl
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
-* Copyright (c) 2018 CTCaer
+* Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -15,16 +15,8 @@
* along with this program. If not, see .
*/
-//Clock config.
-static const cfg_op_t _display_config_1[4] = {
- {0x4E, 0x40000000}, //CLK_RST_CONTROLLER_CLK_SOURCE_DISP1
- {0x34, 0x4830A001}, //CLK_RST_CONTROLLER_PLLD_BASE
- {0x36, 0x20}, //CLK_RST_CONTROLLER_PLLD_MISC1
- {0x37, 0x2D0AAA} //CLK_RST_CONTROLLER_PLLD_MISC
-};
-
//Display A config.
-static const cfg_op_t _display_config_2[94] = {
+static const cfg_op_t _display_dc_setup_win_config[94] = {
{DC_CMD_STATE_ACCESS, 0},
{DC_CMD_STATE_CONTROL, GENERAL_UPDATE},
{DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ},
@@ -128,7 +120,7 @@ static const cfg_op_t _display_config_2[94] = {
};
//DSI Init config.
-static const cfg_op_t _display_config_3[61] = {
+static const cfg_op_t _display_dsi_init_config[61] = {
{DSI_WR_DATA, 0},
{DSI_INT_ENABLE, 0},
{DSI_INT_STATUS, 0},
@@ -192,14 +184,14 @@ static const cfg_op_t _display_config_3[61] = {
{DSI_INIT_SEQ_CONTROL, 0}
};
-//DSI config (if ver == 0x10).
-static const cfg_op_t _display_config_4[43] = {
- {DSI_WR_DATA, 0x439},
- {DSI_WR_DATA, 0x9483FFB9},
+//DSI panel config.
+static const cfg_op_t _display_init_config_jdi[43] = {
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x9483FFB9}, // Enable extension cmd. (Pass: FF 83 94).
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0xBD15},
+ {DSI_WR_DATA, 0x00BD15}, // MIPI_DSI_DCS_SHORT_WRITE_PARAM: 0x0BD.
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x1939},
+ {DSI_WR_DATA, 0x1939}, // MIPI_DSI_DCS_LONG_WRITE: 25 bytes.
{DSI_WR_DATA, 0xAAAAAAD8},
{DSI_WR_DATA, 0xAAAAAAEB},
{DSI_WR_DATA, 0xAAEBAAAA},
@@ -208,9 +200,9 @@ static const cfg_op_t _display_config_4[43] = {
{DSI_WR_DATA, 0xAAEBAAAA},
{DSI_WR_DATA, 0xAA},
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x1BD15},
+ {DSI_WR_DATA, 0x01BD15}, // MIPI_DSI_DCS_SHORT_WRITE_PARAM: 0x1BD.
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x2739},
+ {DSI_WR_DATA, 0x2739}, // MIPI_DSI_DCS_LONG_WRITE: 39 bytes.
{DSI_WR_DATA, 0xFFFFFFD8},
{DSI_WR_DATA, 0xFFFFFFFF},
{DSI_WR_DATA, 0xFFFFFFFF},
@@ -222,25 +214,25 @@ static const cfg_op_t _display_config_4[43] = {
{DSI_WR_DATA, 0xFFFFFFFF},
{DSI_WR_DATA, 0xFFFFFF},
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x2BD15},
+ {DSI_WR_DATA, 0x02BD15}, // MIPI_DSI_DCS_SHORT_WRITE_PARAM: 0x2BD.
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0xF39},
+ {DSI_WR_DATA, 0xF39}, // MIPI_DSI_DCS_LONG_WRITE: 15 bytes.
{DSI_WR_DATA, 0xFFFFFFD8},
{DSI_WR_DATA, 0xFFFFFFFF},
{DSI_WR_DATA, 0xFFFFFFFF},
{DSI_WR_DATA, 0xFFFFFF},
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0xBD15},
+ {DSI_WR_DATA, 0x00BD15}, // MIPI_DSI_DCS_SHORT_WRITE_PARAM: 0x0BD.
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x6D915},
+ {DSI_WR_DATA, 0x06D915}, // MIPI_DSI_DCS_SHORT_WRITE_PARAM: 0x6D9.
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x439},
- {DSI_WR_DATA, 0xB9},
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x000000B9}, // Disable extension cmd.
{DSI_TRIGGER, DSI_TRIGGER_HOST}
};
-//DSI config.
-static const cfg_op_t _display_config_5[21] = {
+//DSI packet config.
+static const cfg_op_t _display_dsi_packet_config[21] = {
{DSI_PAD_CONTROL_1, 0},
{DSI_PHY_TIMING_0, 0x6070601},
{DSI_PHY_TIMING_1, 0x40A0E05},
@@ -264,15 +256,8 @@ static const cfg_op_t _display_config_5[21] = {
{DSI_HOST_CONTROL, 0},
};
-//Clock config.
-static const cfg_op_t _display_config_6[3] = {
- {0x34, 0x4810C001}, //CLK_RST_CONTROLLER_PLLD_BASE
- {0x36, 0x20}, //CLK_RST_CONTROLLER_PLLD_MISC1
- {0x37, 0x2DFC00} //CLK_RST_CONTROLLER_PLLD_MISC
-};
-
-//DSI config.
-static const cfg_op_t _display_config_7[10] = {
+//DSI mode config.
+static const cfg_op_t _display_dsi_mode_config[10] = {
{DSI_TRIGGER, 0},
{DSI_CONTROL, 0},
{DSI_SOL_DELAY, 6},
@@ -286,17 +271,17 @@ static const cfg_op_t _display_config_7[10] = {
};
//MIPI CAL config.
-static const cfg_op_t _display_config_8[6] = {
- {0x18, 0}, // MIPI_CAL_MIPI_BIAS_PAD_CFG2
- {0x02, 0xF3F10000}, // MIPI_CAL_CIL_MIPI_CAL_STATUS
- {0x16, 0}, // MIPI_CAL_MIPI_BIAS_PAD_CFG0
- {0x18, 0}, // MIPI_CAL_MIPI_BIAS_PAD_CFG2
- {0x18, 0x10010}, // MIPI_CAL_MIPI_BIAS_PAD_CFG2
- {0x17, 0x300} // MIPI_CAL_MIPI_BIAS_PAD_CFG1
+static const cfg_op_t _display_mipi_pad_cal_config[6] = {
+ {MIPI_CAL_MIPI_BIAS_PAD_CFG2, 0},
+ {MIPI_CAL_CIL_MIPI_CAL_STATUS, 0xF3F10000},
+ {MIPI_CAL_MIPI_BIAS_PAD_CFG0, 0},
+ {MIPI_CAL_MIPI_BIAS_PAD_CFG2, 0},
+ {MIPI_CAL_MIPI_BIAS_PAD_CFG2, 0x10010},
+ {MIPI_CAL_MIPI_BIAS_PAD_CFG1, 0x300}
};
//DSI config.
-static const cfg_op_t _display_config_9[4] = {
+static const cfg_op_t _display_dsi_pad_cal_config[4] = {
{DSI_PAD_CONTROL_1, 0},
{DSI_PAD_CONTROL_2, 0},
{DSI_PAD_CONTROL_3, DSI_PAD_PREEMP_PD_CLK(0x3) | DSI_PAD_PREEMP_PU_CLK(0x3) | DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3)},
@@ -304,27 +289,27 @@ static const cfg_op_t _display_config_9[4] = {
};
//MIPI CAL config.
-static const cfg_op_t _display_config_10[16] = {
- {0x0E, 0x200200}, // MIPI_CAL_DSIA_MIPI_CAL_CONFIG
- {0x0F, 0x200200}, // MIPI_CAL_DSIB_MIPI_CAL_CONFIG
- {0x19, 0x200002}, // MIPI_CAL_DSIA_MIPI_CAL_CONFIG_2
- {0x1A, 0x200002}, // MIPI_CAL_DSIB_MIPI_CAL_CONFIG_2
- {0x05, 0}, // MIPI_CAL_CILA_MIPI_CAL_CONFIG
- {0x06, 0}, // MIPI_CAL_CILB_MIPI_CAL_CONFIG
- {0x07, 0}, // MIPI_CAL_CILC_MIPI_CAL_CONFIG
- {0x08, 0}, // MIPI_CAL_CILD_MIPI_CAL_CONFIG
- {0x09, 0}, // MIPI_CAL_CILE_MIPI_CAL_CONFIG
- {0x0A, 0}, // MIPI_CAL_CILF_MIPI_CAL_CONFIG
- {0x10, 0}, // MIPI_CAL_DSIC_MIPI_CAL_CONFIG
- {0x11, 0}, // MIPI_CAL_DSID_MIPI_CAL_CONFIG
- {0x1A, 0}, // MIPI_CAL_DSIB_MIPI_CAL_CONFIG_2
- {0x1C, 0}, // MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2
- {0x1D, 0}, // MIPI_CAL_DSID_MIPI_CAL_CONFIG_2
- {0, 0x2A000001} // MIPI_CAL_DSIA_MIPI_CAL_CONFIG
+static const cfg_op_t _display_mipi_apply_dsi_cal_config[16] = {
+ {MIPI_CAL_DSIA_MIPI_CAL_CONFIG, 0x200200},
+ {MIPI_CAL_DSIB_MIPI_CAL_CONFIG, 0x200200},
+ {MIPI_CAL_DSIA_MIPI_CAL_CONFIG_2, 0x200002},
+ {MIPI_CAL_DSIB_MIPI_CAL_CONFIG_2, 0x200002},
+ {MIPI_CAL_CILA_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_CILB_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_CILC_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_CILD_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_CILE_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_CILF_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_DSIC_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_DSID_MIPI_CAL_CONFIG, 0},
+ {MIPI_CAL_DSIB_MIPI_CAL_CONFIG_2, 0},
+ {MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2, 0},
+ {MIPI_CAL_DSID_MIPI_CAL_CONFIG_2, 0},
+ {MIPI_CAL_MIPI_CAL_CTRL, 0x2A000001}
};
//Display A config.
-static const cfg_op_t _display_config_11[113] = {
+static const cfg_op_t _display_video_disp_controller_enable_config[113] = {
{DC_CMD_STATE_ACCESS, 0},
{DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
@@ -449,7 +434,7 @@ static const cfg_op_t _display_config_11[113] = {
};
////Display A config.
-static const cfg_op_t _display_config_12[17] = {
+static const cfg_op_t _display_video_disp_controller_disable_config[17] = {
{DC_DISP_FRONT_PORCH, 0xA0088},
{DC_CMD_INT_MASK, 0},
{DC_CMD_STATE_ACCESS, 0},
@@ -470,7 +455,7 @@ static const cfg_op_t _display_config_12[17] = {
};
//DSI config.
-static const cfg_op_t _display_config_13[16] = {
+static const cfg_op_t _display_dsi_timing_deinit_config[16] = {
{DSI_POWER_CONTROL, 0},
{DSI_PAD_CONTROL_1, 0},
{DSI_PHY_TIMING_0, 0x6070601},
@@ -490,11 +475,11 @@ static const cfg_op_t _display_config_13[16] = {
};
//DSI config (if ver == 0x10).
-static const cfg_op_t _display_config_14[22] = {
- {DSI_WR_DATA, 0x439},
- {DSI_WR_DATA, 0x9483FFB9},
+static const cfg_op_t _display_deinit_config_jdi[22] = {
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x9483FFB9}, // Enable extension cmd. (Pass: FF 83 94).
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x2139},
+ {DSI_WR_DATA, 0x2139}, // MIPI_DSI_DCS_LONG_WRITE: 33 bytes.
{DSI_WR_DATA, 0x191919D5},
{DSI_WR_DATA, 0x19191919},
{DSI_WR_DATA, 0x19191919},
@@ -505,60 +490,107 @@ static const cfg_op_t _display_config_14[22] = {
{DSI_WR_DATA, 0x19191919},
{DSI_WR_DATA, 0x19},
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0xB39},
- {DSI_WR_DATA, 0x4F0F41B1},
+ {DSI_WR_DATA, 0xB39}, // MIPI_DSI_DCS_LONG_WRITE: 11 bytes.
+ {DSI_WR_DATA, 0x4F0F41B1}, // Set Power control.
{DSI_WR_DATA, 0xF179A433},
- {DSI_WR_DATA, 0x2D81},
+ {DSI_WR_DATA, 0x002D81},
{DSI_TRIGGER, DSI_TRIGGER_HOST},
- {DSI_WR_DATA, 0x439},
- {DSI_WR_DATA, 0xB9},
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x000000B9}, // Disable extension cmd.
{DSI_TRIGGER, DSI_TRIGGER_HOST}
};
+static const cfg_op_t _display_deinit_config_auo[37] = {
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x9483FFB9}, // Enable extension cmd. (Pass: FF 83 94).
+ {DSI_TRIGGER, DSI_TRIGGER_HOST},
+ {DSI_WR_DATA, 0x2C39}, // MIPI_DSI_DCS_LONG_WRITE: 44 bytes.
+ {DSI_WR_DATA, 0x191919D5},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_TRIGGER, DSI_TRIGGER_HOST},
+ {DSI_WR_DATA, 0x2C39}, // MIPI_DSI_DCS_LONG_WRITE: 44 bytes.
+ {DSI_WR_DATA, 0x191919D6},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_WR_DATA, 0x19191919},
+ {DSI_TRIGGER, DSI_TRIGGER_HOST},
+ {DSI_WR_DATA, 0xB39}, // MIPI_DSI_DCS_LONG_WRITE: 11 bytes.
+ {DSI_WR_DATA, 0x711148B1}, // Set Power control. (Not deep standby, BT1 / XDK, VRH gamma volt adj 49 / x40).
+ // Set Power control. (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/32, Enter standby / PON / VCOMG).
+ {DSI_WR_DATA, 0x71143209},
+ {DSI_WR_DATA, 0x114D31}, // Set Power control. (Unknown).
+ {DSI_TRIGGER, DSI_TRIGGER_HOST},
+ {DSI_WR_DATA, 0x439}, // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
+ {DSI_WR_DATA, 0x000000B9}, // Disable extension cmd.
+ {DSI_TRIGGER, DSI_TRIGGER_HOST}
+};
+
+static const cfg_op_t _display_init_config_invert[3] = {
+ {DSI_WR_DATA, 0x239},
+ {DSI_WR_DATA, 0x02C1}, // INV_EN.
+ {DSI_TRIGGER, DSI_TRIGGER_HOST},
+};
+
//Display A config.
static const cfg_op_t cfg_display_one_color[8] = {
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT}, //Enable window A.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_B_SELECT}, //Enable window B.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_B_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_C_SELECT}, //Enable window C.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_C_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE}, //DSI_ENABLE
- {DC_CMD_DISPLAY_COMMAND, DISP_CTRL_MODE_C_DISPLAY} //DISPLAY_CTRL_MODE: continuous display.
+ {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE},
+ {DC_CMD_DISPLAY_COMMAND, DISP_CTRL_MODE_C_DISPLAY} // Continuous display.
};
//Display A config.
static const cfg_op_t cfg_display_framebuffer[32] = {
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_C_SELECT}, //Enable window C.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_C_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_B_SELECT}, //Enable window B.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_B_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT}, //Enable window A.
+ {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE}, //DSI_ENABLE
- {DC_WIN_COLOR_DEPTH, WIN_COLOR_DEPTH_B8G8R8A8}, //T_A8R8G8B8 //NX Default: T_A8B8G8R8, WIN_COLOR_DEPTH_R8G8B8A8
+ {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE},
+ {DC_WIN_COLOR_DEPTH, WIN_COLOR_DEPTH_B8G8R8A8}, //NX Default: T_A8B8G8R8, WIN_COLOR_DEPTH_R8G8B8A8
{DC_WIN_WIN_OPTIONS, 0},
{DC_WIN_WIN_OPTIONS, 0},
{DC_WIN_POSITION, 0}, //(0,0)
{DC_WIN_H_INITIAL_DDA, 0},
{DC_WIN_V_INITIAL_DDA, 0},
- {DC_WIN_PRESCALED_SIZE, V_PRESCALED_SIZE(1280) | H_PRESCALED_SIZE(2880)}, //Pre-scaled size: 1280x2880 bytes.
- {DC_WIN_DDA_INC, V_DDA_INC(0x1000) | H_DDA_INC(0x1000)},
- {DC_WIN_SIZE, V_SIZE(1280) | H_SIZE(720)}, //Window size: 1280 vertical lines x 720 horizontal pixels.
- {DC_WIN_LINE_STRIDE, UV_LINE_STRIDE(720 * 2) | LINE_STRIDE(720 * 4)}, //768*2x768*4 (= 0x600 x 0xC00) bytes, see TRM for alignment requirements.
- {DC_WIN_BUFFER_CONTROL, 0},
- {DC_WINBUF_SURFACE_KIND, 0}, //Regular surface.
+ {DC_WIN_PRESCALED_SIZE, V_PRESCALED_SIZE(1280) | H_PRESCALED_SIZE(2880)},
+ {DC_WIN_DDA_INC, V_DDA_INC(0x1000) | H_DDA_INC(0x1000)}, // 1.0x
+ {DC_WIN_SIZE, V_SIZE(1280) | H_SIZE(720)},
+ {DC_WIN_LINE_STRIDE, UV_LINE_STRIDE(720 * 2) | LINE_STRIDE(720 * 4)}, // 720*2x720*4 (= 0x600 x 0xC00) bytes, see TRM for alignment requirements.
+ {DC_WIN_BUFFER_CONTROL, BUFFER_CONTROL_HOST},
+ {DC_WINBUF_SURFACE_KIND, PITCH},
{DC_WINBUF_START_ADDR, IPL_FB_ADDRESS}, // Framebuffer address.
{DC_WINBUF_ADDR_H_OFFSET, 0},
{DC_WINBUF_ADDR_V_OFFSET, 0},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE}, //DSI_ENABLE
+ {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE}, //DSI_ENABLE
+ {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE},
{DC_WIN_WIN_OPTIONS, 0},
- {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE}, //DSI_ENABLE
- {DC_WIN_WIN_OPTIONS, WIN_ENABLE}, //Enable window AD.
- {DC_CMD_DISPLAY_COMMAND, DISP_CTRL_MODE_C_DISPLAY}, //DISPLAY_CTRL_MODE: continuous display.
- {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_A_UPDATE}, //General update; window A update.
- {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_A_ACT_REQ} //General activation request; window A activation request.
+ {DC_DISP_DISP_WIN_OPTIONS, DSI_ENABLE},
+ {DC_WIN_WIN_OPTIONS, WIN_ENABLE}, // Enable window AD.
+ {DC_CMD_DISPLAY_COMMAND, DISP_CTRL_MODE_C_DISPLAY}, // Continuous display.
+ {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_A_UPDATE},
+ {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_A_ACT_REQ}
};
diff --git a/source/gfx/gfx.c b/source/gfx/gfx.c
index 4323e49..e4abe4e 100644
--- a/source/gfx/gfx.c
+++ b/source/gfx/gfx.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (C) 2018-2019 CTCaer
+ * Copyright (c) 2018-2020 CTCaer
* Copyright (c) 2019-2020 shchmue
*
* This program is free software; you can redistribute it and/or modify it
@@ -20,6 +20,10 @@
#include
#include "gfx.h"
+// Global gfx console and context.
+gfx_ctxt_t gfx_ctxt;
+gfx_con_t gfx_con;
+
static const u8 _gfx_font[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 032 ( )
0x00, 0x30, 0x30, 0x18, 0x18, 0x00, 0x0C, 0x00, // Char 033 (!)
diff --git a/source/gfx/gfx.h b/source/gfx/gfx.h
index 94cb0ed..0871820 100644
--- a/source/gfx/gfx.h
+++ b/source/gfx/gfx.h
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (C) 2018-2019 CTCaer
- * Copyright (C) 2018 M4xw
+ * Copyright (c) 2018-2020 CTCaer
+ * Copyright (c) 2018 M4xw
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -49,7 +49,7 @@ void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 po
void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
// Global gfx console and context.
-gfx_ctxt_t gfx_ctxt;
-gfx_con_t gfx_con;
+extern gfx_ctxt_t gfx_ctxt;
+extern gfx_con_t gfx_con;
#endif
diff --git a/source/gfx/tui.h b/source/gfx/tui.h
index 2b7d3f7..a503b08 100644
--- a/source/gfx/tui.h
+++ b/source/gfx/tui.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
-* Copyright (C) 2018 CTCaer
+* Copyright (c) 2018 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
diff --git a/source/hos/fss.c b/source/hos/fss.c
new file mode 100644
index 0000000..8e255ea
--- /dev/null
+++ b/source/hos/fss.c
@@ -0,0 +1,247 @@
+/*
+ * Atmosphère Fusée Secondary Storage parser.
+ *
+ * Copyright (c) 2019-2020 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+
+#include "fss.h"
+// #include "hos.h"
+#include "../config/config.h"
+#include "../libs/fatfs/ff.h"
+#include "../mem/heap.h"
+#include "../storage/emummc.h"
+#include "../storage/nx_sd.h"
+
+#include "../gfx/gfx.h"
+#define DPRINTF(...)
+
+extern hekate_config h_cfg;
+
+extern bool is_ipl_updated(void *buf, char *path, bool force);
+
+// FSS0 Magic and Meta header offset.
+#define FSS0_MAGIC 0x30535346
+#define FSS0_META_OFFSET 0x4
+
+// FSS0 Content Types.
+#define CNT_TYPE_FSP 0
+#define CNT_TYPE_EXO 1 // Exosphere (Secure Monitor).
+#define CNT_TYPE_WBT 2 // Warmboot (SC7Exit fw).
+#define CNT_TYPE_RBT 3 // Rebootstub (Warmboot based reboot fw).
+#define CNT_TYPE_SP1 4 // Sept Primary (TSEC and Sept Secondary loader).
+#define CNT_TYPE_SP2 5 // Sept Secondary (Acts as pkg11 and derives keys).
+#define CNT_TYPE_KIP 6 // KIP1 (Used for replacement or addition).
+#define CNT_TYPE_BMP 7
+#define CNT_TYPE_EMC 8
+#define CNT_TYPE_KLD 9 // Kernel Loader.
+#define CNT_TYPE_KRN 10 // Kernel.
+
+// FSS0 Content Flags.
+#define CNT_FLAG0_EXPERIMENTAL (1 << 0)
+
+// FSS0 Meta Header.
+typedef struct _fss_meta_t
+{
+ u32 magic;
+ u32 size;
+ u32 crt0_off;
+ u32 cnt_off;
+ u32 cnt_count;
+ u32 hos_ver;
+ u32 version;
+ u32 git_rev;
+} fss_meta_t;
+
+// FSS0 Content Header.
+typedef struct _fss_content_t
+{
+ u32 offset;
+ u32 size;
+ u8 type;
+ u8 flags0;
+ u8 flags1;
+ u8 flags2;
+ u32 rsvd1;
+ char name[0x10];
+} fss_content_t;
+
+static void _update_r2p(const char *path)
+{
+ char *r2p_path = malloc(256);
+ u32 path_len = strlen(path);
+ strcpy(r2p_path, path);
+
+ while(path_len)
+ {
+ if ((r2p_path[path_len - 1] == '/') || (r2p_path[path_len - 1] == 0x5C))
+ {
+ r2p_path[path_len] = 0;
+ strcat(r2p_path, "reboot_payload.bin");
+ u8 *r2p_payload = sd_file_read(r2p_path, NULL);
+
+ is_ipl_updated(r2p_payload, r2p_path, h_cfg.updater2p ? true : false);
+
+ free(r2p_payload);
+ break;
+ }
+ path_len--;
+ }
+
+ free(r2p_path);
+}
+
+int parse_fss(launch_ctxt_t *ctxt, const char *path, fss0_sept_t *sept_ctxt)
+{
+ FIL fp;
+
+ bool stock = false;
+ int sept_used = 0;
+
+ if (!sept_ctxt)
+ {
+ LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link)
+ {
+ if (!strcmp("stock", kv->key))
+ if (kv->val[0] == '1')
+ stock = true;
+ }
+
+ if (stock && ctxt->pkg1_id->kb <= KB_FIRMWARE_VERSION_620 && (!emu_cfg.enabled || h_cfg.emummc_force_disable))
+ return 1;
+ }
+
+ if (f_open(&fp, path, FA_READ) != FR_OK)
+ return 0;
+
+ void *fss = malloc(f_size(&fp));
+
+ // Read first 1024 bytes of the fss file.
+ f_read(&fp, fss, 1024, NULL);
+
+ // Get FSS0 Meta header offset.
+ u32 fss_meta_addr = *(u32 *)(fss + FSS0_META_OFFSET);
+ fss_meta_t *fss_meta = (fss_meta_t *)(fss + fss_meta_addr);
+
+ // Check if valid FSS0 and parse it.
+ if (fss_meta->magic == FSS0_MAGIC)
+ {
+ gfx_printf("Found FSS0, Atmosphere %d.%d.%d-%08x\n"
+ "Max HOS supported: %d.%d.%d\n"
+ "Unpacking and loading components.. ",
+ fss_meta->version >> 24, (fss_meta->version >> 16) & 0xFF, (fss_meta->version >> 8) & 0xFF, fss_meta->git_rev,
+ fss_meta->hos_ver >> 24, (fss_meta->hos_ver >> 16) & 0xFF, (fss_meta->hos_ver >> 8) & 0xFF);
+
+ if (!sept_ctxt)
+ {
+ ctxt->atmosphere = true;
+ ctxt->fss0_hosver = fss_meta->hos_ver;
+ }
+
+ // Parse FSS0 contents.
+ fss_content_t *curr_fss_cnt = (fss_content_t *)(fss + fss_meta->cnt_off);
+ void *content;
+ for (u32 i = 0; i < fss_meta->cnt_count; i++)
+ {
+ content = (void *)(fss + curr_fss_cnt[i].offset);
+
+ // Check if offset is inside limits.
+ if ((curr_fss_cnt[i].offset + curr_fss_cnt[i].size) > fss_meta->size)
+ continue;
+
+ // If content is experimental and experimental flag is not enabled, skip it.
+ if ((curr_fss_cnt[i].flags0 & CNT_FLAG0_EXPERIMENTAL) && !ctxt->fss0_enable_experimental)
+ continue;
+
+ // Parse content.
+ if (!sept_ctxt)
+ {
+ // Prepare content context.
+ switch (curr_fss_cnt[i].type)
+ {
+ case CNT_TYPE_KIP:
+ if (stock)
+ continue;
+ merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
+ mkip1->kip1 = content;
+ list_append(&ctxt->kip1_list, &mkip1->link);
+ DPRINTF("Loaded %s.kip1 from FSS0 (size %08X)\n", curr_fss_cnt[i].name, curr_fss_cnt[i].size);
+ break;
+ case CNT_TYPE_EXO:
+ ctxt->secmon_size = curr_fss_cnt[i].size;
+ ctxt->secmon = content;
+ break;
+ case CNT_TYPE_WBT:
+ ctxt->warmboot_size = curr_fss_cnt[i].size;
+ ctxt->warmboot = content;
+ break;
+ default:
+ continue;
+ }
+
+ // Load content to launch context.
+ f_lseek(&fp, curr_fss_cnt[i].offset);
+ f_read(&fp, content, curr_fss_cnt[i].size, NULL);
+ }
+ else
+ {
+ // Load sept content directly to launch context.
+ switch (curr_fss_cnt[i].type)
+ {
+ case CNT_TYPE_SP1:
+ f_lseek(&fp, curr_fss_cnt[i].offset);
+ f_read(&fp, sept_ctxt->sept_primary, curr_fss_cnt[i].size, NULL);
+ break;
+ case CNT_TYPE_SP2:
+ if (!memcmp(curr_fss_cnt[i].name, (sept_ctxt->kb < KB_FIRMWARE_VERSION_810) ? "septsecondary00" : "septsecondary01", 15))
+ {
+ f_lseek(&fp, curr_fss_cnt[i].offset);
+ f_read(&fp, sept_ctxt->sept_secondary, curr_fss_cnt[i].size, NULL);
+ sept_used = 1;
+ goto out;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+out:
+ gfx_printf("Done!\n");
+ f_close(&fp);
+
+ _update_r2p(path);
+
+ return (!sept_ctxt ? 1 : sept_used);
+ }
+
+ f_close(&fp);
+ free(fss);
+
+ return 0;
+}
+
+int load_sept_from_ffs0(fss0_sept_t *sept_ctxt)
+{
+ LIST_FOREACH_ENTRY(ini_kv_t, kv, &sept_ctxt->cfg_sec->kvs, link)
+ {
+ if (!strcmp("fss0", kv->key))
+ return parse_fss(NULL, kv->val, sept_ctxt);
+ }
+
+ return 0;
+}
diff --git a/source/hos/fss.h b/source/hos/fss.h
new file mode 100644
index 0000000..3f56d7c
--- /dev/null
+++ b/source/hos/fss.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _FSS_H_
+#define _FSS_H_
+
+#include "hos.h"
+
+typedef struct _fss0_sept_t
+{
+ u32 kb;
+ ini_sec_t *cfg_sec;
+ void *sept_primary;
+ void *sept_secondary;
+
+} fss0_sept_t;
+
+int parse_fss(launch_ctxt_t *ctxt, const char *path, fss0_sept_t *sept_ctxt);
+int load_sept_from_ffs0(fss0_sept_t *sept_ctxt);
+
+#endif
diff --git a/source/hos/hos.h b/source/hos/hos.h
new file mode 100644
index 0000000..d2c8712
--- /dev/null
+++ b/source/hos/hos.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2020 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _HOS_H_
+#define _HOS_H_
+
+#include "pkg1.h"
+#include "pkg2.h"
+#include "../utils/types.h"
+#include "../config/ini.h"
+#include "../sec/tsec.h"
+
+#include
+
+#define KB_FIRMWARE_VERSION_100_200 0
+#define KB_FIRMWARE_VERSION_300 1
+#define KB_FIRMWARE_VERSION_301 2
+#define KB_FIRMWARE_VERSION_400 3
+#define KB_FIRMWARE_VERSION_500 4
+#define KB_FIRMWARE_VERSION_600 5
+#define KB_FIRMWARE_VERSION_620 6
+#define KB_FIRMWARE_VERSION_700 7
+#define KB_FIRMWARE_VERSION_810 8
+#define KB_FIRMWARE_VERSION_900 9
+#define KB_FIRMWARE_VERSION_910 10
+#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_910
+
+#define HOS_PKG11_MAGIC 0x31314B50
+#define HOS_EKS_MAGIC 0x30534B45
+
+typedef struct _exo_ctxt_t
+{
+ bool no_user_exceptions;
+ bool user_pmu;
+ bool *cal0_blank;
+ bool *cal0_allow_writes_sys;
+} exo_ctxt_t;
+
+typedef struct _hos_eks_keys_t
+{
+ u8 dkg[0x10];
+ u8 mkk[0x10];
+ u8 fdk[0x10];
+ u8 dkk[0x10];
+} hos_eks_keys_t;
+
+typedef struct _hos_eks_mbr_t
+{
+ u32 magic;
+ u32 enabled;
+ u32 sbk_low[2];
+ hos_eks_keys_t keys[6];
+ u32 magic2;
+ u32 rsvd2[3];
+} hos_eks_mbr_t;
+
+static_assert(sizeof(hos_eks_mbr_t) == 416, "HOS EKS storage bigger than MBR!");
+
+typedef struct _launch_ctxt_t
+{
+ void *keyblob;
+
+ void *pkg1;
+ const pkg1_id_t *pkg1_id;
+ const pkg2_kernel_id_t *pkg2_kernel_id;
+
+ void *warmboot;
+ u32 warmboot_size;
+ void *secmon;
+ u32 secmon_size;
+
+ void *pkg2;
+ u32 pkg2_size;
+ bool new_pkg2;
+
+ void *kernel;
+ u32 kernel_size;
+ link_t kip1_list;
+ char* kip1_patches;
+
+ u32 fss0_hosver;
+ bool svcperm;
+ bool debugmode;
+ bool stock;
+ bool atmosphere;
+ bool fss0_enable_experimental;
+ bool emummc_forced;
+
+ exo_ctxt_t exo_cfg;
+
+ ini_sec_t *cfg;
+} launch_ctxt_t;
+
+typedef struct _merge_kip_t
+{
+ void *kip1;
+ link_t link;
+} merge_kip_t;
+
+void hos_eks_get();
+void hos_eks_save(u32 kb);
+void hos_eks_clear(u32 kb);
+int hos_launch(ini_sec_t *cfg);
+int hos_keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, launch_ctxt_t *hos_ctxt);
+
+#endif
diff --git a/source/hos/pkg2.c b/source/hos/pkg2.c
index bc77d1e..09ebb67 100644
--- a/source/hos/pkg2.c
+++ b/source/hos/pkg2.c
@@ -26,6 +26,10 @@
#include "../gfx/gfx.h"
+u32 pkg2_newkern_ini1_val;
+u32 pkg2_newkern_ini1_start;
+u32 pkg2_newkern_ini1_end;
+
/*#include "util.h"
#define DPRINTF(...) gfx_printf(__VA_ARGS__)
#define DEBUG_PRINTING*/
diff --git a/source/hos/pkg2.h b/source/hos/pkg2.h
index ba6a8a0..96e8fe5 100644
--- a/source/hos/pkg2.h
+++ b/source/hos/pkg2.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (C) 2018-2020 CTCaer
+ * Copyright (c) 2018-2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -28,9 +28,17 @@
#define PKG2_NEWKERN_GET_INI1_HEURISTIC 0xD2800015 // Offset of OP + 12 is the INI1 offset.
-u32 pkg2_newkern_ini1_val;
-u32 pkg2_newkern_ini1_start;
-u32 pkg2_newkern_ini1_end;
+extern u32 pkg2_newkern_ini1_val;
+extern u32 pkg2_newkern_ini1_start;
+extern u32 pkg2_newkern_ini1_end;
+
+typedef struct _kernel_patch_t
+{
+ u32 id;
+ u32 off;
+ u32 val;
+ u32 *ptr;
+} kernel_patch_t;
typedef struct _pkg2_hdr_t
{
@@ -87,6 +95,12 @@ typedef struct _pkg2_kip1_info_t
link_t link;
} pkg2_kip1_info_t;
+typedef struct _pkg2_kernel_id_t
+{
+ u8 hash[8];
+ kernel_patch_t *kernel_patchset;
+} pkg2_kernel_id_t;
+
bool pkg2_parse_kips(link_t *info, pkg2_hdr_t *pkg2, bool *new_pkg2);
int pkg2_decompress_kip(pkg2_kip1_info_t* ki, u32 sectsToDecomp);
pkg2_hdr_t *pkg2_decrypt(void *data);
diff --git a/source/hos/sept.c b/source/hos/sept.c
index 2a30f16..4d4c6fa 100644
--- a/source/hos/sept.c
+++ b/source/hos/sept.c
@@ -18,12 +18,14 @@
#include "sept.h"
#include "../gfx/di.h"
+#include "../hos/hos.h"
#include "../libs/fatfs/ff.h"
#include "../mem/heap.h"
#include "../soc/hw_init.h"
#include "../soc/pmc.h"
#include "../soc/t210.h"
#include "../storage/nx_emmc.h"
+#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/btn.h"
#include "../utils/types.h"
@@ -58,7 +60,6 @@ u8 warmboot_reboot[] = {
extern u32 color_idx;
extern boot_cfg_t b_cfg;
-extern void sd_unmount();
extern void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size);
int reboot_to_sept(const u8 *tsec_fw, const u32 tsec_size, const u32 kb)
diff --git a/source/ianos/ianos.c b/source/ianos/ianos.c
index 18d4165..85ac9c9 100644
--- a/source/ianos/ianos.c
+++ b/source/ianos/ianos.c
@@ -18,21 +18,18 @@
#include
#include "ianos.h"
-#include "../utils/types.h"
-#include "../libs/elfload/elfload.h"
#include "../../common/common_module.h"
-#include "../mem/heap.h"
#include "../gfx/gfx.h"
+#include "../libs/elfload/elfload.h"
+#include "../mem/heap.h"
+#include "../storage/nx_sd.h"
+#include "../utils/types.h"
#define IRAM_LIB_ADDR 0x4002B000
#define DRAM_LIB_ADDR 0xE0000000
extern heap_t _heap;
-extern void *sd_file_read(const char *path, u32 *fsize);
-extern bool sd_mount();
-extern void sd_unmount();
-
void *elfBuf = NULL;
void *fileBuf = NULL;
diff --git a/source/keys/keys.c b/source/keys/keys.c
index f54915b..5097a10 100644
--- a/source/keys/keys.c
+++ b/source/keys/keys.c
@@ -20,6 +20,7 @@
#include "../gfx/di.h"
#include "../gfx/gfx.h"
#include "../gfx/tui.h"
+#include "../hos/hos.h"
#include "../hos/pkg1.h"
#include "../hos/pkg2.h"
#include "../hos/sept.h"
@@ -36,6 +37,7 @@
#include "../soc/t210.h"
#include "../storage/emummc.h"
#include "../storage/nx_emmc.h"
+#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/btn.h"
#include "../utils/list.h"
@@ -47,10 +49,6 @@
#include
-extern bool sd_mount();
-extern void sd_unmount();
-extern int sd_save_to_file(void *buf, u32 size, const char *filename);
-
extern hekate_config h_cfg;
extern bool clear_sector_cache;
@@ -149,7 +147,7 @@ void dump_keys() {
tsec_ctxt_t tsec_ctxt;
sdmmc_t sdmmc;
- if (!emummc_storage_init_mmc(&storage, &sdmmc)) {
+ if (emummc_storage_init_mmc(&storage, &sdmmc)) {
EPRINTF("Unable to init MMC.");
goto out_wait;
}
@@ -157,7 +155,7 @@ void dump_keys() {
// Read package1.
u8 *pkg1 = (u8 *)malloc(0x40000);
- emummc_storage_set_mmc_partition(&storage, 1);
+ emummc_storage_set_mmc_partition(&storage, EMMC_BOOT0);
emummc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1);
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
if (!pkg1_id) {
@@ -220,11 +218,13 @@ void dump_keys() {
EPRINTF("Unable to open /sept/payload.bin to write.");
goto out_wait;
}
+ gfx_printf("%kWrite self to /sept/payload.bin...", colors[(color_idx++) % 6]);
if (f_write(&fp, (u8 *)IPL_LOAD_ADDR, payload_size, NULL)) {
EPRINTF("Unable to write self to /sept/payload.bin.");
f_close(&fp);
goto out_wait;
}
+ gfx_printf(" done");
f_close(&fp);
gfx_printf("%k\nFirmware 7.x or higher detected.\n\n", colors[(color_idx++) % 6]);
gfx_printf("%kRenamed /sept/payload.bin", colors[(color_idx++) % 6]);
@@ -388,7 +388,7 @@ get_tsec: ;
u8 *pkg2 = NULL;
pkg2_kip1_info_t *ki = NULL;
- emummc_storage_set_mmc_partition(&storage, 0);
+ emummc_storage_set_mmc_partition(&storage, EMMC_GPP);
// Parse eMMC GPT.
LIST_INIT(gpt);
nx_emmc_gpt_parse(&gpt, &storage);
diff --git a/source/keys/save.c b/source/keys/save.c
index 763c45b..8e11c9a 100644
--- a/source/keys/save.c
+++ b/source/keys/save.c
@@ -351,7 +351,7 @@ void save_allocation_table_iterator_begin(allocation_table_iterator_ctx_t *ctx,
ctx->physical_block = initial_block;
ctx->virtual_block = 0;
- allocation_table_entry_t entry;
+ allocation_table_entry_t entry = {0, 0};
entry.next = initial_block;
ctx->current_segment_size = save_allocation_table_read_entry_with_length(ctx->fat, &entry);
ctx->next_block = entry.next;
@@ -369,7 +369,7 @@ int save_allocation_table_iterator_move_next(allocation_table_iterator_ctx_t *ct
ctx->virtual_block += ctx->current_segment_size;
ctx->physical_block = ctx->next_block;
- allocation_table_entry_t entry;
+ allocation_table_entry_t entry = {0, 0};
entry.next = ctx->next_block;
ctx->current_segment_size = save_allocation_table_read_entry_with_length(ctx->fat, &entry);
ctx->next_block = entry.next;
@@ -383,7 +383,7 @@ int save_allocation_table_iterator_move_prev(allocation_table_iterator_ctx_t *ct
ctx->physical_block = ctx->prev_block;
- allocation_table_entry_t entry;
+ allocation_table_entry_t entry = {0, 0};
entry.next = ctx->prev_block;
ctx->current_segment_size = save_allocation_table_read_entry_with_length(ctx->fat, &entry);
ctx->next_block = entry.next;
diff --git a/source/libs/compr/blz.c b/source/libs/compr/blz.c
index 226d011..685ef4a 100644
--- a/source/libs/compr/blz.c
+++ b/source/libs/compr/blz.c
@@ -15,6 +15,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include "blz.h"
diff --git a/source/libs/fatfs/ffconf.h b/source/libs/fatfs/ffconf.h
index cd8bef0..ebd7f22 100644
--- a/source/libs/fatfs/ffconf.h
+++ b/source/libs/fatfs/ffconf.h
@@ -43,7 +43,7 @@
#define FF_FASTFS 0
-#ifdef FF_FASTFS
+#if FF_FASTFS
#define FF_USE_FASTSEEK 1
#else
#define FF_USE_FASTSEEK 0
diff --git a/source/main.c b/source/main.c
index 5ad772d..855a4af 100644
--- a/source/main.c
+++ b/source/main.c
@@ -33,6 +33,7 @@
#include "soc/hw_init.h"
#include "storage/emummc.h"
#include "storage/nx_emmc.h"
+#include "storage/nx_sd.h"
#include "storage/sdmmc.h"
#include "utils/btn.h"
#include "utils/dirlist.h"
@@ -41,95 +42,11 @@
#include "keys/keys.h"
-sdmmc_t sd_sdmmc;
-sdmmc_storage_t sd_storage;
-__attribute__ ((aligned (16))) FATFS sd_fs;
-static bool sd_mounted;
-
hekate_config h_cfg;
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
-bool sd_mount()
-{
- if (sd_mounted)
- return true;
-
- if (!sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
- {
- EPRINTF("Failed to init SD card.\nMake sure that it is inserted.\nOr that SD reader is properly seated!");
- }
- else
- {
- int res = 0;
- res = f_mount(&sd_fs, "sd:", 1);
- if (res == FR_OK)
- {
- sd_mounted = 1;
- return true;
- }
- else
- {
- EPRINTFARGS("Failed to mount SD card (FatFS Error %d).\nMake sure that a FAT partition exists..", res);
- }
- }
-
- return false;
-}
-
-void sd_unmount()
-{
- if (sd_mounted)
- {
- f_mount(NULL, "sd:", 1);
- sdmmc_storage_end(&sd_storage);
- sd_mounted = false;
- }
-}
-
-void *sd_file_read(const char *path, u32 *fsize)
-{
- FIL fp;
- if (f_open(&fp, path, FA_READ) != FR_OK)
- return NULL;
-
- u32 size = f_size(&fp);
- if (fsize)
- *fsize = size;
-
- void *buf = malloc(size);
-
- if (f_read(&fp, buf, size, NULL) != FR_OK)
- {
- free(buf);
- f_close(&fp);
-
- return NULL;
- }
-
- f_close(&fp);
-
- return buf;
-}
-
-int sd_save_to_file(void *buf, u32 size, const char *filename)
-{
- FIL fp;
- u32 res = 0;
- res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
- if (res)
- {
- EPRINTFARGS("Error (%d) creating file\n%s.\n", res, filename);
- return res;
- }
-
- f_write(&fp, buf, size, NULL);
- f_close(&fp);
-
- return 0;
-}
-
// This is a safe and unused DRAM region for our payloads.
#define RELOC_META_OFF 0x7C
#define PATCHED_RELOC_SZ 0x94
@@ -376,9 +293,9 @@ void _get_key_generations(char *sysnand_label, char *emunand_label)
{
sdmmc_t sdmmc;
sdmmc_storage_t storage;
- sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);
+ sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400);
u8 *pkg1 = (u8 *)malloc(NX_EMMC_BLOCKSIZE);
- sdmmc_storage_set_mmc_partition(&storage, 1);
+ sdmmc_storage_set_mmc_partition(&storage, EMMC_BOOT0);
sdmmc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 1, pkg1);
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
sdmmc_storage_end(&storage);
@@ -394,7 +311,7 @@ void _get_key_generations(char *sysnand_label, char *emunand_label)
emummc_storage_init_mmc(&storage, &sdmmc);
memset(pkg1, 0, NX_EMMC_BLOCKSIZE);
- emummc_storage_set_mmc_partition(&storage, 1);
+ emummc_storage_set_mmc_partition(&storage, EMMC_BOOT0);
emummc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 1, pkg1);
pkg1_id = pkg1_identify(pkg1);
emummc_storage_end(&storage);
diff --git a/source/mem/emc.h b/source/mem/emc.h
index 88e9da9..9be6fe8 100644
--- a/source/mem/emc.h
+++ b/source/mem/emc.h
@@ -2,6 +2,7 @@
* arch/arm/mach-tegra/tegra21_emc.h
*
* Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2019-2020, CTCaer.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,117 +23,117 @@
#ifndef _EMC_H_
#define _EMC_H_
-#define EMC_DBG 0x8
-#define EMC_CFG 0xC
-#define EMC_CONFIG_SAMPLE_DELAY 0x5f0
-#define EMC_CFG_UPDATE 0x5f4
-#define EMC_ADR_CFG 0x10
-#define EMC_REFCTRL 0x20
-#define EMC_PIN 0x24
-#define EMC_TIMING_CONTROL 0x28
-#define EMC_RC 0x2c
-#define EMC_RFC 0x30
-#define EMC_RFCPB 0x590
-#define EMC_RAS 0x34
-#define EMC_RP 0x38
-#define EMC_R2W 0x3c
-#define EMC_W2R 0x40
-#define EMC_R2P 0x44
-#define EMC_W2P 0x48
-#define EMC_CCDMW 0x5c0
-#define EMC_RD_RCD 0x4c
-#define EMC_WR_RCD 0x50
-#define EMC_RRD 0x54
-#define EMC_REXT 0x58
-#define EMC_WDV 0x5c
-#define EMC_QUSE 0x60
-#define EMC_QRST 0x64
-#define EMC_ISSUE_QRST 0x428
-#define EMC_QSAFE 0x68
-#define EMC_RDV 0x6c
-#define EMC_REFRESH 0x70
-#define EMC_BURST_REFRESH_NUM 0x74
-#define EMC_PDEX2WR 0x78
-#define EMC_PDEX2RD 0x7c
-#define EMC_PDEX2CKE 0x118
-#define EMC_PCHG2PDEN 0x80
-#define EMC_ACT2PDEN 0x84
-#define EMC_AR2PDEN 0x88
-#define EMC_RW2PDEN 0x8c
-#define EMC_CKE2PDEN 0x11c
-#define EMC_TXSR 0x90
-#define EMC_TCKE 0x94
-#define EMC_TFAW 0x98
-#define EMC_TRPAB 0x9c
-#define EMC_TCLKSTABLE 0xa0
-#define EMC_TCLKSTOP 0xa4
-#define EMC_TREFBW 0xa8
-#define EMC_TPPD 0xac
-#define EMC_PDEX2MRR 0xb4
-#define EMC_ODT_WRITE 0xb0
-#define EMC_WEXT 0xb8
-#define EMC_RFC_SLR 0xc0
-#define EMC_MRS_WAIT_CNT2 0xc4
-#define EMC_MRS_WAIT_CNT 0xc8
-#define EMC_MRS 0xcc
-#define EMC_EMRS 0xd0
-#define EMC_REF 0xd4
-#define EMC_PRE 0xd8
-#define EMC_NOP 0xdc
-#define EMC_SELF_REF 0xe0
-#define EMC_DPD 0xe4
-#define EMC_MRW 0xe8
-#define EMC_MRR 0xec
-#define EMC_CMDQ 0xf0
-#define EMC_MC2EMCQ 0xf4
-#define EMC_FBIO_SPARE 0x100
-#define EMC_FBIO_CFG5 0x104
-#define EMC_CFG_RSV 0x120
-#define EMC_ACPD_CONTROL 0x124
-#define EMC_MPC 0x128
-#define EMC_EMRS2 0x12c
-#define EMC_EMRS3 0x130
-#define EMC_MRW2 0x134
-#define EMC_MRW3 0x138
-#define EMC_MRW4 0x13c
-#define EMC_MRW5 0x4a0
-#define EMC_MRW6 0x4a4
-#define EMC_MRW7 0x4a8
-#define EMC_MRW8 0x4ac
-#define EMC_MRW9 0x4b0
-#define EMC_MRW10 0x4b4
-#define EMC_MRW11 0x4b8
-#define EMC_MRW12 0x4bc
-#define EMC_MRW13 0x4c0
-#define EMC_MRW14 0x4c4
-#define EMC_MRW15 0x4d0
-#define EMC_CFG_SYNC 0x4d4
-#define EMC_CLKEN_OVERRIDE 0x140
-#define EMC_R2R 0x144
-#define EMC_W2W 0x148
-#define EMC_EINPUT 0x14c
-#define EMC_EINPUT_DURATION 0x150
-#define EMC_PUTERM_EXTRA 0x154
-#define EMC_TCKESR 0x158
-#define EMC_TPD 0x15c
-#define EMC_STAT_CONTROL 0x160
-#define EMC_STAT_STATUS 0x164
-#define EMC_STAT_DRAM_CLOCK_LIMIT_LO 0x19c
-#define EMC_STAT_DRAM_CLOCK_LIMIT_HI 0x1a0
-#define EMC_STAT_DRAM_CLOCKS_LO 0x1a4
-#define EMC_STAT_DRAM_CLOCKS_HI 0x1a8
-#define EMC_STAT_DRAM_DEV0_ACTIVATE_CNT_LO 0x1ac
-#define EMC_STAT_DRAM_DEV0_ACTIVATE_CNT_HI 0x1b0
-#define EMC_STAT_DRAM_DEV0_READ_CNT_LO 0x1b4
-#define EMC_STAT_DRAM_DEV0_READ_CNT_HI 0x1b8
-#define EMC_STAT_DRAM_DEV0_READ8_CNT_LO 0x1bc
-#define EMC_STAT_DRAM_DEV0_READ8_CNT_HI 0x1c0
-#define EMC_STAT_DRAM_DEV0_WRITE_CNT_LO 0x1c4
-#define EMC_STAT_DRAM_DEV0_WRITE_CNT_HI 0x1c8
-#define EMC_STAT_DRAM_DEV0_WRITE8_CNT_LO 0x1cc
-#define EMC_STAT_DRAM_DEV0_WRITE8_CNT_HI 0x1d0
-#define EMC_STAT_DRAM_DEV0_REF_CNT_LO 0x1d4
-#define EMC_STAT_DRAM_DEV0_REF_CNT_HI 0x1d8
+#define EMC_DBG 0x8
+#define EMC_CFG 0xC
+#define EMC_CONFIG_SAMPLE_DELAY 0x5f0
+#define EMC_CFG_UPDATE 0x5f4
+#define EMC_ADR_CFG 0x10
+#define EMC_REFCTRL 0x20
+#define EMC_PIN 0x24
+#define EMC_TIMING_CONTROL 0x28
+#define EMC_RC 0x2c
+#define EMC_RFC 0x30
+#define EMC_RFCPB 0x590
+#define EMC_RAS 0x34
+#define EMC_RP 0x38
+#define EMC_R2W 0x3c
+#define EMC_W2R 0x40
+#define EMC_R2P 0x44
+#define EMC_W2P 0x48
+#define EMC_CCDMW 0x5c0
+#define EMC_RD_RCD 0x4c
+#define EMC_WR_RCD 0x50
+#define EMC_RRD 0x54
+#define EMC_REXT 0x58
+#define EMC_WDV 0x5c
+#define EMC_QUSE 0x60
+#define EMC_QRST 0x64
+#define EMC_ISSUE_QRST 0x428
+#define EMC_QSAFE 0x68
+#define EMC_RDV 0x6c
+#define EMC_REFRESH 0x70
+#define EMC_BURST_REFRESH_NUM 0x74
+#define EMC_PDEX2WR 0x78
+#define EMC_PDEX2RD 0x7c
+#define EMC_PDEX2CKE 0x118
+#define EMC_PCHG2PDEN 0x80
+#define EMC_ACT2PDEN 0x84
+#define EMC_AR2PDEN 0x88
+#define EMC_RW2PDEN 0x8c
+#define EMC_CKE2PDEN 0x11c
+#define EMC_TXSR 0x90
+#define EMC_TCKE 0x94
+#define EMC_TFAW 0x98
+#define EMC_TRPAB 0x9c
+#define EMC_TCLKSTABLE 0xa0
+#define EMC_TCLKSTOP 0xa4
+#define EMC_TREFBW 0xa8
+#define EMC_TPPD 0xac
+#define EMC_PDEX2MRR 0xb4
+#define EMC_ODT_WRITE 0xb0
+#define EMC_WEXT 0xb8
+#define EMC_RFC_SLR 0xc0
+#define EMC_MRS_WAIT_CNT2 0xc4
+#define EMC_MRS_WAIT_CNT 0xc8
+#define EMC_MRS 0xcc
+#define EMC_EMRS 0xd0
+#define EMC_REF 0xd4
+#define EMC_PRE 0xd8
+#define EMC_NOP 0xdc
+#define EMC_SELF_REF 0xe0
+#define EMC_DPD 0xe4
+#define EMC_MRW 0xe8
+#define EMC_MRR 0xec
+#define EMC_CMDQ 0xf0
+#define EMC_MC2EMCQ 0xf4
+#define EMC_FBIO_SPARE 0x100
+#define EMC_FBIO_CFG5 0x104
+#define EMC_CFG_RSV 0x120
+#define EMC_ACPD_CONTROL 0x124
+#define EMC_MPC 0x128
+#define EMC_EMRS2 0x12c
+#define EMC_EMRS3 0x130
+#define EMC_MRW2 0x134
+#define EMC_MRW3 0x138
+#define EMC_MRW4 0x13c
+#define EMC_MRW5 0x4a0
+#define EMC_MRW6 0x4a4
+#define EMC_MRW7 0x4a8
+#define EMC_MRW8 0x4ac
+#define EMC_MRW9 0x4b0
+#define EMC_MRW10 0x4b4
+#define EMC_MRW11 0x4b8
+#define EMC_MRW12 0x4bc
+#define EMC_MRW13 0x4c0
+#define EMC_MRW14 0x4c4
+#define EMC_MRW15 0x4d0
+#define EMC_CFG_SYNC 0x4d4
+#define EMC_CLKEN_OVERRIDE 0x140
+#define EMC_R2R 0x144
+#define EMC_W2W 0x148
+#define EMC_EINPUT 0x14c
+#define EMC_EINPUT_DURATION 0x150
+#define EMC_PUTERM_EXTRA 0x154
+#define EMC_TCKESR 0x158
+#define EMC_TPD 0x15c
+#define EMC_STAT_CONTROL 0x160
+#define EMC_STAT_STATUS 0x164
+#define EMC_STAT_DRAM_CLOCK_LIMIT_LO 0x19c
+#define EMC_STAT_DRAM_CLOCK_LIMIT_HI 0x1a0
+#define EMC_STAT_DRAM_CLOCKS_LO 0x1a4
+#define EMC_STAT_DRAM_CLOCKS_HI 0x1a8
+#define EMC_STAT_DRAM_DEV0_ACTIVATE_CNT_LO 0x1ac
+#define EMC_STAT_DRAM_DEV0_ACTIVATE_CNT_HI 0x1b0
+#define EMC_STAT_DRAM_DEV0_READ_CNT_LO 0x1b4
+#define EMC_STAT_DRAM_DEV0_READ_CNT_HI 0x1b8
+#define EMC_STAT_DRAM_DEV0_READ8_CNT_LO 0x1bc
+#define EMC_STAT_DRAM_DEV0_READ8_CNT_HI 0x1c0
+#define EMC_STAT_DRAM_DEV0_WRITE_CNT_LO 0x1c4
+#define EMC_STAT_DRAM_DEV0_WRITE_CNT_HI 0x1c8
+#define EMC_STAT_DRAM_DEV0_WRITE8_CNT_LO 0x1cc
+#define EMC_STAT_DRAM_DEV0_WRITE8_CNT_HI 0x1d0
+#define EMC_STAT_DRAM_DEV0_REF_CNT_LO 0x1d4
+#define EMC_STAT_DRAM_DEV0_REF_CNT_HI 0x1d8
#define EMC_STAT_DRAM_DEV0_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0x1dc
#define EMC_STAT_DRAM_DEV0_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_HI 0x1e0
#define EMC_STAT_DRAM_DEV0_CLKSTOP_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0x1e4
@@ -149,21 +150,21 @@
#define EMC_STAT_DRAM_DEV0_EXTCLKS_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0x210
#define EMC_STAT_DRAM_DEV0_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_LO 0x214
#define EMC_STAT_DRAM_DEV0_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0x218
-#define EMC_STAT_DRAM_DEV0_SR_CKE_EQ0_CLKS_LO 0x21c
-#define EMC_STAT_DRAM_DEV0_SR_CKE_EQ0_CLKS_HI 0x220
-#define EMC_STAT_DRAM_DEV0_DSR 0x224
-#define EMC_STAT_DRAM_DEV1_ACTIVATE_CNT_LO 0x228
-#define EMC_STAT_DRAM_DEV1_ACTIVATE_CNT_HI 0x22c
-#define EMC_STAT_DRAM_DEV1_READ_CNT_LO 0x230
-#define EMC_STAT_DRAM_DEV1_READ_CNT_HI 0x234
-#define EMC_STAT_DRAM_DEV1_READ8_CNT_LO 0x238
-#define EMC_STAT_DRAM_DEV1_READ8_CNT_HI 0x23c
-#define EMC_STAT_DRAM_DEV1_WRITE_CNT_LO 0x240
-#define EMC_STAT_DRAM_DEV1_WRITE_CNT_HI 0x244
-#define EMC_STAT_DRAM_DEV1_WRITE8_CNT_LO 0x248
-#define EMC_STAT_DRAM_DEV1_WRITE8_CNT_HI 0x24c
-#define EMC_STAT_DRAM_DEV1_REF_CNT_LO 0x250
-#define EMC_STAT_DRAM_DEV1_REF_CNT_HI 0x254
+#define EMC_STAT_DRAM_DEV0_SR_CKE_EQ0_CLKS_LO 0x21c
+#define EMC_STAT_DRAM_DEV0_SR_CKE_EQ0_CLKS_HI 0x220
+#define EMC_STAT_DRAM_DEV0_DSR 0x224
+#define EMC_STAT_DRAM_DEV1_ACTIVATE_CNT_LO 0x228
+#define EMC_STAT_DRAM_DEV1_ACTIVATE_CNT_HI 0x22c
+#define EMC_STAT_DRAM_DEV1_READ_CNT_LO 0x230
+#define EMC_STAT_DRAM_DEV1_READ_CNT_HI 0x234
+#define EMC_STAT_DRAM_DEV1_READ8_CNT_LO 0x238
+#define EMC_STAT_DRAM_DEV1_READ8_CNT_HI 0x23c
+#define EMC_STAT_DRAM_DEV1_WRITE_CNT_LO 0x240
+#define EMC_STAT_DRAM_DEV1_WRITE_CNT_HI 0x244
+#define EMC_STAT_DRAM_DEV1_WRITE8_CNT_LO 0x248
+#define EMC_STAT_DRAM_DEV1_WRITE8_CNT_HI 0x24c
+#define EMC_STAT_DRAM_DEV1_REF_CNT_LO 0x250
+#define EMC_STAT_DRAM_DEV1_REF_CNT_HI 0x254
#define EMC_STAT_DRAM_DEV1_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0x258
#define EMC_STAT_DRAM_DEV1_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_HI 0x25c
#define EMC_STAT_DRAM_DEV1_CLKSTOP_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0x260
@@ -180,9 +181,9 @@
#define EMC_STAT_DRAM_DEV1_EXTCLKS_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0x28c
#define EMC_STAT_DRAM_DEV1_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_LO 0x290
#define EMC_STAT_DRAM_DEV1_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0x294
-#define EMC_STAT_DRAM_DEV1_SR_CKE_EQ0_CLKS_LO 0x298
-#define EMC_STAT_DRAM_DEV1_SR_CKE_EQ0_CLKS_HI 0x29c
-#define EMC_STAT_DRAM_DEV1_DSR 0x2a0
+#define EMC_STAT_DRAM_DEV1_SR_CKE_EQ0_CLKS_LO 0x298
+#define EMC_STAT_DRAM_DEV1_SR_CKE_EQ0_CLKS_HI 0x29c
+#define EMC_STAT_DRAM_DEV1_DSR 0x2a0
#define EMC_STAT_DRAM_IO_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0xc8c
#define EMC_STAT_DRAM_IO_EXTCLKS_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_HI 0xc90
#define EMC_STAT_DRAM_IO_CLKSTOP_CKE_EQ0_NO_BANKS_ACTIVE_CLKS_LO 0xc94
@@ -199,469 +200,494 @@
#define EMC_STAT_DRAM_IO_EXTCLKS_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0xcc0
#define EMC_STAT_DRAM_IO_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_LO 0xcc4
#define EMC_STAT_DRAM_IO_CLKSTOP_CKE_EQ1_SOME_BANKS_ACTIVE_CLKS_HI 0xcc8
-#define EMC_STAT_DRAM_IO_SR_CKE_EQ0_CLKS_LO 0xccc
-#define EMC_STAT_DRAM_IO_SR_CKE_EQ0_CLKS_HI 0xcd0
-#define EMC_STAT_DRAM_IO_DSR 0xcd4
-#define EMC_AUTO_CAL_CONFIG 0x2a4
-#define EMC_AUTO_CAL_CONFIG2 0x458
-#define EMC_AUTO_CAL_CONFIG3 0x45c
-#define EMC_AUTO_CAL_CONFIG4 0x5b0
-#define EMC_AUTO_CAL_CONFIG5 0x5b4
-#define EMC_AUTO_CAL_CONFIG6 0x5cc
-#define EMC_AUTO_CAL_CONFIG7 0x574
-#define EMC_AUTO_CAL_CONFIG8 0x2dc
-#define EMC_AUTO_CAL_VREF_SEL_0 0x2f8
-#define EMC_AUTO_CAL_VREF_SEL_1 0x300
-#define EMC_AUTO_CAL_INTERVAL 0x2a8
-#define EMC_AUTO_CAL_STATUS 0x2ac
-#define EMC_AUTO_CAL_STATUS2 0x3d4
-#define EMC_AUTO_CAL_CHANNEL 0x464
-#define EMC_PMACRO_RX_TERM 0xc48
-#define EMC_PMACRO_DQ_TX_DRV 0xc70
-#define EMC_PMACRO_CA_TX_DRV 0xc74
-#define EMC_PMACRO_CMD_TX_DRV 0xc4c
-#define EMC_PMACRO_AUTOCAL_CFG_0 0x700
-#define EMC_PMACRO_AUTOCAL_CFG_1 0x704
-#define EMC_PMACRO_AUTOCAL_CFG_2 0x708
-#define EMC_PMACRO_AUTOCAL_CFG_COMMON 0xc78
-#define EMC_PMACRO_ZCTRL 0xc44
-#define EMC_XM2COMPPADCTRL 0x30c
-#define EMC_XM2COMPPADCTRL2 0x578
-#define EMC_XM2COMPPADCTRL3 0x2f4
-#define EMC_COMP_PAD_SW_CTRL 0x57c
-#define EMC_REQ_CTRL 0x2b0
-#define EMC_EMC_STATUS 0x2b4
-#define EMC_CFG_2 0x2b8
-#define EMC_CFG_DIG_DLL 0x2bc
-#define EMC_CFG_DIG_DLL_PERIOD 0x2c0
-#define EMC_DIG_DLL_STATUS 0x2c4
-#define EMC_CFG_DIG_DLL_1 0x2c8
-#define EMC_RDV_MASK 0x2cc
-#define EMC_WDV_MASK 0x2d0
-#define EMC_RDV_EARLY_MASK 0x2d4
-#define EMC_RDV_EARLY 0x2d8
-#define EMC_WDV_CHK 0x4e0
-#define EMC_ZCAL_INTERVAL 0x2e0
-#define EMC_ZCAL_WAIT_CNT 0x2e4
-#define EMC_ZCAL_MRW_CMD 0x2e8
-#define EMC_ZQ_CAL 0x2ec
-#define EMC_SCRATCH0 0x324
-#define EMC_STALL_THEN_EXE_BEFORE_CLKCHANGE 0x3c8
-#define EMC_STALL_THEN_EXE_AFTER_CLKCHANGE 0x3cc
-#define EMC_UNSTALL_RW_AFTER_CLKCHANGE 0x3d0
-#define EMC_FDPD_CTRL_CMD_NO_RAMP 0x4d8
-#define EMC_SEL_DPD_CTRL 0x3d8
-#define EMC_FDPD_CTRL_DQ 0x310
-#define EMC_FDPD_CTRL_CMD 0x314
-#define EMC_PRE_REFRESH_REQ_CNT 0x3dc
-#define EMC_REFCTRL2 0x580
-#define EMC_FBIO_CFG7 0x584
-#define EMC_DATA_BRLSHFT_0 0x588
-#define EMC_DATA_BRLSHFT_1 0x58c
-#define EMC_DQS_BRLSHFT_0 0x594
-#define EMC_DQS_BRLSHFT_1 0x598
-#define EMC_CMD_BRLSHFT_0 0x59c
-#define EMC_CMD_BRLSHFT_1 0x5a0
-#define EMC_CMD_BRLSHFT_2 0x5a4
-#define EMC_CMD_BRLSHFT_3 0x5a8
-#define EMC_QUSE_BRLSHFT_0 0x5ac
-#define EMC_QUSE_BRLSHFT_1 0x5b8
-#define EMC_QUSE_BRLSHFT_2 0x5bc
-#define EMC_QUSE_BRLSHFT_3 0x5c4
-#define EMC_FBIO_CFG8 0x5c8
-#define EMC_CMD_MAPPING_CMD0_0 0x380
-#define EMC_CMD_MAPPING_CMD0_1 0x384
-#define EMC_CMD_MAPPING_CMD0_2 0x388
-#define EMC_CMD_MAPPING_CMD1_0 0x38c
-#define EMC_CMD_MAPPING_CMD1_1 0x390
-#define EMC_CMD_MAPPING_CMD1_2 0x394
-#define EMC_CMD_MAPPING_CMD2_0 0x398
-#define EMC_CMD_MAPPING_CMD2_1 0x39c
-#define EMC_CMD_MAPPING_CMD2_2 0x3a0
-#define EMC_CMD_MAPPING_CMD3_0 0x3a4
-#define EMC_CMD_MAPPING_CMD3_1 0x3a8
-#define EMC_CMD_MAPPING_CMD3_2 0x3ac
-#define EMC_CMD_MAPPING_BYTE 0x3b0
-#define EMC_DYN_SELF_REF_CONTROL 0x3e0
-#define EMC_TXSRDLL 0x3e4
-#define EMC_CCFIFO_ADDR 0x3e8
-#define EMC_CCFIFO_DATA 0x3ec
-#define EMC_CCFIFO_STATUS 0x3f0
-#define EMC_SWIZZLE_RANK0_BYTE0 0x404
-#define EMC_SWIZZLE_RANK0_BYTE1 0x408
-#define EMC_SWIZZLE_RANK0_BYTE2 0x40c
-#define EMC_SWIZZLE_RANK0_BYTE3 0x410
-#define EMC_SWIZZLE_RANK1_BYTE0 0x418
-#define EMC_SWIZZLE_RANK1_BYTE1 0x41c
-#define EMC_SWIZZLE_RANK1_BYTE2 0x420
-#define EMC_SWIZZLE_RANK1_BYTE3 0x424
-#define EMC_TR_TIMING_0 0x3b4
-#define EMC_TR_CTRL_0 0x3b8
-#define EMC_TR_CTRL_1 0x3bc
-#define EMC_TR_DVFS 0x460
-#define EMC_SWITCH_BACK_CTRL 0x3c0
-#define EMC_TR_RDV 0x3c4
-#define EMC_TR_QPOP 0x3f4
-#define EMC_TR_RDV_MASK 0x3f8
-#define EMC_TR_QSAFE 0x3fc
-#define EMC_TR_QRST 0x400
-#define EMC_IBDLY 0x468
-#define EMC_OBDLY 0x46c
-#define EMC_TXDSRVTTGEN 0x480
-#define EMC_WE_DURATION 0x48c
-#define EMC_WS_DURATION 0x490
-#define EMC_WEV 0x494
-#define EMC_WSV 0x498
-#define EMC_CFG_3 0x49c
-#define EMC_CFG_PIPE_2 0x554
-#define EMC_CFG_PIPE_CLK 0x558
-#define EMC_CFG_PIPE_1 0x55c
-#define EMC_CFG_PIPE 0x560
-#define EMC_QPOP 0x564
-#define EMC_QUSE_WIDTH 0x568
-#define EMC_PUTERM_WIDTH 0x56c
-#define EMC_PROTOBIST_CONFIG_ADR_1 0x5d0
-#define EMC_PROTOBIST_CONFIG_ADR_2 0x5d4
-#define EMC_PROTOBIST_MISC 0x5d8
-#define EMC_PROTOBIST_WDATA_LOWER 0x5dc
-#define EMC_PROTOBIST_WDATA_UPPER 0x5e0
-#define EMC_PROTOBIST_RDATA 0x5ec
-#define EMC_DLL_CFG_0 0x5e4
-#define EMC_DLL_CFG_1 0x5e8
-#define EMC_TRAINING_CMD 0xe00
-#define EMC_TRAINING_CTRL 0xe04
-#define EMC_TRAINING_STATUS 0xe08
-#define EMC_TRAINING_QUSE_CORS_CTRL 0xe0c
-#define EMC_TRAINING_QUSE_FINE_CTRL 0xe10
-#define EMC_TRAINING_QUSE_CTRL_MISC 0xe14
-#define EMC_TRAINING_WRITE_FINE_CTRL 0xe18
-#define EMC_TRAINING_WRITE_CTRL_MISC 0xe1c
-#define EMC_TRAINING_WRITE_VREF_CTRL 0xe20
-#define EMC_TRAINING_READ_FINE_CTRL 0xe24
-#define EMC_TRAINING_READ_CTRL_MISC 0xe28
-#define EMC_TRAINING_READ_VREF_CTRL 0xe2c
-#define EMC_TRAINING_CA_FINE_CTRL 0xe30
-#define EMC_TRAINING_CA_CTRL_MISC 0xe34
-#define EMC_TRAINING_CA_CTRL_MISC1 0xe38
-#define EMC_TRAINING_CA_VREF_CTRL 0xe3c
-#define EMC_TRAINING_CA_TADR_CTRL 0xe40
-#define EMC_TRAINING_SETTLE 0xe44
-#define EMC_TRAINING_DEBUG_CTRL 0xe48
-#define EMC_TRAINING_DEBUG_DQ0 0xe4c
-#define EMC_TRAINING_DEBUG_DQ1 0xe50
-#define EMC_TRAINING_DEBUG_DQ2 0xe54
-#define EMC_TRAINING_DEBUG_DQ3 0xe58
-#define EMC_TRAINING_MPC 0xe5c
-#define EMC_TRAINING_PATRAM_CTRL 0xe60
-#define EMC_TRAINING_PATRAM_DQ 0xe64
-#define EMC_TRAINING_PATRAM_DMI 0xe68
-#define EMC_TRAINING_VREF_SETTLE 0xe6c
-#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE0 0xe70
-#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE1 0xe74
-#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE2 0xe78
-#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE3 0xe7c
-#define EMC_TRAINING_RW_EYE_CENTER_IB_MISC 0xe80
-#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE0 0xe84
-#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE1 0xe88
-#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE2 0xe8c
-#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE3 0xe90
-#define EMC_TRAINING_RW_EYE_CENTER_OB_MISC 0xe94
-#define EMC_TRAINING_RW_OFFSET_IB_BYTE0 0xe98
-#define EMC_TRAINING_RW_OFFSET_IB_BYTE1 0xe9c
-#define EMC_TRAINING_RW_OFFSET_IB_BYTE2 0xea0
-#define EMC_TRAINING_RW_OFFSET_IB_BYTE3 0xea4
-#define EMC_TRAINING_RW_OFFSET_IB_MISC 0xea8
-#define EMC_TRAINING_RW_OFFSET_OB_BYTE0 0xeac
-#define EMC_TRAINING_RW_OFFSET_OB_BYTE1 0xeb0
-#define EMC_TRAINING_RW_OFFSET_OB_BYTE2 0xeb4
-#define EMC_TRAINING_RW_OFFSET_OB_BYTE3 0xeb8
-#define EMC_TRAINING_RW_OFFSET_OB_MISC 0xebc
-#define EMC_TRAINING_OPT_CA_VREF 0xec0
-#define EMC_TRAINING_OPT_DQ_OB_VREF 0xec4
-#define EMC_TRAINING_OPT_DQ_IB_VREF_RANK0 0xec8
-#define EMC_TRAINING_OPT_DQ_IB_VREF_RANK1 0xecc
-#define EMC_TRAINING_QUSE_VREF_CTRL 0xed0
-#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK0 0xed4
-#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK1 0xed8
-#define EMC_TRAINING_DRAMC_TIMING 0xedc
-#define EMC_PMACRO_QUSE_DDLL_RANK0_0 0x600
-#define EMC_PMACRO_QUSE_DDLL_RANK0_1 0x604
-#define EMC_PMACRO_QUSE_DDLL_RANK0_2 0x608
-#define EMC_PMACRO_QUSE_DDLL_RANK0_3 0x60c
-#define EMC_PMACRO_QUSE_DDLL_RANK0_4 0x610
-#define EMC_PMACRO_QUSE_DDLL_RANK0_5 0x614
-#define EMC_PMACRO_QUSE_DDLL_RANK1_0 0x620
-#define EMC_PMACRO_QUSE_DDLL_RANK1_1 0x624
-#define EMC_PMACRO_QUSE_DDLL_RANK1_2 0x628
-#define EMC_PMACRO_QUSE_DDLL_RANK1_3 0x62c
-#define EMC_PMACRO_QUSE_DDLL_RANK1_4 0x630
-#define EMC_PMACRO_QUSE_DDLL_RANK1_5 0x634
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 0x640
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 0x644
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 0x648
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 0x64c
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4 0x650
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5 0x654
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 0x660
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 0x664
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 0x668
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 0x66c
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4 0x670
-#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5 0x674
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0 0x680
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_1 0x684
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_2 0x688
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_3 0x68c
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_4 0x690
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_5 0x694
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_0 0x6a0
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_1 0x6a4
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_2 0x6a8
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_3 0x6ac
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_4 0x6b0
-#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_5 0x6b4
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_0 0x6c0
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_1 0x6c4
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_2 0x6c8
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_3 0x6cc
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_4 0x6d0
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_5 0x6d4
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_0 0x6e0
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_1 0x6e4
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_2 0x6e8
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_3 0x6ec
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_4 0x6f0
-#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_5 0x6f4
-#define EMC_PMACRO_TX_PWRD_0 0x720
-#define EMC_PMACRO_TX_PWRD_1 0x724
-#define EMC_PMACRO_TX_PWRD_2 0x728
-#define EMC_PMACRO_TX_PWRD_3 0x72c
-#define EMC_PMACRO_TX_PWRD_4 0x730
-#define EMC_PMACRO_TX_PWRD_5 0x734
-#define EMC_PMACRO_TX_SEL_CLK_SRC_0 0x740
-#define EMC_PMACRO_TX_SEL_CLK_SRC_1 0x744
-#define EMC_PMACRO_TX_SEL_CLK_SRC_3 0x74c
-#define EMC_PMACRO_TX_SEL_CLK_SRC_2 0x748
-#define EMC_PMACRO_TX_SEL_CLK_SRC_4 0x750
-#define EMC_PMACRO_TX_SEL_CLK_SRC_5 0x754
-#define EMC_PMACRO_DDLL_BYPASS 0x760
-#define EMC_PMACRO_DDLL_PWRD_0 0x770
-#define EMC_PMACRO_DDLL_PWRD_1 0x774
-#define EMC_PMACRO_DDLL_PWRD_2 0x778
-#define EMC_PMACRO_CMD_CTRL_0 0x780
-#define EMC_PMACRO_CMD_CTRL_1 0x784
-#define EMC_PMACRO_CMD_CTRL_2 0x788
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_0 0x800
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_1 0x804
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_2 0x808
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_3 0x80c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_0 0x810
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_1 0x814
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_2 0x818
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_3 0x81c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_0 0x820
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_1 0x824
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_2 0x828
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_3 0x82c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_0 0x830
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_1 0x834
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_2 0x838
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_3 0x83c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_0 0x840
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_1 0x844
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_2 0x848
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_3 0x84c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_0 0x850
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_1 0x854
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_2 0x858
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_3 0x85c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_0 0x860
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_1 0x864
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_2 0x868
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_3 0x86c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_0 0x870
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_1 0x874
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_2 0x878
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_3 0x87c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_0 0x880
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_1 0x884
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_2 0x888
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_3 0x88c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_0 0x890
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_1 0x894
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_2 0x898
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_3 0x89c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_0 0x8a0
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_1 0x8a4
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_2 0x8a8
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_3 0x8ac
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_0 0x8b0
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_1 0x8b4
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_2 0x8b8
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_3 0x8bc
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_0 0x900
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_1 0x904
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_2 0x908
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_3 0x90c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_0 0x910
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_1 0x914
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_2 0x918
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_3 0x91c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_0 0x920
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_1 0x924
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_2 0x928
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_3 0x92c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_0 0x930
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_1 0x934
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_2 0x938
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_3 0x93c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_0 0x940
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_1 0x944
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_2 0x948
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_3 0x94c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_0 0x950
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_1 0x954
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_2 0x958
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_3 0x95c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_0 0x960
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_1 0x964
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_2 0x968
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_3 0x96c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_0 0x970
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_1 0x974
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_2 0x978
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_3 0x97c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_0 0x980
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_1 0x984
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_2 0x988
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_3 0x98c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_0 0x990
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_1 0x994
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_2 0x998
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_3 0x99c
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_0 0x9a0
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_1 0x9a4
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_2 0x9a8
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_3 0x9ac
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_0 0x9b0
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_1 0x9b4
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_2 0x9b8
-#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_3 0x9bc
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_0 0xa00
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_1 0xa04
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_2 0xa08
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_0 0xa10
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_1 0xa14
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_2 0xa18
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_0 0xa20
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_1 0xa24
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_2 0xa28
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_0 0xa30
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_1 0xa34
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_2 0xa38
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_0 0xa40
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_1 0xa44
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_2 0xa48
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_0 0xa50
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_1 0xa54
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_2 0xa58
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_0 0xa60
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_1 0xa64
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_2 0xa68
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_0 0xa70
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_1 0xa74
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_2 0xa78
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_0 0xa80
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_1 0xa84
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_2 0xa88
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_0 0xa90
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_1 0xa94
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_2 0xa98
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_0 0xaa0
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_1 0xaa4
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_2 0xaa8
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_0 0xab0
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_1 0xab4
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_2 0xab8
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_0 0xb00
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_1 0xb04
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_2 0xb08
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_0 0xb10
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_1 0xb14
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_2 0xb18
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_0 0xb20
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_1 0xb24
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_2 0xb28
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_0 0xb30
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_1 0xb34
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_2 0xb38
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_0 0xb40
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_1 0xb44
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_2 0xb48
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_0 0xb50
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_1 0xb54
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_2 0xb58
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_0 0xb60
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_1 0xb64
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_2 0xb68
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_0 0xb70
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_1 0xb74
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_2 0xb78
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_0 0xb80
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_1 0xb84
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_2 0xb88
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_0 0xb90
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_1 0xb94
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_2 0xb98
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_0 0xba0
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_1 0xba4
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_2 0xba8
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_0 0xbb0
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_1 0xbb4
-#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_2 0xbb8
-#define EMC_PMACRO_IB_VREF_DQ_0 0xbe0
-#define EMC_PMACRO_IB_VREF_DQ_1 0xbe4
-#define EMC_PMACRO_IB_VREF_DQ_2 0xbe8
-#define EMC_PMACRO_IB_VREF_DQS_0 0xbf0
-#define EMC_PMACRO_IB_VREF_DQS_1 0xbf4
-#define EMC_PMACRO_IB_VREF_DQS_2 0xbf8
-#define EMC_PMACRO_IB_RXRT 0xcf4
-#define EMC_PMACRO_DDLL_LONG_CMD_0 0xc00
-#define EMC_PMACRO_DDLL_LONG_CMD_1 0xc04
-#define EMC_PMACRO_DDLL_LONG_CMD_2 0xc08
-#define EMC_PMACRO_DDLL_LONG_CMD_3 0xc0c
-#define EMC_PMACRO_DDLL_LONG_CMD_4 0xc10
-#define EMC_PMACRO_DDLL_LONG_CMD_5 0xc14
-#define EMC_PMACRO_DDLL_SHORT_CMD_0 0xc20
-#define EMC_PMACRO_DDLL_SHORT_CMD_1 0xc24
-#define EMC_PMACRO_DDLL_SHORT_CMD_2 0xc28
-#define EMC_PMACRO_CFG_PM_GLOBAL_0 0xc30
-#define EMC_PMACRO_VTTGEN_CTRL_0 0xc34
-#define EMC_PMACRO_VTTGEN_CTRL_1 0xc38
-#define EMC_PMACRO_VTTGEN_CTRL_2 0xcf0
-#define EMC_PMACRO_BG_BIAS_CTRL_0 0xc3c
-#define EMC_PMACRO_PAD_CFG_CTRL 0xc40
-#define EMC_PMACRO_CMD_PAD_RX_CTRL 0xc50
-#define EMC_PMACRO_DATA_PAD_RX_CTRL 0xc54
-#define EMC_PMACRO_CMD_RX_TERM_MODE 0xc58
-#define EMC_PMACRO_DATA_RX_TERM_MODE 0xc5c
-#define EMC_PMACRO_CMD_PAD_TX_CTRL 0xc60
-#define EMC_PMACRO_DATA_PAD_TX_CTRL 0xc64
-#define EMC_PMACRO_COMMON_PAD_TX_CTRL 0xc68
-#define EMC_PMACRO_BRICK_MAPPING_0 0xc80
-#define EMC_PMACRO_BRICK_MAPPING_1 0xc84
-#define EMC_PMACRO_BRICK_MAPPING_2 0xc88
-#define EMC_PMACRO_DDLLCAL_CAL 0xce0
-#define EMC_PMACRO_DDLL_OFFSET 0xce4
-#define EMC_PMACRO_DDLL_PERIODIC_OFFSET 0xce8
-#define EMC_PMACRO_BRICK_CTRL_RFU1 0x330
-#define EMC_PMACRO_BRICK_CTRL_RFU2 0x334
-#define EMC_PMACRO_CMD_BRICK_CTRL_FDPD 0x318
-#define EMC_PMACRO_DATA_BRICK_CTRL_FDPD 0x31c
-#define EMC_PMACRO_TRAINING_CTRL_0 0xcf8
-#define EMC_PMACRO_TRAINING_CTRL_1 0xcfc
-#define EMC_PMC_SCRATCH1 0x440
-#define EMC_PMC_SCRATCH2 0x444
-#define EMC_PMC_SCRATCH3 0x448
+#define EMC_STAT_DRAM_IO_SR_CKE_EQ0_CLKS_LO 0xccc
+#define EMC_STAT_DRAM_IO_SR_CKE_EQ0_CLKS_HI 0xcd0
+#define EMC_STAT_DRAM_IO_DSR 0xcd4
+#define EMC_AUTO_CAL_CONFIG 0x2a4
+#define EMC_AUTO_CAL_CONFIG2 0x458
+#define EMC_AUTO_CAL_CONFIG3 0x45c
+#define EMC_AUTO_CAL_CONFIG4 0x5b0
+#define EMC_AUTO_CAL_CONFIG5 0x5b4
+#define EMC_AUTO_CAL_CONFIG6 0x5cc
+#define EMC_AUTO_CAL_CONFIG7 0x574
+#define EMC_AUTO_CAL_CONFIG8 0x2dc
+#define EMC_AUTO_CAL_VREF_SEL_0 0x2f8
+#define EMC_AUTO_CAL_VREF_SEL_1 0x300
+#define EMC_AUTO_CAL_INTERVAL 0x2a8
+#define EMC_AUTO_CAL_STATUS 0x2ac
+#define EMC_AUTO_CAL_STATUS2 0x3d4
+#define EMC_AUTO_CAL_CHANNEL 0x464
+#define EMC_PMACRO_RX_TERM 0xc48
+#define EMC_PMACRO_DQ_TX_DRV 0xc70
+#define EMC_PMACRO_CA_TX_DRV 0xc74
+#define EMC_PMACRO_CMD_TX_DRV 0xc4c
+#define EMC_PMACRO_AUTOCAL_CFG_0 0x700
+#define EMC_PMACRO_AUTOCAL_CFG_1 0x704
+#define EMC_PMACRO_AUTOCAL_CFG_2 0x708
+#define EMC_PMACRO_AUTOCAL_CFG_COMMON 0xc78
+#define EMC_PMACRO_ZCTRL 0xc44
+#define EMC_XM2COMPPADCTRL 0x30c
+#define EMC_XM2COMPPADCTRL2 0x578
+#define EMC_XM2COMPPADCTRL3 0x2f4
+#define EMC_COMP_PAD_SW_CTRL 0x57c
+#define EMC_REQ_CTRL 0x2b0
+#define EMC_EMC_STATUS 0x2b4
+#define EMC_STATUS_MRR_DIVLD (1 << 20)
+#define EMC_CFG_2 0x2b8
+#define EMC_CFG_DIG_DLL 0x2bc
+#define EMC_CFG_DIG_DLL_PERIOD 0x2c0
+#define EMC_DIG_DLL_STATUS 0x2c4
+#define EMC_CFG_DIG_DLL_1 0x2c8
+#define EMC_RDV_MASK 0x2cc
+#define EMC_WDV_MASK 0x2d0
+#define EMC_RDV_EARLY_MASK 0x2d4
+#define EMC_RDV_EARLY 0x2d8
+#define EMC_WDV_CHK 0x4e0
+#define EMC_ZCAL_INTERVAL 0x2e0
+#define EMC_ZCAL_WAIT_CNT 0x2e4
+#define EMC_ZCAL_MRW_CMD 0x2e8
+#define EMC_ZQ_CAL 0x2ec
+#define EMC_SCRATCH0 0x324
+#define EMC_STALL_THEN_EXE_BEFORE_CLKCHANGE 0x3c8
+#define EMC_STALL_THEN_EXE_AFTER_CLKCHANGE 0x3cc
+#define EMC_UNSTALL_RW_AFTER_CLKCHANGE 0x3d0
+#define EMC_FDPD_CTRL_CMD_NO_RAMP 0x4d8
+#define EMC_SEL_DPD_CTRL 0x3d8
+#define EMC_FDPD_CTRL_DQ 0x310
+#define EMC_FDPD_CTRL_CMD 0x314
+#define EMC_PRE_REFRESH_REQ_CNT 0x3dc
+#define EMC_REFCTRL2 0x580
+#define EMC_FBIO_CFG7 0x584
+#define EMC_DATA_BRLSHFT_0 0x588
+#define EMC_DATA_BRLSHFT_1 0x58c
+#define EMC_DQS_BRLSHFT_0 0x594
+#define EMC_DQS_BRLSHFT_1 0x598
+#define EMC_CMD_BRLSHFT_0 0x59c
+#define EMC_CMD_BRLSHFT_1 0x5a0
+#define EMC_CMD_BRLSHFT_2 0x5a4
+#define EMC_CMD_BRLSHFT_3 0x5a8
+#define EMC_QUSE_BRLSHFT_0 0x5ac
+#define EMC_QUSE_BRLSHFT_1 0x5b8
+#define EMC_QUSE_BRLSHFT_2 0x5bc
+#define EMC_QUSE_BRLSHFT_3 0x5c4
+#define EMC_FBIO_CFG8 0x5c8
+#define EMC_CMD_MAPPING_CMD0_0 0x380
+#define EMC_CMD_MAPPING_CMD0_1 0x384
+#define EMC_CMD_MAPPING_CMD0_2 0x388
+#define EMC_CMD_MAPPING_CMD1_0 0x38c
+#define EMC_CMD_MAPPING_CMD1_1 0x390
+#define EMC_CMD_MAPPING_CMD1_2 0x394
+#define EMC_CMD_MAPPING_CMD2_0 0x398
+#define EMC_CMD_MAPPING_CMD2_1 0x39c
+#define EMC_CMD_MAPPING_CMD2_2 0x3a0
+#define EMC_CMD_MAPPING_CMD3_0 0x3a4
+#define EMC_CMD_MAPPING_CMD3_1 0x3a8
+#define EMC_CMD_MAPPING_CMD3_2 0x3ac
+#define EMC_CMD_MAPPING_BYTE 0x3b0
+#define EMC_DYN_SELF_REF_CONTROL 0x3e0
+#define EMC_TXSRDLL 0x3e4
+#define EMC_CCFIFO_ADDR 0x3e8
+#define EMC_CCFIFO_DATA 0x3ec
+#define EMC_CCFIFO_STATUS 0x3f0
+#define EMC_SWIZZLE_RANK0_BYTE0 0x404
+#define EMC_SWIZZLE_RANK0_BYTE1 0x408
+#define EMC_SWIZZLE_RANK0_BYTE2 0x40c
+#define EMC_SWIZZLE_RANK0_BYTE3 0x410
+#define EMC_SWIZZLE_RANK1_BYTE0 0x418
+#define EMC_SWIZZLE_RANK1_BYTE1 0x41c
+#define EMC_SWIZZLE_RANK1_BYTE2 0x420
+#define EMC_SWIZZLE_RANK1_BYTE3 0x424
+#define EMC_TR_TIMING_0 0x3b4
+#define EMC_TR_CTRL_0 0x3b8
+#define EMC_TR_CTRL_1 0x3bc
+#define EMC_TR_DVFS 0x460
+#define EMC_SWITCH_BACK_CTRL 0x3c0
+#define EMC_TR_RDV 0x3c4
+#define EMC_TR_QPOP 0x3f4
+#define EMC_TR_RDV_MASK 0x3f8
+#define EMC_TR_QSAFE 0x3fc
+#define EMC_TR_QRST 0x400
+#define EMC_IBDLY 0x468
+#define EMC_OBDLY 0x46c
+#define EMC_TXDSRVTTGEN 0x480
+#define EMC_WE_DURATION 0x48c
+#define EMC_WS_DURATION 0x490
+#define EMC_WEV 0x494
+#define EMC_WSV 0x498
+#define EMC_CFG_3 0x49c
+#define EMC_CFG_PIPE_2 0x554
+#define EMC_CFG_PIPE_CLK 0x558
+#define EMC_CFG_PIPE_1 0x55c
+#define EMC_CFG_PIPE 0x560
+#define EMC_QPOP 0x564
+#define EMC_QUSE_WIDTH 0x568
+#define EMC_PUTERM_WIDTH 0x56c
+#define EMC_PROTOBIST_CONFIG_ADR_1 0x5d0
+#define EMC_PROTOBIST_CONFIG_ADR_2 0x5d4
+#define EMC_PROTOBIST_MISC 0x5d8
+#define EMC_PROTOBIST_WDATA_LOWER 0x5dc
+#define EMC_PROTOBIST_WDATA_UPPER 0x5e0
+#define EMC_PROTOBIST_RDATA 0x5ec
+#define EMC_DLL_CFG_0 0x5e4
+#define EMC_DLL_CFG_1 0x5e8
+#define EMC_TRAINING_CMD 0xe00
+#define EMC_TRAINING_CTRL 0xe04
+#define EMC_TRAINING_STATUS 0xe08
+#define EMC_TRAINING_QUSE_CORS_CTRL 0xe0c
+#define EMC_TRAINING_QUSE_FINE_CTRL 0xe10
+#define EMC_TRAINING_QUSE_CTRL_MISC 0xe14
+#define EMC_TRAINING_WRITE_FINE_CTRL 0xe18
+#define EMC_TRAINING_WRITE_CTRL_MISC 0xe1c
+#define EMC_TRAINING_WRITE_VREF_CTRL 0xe20
+#define EMC_TRAINING_READ_FINE_CTRL 0xe24
+#define EMC_TRAINING_READ_CTRL_MISC 0xe28
+#define EMC_TRAINING_READ_VREF_CTRL 0xe2c
+#define EMC_TRAINING_CA_FINE_CTRL 0xe30
+#define EMC_TRAINING_CA_CTRL_MISC 0xe34
+#define EMC_TRAINING_CA_CTRL_MISC1 0xe38
+#define EMC_TRAINING_CA_VREF_CTRL 0xe3c
+#define EMC_TRAINING_CA_TADR_CTRL 0xe40
+#define EMC_TRAINING_SETTLE 0xe44
+#define EMC_TRAINING_DEBUG_CTRL 0xe48
+#define EMC_TRAINING_DEBUG_DQ0 0xe4c
+#define EMC_TRAINING_DEBUG_DQ1 0xe50
+#define EMC_TRAINING_DEBUG_DQ2 0xe54
+#define EMC_TRAINING_DEBUG_DQ3 0xe58
+#define EMC_TRAINING_MPC 0xe5c
+#define EMC_TRAINING_PATRAM_CTRL 0xe60
+#define EMC_TRAINING_PATRAM_DQ 0xe64
+#define EMC_TRAINING_PATRAM_DMI 0xe68
+#define EMC_TRAINING_VREF_SETTLE 0xe6c
+#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE0 0xe70
+#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE1 0xe74
+#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE2 0xe78
+#define EMC_TRAINING_RW_EYE_CENTER_IB_BYTE3 0xe7c
+#define EMC_TRAINING_RW_EYE_CENTER_IB_MISC 0xe80
+#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE0 0xe84
+#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE1 0xe88
+#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE2 0xe8c
+#define EMC_TRAINING_RW_EYE_CENTER_OB_BYTE3 0xe90
+#define EMC_TRAINING_RW_EYE_CENTER_OB_MISC 0xe94
+#define EMC_TRAINING_RW_OFFSET_IB_BYTE0 0xe98
+#define EMC_TRAINING_RW_OFFSET_IB_BYTE1 0xe9c
+#define EMC_TRAINING_RW_OFFSET_IB_BYTE2 0xea0
+#define EMC_TRAINING_RW_OFFSET_IB_BYTE3 0xea4
+#define EMC_TRAINING_RW_OFFSET_IB_MISC 0xea8
+#define EMC_TRAINING_RW_OFFSET_OB_BYTE0 0xeac
+#define EMC_TRAINING_RW_OFFSET_OB_BYTE1 0xeb0
+#define EMC_TRAINING_RW_OFFSET_OB_BYTE2 0xeb4
+#define EMC_TRAINING_RW_OFFSET_OB_BYTE3 0xeb8
+#define EMC_TRAINING_RW_OFFSET_OB_MISC 0xebc
+#define EMC_TRAINING_OPT_CA_VREF 0xec0
+#define EMC_TRAINING_OPT_DQ_OB_VREF 0xec4
+#define EMC_TRAINING_OPT_DQ_IB_VREF_RANK0 0xec8
+#define EMC_TRAINING_OPT_DQ_IB_VREF_RANK1 0xecc
+#define EMC_TRAINING_QUSE_VREF_CTRL 0xed0
+#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK0 0xed4
+#define EMC_TRAINING_OPT_DQS_IB_VREF_RANK1 0xed8
+#define EMC_TRAINING_DRAMC_TIMING 0xedc
+#define EMC_PMACRO_QUSE_DDLL_RANK0_0 0x600
+#define EMC_PMACRO_QUSE_DDLL_RANK0_1 0x604
+#define EMC_PMACRO_QUSE_DDLL_RANK0_2 0x608
+#define EMC_PMACRO_QUSE_DDLL_RANK0_3 0x60c
+#define EMC_PMACRO_QUSE_DDLL_RANK0_4 0x610
+#define EMC_PMACRO_QUSE_DDLL_RANK0_5 0x614
+#define EMC_PMACRO_QUSE_DDLL_RANK1_0 0x620
+#define EMC_PMACRO_QUSE_DDLL_RANK1_1 0x624
+#define EMC_PMACRO_QUSE_DDLL_RANK1_2 0x628
+#define EMC_PMACRO_QUSE_DDLL_RANK1_3 0x62c
+#define EMC_PMACRO_QUSE_DDLL_RANK1_4 0x630
+#define EMC_PMACRO_QUSE_DDLL_RANK1_5 0x634
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 0x640
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 0x644
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 0x648
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 0x64c
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4 0x650
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5 0x654
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 0x660
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 0x664
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 0x668
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 0x66c
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4 0x670
+#define EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5 0x674
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0 0x680
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_1 0x684
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_2 0x688
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_3 0x68c
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_4 0x690
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_5 0x694
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_0 0x6a0
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_1 0x6a4
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_2 0x6a8
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_3 0x6ac
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_4 0x6b0
+#define EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_5 0x6b4
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_0 0x6c0
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_1 0x6c4
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_2 0x6c8
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_3 0x6cc
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_4 0x6d0
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_5 0x6d4
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_0 0x6e0
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_1 0x6e4
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_2 0x6e8
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_3 0x6ec
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_4 0x6f0
+#define EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_5 0x6f4
+#define EMC_PMACRO_TX_PWRD_0 0x720
+#define EMC_PMACRO_TX_PWRD_1 0x724
+#define EMC_PMACRO_TX_PWRD_2 0x728
+#define EMC_PMACRO_TX_PWRD_3 0x72c
+#define EMC_PMACRO_TX_PWRD_4 0x730
+#define EMC_PMACRO_TX_PWRD_5 0x734
+#define EMC_PMACRO_TX_SEL_CLK_SRC_0 0x740
+#define EMC_PMACRO_TX_SEL_CLK_SRC_1 0x744
+#define EMC_PMACRO_TX_SEL_CLK_SRC_3 0x74c
+#define EMC_PMACRO_TX_SEL_CLK_SRC_2 0x748
+#define EMC_PMACRO_TX_SEL_CLK_SRC_4 0x750
+#define EMC_PMACRO_TX_SEL_CLK_SRC_5 0x754
+#define EMC_PMACRO_DDLL_BYPASS 0x760
+#define EMC_PMACRO_DDLL_PWRD_0 0x770
+#define EMC_PMACRO_DDLL_PWRD_1 0x774
+#define EMC_PMACRO_DDLL_PWRD_2 0x778
+#define EMC_PMACRO_CMD_CTRL_0 0x780
+#define EMC_PMACRO_CMD_CTRL_1 0x784
+#define EMC_PMACRO_CMD_CTRL_2 0x788
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_0 0x800
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_1 0x804
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_2 0x808
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_3 0x80c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_0 0x810
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_1 0x814
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_2 0x818
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_3 0x81c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_0 0x820
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_1 0x824
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_2 0x828
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_3 0x82c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_0 0x830
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_1 0x834
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_2 0x838
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_3 0x83c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_0 0x840
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_1 0x844
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_2 0x848
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_3 0x84c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_0 0x850
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_1 0x854
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_2 0x858
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_3 0x85c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_0 0x860
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_1 0x864
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_2 0x868
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_3 0x86c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_0 0x870
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_1 0x874
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_2 0x878
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_3 0x87c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_0 0x880
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_1 0x884
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_2 0x888
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_3 0x88c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_0 0x890
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_1 0x894
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_2 0x898
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_3 0x89c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_0 0x8a0
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_1 0x8a4
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_2 0x8a8
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_3 0x8ac
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_0 0x8b0
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_1 0x8b4
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_2 0x8b8
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_3 0x8bc
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_0 0x900
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_1 0x904
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_2 0x908
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_3 0x90c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_0 0x910
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_1 0x914
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_2 0x918
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_3 0x91c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_0 0x920
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_1 0x924
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_2 0x928
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_3 0x92c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_0 0x930
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_1 0x934
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_2 0x938
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_3 0x93c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_0 0x940
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_1 0x944
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_2 0x948
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_3 0x94c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_0 0x950
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_1 0x954
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_2 0x958
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_3 0x95c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_0 0x960
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_1 0x964
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_2 0x968
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_3 0x96c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_0 0x970
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_1 0x974
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_2 0x978
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_3 0x97c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_0 0x980
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_1 0x984
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_2 0x988
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_3 0x98c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_0 0x990
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_1 0x994
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_2 0x998
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_3 0x99c
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_0 0x9a0
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_1 0x9a4
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_2 0x9a8
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_3 0x9ac
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_0 0x9b0
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_1 0x9b4
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_2 0x9b8
+#define EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_3 0x9bc
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_0 0xa00
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_1 0xa04
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_2 0xa08
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_0 0xa10
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_1 0xa14
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_2 0xa18
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_0 0xa20
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_1 0xa24
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_2 0xa28
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_0 0xa30
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_1 0xa34
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_2 0xa38
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_0 0xa40
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_1 0xa44
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_2 0xa48
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_0 0xa50
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_1 0xa54
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_2 0xa58
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_0 0xa60
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_1 0xa64
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_2 0xa68
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_0 0xa70
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_1 0xa74
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_2 0xa78
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_0 0xa80
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_1 0xa84
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD0_2 0xa88
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_0 0xa90
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_1 0xa94
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD1_2 0xa98
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_0 0xaa0
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_1 0xaa4
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD2_2 0xaa8
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_0 0xab0
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_1 0xab4
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_CMD3_2 0xab8
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_0 0xb00
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_1 0xb04
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_2 0xb08
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_0 0xb10
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_1 0xb14
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_2 0xb18
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_0 0xb20
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_1 0xb24
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_2 0xb28
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_0 0xb30
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_1 0xb34
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_2 0xb38
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_0 0xb40
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_1 0xb44
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_2 0xb48
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_0 0xb50
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_1 0xb54
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_2 0xb58
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_0 0xb60
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_1 0xb64
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_2 0xb68
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_0 0xb70
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_1 0xb74
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_2 0xb78
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_0 0xb80
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_1 0xb84
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD0_2 0xb88
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_0 0xb90
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_1 0xb94
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD1_2 0xb98
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_0 0xba0
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_1 0xba4
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD2_2 0xba8
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_0 0xbb0
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_1 0xbb4
+#define EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_CMD3_2 0xbb8
+#define EMC_PMACRO_IB_VREF_DQ_0 0xbe0
+#define EMC_PMACRO_IB_VREF_DQ_1 0xbe4
+#define EMC_PMACRO_IB_VREF_DQ_2 0xbe8
+#define EMC_PMACRO_IB_VREF_DQS_0 0xbf0
+#define EMC_PMACRO_IB_VREF_DQS_1 0xbf4
+#define EMC_PMACRO_IB_VREF_DQS_2 0xbf8
+#define EMC_PMACRO_IB_RXRT 0xcf4
+#define EMC_PMACRO_DDLL_LONG_CMD_0 0xc00
+#define EMC_PMACRO_DDLL_LONG_CMD_1 0xc04
+#define EMC_PMACRO_DDLL_LONG_CMD_2 0xc08
+#define EMC_PMACRO_DDLL_LONG_CMD_3 0xc0c
+#define EMC_PMACRO_DDLL_LONG_CMD_4 0xc10
+#define EMC_PMACRO_DDLL_LONG_CMD_5 0xc14
+#define EMC_PMACRO_DDLL_SHORT_CMD_0 0xc20
+#define EMC_PMACRO_DDLL_SHORT_CMD_1 0xc24
+#define EMC_PMACRO_DDLL_SHORT_CMD_2 0xc28
+#define EMC_PMACRO_CFG_PM_GLOBAL_0 0xc30
+#define EMC_PMACRO_VTTGEN_CTRL_0 0xc34
+#define EMC_PMACRO_VTTGEN_CTRL_1 0xc38
+#define EMC_PMACRO_VTTGEN_CTRL_2 0xcf0
+#define EMC_PMACRO_BG_BIAS_CTRL_0 0xc3c
+#define EMC_PMACRO_PAD_CFG_CTRL 0xc40
+#define EMC_PMACRO_CMD_PAD_RX_CTRL 0xc50
+#define EMC_PMACRO_DATA_PAD_RX_CTRL 0xc54
+#define EMC_PMACRO_CMD_RX_TERM_MODE 0xc58
+#define EMC_PMACRO_DATA_RX_TERM_MODE 0xc5c
+#define EMC_PMACRO_CMD_PAD_TX_CTRL 0xc60
+#define EMC_PMACRO_DATA_PAD_TX_CTRL 0xc64
+#define EMC_PMACRO_COMMON_PAD_TX_CTRL 0xc68
+#define EMC_PMACRO_BRICK_MAPPING_0 0xc80
+#define EMC_PMACRO_BRICK_MAPPING_1 0xc84
+#define EMC_PMACRO_BRICK_MAPPING_2 0xc88
+#define EMC_PMACRO_DDLLCAL_CAL 0xce0
+#define EMC_PMACRO_DDLL_OFFSET 0xce4
+#define EMC_PMACRO_DDLL_PERIODIC_OFFSET 0xce8
+#define EMC_PMACRO_BRICK_CTRL_RFU1 0x330
+#define EMC_PMACRO_BRICK_CTRL_RFU2 0x334
+#define EMC_PMACRO_CMD_BRICK_CTRL_FDPD 0x318
+#define EMC_PMACRO_DATA_BRICK_CTRL_FDPD 0x31c
+#define EMC_PMACRO_TRAINING_CTRL_0 0xcf8
+#define EMC_PMACRO_TRAINING_CTRL_1 0xcfc
+#define EMC_PMC_SCRATCH1 0x440
+#define EMC_PMC_SCRATCH2 0x444
+#define EMC_PMC_SCRATCH3 0x448
+
+#define EMC_STATUS_UPDATE_TIMEOUT 1000
+
+typedef enum _emc_mr_t
+{
+ MR5_MAN_ID = 5,
+ MR6_REV_ID1 = 6,
+ MR7_REV_ID2 = 7,
+ MR8_DENSITY = 8,
+} emc_mr_t;
+
+enum
+{
+ EMC_CHAN0 = 0,
+ EMC_CHAN1 = 1
+};
+
+typedef struct _emc_mr_data_t
+{
+ u8 dev0_ch0;
+ u8 dev0_ch1;
+ u8 dev1_ch0;
+ u8 dev1_ch1;
+} emc_mr_data_t;
#endif
diff --git a/source/mem/heap.c b/source/mem/heap.c
index 4ed7230..7c0e202 100644
--- a/source/mem/heap.c
+++ b/source/mem/heap.c
@@ -136,7 +136,7 @@ void *malloc(u32 size)
void *calloc(u32 num, u32 size)
{
void *res = (void *)_heap_alloc(&_heap, num * size);
- memset(res, 0, num * size);
+ memset(res, 0, ALIGN(num * size, sizeof(hnode_t))); // Clear the aligned size.
return res;
}
@@ -164,7 +164,7 @@ void heap_monitor(heap_monitor_t *mon, bool print_node_stats)
count, node->used, (u32)node + sizeof(hnode_t), node->size);
count++;
-
+
if (node->next)
node = node->next;
else
diff --git a/source/mem/mc_t210.h b/source/mem/mc_t210.h
index 602915f..87fe2ca 100644
--- a/source/mem/mc_t210.h
+++ b/source/mem/mc_t210.h
@@ -463,4 +463,54 @@
#define MC_ERR_APB_ASID_UPDATE_STATUS 0x9d0
#define MC_DA_CONFIG0 0x9dc
+// MC_SECURITY_CARVEOUTX_CFG0
+// Mode of LOCK_MODE.
+#define PROTECT_MODE_SHIFT 0
+#define SEC_CARVEOUT_CFG_SECURE (0 << PROTECT_MODE_SHIFT0)
+#define SEC_CARVEOUT_CFG_TZ_SECURE (1 << PROTECT_MODE_SHIFT0)
+// Enables PROTECT_MODE.
+#define LOCK_MODE_SHIFT 1
+#define SEC_CARVEOUT_CFG_UNLOCKED (0 << LOCK_MODE_SHIFT)
+#define SEC_CARVEOUT_CFG_LOCKED (1 << LOCK_MODE_SHIFT)
+
+#define ADDRESS_TYPE_SHIFT 2
+#define SEC_CARVEOUT_CFG_ANY_ADDRESS (0 << ADDRESS_TYPE_SHIFT)
+#define SEC_CARVEOUT_CFG_UNTRANSLATED_ONLY (1 << ADDRESS_TYPE_SHIFT)
+
+#define READ_ACCESS_LEVEL_SHIFT 3
+#define SEC_CARVEOUT_CFG_RD_ALL (1 << READ_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_RD_UNK (2 << READ_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_RD_FALCON_LS (4 << READ_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_RD_FALCON_HS (8 << READ_ACCESS_LEVEL_SHIFT)
+
+#define WRITE_ACCESS_LEVEL_SHIFT 7
+#define SEC_CARVEOUT_CFG_WR_ALL (1 << WRITE_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_WR_UNK (2 << WRITE_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_WR_FALCON_LS (4 << WRITE_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_WR_FALCON_HS (8 << WRITE_ACCESS_LEVEL_SHIFT)
+
+#define SEC_CARVEOUT_CFG_APERTURE_ID_MASK (3 << 11)
+
+#define DISABLE_READ_CHECK_ACCESS_LEVEL_SHIFT 14
+#define SEC_CARVEOUT_CFG_DIS_RD_CHECK_L0 (1 << DISABLE_READ_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_RD_CHECK_L1 (2 << DISABLE_READ_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_RD_CHECK_L2 (4 << DISABLE_READ_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_RD_CHECK_L3 (8 << DISABLE_READ_CHECK_ACCESS_LEVEL_SHIFT)
+
+#define DISABLE_WRITE_CHECK_ACCESS_LEVEL_SHIFT 18
+#define SEC_CARVEOUT_CFG_DIS_WR_CHECK_L0 (1 << DISABLE_WRITE_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_WR_CHECK_L1 (2 << DISABLE_WRITE_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_WR_CHECK_L2 (4 << DISABLE_WRITE_CHECK_ACCESS_LEVEL_SHIFT)
+#define SEC_CARVEOUT_CFG_DIS_WR_CHECK_L3 (8 << DISABLE_WRITE_CHECK_ACCESS_LEVEL_SHIFT)
+
+#define SEC_CARVEOUT_CFG_SEND_CFG_TO_GPU (1 << 22)
+
+#define SEC_CARVEOUT_CFG_TZ_GLOBAL_WR_EN_BYPASS_CHECK (1 << 23)
+#define SEC_CARVEOUT_CFG_TZ_GLOBAL_RD_EN_BYPASS_CHECK (1 << 24)
+
+#define SEC_CARVEOUT_CFG_ALLOW_APERTURE_ID_MISMATCH (1 << 25)
+#define SEC_CARVEOUT_CFG_FORCE_APERTURE_ID_MATCH (1 << 26)
+
+#define SEC_CARVEOUT_CFG_IS_WPR (1 << 27)
+
#endif
diff --git a/source/mem/minerva.c b/source/mem/minerva.c
index 84efee0..2607c4b 100644
--- a/source/mem/minerva.c
+++ b/source/mem/minerva.c
@@ -27,6 +27,7 @@
#include "../soc/t210.h"
extern volatile nyx_storage_t *nyx_str;
+void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *);
u32 minerva_init()
{
@@ -37,7 +38,7 @@ u32 minerva_init()
memset(mtc_cfg, 0, sizeof(mtc_config_t));
// Set table to nyx storage.
- mtc_cfg->mtc_table = (emc_table_t *)&nyx_str->mtc_table;
+ mtc_cfg->mtc_table = (emc_table_t *)nyx_str->mtc_table;
mtc_cfg->sdram_id = (fuse_read_odm(4) >> 3) & 0x1F;
mtc_cfg->init_done = MTC_NEW_MAGIC; // Initialize mtc table.
diff --git a/source/mem/minerva.h b/source/mem/minerva.h
index 00228f4..9be55c9 100644
--- a/source/mem/minerva.h
+++ b/source/mem/minerva.h
@@ -57,7 +57,7 @@ typedef enum
FREQ_1600 = 1600000
} minerva_freq_t;
-void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *);
+extern void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *);
u32 minerva_init();
void minerva_change_freq(minerva_freq_t freq);
void minerva_periodic_training();
diff --git a/source/mem/sdram.c b/source/mem/sdram.c
index 3bc283d..36f54c1 100644
--- a/source/mem/sdram.c
+++ b/source/mem/sdram.c
@@ -16,6 +16,8 @@
* along with this program. If not, see .
*/
+#include
+
#include "mc.h"
#include "emc.h"
#include "sdram_param_t210.h"
@@ -29,7 +31,7 @@
#include "../soc/t210.h"
#include "../utils/util.h"
-#define CONFIG_SDRAM_COMPRESS_CFG
+#define CONFIG_SDRAM_KEEP_ALIVE
#ifdef CONFIG_SDRAM_COMPRESS_CFG
#include "../libs/compr/lz.h"
@@ -40,13 +42,57 @@
static u32 _get_sdram_id()
{
- u32 sdram_id = (fuse_read_odm(4) & 0x38) >> 3;
+ return ((fuse_read_odm(4) & 0x38) >> 3);
+}
- // Check if id is proper.
- if (sdram_id > 7)
- sdram_id = 0;
+static bool _sdram_wait_emc_status(u32 reg_offset, u32 bit_mask, bool updated_state, s32 emc_channel)
+{
+ bool err = true;
- return sdram_id;
+ for (s32 i = 0; i < EMC_STATUS_UPDATE_TIMEOUT; i++)
+ {
+ if (emc_channel)
+ {
+ if (emc_channel != 1)
+ goto done;
+
+ if (((EMC_CH1(reg_offset) & bit_mask) != 0) == updated_state)
+ {
+ err = false;
+ break;
+ }
+ }
+ else if (((EMC(reg_offset) & bit_mask) != 0) == updated_state)
+ {
+ err = false;
+ break;
+ }
+ usleep(1);
+ }
+
+done:
+ return err;
+}
+
+static void _sdram_req_mrr_data(u32 data, bool dual_channel)
+{
+ EMC(EMC_MRR) = data;
+ _sdram_wait_emc_status(EMC_EMC_STATUS, EMC_STATUS_MRR_DIVLD, true, EMC_CHAN0);
+ if (dual_channel)
+ _sdram_wait_emc_status(EMC_EMC_STATUS, EMC_STATUS_MRR_DIVLD, true, EMC_CHAN1);
+}
+
+emc_mr_data_t sdram_read_mrx(emc_mr_t mrx)
+{
+ emc_mr_data_t data;
+ _sdram_req_mrr_data((1 << 31) | (mrx << 16), EMC_CHAN0);
+ data.dev0_ch0 = EMC(EMC_MRR) & 0xFF;
+ data.dev0_ch1 = (EMC(EMC_MRR) & 0xFF00 >> 8);
+ _sdram_req_mrr_data((1 << 30) | (mrx << 16), EMC_CHAN1);
+ data.dev1_ch0 = EMC(EMC_MRR) & 0xFF;
+ data.dev1_ch1 = (EMC(EMC_MRR) & 0xFF00 >> 8);
+
+ return data;
}
static void _sdram_config(const sdram_params_t *params)
@@ -73,10 +119,14 @@ static void _sdram_config(const sdram_params_t *params)
CLOCK(CLK_RST_CONTROLLER_PLLM_MISC1) = params->pllm_setup_control;
CLOCK(CLK_RST_CONTROLLER_PLLM_MISC2) = 0;
- // u32 tmp = (params->pllm_feedback_divider << 8) | params->pllm_input_divider | ((params->pllm_post_divider & 0xFFFF) << 20);
- // CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) = tmp;
- // CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) = tmp | 0x40000000;
- CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) = (params->pllm_feedback_divider << 8) | params->pllm_input_divider | 0x40000000 | ((params->pllm_post_divider & 0xFFFF) << 20);
+#ifdef CONFIG_SDRAM_KEEP_ALIVE
+ CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) =
+ (params->pllm_feedback_divider << 8) | params->pllm_input_divider | ((params->pllm_post_divider & 0xFFFF) << 20) | PLLCX_BASE_ENABLE;
+#else
+ u32 pllm_div = (params->pllm_feedback_divider << 8) | params->pllm_input_divider | ((params->pllm_post_divider & 0xFFFF) << 20);
+ CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) = pllm_div;
+ CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) = pllm_div | PLLCX_BASE_ENABLE;
+#endif
u32 wait_end = get_tmr_us() + 300;
while (!(CLOCK(CLK_RST_CONTROLLER_PLLM_BASE) & 0x8000000))
@@ -91,7 +141,7 @@ break_nosleep:
if (params->emc_clock_source_dll)
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_EMC_DLL) = params->emc_clock_source_dll;
if (params->clear_clock2_mc1)
- CLOCK(CLK_RST_CONTROLLER_CLK_ENB_W_CLR) = 0x40000000;
+ CLOCK(CLK_RST_CONTROLLER_CLK_ENB_W_CLR) = 0x40000000; // Clear Reset to MC1.
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_H_SET) = 0x2000001; // Enable EMC and MEM clocks.
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_X_SET) = 0x4000; // Enable EMC_DLL clock.
@@ -509,9 +559,9 @@ break_nosleep:
// ZQ CAL setup (not actually issuing ZQ CAL now).
if (params->emc_zcal_warm_cold_boot_enables & 1)
{
- if (params->memory_type == 2)
+ if (params->memory_type == MEMORY_TYPE_DDR3L)
EMC(EMC_ZCAL_WAIT_CNT) = params->emc_zcal_wait_cnt << 3;
- if (params->memory_type == 3)
+ if (params->memory_type == MEMORY_TYPE_LPDDR4)
{
EMC(EMC_ZCAL_WAIT_CNT) = params->emc_zcal_wait_cnt;
EMC(EMC_ZCAL_MRW_CMD) = params->emc_zcal_mrw_cmd;
@@ -527,7 +577,7 @@ break_nosleep:
// Set clock enable signal.
u32 pin_gpio_cfg = (params->emc_pin_gpio_enable << 16) | (params->emc_pin_gpio << 12);
- if (params->memory_type == 2 || params->memory_type == 3)
+ if (params->memory_type == MEMORY_TYPE_DDR3L || params->memory_type == MEMORY_TYPE_LPDDR4)
{
EMC(EMC_PIN) = pin_gpio_cfg;
(void)EMC(EMC_PIN);
@@ -536,9 +586,9 @@ break_nosleep:
(void)EMC(EMC_PIN);
}
- if (params->memory_type == 3)
+ if (params->memory_type == MEMORY_TYPE_LPDDR4)
usleep(params->emc_pin_extra_wait + 2000);
- else if (params->memory_type == 2)
+ else if (params->memory_type == MEMORY_TYPE_DDR3L)
usleep(params->emc_pin_extra_wait + 500);
// Enable clock enable signal.
@@ -547,15 +597,15 @@ break_nosleep:
usleep(params->emc_pin_program_wait);
// Send NOP (trigger just needs to be non-zero).
- if (params->memory_type != 3)
+ if (params->memory_type != MEMORY_TYPE_LPDDR4)
EMC(EMC_NOP) = (params->emc_dev_select << 30) + 1;
// On coldboot w/LPDDR2/3, wait 200 uSec after asserting CKE high.
- if (params->memory_type == 1)
+ if (params->memory_type == MEMORY_TYPE_LPDDR2)
usleep(params->emc_pin_extra_wait + 200);
// Init zq calibration,
- if (params->memory_type == 3)
+ if (params->memory_type == MEMORY_TYPE_LPDDR4)
{
// Patch 6 using BCT spare variables.
if (params->emc_bct_spare10)
@@ -596,7 +646,7 @@ break_nosleep:
PMC(APBDEV_PMC_DDR_CFG) = params->pmc_ddr_cfg;
// Start periodic ZQ calibration (LPDDRx only).
- if (params->memory_type - 1 <= 2)
+ if (params->memory_type && params->memory_type <= MEMORY_TYPE_LPDDR4)
{
EMC(EMC_ZCAL_INTERVAL) = params->emc_zcal_interval;
EMC(EMC_ZCAL_WAIT_CNT) = params->emc_zcal_wait_cnt;
@@ -641,18 +691,47 @@ break_nosleep:
MC(MC_SEC_CARVEOUT_REG_CTRL) = params->mc_sec_carveout_protect_write_access;
MC(MC_MTS_CARVEOUT_REG_CTRL) = params->mc_mts_carveout_reg_ctrl;
- //Disable write access to a bunch of EMC registers.
+ // Disable write access to a bunch of EMC registers.
MC(MC_EMEM_CFG_ACCESS_CTRL) = 1;
}
+#ifndef CONFIG_SDRAM_COMPRESS_CFG
+static void _sdram_patch_model_params(u32 dramid, u32 *params)
+{
+ for (u32 i = 0; i < sizeof(sdram_cfg_vendor_patches) / sizeof(sdram_vendor_patch_t); i++)
+ if (sdram_cfg_vendor_patches[i].dramid & DRAM_ID(dramid))
+ params[sdram_cfg_vendor_patches[i].addr] = sdram_cfg_vendor_patches[i].val;
+}
+#endif
+
sdram_params_t *sdram_get_params()
{
+ // Check if id is proper.
+ u32 dramid = _get_sdram_id();
+ if (dramid > 6)
+ dramid = 0;
+
#ifdef CONFIG_SDRAM_COMPRESS_CFG
u8 *buf = (u8 *)SDRAM_PARAMS_ADDR;
LZ_Uncompress(_dram_cfg_lz, buf, sizeof(_dram_cfg_lz));
- return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()];
+ return (sdram_params_t *)&buf[sizeof(sdram_params_t) * dramid];
#else
- return _dram_cfgs[_get_sdram_id()];
+ sdram_params_t *buf = (sdram_params_t *)SDRAM_PARAMS_ADDR;
+ memcpy(buf, &_dram_cfg_0_samsung_4gb, sizeof(sdram_params_t));
+ switch (dramid)
+ {
+ case DRAM_4GB_SAMSUNG_K4F6E304HB_MGCH:
+ case DRAM_4GB_MICRON_MT53B512M32D2NP_062_WT:
+ break;
+ case DRAM_4GB_HYNIX_H9HCNNNBPUMLHR_NLN:
+ case DRAM_4GB_COPPER_UNK_3:
+ case DRAM_6GB_SAMSUNG_K4FHE3D4HM_MFCH:
+ case DRAM_4GB_COPPER_UNK_5:
+ case DRAM_4GB_COPPER_UNK_6:
+ _sdram_patch_model_params(dramid, (u32 *)buf);
+ break;
+ }
+ return buf;
#endif
}
diff --git a/source/mem/sdram.h b/source/mem/sdram.h
index badc703..059bc9c 100644
--- a/source/mem/sdram.h
+++ b/source/mem/sdram.h
@@ -17,11 +17,13 @@
#ifndef _SDRAM_H_
#define _SDRAM_H_
+#include "emc.h"
#include "sdram_param_t210.h"
void sdram_init();
sdram_params_t *sdram_get_params();
sdram_params_t *sdram_get_params_patched();
void sdram_lp0_save_params(const void *params);
+emc_mr_data_t sdram_read_mrx(emc_mr_t mrx);
#endif
diff --git a/source/mem/sdram_config.inl b/source/mem/sdram_config.inl
index d23f4da..58eb62d 100644
--- a/source/mem/sdram_config.inl
+++ b/source/mem/sdram_config.inl
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -14,1139 +15,683 @@
* along with this program. If not, see .
*/
-static const u8 _dram_cfg_0[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x10, 0x00, 0x10, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+#define DRAM_ID(x) (1 << (x))
+
+#define DRAM_4GB_SAMSUNG_K4F6E304HB_MGCH 0
+#define DRAM_4GB_HYNIX_H9HCNNNBPUMLHR_NLN 1
+#define DRAM_4GB_MICRON_MT53B512M32D2NP_062_WT 2
+#define DRAM_4GB_COPPER_UNK_3 3 // Samsung?
+#define DRAM_6GB_SAMSUNG_K4FHE3D4HM_MFCH 4
+#define DRAM_4GB_COPPER_UNK_5 5 // Samsung?
+#define DRAM_4GB_COPPER_UNK_6 6 // Samsung?
+
+typedef struct _sdram_vendor_patch_t
+{
+ u32 val;
+ u16 addr:9;
+ u16 dramid:7;
+} sdram_vendor_patch_t;
+
+static const sdram_params_t _dram_cfg_0_samsung_4gb = {
+ /* Specifies the type of memory device */
+ .memory_type = MEMORY_TYPE_LPDDR4,
+
+ /* MC/EMC clock source configuration */
+ .pllm_input_divider = 0x00000001, // M div.
+ .pllm_feedback_divider = 0x00000022, // N div.
+ .pllm_stable_time = 0x0000012C,
+ .pllm_setup_control = 0x00000000,
+ .pllm_post_divider = 0x00000000, // P div.
+ .pllm_kcp = 0x00000000,
+ .pllm_kvco = 0x00000000,
+
+ /* Spare BCT params */
+ .emc_bct_spare0 = 0x00000000,
+ .emc_bct_spare1 = 0x00000000,
+ .emc_bct_spare2 = 0x00000000,
+ .emc_bct_spare3 = 0x00000000,
+ .emc_bct_spare4 = 0x7001BC68, // EMC_PMACRO_COMMON_PAD_TX_CTRL.
+ .emc_bct_spare5 = 0x0000000A,
+ .emc_bct_spare6 = 0x7001B404, // EMC_SWIZZLE_RANK0_BYTE0.
+ .emc_bct_spare7 = 0x76543201,
+ .emc_bct_spare8 = 0x7000E6C8, // APBDEV_PMC_WEAK_BIAS.
+ .emc_bct_spare9 = 0x00000000,
+ .emc_bct_spare10 = 0x00000000,
+ .emc_bct_spare11 = 0x00000000,
+ .emc_bct_spare12 = 0x00000000, // Used to hold EMC_PMACRO_BG_BIAS_CTRL.
+ .emc_bct_spare13 = 0x00000034,
+
+ /* EMC clock configuration */
+ .emc_clock_source = 0x40188002,
+ .emc_clock_source_dll = 0x40000000,
+
+ .clk_rst_pllm_misc20_override = 0x00000000,
+ .clk_rst_pllm_misc20_override_enable = 0x00000000,
+
+ .clear_clock2_mc1 = 0x00000000,
+
+ /* Auto-calibration of EMC pads */
+ .emc_auto_cal_interval = 0x001FFFFF,
+
+ .emc_auto_cal_config = 0xA01A51D8,
+ .emc_auto_cal_config2 = 0x05500000,
+ .emc_auto_cal_config3 = 0x00770000,
+
+ .emc_auto_cal_config4 = 0x00770000,
+ .emc_auto_cal_config5 = 0x00770000,
+ .emc_auto_cal_config6 = 0x00770000,
+ .emc_auto_cal_config7 = 0x00770000,
+ .emc_auto_cal_config8 = 0x00770000,
+
+ .emc_auto_cal_vref_sel0 = 0xB3AFA6A6,
+ .emc_auto_cal_vref_sel1 = 0x00009E3C,
+
+ .emc_auto_cal_channel = 0xC1E00303,
+
+ .emc_pmacro_auto_cal_cfg0 = 0x04040404,
+ .emc_pmacro_auto_cal_cfg1 = 0x04040404,
+ .emc_pmacro_auto_cal_cfg2 = 0x00000000,
+
+ .emc_pmacro_rx_term = 0x1F1F1F1F,
+ .emc_pmacro_dq_tx_drive = 0x1F1F1F1F,
+ .emc_pmacro_ca_tx_drive = 0x1F1F1F1F,
+ .emc_pmacro_cmd_tx_drive = 0x00001F1F,
+ .emc_pmacro_auto_cal_common = 0x00000804,
+ .emc_pmacro_zcrtl = 0x00000550,
+
+ /* Specifies the time for the calibration to stabilize (in microseconds) */
+ .emc_auto_cal_wait = 0x000001A1,
+
+ .emc_xm2_comp_pad_ctrl = 0x00000032,
+ .emc_xm2_comp_pad_ctrl2 = 0x00000000,
+ .emc_xm2_comp_pad_ctrl3 = 0x00000000,
+
+ /*
+ * DRAM size information
+ * Specifies the value for EMC_ADR_CFG
+ */
+ .emc_adr_cfg = 0x00000001,
+
+ /*
+ * Specifies the time to wait after asserting pin
+ * CKE (in microseconds)
+ */
+ .emc_pin_program_wait = 0x00000002,
+ /* Specifies the extra delay before/after pin RESET/CKE command */
+ .emc_pin_extra_wait = 0x00000000,
+
+ .emc_pin_gpio_enable = 0x00000003,
+ .emc_pin_gpio = 0x00000003,
+
+ /* Specifies the extra delay after the first writing of EMC_TIMING_CONTROL */
+ .emc_timing_control_wait = 0x0000001E,
+
+ /* Timing parameters required for the SDRAM */
+ .emc_rc = 0x0000000D,
+ .emc_rfc = 0x00000025,
+ .emc_rfc_pb = 0x00000013,
+ .emc_ref_ctrl2 = 0x00000000,
+ .emc_rfc_slr = 0x00000000,
+ .emc_ras = 0x00000009,
+ .emc_rp = 0x00000004,
+ .emc_r2r = 0x00000000,
+ .emc_w2w = 0x00000000,
+ .emc_r2w = 0x0000000B,
+ .emc_w2r = 0x0000000D,
+ .emc_r2p = 0x00000008,
+ .emc_w2p = 0x0000000B,
+ .emc_tppd = 0x00000004,
+ .emc_ccdmw = 0x00000020,
+ .emc_rd_rcd = 0x00000006,
+ .emc_wr_rcd = 0x00000006,
+ .emc_rrd = 0x00000006,
+ .emc_rext = 0x00000003,
+ .emc_wext = 0x00000000,
+ .emc_wdv = 0x00000004,
+ .emc_wdv_chk = 0x00000006,
+ .emc_wsv = 0x00000002,
+ .emc_wev = 0x00000000,
+ .emc_wdv_mask = 0x00000004,
+ .emc_ws_duration = 0x00000008,
+ .emc_we_duration = 0x0000000D,
+ .emc_quse = 0x00000005,
+ .emc_quse_width = 0x00000006,
+ .emc_ibdly = 0x00000000,
+ .emc_obdly = 0x00000000,
+ .emc_einput = 0x00000002,
+ .emc_einput_duration = 0x0000000D,
+ .emc_puterm_extra = 0x00000000,
+ .emc_puterm_width = 0x0000000B,
+ .emc_qrst = 0x00010000,
+ .emc_qsafe = 0x00000012,
+ .emc_rdv = 0x00000014,
+ .emc_rdv_mask = 0x00000016,
+ .emc_rdv_early = 0x00000012,
+ .emc_rdv_early_mask = 0x00000014,
+ .emc_qpop = 0x0000000A,
+ .emc_refresh = 0x00000304,
+ .emc_burst_refresh_num = 0x00000000,
+ .emc_prerefresh_req_cnt = 0x000000C1,
+ .emc_pdex2wr = 0x00000008,
+ .emc_pdex2rd = 0x00000008,
+ .emc_pchg2pden = 0x00000003,
+ .emc_act2pden = 0x00000003,
+ .emc_ar2pden = 0x00000003,
+ .emc_rw2pden = 0x00000014,
+ .emc_cke2pden = 0x00000005,
+ .emc_pdex2che = 0x00000002,
+ .emc_pdex2mrr = 0x0000000D,
+ .emc_txsr = 0x00000027,
+ .emc_txsr_dll = 0x00000027,
+ .emc_tcke = 0x00000005,
+ .emc_tckesr = 0x00000005,
+ .emc_tpd = 0x00000004,
+ .emc_tfaw = 0x00000009,
+ .emc_trpab = 0x00000005,
+ .emc_tclkstable = 0x00000004,
+ .emc_tclkstop = 0x00000009,
+ .emc_trefbw = 0x0000031C,
+
+ /* FBIO configuration values */
+ .emc_fbio_cfg5 = 0x9160A00D,
+ .emc_fbio_cfg7 = 0x00003BBF,
+ .emc_fbio_cfg8 = 0x0CF30000,
+
+ /* Command mapping for CMD brick 0 */
+ .emc_cmd_mapping_cmd0_0 = 0x061B0504,
+ .emc_cmd_mapping_cmd0_1 = 0x1C070302,
+ .emc_cmd_mapping_cmd0_2 = 0x05252523,
+ .emc_cmd_mapping_cmd1_0 = 0x0A091D08,
+ .emc_cmd_mapping_cmd1_1 = 0x0D1E0B24,
+ .emc_cmd_mapping_cmd1_2 = 0x0326260C,
+ .emc_cmd_mapping_cmd2_0 = 0x231C1B02,
+ .emc_cmd_mapping_cmd2_1 = 0x05070403,
+ .emc_cmd_mapping_cmd2_2 = 0x02252506,
+ .emc_cmd_mapping_cmd3_0 = 0x0D1D0B0A,
+ .emc_cmd_mapping_cmd3_1 = 0x1E090C08,
+ .emc_cmd_mapping_cmd3_2 = 0x08262624,
+ .emc_cmd_mapping_byte = 0x9A070624,
+
+ .emc_fbio_spare = 0x00000012,
+ .emc_cfg_rsv = 0xFF00FF00,
+
+ /* MRS command values */
+ .emc_mrs = 0x00000000,
+ .emc_emrs = 0x00000000,
+ .emc_emrs2 = 0x00000000,
+ .emc_emrs3 = 0x00000000,
+ .emc_mrw1 = 0x08010004,
+ .emc_mrw2 = 0x08020000,
+ .emc_mrw3 = 0x080D0000,
+ .emc_mrw4 = 0xC0000000,
+ .emc_mrw6 = 0x08037171,
+ .emc_mrw8 = 0x080B0000,
+ .emc_mrw9 = 0x0C0E7272,
+ .emc_mrw10 = 0x00000000,
+ .emc_mrw12 = 0x0C0D0808,
+ .emc_mrw13 = 0x0C0D0000,
+ .emc_mrw14 = 0x08161414,
+ .emc_mrw_extra = 0x08010004,
+ .emc_warm_boot_mrw_extra = 0x08110000,
+ .emc_warm_boot_extramode_reg_write_enable = 0x00000001,
+ .emc_extramode_reg_write_enable = 0x00000000,
+ .emc_mrw_reset_command = 0x00000000,
+ .emc_mrw_reset_ninit_wait = 0x00000000,
+ .emc_mrs_wait_cnt = 0x00CC0015,
+ .emc_mrs_wait_cnt2 = 0x0033000A,
+
+ /* EMC miscellaneous configurations */
+ .emc_cfg = 0xF3200000,
+ .emc_cfg2 = 0x00110805,
+ .emc_cfg_pipe = 0x0FFF0FFF,
+ .emc_cfg_pipe_clk = 0x00000000,
+ .emc_fdpd_ctrl_cmd_no_ramp = 0x00000001,
+ .emc_cfg_update = 0x70000301,
+ .emc_dbg = 0x01000C00,
+ .emc_dbg_write_mux = 0x00000001,
+ .emc_cmd_q = 0x10004408,
+ .emc_mc2emc_q = 0x06000404,
+ .emc_dyn_self_ref_control = 0x80000713,
+ .ahb_arbitration_xbar_ctrl_meminit_done = 0x00000001,
+ .emc_cfg_dig_dll = 0x002C00A0,
+ .emc_cfg_dig_dll_1 = 0x00003701,
+ .emc_cfg_dig_dll_period = 0x00008000,
+ .emc_dev_select = 0x00000000,
+ .emc_sel_dpd_ctrl = 0x00040008,
+
+ /* Pads trimmer delays */
+ .emc_fdpd_ctrl_dq = 0x8020221F,
+ .emc_fdpd_ctrl_cmd = 0x0220F40F,
+ .emc_pmacro_ib_vref_dq_0 = 0x28282828,
+ .emc_pmacro_ib_vref_dq_1 = 0x28282828,
+ .emc_pmacro_ib_vref_dqs_0 = 0x11111111,
+ .emc_pmacro_ib_vref_dqs_1 = 0x11111111,
+ .emc_pmacro_ib_rxrt = 0x000000BE,
+ .emc_cfg_pipe1 = 0x0FFF0FFF,
+ .emc_cfg_pipe2 = 0x0FFF0FFF,
+
+ .emc_pmacro_quse_ddll_rank0_0 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank0_1 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank0_2 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank0_3 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank0_4 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank0_5 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_0 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_1 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_2 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_3 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_4 = 0x00000000,
+ .emc_pmacro_quse_ddll_rank1_5 = 0x00000000,
+
+ .emc_pmacro_ob_ddll_long_dq_rank0_0 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank0_1 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank0_2 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank0_3 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank0_4 = 0x00120014,
+ .emc_pmacro_ob_ddll_long_dq_rank0_5 = 0x00140010,
+ .emc_pmacro_ob_ddll_long_dq_rank1_0 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank1_1 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank1_2 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank1_3 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dq_rank1_4 = 0x00120014,
+ .emc_pmacro_ob_ddll_long_dq_rank1_5 = 0x00140010,
+
+ .emc_pmacro_ob_ddll_long_dqs_rank0_0 = 0x002E0030,
+ .emc_pmacro_ob_ddll_long_dqs_rank0_1 = 0x00300033,
+ .emc_pmacro_ob_ddll_long_dqs_rank0_2 = 0x00350033,
+ .emc_pmacro_ob_ddll_long_dqs_rank0_3 = 0x00320030,
+ .emc_pmacro_ob_ddll_long_dqs_rank0_4 = 0x00000005,
+ .emc_pmacro_ob_ddll_long_dqs_rank0_5 = 0x00000000,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_0 = 0x002E0030,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_1 = 0x00300033,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_2 = 0x00350033,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_3 = 0x00320030,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_4 = 0x00000005,
+ .emc_pmacro_ob_ddll_long_dqs_rank1_5 = 0x00000000,
+
+ .emc_pmacro_ib_ddll_long_dqs_rank0_0 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank0_1 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank0_2 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank0_3 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank1_0 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank1_1 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank1_2 = 0x00280028,
+ .emc_pmacro_ib_ddll_long_dqs_rank1_3 = 0x00280028,
+
+ .emc_pmacro_ddll_long_cmd_0 = 0x00140014,
+ .emc_pmacro_ddll_long_cmd_1 = 0x00120012,
+ .emc_pmacro_ddll_long_cmd_2 = 0x00100010,
+ .emc_pmacro_ddll_long_cmd_3 = 0x00140014,
+ .emc_pmacro_ddll_long_cmd_4 = 0x00000014,
+ .emc_pmacro_ddll_short_cmd_0 = 0x00000000,
+ .emc_pmacro_ddll_short_cmd_1 = 0x00000000,
+ .emc_pmacro_ddll_short_cmd_2 = 0x00000000,
+
+ /*
+ * Specifies the delay after asserting CKE pin during a WarmBoot0
+ * sequence (in microseconds)
+ */
+ .warm_boot_wait = 0x00000001,
+
+ .emc_odt_write = 0x00000000,
+
+ /* Periodic ZQ calibration */
+
+ /*
+ * Specifies the value for EMC_ZCAL_INTERVAL
+ * Value 0 disables ZQ calibration
+ */
+ .emc_zcal_interval = 0x00064000,
+ .emc_zcal_wait_cnt = 0x000900CC,
+ .emc_zcal_mrw_cmd = 0x0051004F,
+
+ /* DRAM initialization sequence flow control */
+ .emc_mrs_reset_dll = 0x00000000,
+ .emc_zcal_init_dev0 = 0x80000001,
+ .emc_zcal_init_dev1 = 0x40000001,
+ /*
+ * Specifies the wait time after programming a ZQ initialization
+ * command (in microseconds)
+ */
+ .emc_zcal_init_wait = 0x00000001,
+ /*
+ * Specifies the enable for ZQ calibration at cold boot [bit 0]
+ * and warm boot [bit 1]
+ */
+ .emc_zcal_warm_cold_boot_enables = 0x00000003,
+
+ /*
+ * Specifies the MRW command to LPDDR2 for ZQ calibration
+ * on warmboot
+ */
+ /* Is issued to both devices separately */
+ .emc_mrw_lpddr2zcal_warm_boot = 0x040A00AB,
+ /*
+ * Specifies the ZQ command to DDR3 for ZQ calibration on warmboot
+ * Is issued to both devices separately
+ */
+ .emc_zqcal_ddr3_warm_boot = 0x00000011,
+ .emc_zqcal_lpddr4_warm_boot = 0x00000001,
+
+ /*
+ * Specifies the wait time for ZQ calibration on warmboot
+ * (in microseconds)
+ */
+ .emc_zcal_warm_boot_wait = 0x00000001,
+ /*
+ * Specifies the enable for DRAM Mode Register programming
+ * at warm boot
+ */
+ .emc_mrs_warm_boot_enable = 0x00000001,
+ .emc_mrs_reset_dll_wait = 0x00000000,
+ .emc_mrs_extra = 0x00000000,
+ .emc_warm_boot_mrs_extra = 0x00000000,
+ .emc_emrs_ddr2_dll_enable = 0x00000000,
+ .emc_mrs_ddr2_dll_reset = 0x00000000,
+ .emc_emrs_ddr2_ocd_calib = 0x00000000,
+ /*
+ * Specifies the wait between initializing DDR and setting OCD
+ * calibration (in microseconds)
+ */
+ .emc_ddr2_wait = 0x00000000,
+ .emc_clken_override = 0x00000000,
+ /*
+ * Specifies LOG2 of the extra refresh numbers after booting
+ * Program 0 to disable
+ */
+ .emc_extra_refresh_num = 0x00000002,
+ .emc_clken_override_allwarm_boot = 0x00000000,
+ .mc_clken_override_allwarm_boot = 0x00000000,
+ /* Specifies digital dll period, choosing between 4 to 64 ms */
+ .emc_cfg_dig_dll_period_warm_boot = 0x00000003,
+
+ /* Pad controls */
+ .pmc_vddp_sel = 0x00000001,
+ .pmc_vddp_sel_wait = 0x00000002,
+ .pmc_ddr_pwr = 0x0000000F,
+ .pmc_ddr_cfg = 0x04220100,
+ .pmc_io_dpd3_req = 0x4FAFFFFF,
+ .pmc_io_dpd3_req_wait = 0x00000001,
+ .pmc_io_dpd4_req_wait = 0x00000002,
+ .pmc_reg_short = 0x00000000,
+ .pmc_no_io_power = 0x00000000,
+ .pmc_ddr_ctrl_wait = 0x00000000,
+ .pmc_ddr_ctrl = 0x0007FF8B,
+ .emc_acpd_control = 0x00000000,
+
+ .emc_swizzle_rank0_byte0 = 0x76543201,
+ .emc_swizzle_rank0_byte1 = 0x65324710,
+ .emc_swizzle_rank0_byte2 = 0x25763410,
+ .emc_swizzle_rank0_byte3 = 0x25673401,
+ .emc_swizzle_rank1_byte0 = 0x32647501,
+ .emc_swizzle_rank1_byte1 = 0x34567201,
+ .emc_swizzle_rank1_byte2 = 0x56742310,
+ .emc_swizzle_rank1_byte3 = 0x67324501,
+
+ .emc_txdsrvttgen = 0x00000000,
+
+ .emc_data_brlshft0 = 0x00249249,
+ .emc_data_brlshft1 = 0x00249249,
+
+ .emc_dqs_brlshft0 = 0x00000000,
+ .emc_dqs_brlshft1 = 0x00000000,
+
+ .emc_cmd_brlshft0 = 0x00000000,
+ .emc_cmd_brlshft1 = 0x00000000,
+ .emc_cmd_brlshft2 = 0x0000001B,
+ .emc_cmd_brlshft3 = 0x0000001B,
+
+ .emc_quse_brlshft0 = 0x00000000,
+ .emc_quse_brlshft1 = 0x00000000,
+ .emc_quse_brlshft2 = 0x00000000,
+ .emc_quse_brlshft3 = 0x00000000,
+
+ .emc_dll_cfg0 = 0x1F13412F,
+ .emc_dll_cfg1 = 0x00010014,
+
+ .emc_pmc_scratch1 = 0x4FAFFFFF,
+ .emc_pmc_scratch2 = 0x7FFFFFFF,
+ .emc_pmc_scratch3 = 0x4006D70B,
+
+ .emc_pmacro_pad_cfg_ctrl = 0x00020000,
+ .emc_pmacro_vttgen_ctrl0 = 0x00030808,
+ .emc_pmacro_vttgen_ctrl1 = 0x00015C00,
+ .emc_pmacro_vttgen_ctrl2 = 0x00101010,
+ .emc_pmacro_brick_ctrl_rfu1 = 0x00001600,
+ .emc_pmacro_cmd_brick_ctrl_fdpd = 0x00000000,
+ .emc_pmacro_brick_ctrl_rfu2 = 0x00000000,
+ .emc_pmacro_data_brick_ctrl_fdpd = 0x00000000,
+ .emc_pmacro_bg_bias_ctrl0 = 0x00000034,
+ .emc_pmacro_data_pad_rx_ctrl = 0x00050037,
+ .emc_pmacro_cmd_pad_rx_ctrl = 0x00000000,
+ .emc_pmacro_data_rx_term_mode = 0x00000010,
+ .emc_pmacro_cmd_rx_term_mode = 0x00003000,
+ .emc_pmacro_data_pad_tx_ctrl = 0x02000111,
+ .emc_pmacro_common_pad_tx_ctrl = 0x00000008,
+ .emc_pmacro_cmd_pad_tx_ctrl = 0x0A000000,
+
+ .emc_cfg3 = 0x00000040,
+
+ .emc_pmacro_tx_pwrd0 = 0x10000000,
+ .emc_pmacro_tx_pwrd1 = 0x08000000,
+ .emc_pmacro_tx_pwrd2 = 0x08000000,
+ .emc_pmacro_tx_pwrd3 = 0x00000000,
+ .emc_pmacro_tx_pwrd4 = 0x00000000,
+ .emc_pmacro_tx_pwrd5 = 0x00001000,
+
+ .emc_config_sample_delay = 0x00000020,
+
+ .emc_pmacro_brick_mapping0 = 0x28091081,
+ .emc_pmacro_brick_mapping1 = 0x44A53293,
+ .emc_pmacro_brick_mapping2 = 0x76678A5B,
+
+ .emc_pmacro_tx_sel_clk_src0 = 0x00000000,
+ .emc_pmacro_tx_sel_clk_src1 = 0x00000000,
+ .emc_pmacro_tx_sel_clk_src2 = 0x00000000,
+ .emc_pmacro_tx_sel_clk_src3 = 0x00000000,
+ .emc_pmacro_tx_sel_clk_src4 = 0x00000000,
+ .emc_pmacro_tx_sel_clk_src5 = 0x00000000,
+
+ .emc_pmacro_ddll_bypass = 0xEFFFEFFF,
+
+ .emc_pmacro_ddll_pwrd0 = 0xC0C0C0C0,
+ .emc_pmacro_ddll_pwrd1 = 0xC0C0C0C0,
+ .emc_pmacro_ddll_pwrd2 = 0xDCDCDCDC,
+
+ .emc_pmacro_cmd_ctrl0 = 0x0A0A0A0A,
+ .emc_pmacro_cmd_ctrl1 = 0x0A0A0A0A,
+ .emc_pmacro_cmd_ctrl2 = 0x0A0A0A0A,
+
+ /* DRAM size information */
+ .mc_emem_adr_cfg = 0x00000001,
+ .mc_emem_adr_cfg_dev0 = 0x00070302,
+ .mc_emem_adr_cfg_dev1 = 0x00070302,
+ .mc_emem_adr_cfg_channel_mask = 0xFFFF2400,
+ .mc_emem_adr_cfg_bank_mask0 = 0x6E574400,
+ .mc_emem_adr_cfg_bank_mask1 = 0x39722800,
+ .mc_emem_adr_cfg_bank_mask2 = 0x4B9C1000,
+ /*
+ * Specifies the value for MC_EMEM_CFG which holds the external memory
+ * size (in KBytes)
+ */
+ .mc_emem_cfg = 0x00001000,
+
+ /* MC arbitration configuration */
+ .mc_emem_arb_cfg = 0x08000001,
+ .mc_emem_arb_outstanding_req = 0x8000004C,
+ .emc_emem_arb_refpb_hp_ctrl = 0x000A1020,
+ .emc_emem_arb_refpb_bank_ctrl = 0x80001028,
+
+ .mc_emem_arb_timing_rcd = 0x00000001,
+ .mc_emem_arb_timing_rp = 0x00000000,
+ .mc_emem_arb_timing_rc = 0x00000003,
+ .mc_emem_arb_timing_ras = 0x00000001,
+ .mc_emem_arb_timing_faw = 0x00000002,
+ .mc_emem_arb_timing_rrd = 0x00000001,
+ .mc_emem_arb_timing_rap2pre = 0x00000002,
+ .mc_emem_arb_timing_wap2pre = 0x00000005,
+ .mc_emem_arb_timing_r2r = 0x00000002,
+ .mc_emem_arb_timing_w2w = 0x00000001,
+ .mc_emem_arb_timing_r2w = 0x00000004,
+ .mc_emem_arb_timing_w2r = 0x00000005,
+ .mc_emem_arb_timing_rfcpb = 0x00000004,
+
+ .mc_emem_arb_da_turns = 0x02020001,
+ .mc_emem_arb_da_covers = 0x00030201,
+ .mc_emem_arb_misc0 = 0x71C30504,
+ .mc_emem_arb_misc1 = 0x70000F0F,
+ .mc_emem_arb_misc2 = 0x00000000,
+
+ .mc_emem_arb_ring1_throttle = 0x001F0000,
+ .mc_emem_arb_override = 0x10000000,
+ .mc_emem_arb_override1 = 0x00000000,
+ .mc_emem_arb_rsv = 0xFF00FF00,
+
+ .mc_da_cfg0 = 0x00000001,
+ .mc_emem_arb_timing_ccdmw = 0x00000008,
+
+ .mc_clken_override = 0x00008000,
+
+ .mc_stat_control = 0x00000000,
+ .mc_video_protect_bom = 0xFFF00000,
+ .mc_video_protect_bom_adr_hi = 0x00000000,
+ .mc_video_protect_size_mb = 0x00000000,
+ .mc_video_protect_vpr_override = 0xE4BAC343,
+ .mc_video_protect_vpr_override1 = 0x00001ED3,
+ .mc_video_protect_gpu_override0 = 0x00000000,
+ .mc_video_protect_gpu_override1 = 0x00000000,
+ .mc_sec_carveout_bom = 0xFFF00000,
+ .mc_sec_carveout_adr_hi = 0x00000000,
+ .mc_sec_carveout_size_mb = 0x00000000,
+ .mc_video_protect_write_access = 0x00000000,
+ .mc_sec_carveout_protect_write_access = 0x00000000,
+
+ .mc_generalized_carveout1_bom = 0x00000000,
+ .mc_generalized_carveout1_bom_hi = 0x00000000,
+ .mc_generalized_carveout1_size_128kb = 0x00000008,
+ .mc_generalized_carveout1_access0 = 0x00000000,
+ .mc_generalized_carveout1_access1 = 0x00000000,
+ .mc_generalized_carveout1_access2 = 0x00300000,
+ .mc_generalized_carveout1_access3 = 0x03000000,
+ .mc_generalized_carveout1_access4 = 0x00000000,
+ .mc_generalized_carveout1_force_internal_access0 = 0x00000000,
+ .mc_generalized_carveout1_force_internal_access1 = 0x00000000,
+ .mc_generalized_carveout1_force_internal_access2 = 0x00000000,
+ .mc_generalized_carveout1_force_internal_access3 = 0x00000000,
+ .mc_generalized_carveout1_force_internal_access4 = 0x00000000,
+ .mc_generalized_carveout1_cfg0 = 0x04000C76,
+
+ .mc_generalized_carveout2_bom = 0x00000000,
+ .mc_generalized_carveout2_bom_hi = 0x00000000,
+ .mc_generalized_carveout2_size_128kb = 0x00000002,
+ .mc_generalized_carveout2_access0 = 0x00000000,
+ .mc_generalized_carveout2_access1 = 0x00000000,
+ .mc_generalized_carveout2_access2 = 0x03000000,
+ .mc_generalized_carveout2_access3 = 0x00000000,
+ .mc_generalized_carveout2_access4 = 0x00000300,
+ .mc_generalized_carveout2_force_internal_access0 = 0x00000000,
+ .mc_generalized_carveout2_force_internal_access1 = 0x00000000,
+ .mc_generalized_carveout2_force_internal_access2 = 0x00000000,
+ .mc_generalized_carveout2_force_internal_access3 = 0x00000000,
+ .mc_generalized_carveout2_force_internal_access4 = 0x00000000,
+ .mc_generalized_carveout2_cfg0 = 0x0440167E,
+
+ .mc_generalized_carveout3_bom = 0x00000000,
+ .mc_generalized_carveout3_bom_hi = 0x00000000,
+ .mc_generalized_carveout3_size_128kb = 0x00000000,
+ .mc_generalized_carveout3_access0 = 0x00000000,
+ .mc_generalized_carveout3_access1 = 0x00000000,
+ .mc_generalized_carveout3_access2 = 0x03000000,
+ .mc_generalized_carveout3_access3 = 0x00000000,
+ .mc_generalized_carveout3_access4 = 0x00000300,
+ .mc_generalized_carveout3_force_internal_access0 = 0x00000000,
+ .mc_generalized_carveout3_force_internal_access1 = 0x00000000,
+ .mc_generalized_carveout3_force_internal_access2 = 0x00000000,
+ .mc_generalized_carveout3_force_internal_access3 = 0x00000000,
+ .mc_generalized_carveout3_force_internal_access4 = 0x00000000,
+ .mc_generalized_carveout3_cfg0 = 0x04401E7E,
+
+ .mc_generalized_carveout4_bom = 0x00000000,
+ .mc_generalized_carveout4_bom_hi = 0x00000000,
+ .mc_generalized_carveout4_size_128kb = 0x00000008,
+ .mc_generalized_carveout4_access0 = 0x00000000,
+ .mc_generalized_carveout4_access1 = 0x00000000,
+ .mc_generalized_carveout4_access2 = 0x00300000,
+ .mc_generalized_carveout4_access3 = 0x00000000,
+ .mc_generalized_carveout4_access4 = 0x000000C0,
+ .mc_generalized_carveout4_force_internal_access0 = 0x00000000,
+ .mc_generalized_carveout4_force_internal_access1 = 0x00000000,
+ .mc_generalized_carveout4_force_internal_access2 = 0x00000000,
+ .mc_generalized_carveout4_force_internal_access3 = 0x00000000,
+ .mc_generalized_carveout4_force_internal_access4 = 0x00000000,
+ .mc_generalized_carveout4_cfg0 = 0x04002446,
+
+ .mc_generalized_carveout5_bom = 0x00000000,
+ .mc_generalized_carveout5_bom_hi = 0x00000000,
+ .mc_generalized_carveout5_size_128kb = 0x00000008,
+ .mc_generalized_carveout5_access0 = 0x00000000,
+ .mc_generalized_carveout5_access1 = 0x00000000,
+ .mc_generalized_carveout5_access2 = 0x00300000,
+ .mc_generalized_carveout5_access3 = 0x00000000,
+ .mc_generalized_carveout5_access4 = 0x00000000,
+ .mc_generalized_carveout5_force_internal_access0 = 0x00000000,
+ .mc_generalized_carveout5_force_internal_access1 = 0x00000000,
+ .mc_generalized_carveout5_force_internal_access2 = 0x00000000,
+ .mc_generalized_carveout5_force_internal_access3 = 0x00000000,
+ .mc_generalized_carveout5_force_internal_access4 = 0x00000000,
+ .mc_generalized_carveout5_cfg0 = 0x04002C46,
+
+ /* Specifies enable for CA training */
+ .emc_ca_training_enable = 0x00000000,
+ /* Set if bit 6 select is greater than bit 7 select; uses aremc.spec packet SWIZZLE_BIT6_GT_BIT7 */
+ .swizzle_rank_byte_encode = 0x000000EC,
+
+ /* Specifies enable and offset for patched boot rom write */
+ .boot_rom_patch_control = 0x00000000,
+ /* Specifies data for patched boot rom write */
+ .boot_rom_patch_data = 0x00000000,
+
+ .mc_mts_carveout_bom = 0xFFF00000,
+ .mc_mts_carveout_adr_hi = 0x00000000,
+ .mc_mts_carveout_size_mb = 0x00000000,
+ .mc_mts_carveout_reg_ctrl = 0x00000000
};
-static const u8 _dram_cfg_1[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x10, 0x00, 0x10, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 _dram_cfg_2[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x10, 0x00, 0x10, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 _dram_cfg_3[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x12, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x10, 0x00, 0x10, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 _dram_cfg_4[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x10, 0x00, 0x14, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x2E, 0x00, 0x33, 0x00, 0x30, 0x00, 0x33, 0x00, 0x35, 0x00,
- 0x30, 0x00, 0x32, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x10, 0x00, 0x10, 0x00, 0x14, 0x00, 0x14, 0x00,
- 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x0C, 0x00,
- 0x02, 0x03, 0x0C, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x18, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 _dram_cfg_5[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
- 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x12, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00,
- 0x32, 0x00, 0x2F, 0x00, 0x32, 0x00, 0x31, 0x00, 0x34, 0x00, 0x36, 0x00,
- 0x2F, 0x00, 0x33, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x32, 0x00, 0x2F, 0x00, 0x32, 0x00, 0x31, 0x00, 0x34, 0x00, 0x36, 0x00,
- 0x2F, 0x00, 0x33, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x15, 0x00, 0x15, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00, 0x16, 0x00,
- 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xC3, 0x71, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u8 _dram_cfg_6[1896] = {
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
- 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x68, 0xBC, 0x01, 0x70, 0x0A, 0x00, 0x00, 0x00, 0x04, 0xB4, 0x01, 0x70,
- 0x01, 0x32, 0x54, 0x76, 0xC8, 0xE6, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x34, 0x00, 0x00, 0x00, 0x02, 0x80, 0x18, 0x40, 0x00, 0x00, 0x00, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0x1F, 0x00, 0xD8, 0x51, 0x1A, 0xA0, 0x00, 0x00, 0x50, 0x05,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x77, 0x00,
- 0xA6, 0xA6, 0xAF, 0xB3, 0x3C, 0x9E, 0x00, 0x00, 0x03, 0x03, 0xE0, 0xC1,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
- 0x1F, 0x1F, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00,
- 0xA1, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
- 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x0A, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC1, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x12, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0D, 0x00, 0x00, 0x00, 0x3B, 0x00, 0x00, 0x00, 0x3B, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x0D, 0xA0, 0x60, 0x91,
- 0xBF, 0x3B, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x0C, 0x04, 0x05, 0x1B, 0x06,
- 0x02, 0x03, 0x07, 0x1C, 0x23, 0x25, 0x25, 0x05, 0x08, 0x1D, 0x09, 0x0A,
- 0x24, 0x0B, 0x1E, 0x0D, 0x0C, 0x26, 0x26, 0x03, 0x02, 0x1B, 0x1C, 0x23,
- 0x03, 0x04, 0x07, 0x05, 0x06, 0x25, 0x25, 0x02, 0x0A, 0x0B, 0x1D, 0x0D,
- 0x08, 0x0C, 0x09, 0x1E, 0x24, 0x26, 0x26, 0x08, 0x24, 0x06, 0x07, 0x9A,
- 0x12, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0D, 0x08,
- 0x00, 0x00, 0x00, 0xC0, 0x71, 0x71, 0x03, 0x08, 0x00, 0x00, 0x0B, 0x08,
- 0x72, 0x72, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0D, 0x0C,
- 0x00, 0x00, 0x0D, 0x0C, 0x14, 0x14, 0x16, 0x08, 0x04, 0x00, 0x01, 0x08,
- 0x00, 0x00, 0x11, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0xCC, 0x00,
- 0x0A, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0xF3, 0x05, 0x08, 0x11, 0x00,
- 0xFF, 0x0F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x44, 0x00, 0x10, 0x04, 0x04, 0x00, 0x06, 0x13, 0x07, 0x00, 0x80,
- 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x2C, 0x00, 0x01, 0x37, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,
- 0x1F, 0x22, 0x20, 0x80, 0x0F, 0xF4, 0x20, 0x02, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
- 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00,
- 0x32, 0x00, 0x2F, 0x00, 0x32, 0x00, 0x31, 0x00, 0x34, 0x00, 0x36, 0x00,
- 0x2F, 0x00, 0x33, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x32, 0x00, 0x2F, 0x00, 0x32, 0x00, 0x31, 0x00, 0x34, 0x00, 0x36, 0x00,
- 0x2F, 0x00, 0x33, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00,
- 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x15, 0x00, 0x15, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x16, 0x00, 0x16, 0x00,
- 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x06, 0x00, 0xCC, 0x00, 0x09, 0x00, 0x4F, 0x00, 0x51, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40,
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xAB, 0x00, 0x0A, 0x04,
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x04, 0xFF, 0xFF, 0xAF, 0x4F,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x54, 0x76, 0x10, 0x47, 0x32, 0x65,
- 0x10, 0x34, 0x76, 0x25, 0x01, 0x34, 0x67, 0x25, 0x01, 0x75, 0x64, 0x32,
- 0x01, 0x72, 0x56, 0x34, 0x10, 0x23, 0x74, 0x56, 0x01, 0x45, 0x32, 0x67,
- 0x00, 0x00, 0x00, 0x00, 0x49, 0x92, 0x24, 0x00, 0x49, 0x92, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x2F, 0x41, 0x13, 0x1F, 0x14, 0x00, 0x01, 0x00,
- 0xFF, 0xFF, 0xAF, 0x4F, 0xFF, 0xFF, 0xFF, 0x7F, 0x0B, 0xD7, 0x06, 0x40,
- 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x03, 0x00, 0x00, 0x5C, 0x01, 0x00,
- 0x10, 0x10, 0x10, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
- 0x37, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x30, 0x00, 0x00, 0x11, 0x01, 0x00, 0x02, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x0A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x81, 0x10, 0x09, 0x28, 0x93, 0x32, 0xA5, 0x44, 0x5B, 0x8A, 0x67, 0x76,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xEF, 0xFF, 0xEF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
- 0xDC, 0xDC, 0xDC, 0xDC, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0A, 0x0A, 0x0A, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x02, 0x03, 0x07, 0x00,
- 0x02, 0x03, 0x07, 0x00, 0x00, 0x24, 0xFF, 0xFF, 0x00, 0x44, 0x57, 0x6E,
- 0x00, 0x28, 0x72, 0x39, 0x00, 0x10, 0x9C, 0x4B, 0x00, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x08, 0x4C, 0x00, 0x00, 0x80, 0x20, 0x10, 0x0A, 0x00,
- 0x28, 0x10, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x05, 0xA3, 0x72, 0x0F, 0x0F, 0x00, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0xC3, 0xBA, 0xE4, 0xD3, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x76, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x16, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x1E, 0x40, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x46, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x46, 0x2C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static const u32 *_dram_cfgs[7] = {
- (const u32 *)_dram_cfg_0,
- (const u32 *)_dram_cfg_1,
- (const u32 *)_dram_cfg_2,
- (const u32 *)_dram_cfg_3,
- (const u32 *)_dram_cfg_4,
- (const u32 *)_dram_cfg_5,
- (const u32 *)_dram_cfg_6
+static const sdram_vendor_patch_t sdram_cfg_vendor_patches[] = {
+ { 0x0000003A, 59, DRAM_ID(6) }, // emc_rfc. Auto refresh.
+ { 0x0000001D, 60, DRAM_ID(6) }, // emc_rfc_pb. Bank Auto refresh.
+ { 0x0000000D, 67, DRAM_ID(1) | DRAM_ID(5) }, // emc_r2w.
+ { 0x00000001, 91, DRAM_ID(1) | DRAM_ID(5) }, // emc_puterm_extra.
+ { 0x80000000, 92, DRAM_ID(1) | DRAM_ID(5) }, // emc_puterm_width.
+ { 0x00000012, 108, DRAM_ID(3) | DRAM_ID(5) | DRAM_ID(6) }, // emc_rw2pden.
+ { 0x0000003B, 112, DRAM_ID(6) }, // emc_txsr.
+ { 0x0000003B, 113, DRAM_ID(6) }, // emc_txsr_dll.
+ { 0x00000003, 119, DRAM_ID(3) | DRAM_ID(5) | DRAM_ID(6) }, // emc_tclkstable.
+ { 0x00120015, 205, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dq_rank0_4.
+ { 0x00160012, 206, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dq_rank0_5.
+ { 0x00120015, 211, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dq_rank1_4.
+ { 0x00160012, 212, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dq_rank1_5.
+ { 0x002F0032, 213, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank0_0.
+ { 0x00310032, 214, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank0_1.
+ { 0x00360034, 215, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank0_2.
+ { 0x0033002F, 216, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank0_3.
+ { 0x00000006, 217, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank0_4.
+ { 0x002F0032, 219, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank1_0.
+ { 0x00310032, 220, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank1_1.
+ { 0x00360034, 221, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank1_2.
+ { 0x0033002F, 222, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank1_3.
+ { 0x00000006, 223, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ob_ddll_long_dqs_rank1_4.
+ { 0x00150015, 233, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ddll_long_cmd_0.
+ { 0x00120012, 235, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ddll_long_cmd_2.
+ { 0x00160016, 236, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ddll_long_cmd_3.
+ { 0x00000015, 237, DRAM_ID(5) | DRAM_ID(6) }, // emc_pmacro_ddll_long_cmd_4.
+ { 0x00000012, 295, DRAM_ID(3) | DRAM_ID(5) | DRAM_ID(6) }, // emc_cmd_brlshft2.
+ { 0x00000012, 296, DRAM_ID(3) | DRAM_ID(5) | DRAM_ID(6) }, // emc_cmd_brlshft3.
+ { 0x00000210, 317, DRAM_ID(1) | DRAM_ID(5) }, // emc_pmacro_data_rx_term_mode.
+ { 0x000C0302, 347, DRAM_ID(4) }, // mc_emem_adr_cfg_dev0. 768MB sub-partition density.
+ { 0x000C0302, 348, DRAM_ID(4) }, // mc_emem_adr_cfg_dev1. 768MB sub-partition density.
+ { 0x00001800, 353, DRAM_ID(4) }, // mc_emem_cfg. 6GB total density.
+ { 0x00000005, 368, DRAM_ID(1) | DRAM_ID(5) }, // mc_emem_arb_timing_r2w.
+ { 0x00000007, 370, DRAM_ID(6) }, // mc_emem_arb_timing_rfcpb. Bank refresh.
+ { 0x72A30504, 373, DRAM_ID(6) } // mc_emem_arb_misc0.
};
diff --git a/source/mem/sdram_param_t210.h b/source/mem/sdram_param_t210.h
index d926fa4..4980918 100644
--- a/source/mem/sdram_param_t210.h
+++ b/source/mem/sdram_param_t210.h
@@ -26,12 +26,12 @@
#ifndef _SDRAM_PARAM_T210_H_
#define _SDRAM_PARAM_T210_H_
-#define MEMORY_TYPE_NONE 0
-#define MEMORY_TYPE_DDR 0
-#define MEMORY_TYPE_LPDDR 0
-#define MEMORY_TYPE_DDR2 0
+#define MEMORY_TYPE_NONE 0
+#define MEMORY_TYPE_DDR 0
+#define MEMORY_TYPE_LPDDR 0
+#define MEMORY_TYPE_DDR2 0
#define MEMORY_TYPE_LPDDR2 1
-#define MEMORY_TYPE_DDR3 2
+#define MEMORY_TYPE_DDR3L 2
#define MEMORY_TYPE_LPDDR4 3
/**
diff --git a/source/power/max17050.h b/source/power/max17050.h
index 30a7ca0..eb55e65 100644
--- a/source/power/max17050.h
+++ b/source/power/max17050.h
@@ -24,6 +24,8 @@
#ifndef __MAX17050_H_
#define __MAX17050_H_
+#include "../utils/types.h"
+
#define MAX17050_STATUS_BattAbsent (1 << 3)
#define MAX17050_DEFAULT_SNS_RESISTOR 10000
@@ -128,5 +130,6 @@ enum MAX17050_reg {
int max17050_get_property(enum MAX17050_reg reg, int *value);
int max17050_fix_configuration();
+u32 max17050_get_cached_batt_volt();
#endif /* __MAX17050_H_ */
diff --git a/source/sec/se.c b/source/sec/se.c
index d129eda..484f3c8 100644
--- a/source/sec/se.c
+++ b/source/sec/se.c
@@ -95,7 +95,12 @@ static int _se_wait()
static int _se_execute(u32 op, void *dst, u32 dst_size, const void *src, u32 src_size)
{
- se_ll_t *ll_dst = (se_ll_t *)(NYX_STORAGE_ADDR - 0x20), *ll_src = (se_ll_t *)(NYX_STORAGE_ADDR - 0x10);
+ static se_ll_t *ll_dst = NULL, *ll_src = NULL;
+ if (!ll_dst)
+ {
+ ll_dst = (se_ll_t *)malloc(sizeof(se_ll_t));
+ ll_src = (se_ll_t *)malloc(sizeof(se_ll_t));
+ }
if (dst)
{
@@ -339,10 +344,9 @@ int se_initialize_rng(u32 ks)
SE(SE_CONFIG_REG_OFFSET) = SE_CONFIG_ENC_ALG(ALG_RNG) | SE_CONFIG_DST(DST_MEMORY);
SE(SE_CRYPTO_REG_OFFSET) = SE_CRYPTO_KEY_INDEX(ks) | SE_CRYPTO_CORE_SEL(CORE_ENCRYPT) |
SE_CRYPTO_INPUT_SEL(INPUT_RANDOM);
- SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(DRBG_MODE_FORCE_INSTANTION) | SE_RNG_CONFIG_SRC(DRBG_SRC_ENTROPY);
+ SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(RNG_MODE_FORCE_INSTANTION) | SE_RNG_CONFIG_SRC(RNG_SRC_ENTROPY);
SE(SE_RNG_RESEED_INTERVAL_REG_OFFSET) = 70001;
- SE(SE_RNG_SRC_CONFIG_REG_OFFSET) = SE_RNG_SRC_CONFIG_RO_ENT_SRC_LOCK(DRBG_RO_ENT_SRC_LOCK_ENABLE) |
- SE_RNG_SRC_CONFIG_RO_ENT_SRC(DRBG_RO_ENT_SRC_LOCK_ENABLE);
+ SE(SE_RNG_SRC_CONFIG_REG_OFFSET) = SE_RNG_SRC_CONFIG_ENT_SRC_LOCK(RNG_SRC_RO_ENT_LOCK_ENABLE);
SE(SE_BLOCK_COUNT_REG_OFFSET) = 0;
int res =_se_execute(OP_START, output_buf, 0x10, NULL, 0);
@@ -356,7 +360,7 @@ int se_generate_random(u32 ks, void *dst, u32 size)
SE(SE_CONFIG_REG_OFFSET) = SE_CONFIG_ENC_ALG(ALG_RNG) | SE_CONFIG_DST(DST_MEMORY);
SE(SE_CRYPTO_REG_OFFSET) = SE_CRYPTO_KEY_INDEX(ks) | SE_CRYPTO_CORE_SEL(CORE_ENCRYPT) |
SE_CRYPTO_INPUT_SEL(INPUT_RANDOM);
- SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(DRBG_MODE_NORMAL) | SE_RNG_CONFIG_SRC(DRBG_SRC_ENTROPY);
+ SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(RNG_MODE_NORMAL) | SE_RNG_CONFIG_SRC(RNG_SRC_ENTROPY);
u32 num_blocks = size >> 4;
u32 aligned_size = num_blocks << 4;
@@ -376,7 +380,7 @@ int se_generate_random_key(u32 ks_dst, u32 ks_src)
SE(SE_CONFIG_REG_OFFSET) = SE_CONFIG_ENC_ALG(ALG_RNG) | SE_CONFIG_DST(DST_MEMORY);
SE(SE_CRYPTO_REG_OFFSET) = SE_CRYPTO_KEY_INDEX(ks_src) | SE_CRYPTO_CORE_SEL(CORE_ENCRYPT) |
SE_CRYPTO_INPUT_SEL(INPUT_RANDOM);
- SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(DRBG_MODE_NORMAL) | SE_RNG_CONFIG_SRC(DRBG_SRC_ENTROPY);
+ SE(SE_RNG_CONFIG_REG_OFFSET) = SE_RNG_CONFIG_MODE(RNG_MODE_NORMAL) | SE_RNG_CONFIG_SRC(RNG_SRC_ENTROPY);
SE(SE_CRYPTO_KEYTABLE_DST_REG_OFFSET) = SE_CRYPTO_KEYTABLE_DST_KEY_INDEX(ks_dst);
if (!_se_execute(OP_START, NULL, 0, NULL, 0))
diff --git a/source/sec/se_t210.h b/source/sec/se_t210.h
index 3b610bc..01828c7 100644
--- a/source/sec/se_t210.h
+++ b/source/sec/se_t210.h
@@ -70,27 +70,26 @@
#define SE_CONFIG_DEC_MODE(x) (x << SE_CONFIG_DEC_MODE_SHIFT)
#define SE_RNG_CONFIG_REG_OFFSET 0x340
-#define DRBG_MODE_SHIFT 0
-#define DRBG_MODE_NORMAL 0
-#define DRBG_MODE_FORCE_INSTANTION 1
-#define DRBG_MODE_FORCE_RESEED 2
-#define SE_RNG_CONFIG_MODE(x) (x << DRBG_MODE_SHIFT)
+#define RNG_MODE_SHIFT 0
+#define RNG_MODE_NORMAL 0
+#define RNG_MODE_FORCE_INSTANTION 1
+#define RNG_MODE_FORCE_RESEED 2
+#define SE_RNG_CONFIG_MODE(x) (x << RNG_MODE_SHIFT)
+#define RNG_SRC_SHIFT 2
+#define RNG_SRC_NONE 0
+#define RNG_SRC_ENTROPY 1
+#define RNG_SRC_LFSR 2
+#define SE_RNG_CONFIG_SRC(x) (x << RNG_SRC_SHIFT)
#define SE_RNG_SRC_CONFIG_REG_OFFSET 0x344
-#define DRBG_RO_ENT_SRC_SHIFT 1
-#define DRBG_RO_ENT_SRC_ENABLE 1
-#define DRBG_RO_ENT_SRC_DISABLE 0
-#define SE_RNG_SRC_CONFIG_RO_ENT_SRC(x) (x << DRBG_RO_ENT_SRC_SHIFT)
-#define DRBG_RO_ENT_SRC_LOCK_SHIFT 0
-#define DRBG_RO_ENT_SRC_LOCK_ENABLE 1
-#define DRBG_RO_ENT_SRC_LOCK_DISABLE 0
-#define SE_RNG_SRC_CONFIG_RO_ENT_SRC_LOCK(x) (x << DRBG_RO_ENT_SRC_LOCK_SHIFT)
-
-#define DRBG_SRC_SHIFT 2
-#define DRBG_SRC_NONE 0
-#define DRBG_SRC_ENTROPY 1
-#define DRBG_SRC_LFSR 2
-#define SE_RNG_CONFIG_SRC(x) (x << DRBG_SRC_SHIFT)
+#define RNG_SRC_RO_ENT_SHIFT 1
+#define RNG_SRC_RO_ENT_ENABLE 1
+#define RNG_SRC_RO_ENT_DISABLE 0
+#define SE_RNG_SRC_CONFIG_ENT_SRC(x) (x << RNG_SRC_RO_ENT_SHIFT)
+#define RNG_SRC_RO_ENT_LOCK_SHIFT 0
+#define RNG_SRC_RO_ENT_LOCK_ENABLE 1
+#define RNG_SRC_RO_ENT_LOCK_DISABLE 0
+#define SE_RNG_SRC_CONFIG_ENT_SRC_LOCK(x) (x << RNG_SRC_RO_ENT_LOCK_SHIFT)
#define SE_RNG_RESEED_INTERVAL_REG_OFFSET 0x348
@@ -119,6 +118,8 @@
#define OP_DONE 1
#define SE_OP_DONE(x, y) ((x) && (y << SE_OP_DONE_SHIFT))
+#define SE_CRYPTO_LAST_BLOCK 0x080
+
#define SE_CRYPTO_REG_OFFSET 0x304
#define SE_CRYPTO_HASH_SHIFT 0
#define HASH_DISABLE 0
@@ -191,6 +192,7 @@
#define SRK 6
#define RSA_KEYTABLE 1
+#define AES_KEYTABLE 2
#define SE_CONTEXT_SAVE_SRC(x) (x << SE_CONTEXT_SAVE_SRC_SHIFT)
#define SE_CONTEXT_SAVE_RSA_KEY_INDEX_SHIFT 16
diff --git a/source/sec/tsec.c b/source/sec/tsec.c
index 17cd623..0a8169e 100644
--- a/source/sec/tsec.c
+++ b/source/sec/tsec.c
@@ -18,6 +18,7 @@
#include
+#include "../hos/hos.h"
#include "../sec/tsec.h"
#include "../sec/tsec_t210.h"
#include "../sec/se_t210.h"
diff --git a/source/soc/bpmp.c b/source/soc/bpmp.c
index 94ce6d5..eea0de5 100644
--- a/source/soc/bpmp.c
+++ b/source/soc/bpmp.c
@@ -1,7 +1,7 @@
/*
* BPMP-Lite Cache/MMU and Frequency driver for Tegra X1
*
- * Copyright (c) 2019 CTCaer
+ * Copyright (c) 2019-2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -22,56 +22,101 @@
#include "../../common/memory_map.h"
#include "../utils/util.h"
+#define BPMP_MMU_CACHE_LINE_SIZE 0x20
+
#define BPMP_CACHE_CONFIG 0x0
-#define CFG_ENABLE (1 << 0)
+#define CFG_ENABLE_CACHE (1 << 0)
+#define CFG_ENABLE_SKEW_ASSOC (1 << 1)
+#define CFG_DISABLE_RANDOM_ALLOC (1 << 2)
#define CFG_FORCE_WRITE_THROUGH (1 << 3)
+#define CFG_NEVER_ALLOCATE (1 << 6)
+#define CFG_ENABLE_INTERRUPT (1 << 7)
+#define CFG_MMU_TAG_MODE(x) (x << 8)
+#define TAG_MODE_PARALLEL 0
+#define TAG_MODE_TAG_FIRST 1
+#define TAG_MODE_MMU_FIRST 2
#define CFG_DISABLE_WRITE_BUFFER (1 << 10)
#define CFG_DISABLE_READ_BUFFER (1 << 11)
+#define CFG_ENABLE_HANG_DETECT (1 << 12)
#define CFG_FULL_LINE_DIRTY (1 << 13)
#define CFG_TAG_CHK_ABRT_ON_ERR (1 << 14)
+#define CFG_TAG_CHK_CLR_ERR (1 << 15)
+#define CFG_DISABLE_SAMELINE (1 << 16)
+#define CFG_OBS_BUS_EN (1 << 31)
+
#define BPMP_CACHE_LOCK 0x4
+#define LOCK_LINE(x) (1 << x)
+
#define BPMP_CACHE_SIZE 0xC
#define BPMP_CACHE_LFSR 0x10
+
#define BPMP_CACHE_TAG_STATUS 0x14
+#define TAG_STATUS_TAG_CHECK_ERROR (1 << 0)
+#define TAG_STATUS_CONFLICT_ADDR_MASK 0xFFFFFFE0
+
#define BPMP_CACHE_CLKEN_OVERRIDE 0x18
+#define CLKEN_OVERRIDE_WR_MCCIF_CLKEN (1 << 0)
+#define CLKEN_OVERRIDE_RD_MCCIF_CLKEN (1 << 1)
+
#define BPMP_CACHE_MAINT_ADDR 0x20
#define BPMP_CACHE_MAINT_DATA 0x24
+
#define BPMP_CACHE_MAINT_REQ 0x28
#define MAINT_REQ_WAY_BITMAP(x) ((x) << 8)
#define BPMP_CACHE_INT_MASK 0x40
#define BPMP_CACHE_INT_CLEAR 0x44
-#define INT_CLR_MAINT_DONE (1 << 0)
-
#define BPMP_CACHE_INT_RAW_EVENT 0x48
-#define INT_RAW_EVENT_MAINT_DONE (1 << 0)
#define BPMP_CACHE_INT_STATUS 0x4C
+#define INT_MAINT_DONE (1 << 0)
+#define INT_MAINT_ERROR (1 << 1)
#define BPMP_CACHE_RB_CFG 0x80
#define BPMP_CACHE_WB_CFG 0x84
#define BPMP_CACHE_MMU_FALLBACK_ENTRY 0xA0
#define BPMP_CACHE_MMU_SHADOW_COPY_MASK 0xA4
+
#define BPMP_CACHE_MMU_CFG 0xAC
+#define MMU_CFG_BLOCK_MAIN_ENTRY_WR (1 << 0)
#define MMU_CFG_SEQ_EN (1 << 1)
#define MMU_CFG_TLB_EN (1 << 2)
+#define MMU_CFG_SEG_CHECK_ALL_ENTRIES (1 << 3)
#define MMU_CFG_ABORT_STORE_LAST (1 << 4)
+#define MMU_CFG_CLR_ABORT (1 << 5)
+
#define BPMP_CACHE_MMU_CMD 0xB0
#define MMU_CMD_NOP 0
#define MMU_CMD_INIT 1
#define MMU_CMD_COPY_SHADOW 2
+
#define BPMP_CACHE_MMU_ABORT_STAT 0xB4
+#define ABORT_STAT_UNIT_MASK 0x7
+#define ABORT_STAT_UNIT_NONE 0
+#define ABORT_STAT_UNIT_CACHE 1
+#define ABORT_STAT_UNIT_SEQ 2
+#define ABORT_STAT_UNIT_TLB 3
+#define ABORT_STAT_UNIT_SEG 4
+#define ABORT_STAT_UNIT_FALLBACK 5
+#define ABORT_STAT_OVERLAP (1 << 3)
+#define ABORT_STAT_ENTRY (0x1F << 4)
+#define ABORT_STAT_TYPE_MASK (3 << 16)
+#define ABORT_STAT_TYPE_EXE (0 << 16)
+#define ABORT_STAT_TYPE_RD (1 << 16)
+#define ABORT_STAT_TYPE_WR (2 << 16)
+#define ABORT_STAT_SIZE (3 << 18)
+#define ABORT_STAT_SEQ (1 << 20)
+#define ABORT_STAT_PROT (1 << 21)
+
#define BPMP_CACHE_MMU_ABORT_ADDR 0xB8
#define BPMP_CACHE_MMU_ACTIVE_ENTRIES 0xBC
-#define BPMP_MMU_SHADOW_ENTRY_BASE (BPMP_CACHE_BASE + 0x400)
-#define BPMP_MMU_MAIN_ENTRY_BASE (BPMP_CACHE_BASE + 0x800)
-#define MMU_ENTRY_ADDR_MASK 0xFFFFFFE0
-
-#define MMU_EN_CACHED (1 << 0)
-#define MMU_EN_EXEC (1 << 1)
-#define MMU_EN_READ (1 << 2)
-#define MMU_EN_WRITE (1 << 3)
+#define BPMP_MMU_SHADOW_ENTRY_BASE (BPMP_CACHE_BASE + 0x400)
+#define BPMP_MMU_MAIN_ENTRY_BASE (BPMP_CACHE_BASE + 0x800)
+#define MMU_EN_CACHED (1 << 0)
+#define MMU_EN_EXEC (1 << 1)
+#define MMU_EN_READ (1 << 2)
+#define MMU_EN_WRITE (1 << 3)
bpmp_mmu_entry_t mmu_entries[] =
{
@@ -81,15 +126,15 @@ bpmp_mmu_entry_t mmu_entries[] =
void bpmp_mmu_maintenance(u32 op, bool force)
{
- if (!force && !(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
+ if (!force && !(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE_CACHE))
return;
- BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
+ BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_MAINT_DONE;
// This is a blocking operation.
BPMP_CACHE_CTRL(BPMP_CACHE_MAINT_REQ) = MAINT_REQ_WAY_BITMAP(0xF) | op;
- while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_RAW_EVENT_MAINT_DONE))
+ while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_MAINT_DONE))
;
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT);
@@ -104,8 +149,8 @@ void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply)
if (entry->enable)
{
- mmu_entry->min_addr = entry->min_addr & MMU_ENTRY_ADDR_MASK;
- mmu_entry->max_addr = entry->max_addr & MMU_ENTRY_ADDR_MASK;
+ mmu_entry->start_addr = ALIGN(entry->start_addr, BPMP_MMU_CACHE_LINE_SIZE);
+ mmu_entry->end_addr = ALIGN_DOWN(entry->end_addr, BPMP_MMU_CACHE_LINE_SIZE);
mmu_entry->attr = entry->attr;
BPMP_CACHE_CTRL(BPMP_CACHE_MMU_SHADOW_COPY_MASK) |= (1 << idx);
@@ -117,7 +162,7 @@ void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply)
void bpmp_mmu_enable()
{
- if (BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE)
+ if (BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE_CACHE)
return;
// Init BPMP MMU.
@@ -136,7 +181,8 @@ void bpmp_mmu_enable()
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, true);
// Enable cache.
- BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE | CFG_FORCE_WRITE_THROUGH | CFG_TAG_CHK_ABRT_ON_ERR;
+ BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = CFG_ENABLE_CACHE | CFG_FORCE_WRITE_THROUGH |
+ CFG_MMU_TAG_MODE(TAG_MODE_PARALLEL) | CFG_TAG_CHK_ABRT_ON_ERR;
// HW bug. Invalidate cache again.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
@@ -144,7 +190,7 @@ void bpmp_mmu_enable()
void bpmp_mmu_disable()
{
- if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
+ if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE_CACHE))
return;
// Clean and invalidate cache.
@@ -154,7 +200,10 @@ void bpmp_mmu_disable()
BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) = 0;
}
-const u8 pllc4_divn[] = {
+// APB clock affects RTC, PWM, MEMFETCH, APE, USB, SOR PWM,
+// I2C host, DC/DSI/DISP. UART gives extra stress.
+// 92: 100% success ratio. 93-94: 595-602MHz has 99% success ratio. 95: 608MHz less.
+const u8 pll_divn[] = {
0, // BPMP_CLK_NORMAL: 408MHz 0% - 136MHz APB.
85, // BPMP_CLK_HIGH_BOOST: 544MHz 33% - 136MHz APB.
90, // BPMP_CLK_SUPER_BOOST: 576MHz 41% - 144MHz APB.
@@ -165,6 +214,28 @@ const u8 pllc4_divn[] = {
bpmp_freq_t bpmp_clock_set = BPMP_CLK_NORMAL;
+void bpmp_clk_rate_get()
+{
+ bool clk_src_is_pllp = ((CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) >> 4) & 7) == 3;
+
+ if (clk_src_is_pllp)
+ bpmp_clock_set = BPMP_CLK_NORMAL;
+ else
+ {
+ bpmp_clock_set = BPMP_CLK_HIGH_BOOST;
+
+ u8 pll_divn_curr = (CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) >> 10) & 0xFF;
+ for (u32 i = 1; i < sizeof(pll_divn); i++)
+ {
+ if (pll_divn[i] == pll_divn_curr)
+ {
+ bpmp_clock_set = i;
+ break;
+ }
+ }
+ }
+}
+
void bpmp_clk_rate_set(bpmp_freq_t fid)
{
if (fid > (BPMP_CLK_MAX - 1))
@@ -179,37 +250,26 @@ void bpmp_clk_rate_set(bpmp_freq_t fid)
{
// Restore to PLLP source during PLLC4 configuration.
CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003333; // PLLP_OUT.
- // Wait a bit for clock source change.
- msleep(10);
+ msleep(1); // Wait a bit for clock source change.
}
- CLOCK(CLK_RST_CONTROLLER_PLLC4_MISC) = PLLC4_MISC_EN_LCKDET;
- CLOCK(CLK_RST_CONTROLLER_PLLC4_BASE) = 4 | (pllc4_divn[fid] << 8) | PLL_BASE_ENABLE; // DIVM: 4, DIVP: 1.
+ // Configure and enable PLLC.
+ clock_enable_pllc(pll_divn[fid]);
- while (!(CLOCK(CLK_RST_CONTROLLER_PLLC4_BASE) & PLLC4_BASE_LOCK))
- ;
-
- CLOCK(CLK_RST_CONTROLLER_PLLC4_OUT) = (1 << 8) | PLLC4_OUT3_CLKEN; // 1.5 div.
- CLOCK(CLK_RST_CONTROLLER_PLLC4_OUT) |= PLLC4_OUT3_RSTN_CLR; // Get divider out of reset.
-
- // Wait a bit for PLLC4 to stabilize.
- msleep(10);
- CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 3; // PCLK = HCLK / 4.
- CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003323; // PLLC4_OUT3.
-
- bpmp_clock_set = fid;
+ // Set SCLK / HCLK / PCLK.
+ CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 3; // PCLK = HCLK / (3 + 1). HCLK == SCLK.
+ CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003310; // PLLC_OUT1 for active and CLKM for idle.
}
else
{
- CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003333; // PLLP_OUT.
+ CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003330; // PLLP_OUT for active and CLKM for idle.
+ msleep(1); // Wait a bit for clock source change.
+ CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 2; // PCLK = HCLK / (2 + 1). HCLK == SCLK.
- // Wait a bit for clock source change.
- msleep(10);
-
- CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 2; // PCLK = HCLK / 3.
- CLOCK(CLK_RST_CONTROLLER_PLLC4_BASE) &= ~PLL_BASE_ENABLE;
- bpmp_clock_set = BPMP_CLK_NORMAL;
+ // Disable PLLC to save power.
+ clock_disable_pllc();
}
+ bpmp_clock_set = fid;
}
// The following functions halt BPMP to reduce power while sleeping.
diff --git a/source/soc/bpmp.h b/source/soc/bpmp.h
index 4c1155e..aad901a 100644
--- a/source/soc/bpmp.h
+++ b/source/soc/bpmp.h
@@ -1,7 +1,7 @@
/*
* BPMP-Lite Cache/MMU and Frequency driver for Tegra X1
*
- * Copyright (c) 2019 CTCaer
+ * Copyright (c) 2019-2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -21,14 +21,24 @@
#include "../utils/types.h"
-#define BPMP_MMU_MAINT_CLEAN_WAY 17
-#define BPMP_MMU_MAINT_INVALID_WAY 18
-#define BPMP_MMU_MAINT_CLN_INV_WAY 19
+typedef enum
+{
+ BPMP_MMU_MAINT_NOP = 0,
+ BPMP_MMU_MAINT_CLEAN_PHY = 1,
+ BPMP_MMU_MAINT_INVALID_PHY = 2,
+ BPMP_MMU_MAINT_CLEAN_INVALID_PHY = 3,
+ BPMP_MMU_MAINT_CLEAN_LINE = 9,
+ BPMP_MMU_MAINT_INVALID_LINE = 10,
+ BPMP_MMU_MAINT_CLEAN_INVALID_LINE = 11,
+ BPMP_MMU_MAINT_CLEAN_WAY = 17,
+ BPMP_MMU_MAINT_INVALID_WAY = 18,
+ BPMP_MMU_MAINT_CLN_INV_WAY = 19
+} bpmp_maintenance_t;
typedef struct _bpmp_mmu_entry_t
{
- u32 min_addr;
- u32 max_addr;
+ u32 start_addr;
+ u32 end_addr;
u32 attr;
u32 enable;
} bpmp_mmu_entry_t;
@@ -49,6 +59,7 @@ void bpmp_mmu_maintenance(u32 op, bool force);
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply);
void bpmp_mmu_enable();
void bpmp_mmu_disable();
+void bpmp_clk_rate_get();
void bpmp_clk_rate_set(bpmp_freq_t fid);
void bpmp_usleep(u32 us);
void bpmp_msleep(u32 ms);
diff --git a/source/soc/clock.c b/source/soc/clock.c
index dda6d4b..60a069b 100644
--- a/source/soc/clock.c
+++ b/source/soc/clock.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -19,6 +20,17 @@
#include "../utils/util.h"
#include "../storage/sdmmc.h"
+/*
+ * CLOCK Peripherals:
+ * L 0 - 31
+ * H 32 - 63
+ * U 64 - 95
+ * V 96 - 127
+ * W 128 - 159
+ * X 160 - 191
+ * Y 192 - 223
+ */
+
/* clock_t: reset, enable, source, index, clk_src, clk_div */
static const clock_t _clock_uart[] = {
@@ -29,7 +41,7 @@ static const clock_t _clock_uart[] = {
/* UART E */ { CLK_RST_CONTROLLER_RST_DEVICES_Y, CLK_RST_CONTROLLER_CLK_OUT_ENB_Y, CLK_RST_CONTROLLER_CLK_SOURCE_UARTAPE, 20, 0, 2 }
};
-//I2C default parameters - TLOW: 4, THIGH: 2, DEBOUNCE: 0 FM_DIV: 26.
+//I2C default parameters - TLOW: 4, THIGH: 2, DEBOUNCE: 0, FM_DIV: 26.
static const clock_t _clock_i2c[] = {
/* I2C1 */ { CLK_RST_CONTROLLER_RST_DEVICES_L, CLK_RST_CONTROLLER_CLK_OUT_ENB_L, CLK_RST_CONTROLLER_CLK_SOURCE_I2C1, 12, 0, 19 }, //20.4MHz -> 100KHz
/* I2C2 */ { CLK_RST_CONTROLLER_RST_DEVICES_H, CLK_RST_CONTROLLER_CLK_OUT_ENB_H, CLK_RST_CONTROLLER_CLK_SOURCE_I2C2, 22, 0, 4 }, //81.6MHz -> 400KHz
@@ -77,6 +89,10 @@ static clock_t _clock_pwm = {
CLK_RST_CONTROLLER_RST_DEVICES_L, CLK_RST_CONTROLLER_CLK_OUT_ENB_L, CLK_RST_CONTROLLER_CLK_SOURCE_PWM, 17, 6, 4 // Fref: 6.2MHz.
};
+static clock_t _clock_sdmmc_legacy_tm = {
+ CLK_RST_CONTROLLER_RST_DEVICES_Y, CLK_RST_CONTROLLER_CLK_OUT_ENB_Y, CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC_LEGACY_TM, 1, 4, 66
+};
+
void clock_enable(const clock_t *clk)
{
// Put clock into reset.
@@ -112,6 +128,29 @@ void clock_enable_uart(u32 idx)
clock_enable(&_clock_uart[idx]);
}
+void clock_disable_uart(u32 idx)
+{
+ clock_disable(&_clock_uart[idx]);
+}
+
+#define UART_SRC_CLK_DIV_EN (1 << 24)
+
+int clock_uart_use_src_div(u32 idx, u32 baud)
+{
+ u32 clk_src_div = CLOCK(_clock_uart[idx].source) & 0xE0000000;
+
+ if (baud == 1000000)
+ CLOCK(_clock_uart[idx].source) = clk_src_div | UART_SRC_CLK_DIV_EN | 49;
+ else
+ {
+ CLOCK(_clock_uart[idx].source) = clk_src_div | 2;
+
+ return 1;
+ }
+
+ return 0;
+}
+
void clock_enable_i2c(u32 idx)
{
clock_enable(&_clock_i2c[idx]);
@@ -228,6 +267,51 @@ void clock_disable_pwm()
clock_disable(&_clock_pwm);
}
+void clock_enable_pllc(u32 divn)
+{
+ u8 pll_divn_curr = (CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) >> 10) & 0xFF;
+
+ // Check if already enabled and configured.
+ if ((CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) & PLLCX_BASE_ENABLE) && (pll_divn_curr == divn))
+ return;
+
+ // Take PLLC out of reset and set basic misc parameters.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_MISC) =
+ ((CLOCK(CLK_RST_CONTROLLER_PLLC_MISC) & 0xFFF0000F) & ~PLLC_MISC_RESET) | (0x80000 << 4); // PLLC_EXT_FRU.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_MISC_2) |= 0xF0 << 8; // PLLC_FLL_LD_MEM.
+
+ // Disable PLL and IDDQ in case they are on.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) &= ~PLLCX_BASE_ENABLE;
+ CLOCK(CLK_RST_CONTROLLER_PLLC_MISC_1) &= ~PLLC_MISC1_IDDQ;
+ usleep(10);
+
+ // Set PLLC dividers.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) = (divn << 10) | 4; // DIVM: 4, DIVP: 1.
+
+ // Enable PLLC and wait for Phase and Frequency lock.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) |= PLLCX_BASE_ENABLE;
+ while (!(CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) & PLLCX_BASE_LOCK))
+ ;
+
+ // Disable PLLC_OUT1, enable reset and set div to 1.5.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_OUT) = (1 << 8);
+
+ // Enable PLLC_OUT1 and bring it out of reset.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_OUT) |= (PLLC_OUT1_CLKEN | PLLC_OUT1_RSTN_CLR);
+ msleep(1); // Wait a bit for PLL to stabilize.
+}
+
+void clock_disable_pllc()
+{
+ // Disable PLLC and PLLC_OUT1.
+ CLOCK(CLK_RST_CONTROLLER_PLLC_OUT) &= ~(PLLC_OUT1_CLKEN | PLLC_OUT1_RSTN_CLR);
+ CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) &= ~PLLCX_BASE_ENABLE;
+ CLOCK(CLK_RST_CONTROLLER_PLLC_BASE) |= PLLCX_BASE_REF_DIS;
+ CLOCK(CLK_RST_CONTROLLER_PLLC_MISC_1) |= PLLC_MISC1_IDDQ;
+ CLOCK(CLK_RST_CONTROLLER_PLLC_MISC) |= PLLC_MISC_RESET;
+ usleep(10);
+}
+
#define L_SWR_SDMMC1_RST (1 << 14)
#define L_SWR_SDMMC2_RST (1 << 9)
#define L_SWR_SDMMC4_RST (1 << 15)
@@ -366,56 +450,78 @@ static void _clock_sdmmc_clear_enable(u32 id)
}
}
-static u32 _clock_sdmmc_table[8] = { 0 };
+static void _clock_sdmmc_config_legacy_tm()
+{
+ clock_t *clk = &_clock_sdmmc_legacy_tm;
+ if (!(CLOCK(clk->enable) & (1 << clk->index)))
+ clock_enable(clk);
+}
-#define PLLP_OUT0 0x0
-static int _clock_sdmmc_config_clock_host(u32 *pout, u32 id, u32 val)
+typedef struct _clock_sdmmc_t
+{
+ u32 clock;
+ u32 real_clock;
+} clock_sdmmc_t;
+
+static clock_sdmmc_t _clock_sdmmc_table[4] = { 0 };
+
+#define SDMMC_CLOCK_SRC_PLLP_OUT0 0x0
+#define SDMMC_CLOCK_SRC_PLLC4_OUT2 0x3
+#define SDMMC4_CLOCK_SRC_PLLC4_OUT2_LJ 0x1
+
+static int _clock_sdmmc_config_clock_host(u32 *pclock, u32 id, u32 val)
{
u32 divisor = 0;
- u32 source = PLLP_OUT0;
+ u32 source = SDMMC_CLOCK_SRC_PLLP_OUT0;
+
+ if (id > SDMMC_4)
+ return 0;
// Get IO clock divisor.
switch (val)
{
case 25000:
- *pout = 24728;
+ *pclock = 24728;
divisor = 31; // 16.5 div.
break;
case 26000:
- *pout = 25500;
+ *pclock = 25500;
divisor = 30; // 16 div.
break;
case 40800:
- *pout = 40800;
+ *pclock = 40800;
divisor = 18; // 10 div.
break;
case 50000:
- *pout = 48000;
+ *pclock = 48000;
divisor = 15; // 8.5 div.
break;
case 52000:
- *pout = 51000;
+ *pclock = 51000;
divisor = 14; // 8 div.
break;
case 100000:
- *pout = 90667;
+ *pclock = 90667;
divisor = 7; // 4.5 div.
break;
- case 200000:
- *pout = 163200;
+ case 164000:
+ *pclock = 163200;
divisor = 3; // 2.5 div.
break;
- case 208000:
- *pout = 204000;
+ case 200000:
+ *pclock = 204000;
divisor = 2; // 2 div.
break;
default:
- *pout = 24728;
+ *pclock = 24728;
divisor = 31; // 16.5 div.
}
- _clock_sdmmc_table[2 * id] = val;
- _clock_sdmmc_table[2 * id + 1] = *pout;
+ _clock_sdmmc_table[id].clock = val;
+ _clock_sdmmc_table[id].real_clock = *pclock;
+
+ // Set SDMMC legacy timeout clock.
+ _clock_sdmmc_config_legacy_tm();
// Set SDMMC clock.
switch (id)
@@ -437,70 +543,75 @@ static int _clock_sdmmc_config_clock_host(u32 *pout, u32 id, u32 val)
return 1;
}
-void clock_sdmmc_config_clock_source(u32 *pout, u32 id, u32 val)
+void clock_sdmmc_config_clock_source(u32 *pclock, u32 id, u32 val)
{
- if (_clock_sdmmc_table[2 * id] == val)
+ if (_clock_sdmmc_table[id].clock == val)
{
- *pout = _clock_sdmmc_table[2 * id + 1];
+ *pclock = _clock_sdmmc_table[id].real_clock;
}
else
{
int is_enabled = _clock_sdmmc_is_enabled(id);
if (is_enabled)
_clock_sdmmc_clear_enable(id);
- _clock_sdmmc_config_clock_host(pout, id, val);
+ _clock_sdmmc_config_clock_host(pclock, id, val);
if (is_enabled)
_clock_sdmmc_set_enable(id);
_clock_sdmmc_is_reset(id);
}
}
-void clock_sdmmc_get_card_clock_div(u32 *pout, u16 *pdivisor, u32 type)
+void clock_sdmmc_get_card_clock_div(u32 *pclock, u16 *pdivisor, u32 type)
{
// Get Card clock divisor.
switch (type)
{
- case 0:
- *pout = 26000;
+ case SDHCI_TIMING_MMC_ID: // Actual IO Freq: 380.59 KHz.
+ *pclock = 26000;
*pdivisor = 66;
break;
- case 1:
- *pout = 26000;
+ case SDHCI_TIMING_MMC_LS26:
+ *pclock = 26000;
*pdivisor = 1;
break;
- case 2:
- *pout = 52000;
+ case SDHCI_TIMING_MMC_HS52:
+ *pclock = 52000;
*pdivisor = 1;
break;
- case 3:
- case 4:
- case 11:
- *pout = 200000;
+ case SDHCI_TIMING_MMC_HS200:
+ case SDHCI_TIMING_MMC_HS400:
+ case SDHCI_TIMING_UHS_SDR104:
+ *pclock = 200000;
*pdivisor = 1;
break;
- case 5:
- *pout = 25000;
+ case SDHCI_TIMING_SD_ID: // Actual IO Freq: 380.43 KHz.
+ *pclock = 25000;
*pdivisor = 64;
break;
- case 6:
- case 8:
- *pout = 25000;
+ case SDHCI_TIMING_SD_DS12:
+ case SDHCI_TIMING_UHS_SDR12:
+ *pclock = 25000;
*pdivisor = 1;
break;
- case 7:
- *pout = 50000;
+ case SDHCI_TIMING_SD_HS25:
+ case SDHCI_TIMING_UHS_SDR25:
+ *pclock = 50000;
*pdivisor = 1;
break;
- case 10:
- *pout = 100000;
+ case SDHCI_TIMING_UHS_SDR50:
+ *pclock = 100000;
*pdivisor = 1;
break;
- case 13:
- *pout = 40800;
+ case SDHCI_TIMING_UHS_SDR82:
+ *pclock = 164000;
*pdivisor = 1;
break;
- case 14:
- *pout = 200000;
+ case SDHCI_TIMING_UHS_DDR50:
+ *pclock = 40800;
+ *pdivisor = 1;
+ break;
+ case SDHCI_TIMING_MMC_DDR52: // Actual IO Freq: 49.92 MHz.
+ *pclock = 200000;
*pdivisor = 2;
break;
}
@@ -513,15 +624,15 @@ int clock_sdmmc_is_not_reset_and_enabled(u32 id)
void clock_sdmmc_enable(u32 id, u32 val)
{
- u32 div = 0;
+ u32 clock = 0;
if (_clock_sdmmc_is_enabled(id))
_clock_sdmmc_clear_enable(id);
_clock_sdmmc_set_reset(id);
- _clock_sdmmc_config_clock_host(&div, id, val);
+ _clock_sdmmc_config_clock_host(&clock, id, val);
_clock_sdmmc_set_enable(id);
_clock_sdmmc_is_reset(id);
- usleep((100000 + div - 1) / div);
+ usleep((100000 + clock - 1) / clock);
_clock_sdmmc_clear_reset(id);
_clock_sdmmc_is_reset(id);
}
diff --git a/source/soc/clock.h b/source/soc/clock.h
index ce6a81d..a9b9f9a 100644
--- a/source/soc/clock.h
+++ b/source/soc/clock.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2020 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -35,11 +36,19 @@
#define CLK_RST_CONTROLLER_MISC_CLK_ENB 0x48
#define CLK_RST_CONTROLLER_OSC_CTRL 0x50
#define CLK_RST_CONTROLLER_PLLC_BASE 0x80
+#define CLK_RST_CONTROLLER_PLLC_OUT 0x84
#define CLK_RST_CONTROLLER_PLLC_MISC 0x88
+#define CLK_RST_CONTROLLER_PLLC_MISC_1 0x8C
#define CLK_RST_CONTROLLER_PLLM_BASE 0x90
#define CLK_RST_CONTROLLER_PLLM_MISC1 0x98
#define CLK_RST_CONTROLLER_PLLM_MISC2 0x9C
#define CLK_RST_CONTROLLER_PLLP_BASE 0xA0
+#define CLK_RST_CONTROLLER_PLLA_BASE 0xB0
+#define CLK_RST_CONTROLLER_PLLA_OUT 0xB4
+#define CLK_RST_CONTROLLER_PLLA_MISC1 0xB8
+#define CLK_RST_CONTROLLER_PLLA_MISC 0xBC
+#define CLK_RST_CONTROLLER_PLLU_BASE 0xC0
+#define CLK_RST_CONTROLLER_PLLU_MISC 0xCC
#define CLK_RST_CONTROLLER_PLLD_BASE 0xD0
#define CLK_RST_CONTROLLER_PLLD_MISC1 0xD8
#define CLK_RST_CONTROLLER_PLLD_MISC 0xDC
@@ -49,6 +58,7 @@
#define CLK_RST_CONTROLLER_PLLE_MISC 0xEC
#define CLK_RST_CONTROLLER_LVL2_CLK_GATE_OVRA 0xF8
#define CLK_RST_CONTROLLER_LVL2_CLK_GATE_OVRB 0xFC
+#define CLK_RST_CONTROLLER_CLK_SOURCE_I2S2 0x100
#define CLK_RST_CONTROLLER_CLK_SOURCE_PWM 0x110
#define CLK_RST_CONTROLLER_CLK_SOURCE_I2C1 0x124
#define CLK_RST_CONTROLLER_CLK_SOURCE_I2C5 0x128
@@ -67,6 +77,7 @@
#define CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC3 0x1BC
#define CLK_RST_CONTROLLER_CLK_SOURCE_UARTD 0x1C0
#define CLK_RST_CONTROLLER_CLK_SOURCE_CSITE 0x1D4
+#define CLK_RST_CONTROLLER_CLK_SOURCE_I2S1 0x1D8
#define CLK_RST_CONTROLLER_CLK_SOURCE_TSEC 0x1F4
#define CLK_RST_CONTROLLER_CLK_OUT_ENB_X 0x280
#define CLK_RST_CONTROLLER_CLK_ENB_X_SET 0x284
@@ -101,24 +112,32 @@
#define CLK_RST_CONTROLLER_LVL2_CLK_GATE_OVRD 0x3A4
#define CLK_RST_CONTROLLER_CLK_SOURCE_MSELECT 0x3B4
#define CLK_RST_CONTROLLER_CLK_SOURCE_I2C4 0x3C4
+#define CLK_RST_CONTROLLER_CLK_SOURCE_EXTPERIPH1 0x3EC
#define CLK_RST_CONTROLLER_CLK_SOURCE_SYS 0x400
#define CLK_RST_CONTROLLER_CLK_SOURCE_SOR1 0x410
#define CLK_RST_CONTROLLER_CLK_SOURCE_SE 0x42C
+#define CLK_RST_CONTROLLER_RST_DEV_V_SET 0x430
#define CLK_RST_CONTROLLER_RST_DEV_V_CLR 0x434
+#define CLK_RST_CONTROLLER_RST_DEV_W_SET 0x438
+#define CLK_RST_CONTROLLER_RST_DEV_W_CLR 0x43C
#define CLK_RST_CONTROLLER_CLK_ENB_V_SET 0x440
#define CLK_RST_CONTROLLER_CLK_ENB_V_CLR 0x444
#define CLK_RST_CONTROLLER_CLK_ENB_W_SET 0x448
#define CLK_RST_CONTROLLER_CLK_ENB_W_CLR 0x44C
#define CLK_RST_CONTROLLER_RST_CPUG_CMPLX_SET 0x450
#define CLK_RST_CONTROLLER_RST_CPUG_CMPLX_CLR 0x454
+#define CLK_RST_CONTROLLER_UTMIP_PLL_CFG0 0x480
+#define CLK_RST_CONTROLLER_UTMIP_PLL_CFG1 0x484
#define CLK_RST_CONTROLLER_UTMIP_PLL_CFG2 0x488
#define CLK_RST_CONTROLLER_PLLE_AUX 0x48C
#define CLK_RST_CONTROLLER_AUDIO_SYNC_CLK_I2S0 0x4A0
#define CLK_RST_CONTROLLER_PLLX_MISC_3 0x518
+#define CLK_RST_CONTROLLER_UTMIPLL_HW_PWRDN_CFG0 0x52C
#define CLK_RST_CONTROLLER_LVL2_CLK_GATE_OVRE 0x554
#define CLK_RST_CONTROLLER_SPARE_REG0 0x55C
#define CLK_RST_CONTROLLER_PLLC4_BASE 0x5A4
#define CLK_RST_CONTROLLER_PLLC4_MISC 0x5A8
+#define CLK_RST_CONTROLLER_PLLC_MISC_2 0x5D0
#define CLK_RST_CONTROLLER_PLLC4_OUT 0x5E4
#define CLK_RST_CONTROLLER_PLLMB_BASE 0x5E8
#define CLK_RST_CONTROLLER_CLK_SOURCE_DSIA_LP 0x620
@@ -127,16 +146,27 @@
#define CLK_RST_CONTROLLER_CLK_SOURCE_UART_FST_MIPI_CAL 0x66C
#define CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC_LEGACY_TM 0x694
#define CLK_RST_CONTROLLER_CLK_SOURCE_NVENC 0x6A0
+#define CLK_RST_CONTROLLER_CLK_SOURCE_USB2_HSIC_TRK 0x6CC
#define CLK_RST_CONTROLLER_SE_SUPER_CLK_DIVIDER 0x704
#define CLK_RST_CONTROLLER_CLK_SOURCE_UARTAPE 0x710
#define CLK_NO_SOURCE 0x0
/*! PLL control and status bits */
-#define PLL_BASE_ENABLE (1 << 30)
+#define PLLCX_BASE_ENABLE (1 << 30)
+#define PLLCX_BASE_REF_DIS (1 << 29)
+#define PLLCX_BASE_LOCK (1 << 27)
+
+#define PLLA_BASE_IDDQ (1 << 25)
+#define PLLA_OUT0_CLKEN (1 << 1)
+#define PLLA_OUT0_RSTN_CLR (1 << 0)
+
+#define PLLC_MISC_RESET (1 << 30)
+#define PLLC_MISC1_IDDQ (1 << 27)
+#define PLLC_OUT1_CLKEN (1 << 1)
+#define PLLC_OUT1_RSTN_CLR (1 << 0)
#define PLLC4_MISC_EN_LCKDET (1 << 30)
-#define PLLC4_BASE_LOCK (1 << 27)
#define PLLC4_BASE_IDDQ (1 << 18)
#define PLLC4_OUT3_CLKEN (1 << 1)
#define PLLC4_OUT3_RSTN_CLR (1 << 0)
@@ -159,6 +189,8 @@ void clock_disable(const clock_t *clk);
/*! Clock control for specific hardware portions. */
void clock_enable_fuse(bool enable);
void clock_enable_uart(u32 idx);
+void clock_disable_uart(u32 idx);
+int clock_uart_use_src_div(u32 idx, u32 baud);
void clock_enable_i2c(u32 idx);
void clock_disable_i2c(u32 idx);
void clock_enable_se();
@@ -181,9 +213,11 @@ void clock_enable_coresight();
void clock_disable_coresight();
void clock_enable_pwm();
void clock_disable_pwm();
-void clock_sdmmc_config_clock_source(u32 *pout, u32 id, u32 val);
-void clock_sdmmc_get_card_clock_div(u32 *pout, u16 *pdivisor, u32 type);
-int clock_sdmmc_is_not_reset_and_enabled(u32 id);
+void clock_enable_pllc(u32 divn);
+void clock_disable_pllc();
+void clock_sdmmc_config_clock_source(u32 *pclock, u32 id, u32 val);
+void clock_sdmmc_get_card_clock_div(u32 *pclock, u16 *pdivisor, u32 type);
+int clock_sdmmc_is_not_reset_and_enabled(u32 id);
void clock_sdmmc_enable(u32 id, u32 val);
void clock_sdmmc_disable(u32 id);
diff --git a/source/soc/fuse.h b/source/soc/fuse.h
index 9240b04..00ee63c 100644
--- a/source/soc/fuse.h
+++ b/source/soc/fuse.h
@@ -54,6 +54,7 @@
#define FUSE_PRIVATE_KEY3 0x1B0
#define FUSE_PRIVATE_KEY4 0x1B4
#define FUSE_RESERVED_SW 0x1C0
+#define FUSE_USB_CALIB 0x1F0
#define FUSE_SKU_DIRECT_CONFIG 0x1F4
#define FUSE_OPT_VENDOR_CODE 0x200
#define FUSE_OPT_FAB_CODE 0x204
@@ -63,6 +64,7 @@
#define FUSE_OPT_X_COORDINATE 0x214
#define FUSE_OPT_Y_COORDINATE 0x218
#define FUSE_GPU_IDDQ_CALIB 0x228
+#define FUSE_USB_CALIB_EXT 0x350
/*! Fuse commands. */
#define FUSE_READ 0x1
diff --git a/source/soc/gpio.c b/source/soc/gpio.c
index 053c43a..9183a04 100644
--- a/source/soc/gpio.c
+++ b/source/soc/gpio.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -14,81 +15,146 @@
* along with this program. If not, see .
*/
-#include "../soc/gpio.h"
-#include "../soc/t210.h"
+#include "gpio.h"
+#include "irq.h"
+#include "t210.h"
-static const u16 _gpio_cnf[31] = {
- 0x000, 0x004, 0x008, 0x00C,
- 0x100, 0x104, 0x108, 0x10C,
- 0x200, 0x204, 0x208, 0x20C,
- 0x300, 0x304, 0x308, 0x30C,
- 0x400, 0x404, 0x408, 0x40C,
- 0x500, 0x504, 0x508, 0x50C,
- 0x600, 0x604, 0x608, 0x60C,
- 0x700, 0x704, 0x708
-};
+#define GPIO_BANK_IDX(port) (port >> 2)
-static const u16 _gpio_oe[31] = {
- 0x010, 0x014, 0x018, 0x01C,
- 0x110, 0x114, 0x118, 0x11C,
- 0x210, 0x214, 0x218, 0x21C,
- 0x310, 0x314, 0x318, 0x31C,
- 0x410, 0x414, 0x418, 0x41C,
- 0x510, 0x514, 0x518, 0x51C,
- 0x610, 0x614, 0x618, 0x61C,
- 0x710, 0x714, 0x718
-};
+#define GPIO_CNF_OFFSET(port) (0x00 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_OE_OFFSET(port) (0x10 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_OUT_OFFSET(port) (0x20 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_IN_OFFSET(port) (0x30 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_STA_OFFSET(port) (0x40 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_ENB_OFFSET(port) (0x50 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_LVL_OFFSET(port) (0x60 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_CLR_OFFSET(port) (0x70 + ((port >> 2) << 8) + ((port % 4) << 2))
-static const u16 _gpio_out[31] = {
- 0x020, 0x024, 0x028, 0x02C,
- 0x120, 0x124, 0x128, 0x12C,
- 0x220, 0x224, 0x228, 0x22C,
- 0x320, 0x324, 0x328, 0x32C,
- 0x420, 0x424, 0x428, 0x42C,
- 0x520, 0x524, 0x528, 0x52C,
- 0x620, 0x624, 0x628, 0x62C,
- 0x720, 0x724, 0x728
-};
+#define GPIO_CNF_MASKED_OFFSET(port) (0x80 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_OE_MASKED_OFFSET(port) (0x90 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_OUT_MASKED_OFFSET(port) (0xA0 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_STA_MASKED_OFFSET(port) (0xC0 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_ENB_MASKED_OFFSET(port) (0xD0 + ((port >> 2) << 8) + ((port % 4) << 2))
+#define GPIO_INT_LVL_MASKED_OFFSET(port) (0xE0 + ((port >> 2) << 8) + ((port % 4) << 2))
-static const u16 _gpio_in[31] = {
- 0x030, 0x034, 0x038, 0x03C,
- 0x130, 0x134, 0x138, 0x13C,
- 0x230, 0x234, 0x238, 0x23C,
- 0x330, 0x334, 0x338, 0x33C,
- 0x430, 0x434, 0x438, 0x43C,
- 0x530, 0x534, 0x538, 0x53C,
- 0x630, 0x634, 0x638, 0x63C,
- 0x730, 0x734, 0x738
+static u8 gpio_bank_irq_ids[8] = {
+ IRQ_GPIO1, IRQ_GPIO2, IRQ_GPIO3, IRQ_GPIO4,
+ IRQ_GPIO5, IRQ_GPIO6, IRQ_GPIO7, IRQ_GPIO8
};
void gpio_config(u32 port, u32 pins, int mode)
{
+ u32 offset = GPIO_CNF_OFFSET(port);
+
if (mode)
- GPIO(_gpio_cnf[port]) |= pins;
+ GPIO(offset) |= pins;
else
- GPIO(_gpio_cnf[port]) &= ~pins;
- (void)GPIO(_gpio_cnf[port]);
+ GPIO(offset) &= ~pins;
+
+ (void)GPIO(offset); // Commit the write.
}
void gpio_output_enable(u32 port, u32 pins, int enable)
{
+ u32 port_offset = GPIO_OE_OFFSET(port);
+
if (enable)
- GPIO(_gpio_oe[port]) |= pins;
+ GPIO(port_offset) |= pins;
else
- GPIO(_gpio_oe[port]) &= ~pins;
- (void)GPIO(_gpio_oe[port]);
+ GPIO(port_offset) &= ~pins;
+
+ (void)GPIO(port_offset); // Commit the write.
}
void gpio_write(u32 port, u32 pins, int high)
{
+ u32 port_offset = GPIO_OUT_OFFSET(port);
+
if (high)
- GPIO(_gpio_out[port]) |= pins;
+ GPIO(port_offset) |= pins;
else
- GPIO(_gpio_out[port]) &= ~pins;
- (void)GPIO(_gpio_out[port]);
+ GPIO(port_offset) &= ~pins;
+
+ (void)GPIO(port_offset); // Commit the write.
}
int gpio_read(u32 port, u32 pins)
{
- return (GPIO(_gpio_in[port]) & pins) ? 1 : 0;
+ u32 port_offset = GPIO_IN_OFFSET(port);
+
+ return (GPIO(port_offset) & pins) ? 1 : 0;
}
+
+static void _gpio_interrupt_clear(u32 port, u32 pins)
+{
+ u32 port_offset = GPIO_INT_CLR_OFFSET(port);
+
+ GPIO(port_offset) |= pins;
+
+ (void)GPIO(port_offset); // Commit the write.
+}
+
+int gpio_interrupt_status(u32 port, u32 pins)
+{
+ u32 port_offset = GPIO_INT_STA_OFFSET(port);
+ u32 enabled = GPIO(GPIO_INT_ENB_OFFSET(port)) & pins;
+
+ int status = ((GPIO(port_offset) & pins) && enabled) ? 1 : 0;
+
+ // Clear the interrupt status.
+ if (status)
+ _gpio_interrupt_clear(port, pins);
+
+ return status;
+}
+
+void gpio_interrupt_enable(u32 port, u32 pins, int enable)
+{
+ u32 port_offset = GPIO_INT_ENB_OFFSET(port);
+
+ // Clear any possible stray interrupt.
+ _gpio_interrupt_clear(port, pins);
+
+ if (enable)
+ GPIO(port_offset) |= pins;
+ else
+ GPIO(port_offset) &= ~pins;
+
+ (void)GPIO(port_offset); // Commit the write.
+}
+
+void gpio_interrupt_level(u32 port, u32 pins, int high, int edge, int delta)
+{
+ u32 port_offset = GPIO_INT_LVL_OFFSET(port);
+
+ u32 val = GPIO(port_offset);
+
+ if (high)
+ val |= pins;
+ else
+ val &= ~pins;
+
+ if (edge)
+ val |= pins << 8;
+ else
+ val &= ~(pins << 8);
+
+ if (delta)
+ val |= pins << 16;
+ else
+ val &= ~(pins << 16);
+
+ GPIO(port_offset) = val;
+
+ (void)GPIO(port_offset); // Commit the write.
+
+ // Clear any possible stray interrupt.
+ _gpio_interrupt_clear(port, pins);
+}
+
+u32 gpio_get_bank_irq_id(u32 port)
+{
+ u32 bank_idx = GPIO_BANK_IDX(port);
+
+ return gpio_bank_irq_ids[bank_idx];
+}
\ No newline at end of file
diff --git a/source/soc/gpio.h b/source/soc/gpio.h
index 83170b0..a7f999d 100644
--- a/source/soc/gpio.h
+++ b/source/soc/gpio.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -21,10 +22,23 @@
#define GPIO_MODE_SPIO 0
#define GPIO_MODE_GPIO 1
+
#define GPIO_OUTPUT_DISABLE 0
#define GPIO_OUTPUT_ENABLE 1
+
+#define GPIO_IRQ_DISABLE 0
+#define GPIO_IRQ_ENABLE 1
+
#define GPIO_LOW 0
#define GPIO_HIGH 1
+#define GPIO_FALLING 0
+#define GPIO_RISING 1
+
+#define GPIO_LEVEL 0
+#define GPIO_EDGE 1
+
+#define GPIO_CONFIGURED_EDGE 0
+#define GPIO_ANY_EDGE_CHANGE 1
/*! GPIO pins (0-7 for each port). */
#define GPIO_PIN_0 (1 << 0)
@@ -72,6 +86,10 @@
void gpio_config(u32 port, u32 pins, int mode);
void gpio_output_enable(u32 port, u32 pins, int enable);
void gpio_write(u32 port, u32 pins, int high);
-int gpio_read(u32 port, u32 pins);
+int gpio_read(u32 port, u32 pins);
+int gpio_interrupt_status(u32 port, u32 pins);
+void gpio_interrupt_enable(u32 port, u32 pins, int enable);
+void gpio_interrupt_level(u32 port, u32 pins, int high, int edge, int delta);
+u32 gpio_get_bank_irq_id(u32 port);
#endif
diff --git a/source/soc/hw_init.c b/source/soc/hw_init.c
index a7703a2..8867ff2 100644
--- a/source/soc/hw_init.c
+++ b/source/soc/hw_init.c
@@ -34,10 +34,10 @@
#include "../power/max7762x.h"
#include "../sec/se.h"
#include "../sec/se_t210.h"
+#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/util.h"
-extern sdmmc_t sd_sdmmc;
extern boot_cfg_t b_cfg;
extern volatile nyx_storage_t *nyx_str;
@@ -314,6 +314,9 @@ void config_hw()
bpmp_mmu_enable();
mc_enable_ahb_redirect();
+
+ // Clear flags from PMC_SCRATCH0
+ PMC(APBDEV_PMC_SCRATCH0) &= ~PMC_SCRATCH0_MODE_PAYLOAD;
}
void reconfig_hw_workaround(bool extra_reconfig, u32 magic)
diff --git a/source/soc/i2c.c b/source/soc/i2c.c
index 94239b5..40ab097 100644
--- a/source/soc/i2c.c
+++ b/source/soc/i2c.c
@@ -38,21 +38,39 @@ static void _i2c_wait(vu32 *base)
static int _i2c_send_pkt(u32 idx, u32 x, u8 *buf, u32 size)
{
- if (size > 4)
+ if (size > 8)
return 0;
u32 tmp = 0;
- memcpy(&tmp, buf, size);
vu32 *base = (vu32 *)i2c_addrs[idx];
- base[I2C_CMD_ADDR0] = x << 1; //Set x (send mode).
- base[I2C_CMD_DATA1] = tmp; //Set value.
+ base[I2C_CMD_ADDR0] = x << 1; //Set x (send mode).
+
+ if (size > 4)
+ {
+ memcpy(&tmp, buf, 4);
+ base[I2C_CMD_DATA1] = tmp; //Set value.
+ tmp = 0;
+ memcpy(&tmp, buf + 4, size - 4);
+ base[I2C_CMD_DATA2] = tmp;
+ }
+ else
+ {
+ memcpy(&tmp, buf, size);
+ base[I2C_CMD_DATA1] = tmp; //Set value.
+ }
+
base[I2C_CNFG] = ((size - 1) << 1) | 0x2800; //Set size and send mode.
_i2c_wait(base); //Kick transaction.
base[I2C_CNFG] = (base[I2C_CNFG] & 0xFFFFFDFF) | 0x200;
+
+ u32 timeout = get_tmr_ms() + 1500;
while (base[I2C_STATUS] & 0x100)
- ;
+ {
+ if (get_tmr_ms() > timeout)
+ return 0;
+ }
if (base[I2C_STATUS] << 28)
return 0;
@@ -71,8 +89,13 @@ static int _i2c_recv_pkt(u32 idx, u8 *buf, u32 size, u32 x)
_i2c_wait(base); // Kick transaction.
base[I2C_CNFG] = (base[I2C_CNFG] & 0xFFFFFDFF) | 0x200;
+
+ u32 timeout = get_tmr_ms() + 1500;
while (base[I2C_STATUS] & 0x100)
- ;
+ {
+ if (get_tmr_ms() > timeout)
+ return 0;
+ }
if (base[I2C_STATUS] << 28)
return 0;
@@ -113,7 +136,7 @@ int i2c_send_buf_small(u32 idx, u32 x, u32 y, u8 *buf, u32 size)
{
u8 tmp[4];
- if (size > 3)
+ if (size > 7)
return 0;
tmp[0] = y;
diff --git a/source/soc/irq.c b/source/soc/irq.c
new file mode 100644
index 0000000..627976d
--- /dev/null
+++ b/source/soc/irq.c
@@ -0,0 +1,263 @@
+/*
+ * BPMP-Lite IRQ driver for Tegra X1
+ *
+ * Copyright (c) 2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+
+#include "irq.h"
+#include "t210.h"
+#include "../gfx/gfx.h"
+#include "../mem/heap.h"
+
+//#define DPRINTF(...) gfx_printf(__VA_ARGS__)
+#define DPRINTF(...)
+
+extern void irq_disable();
+extern void irq_enable_cpu_irq_exceptions();
+extern void irq_disable_cpu_irq_exceptions();
+
+typedef struct _irq_ctxt_t
+{
+ u32 irq;
+ int (*handler)(u32 irq, void *data);
+ void *data;
+ u32 flags;
+} irq_ctxt_t;
+
+bool irq_init_done = false;
+irq_ctxt_t irqs[IRQ_MAX_HANDLERS];
+
+static void _irq_enable_source(u32 irq)
+{
+ u32 ctrl_idx = irq >> 5;
+ u32 bit = irq % 32;
+
+ // Set as normal IRQ.
+ ICTLR(ctrl_idx, PRI_ICTLR_COP_IEP_CLASS) &= ~(1 << bit);
+
+ // Enable IRQ source.
+ ICTLR(ctrl_idx, PRI_ICTLR_COP_IER_SET) = 1 << bit;
+}
+
+static void _irq_disable_source(u32 irq)
+{
+ u32 ctrl_idx = irq >> 5;
+ u32 bit = irq % 32;
+
+ // Disable IRQ source.
+ ICTLR(ctrl_idx, PRI_ICTLR_COP_IER_CLR) = 1 << bit;
+}
+
+static void _irq_disable_and_ack_all()
+{
+ // Disable and ack all IRQ sources.
+ for (u32 ctrl_idx = 0; ctrl_idx < 6; ctrl_idx++)
+ {
+ u32 enabled_irqs = ICTLR(ctrl_idx, PRI_ICTLR_COP_IER);
+ ICTLR(ctrl_idx, PRI_ICTLR_COP_IER_CLR) = enabled_irqs;
+ ICTLR(ctrl_idx, PRI_ICTLR_FIR_CLR) = enabled_irqs;
+ }
+}
+
+static void _irq_ack_source(u32 irq)
+{
+ u32 ctrl_idx = irq >> 5;
+ u32 bit = irq % 32;
+
+ // Force stop the interrupt as it's serviced here.
+ ICTLR(ctrl_idx, PRI_ICTLR_FIR_CLR) = 1 << bit;
+}
+
+void irq_free(u32 irq)
+{
+ for (u32 idx = 0; idx < IRQ_MAX_HANDLERS; idx++)
+ {
+ if (irqs[idx].irq == irq && irqs[idx].handler)
+ {
+ irqs[idx].irq = 0;
+ irqs[idx].handler = NULL;
+ irqs[idx].data = NULL;
+ irqs[idx].flags = 0;
+
+ _irq_disable_source(irq);
+ }
+ }
+}
+
+static void _irq_free_all()
+{
+ for (u32 idx = 0; idx < IRQ_MAX_HANDLERS; idx++)
+ {
+ if (irqs[idx].handler)
+ {
+ _irq_disable_source(irqs[idx].irq);
+
+ irqs[idx].irq = 0;
+ irqs[idx].handler = NULL;
+ irqs[idx].data = NULL;
+ irqs[idx].flags = 0;
+ }
+ }
+}
+
+static irq_status_t _irq_handle_source(u32 irq)
+{
+ int status = IRQ_NONE;
+
+ _irq_disable_source(irq);
+ _irq_ack_source(irq);
+
+ u32 idx;
+ for (idx = 0; idx < IRQ_MAX_HANDLERS; idx++)
+ {
+ if (irqs[idx].irq == irq)
+ {
+ status = irqs[idx].handler(irqs[idx].irq, irqs[idx].data);
+
+ if (status == IRQ_HANDLED)
+ break;
+ }
+ }
+
+ if (irqs[idx].flags & IRQ_FLAG_ONE_OFF)
+ irq_free(irq);
+ else
+ _irq_enable_source(irq);
+
+ return status;
+}
+
+void irq_handler()
+{
+ // Get IRQ source.
+ u32 irq = EXCP_VEC(EVP_COP_IRQ_STS) & 0xFF;
+
+ if (!irq_init_done)
+ {
+ _irq_ack_source(irq);
+ return;
+ }
+
+ DPRINTF("IRQ: %d\n", irq);
+
+ int err = _irq_handle_source(irq);
+
+ //TODO: disable if unhandhled.
+ if (err == IRQ_NONE)
+ gfx_printf("Unhandled IRQ: %d\n", irq);
+}
+
+static void _irq_init()
+{
+ _irq_disable_and_ack_all();
+ memset(irqs, 0, sizeof(irq_ctxt_t) * IRQ_MAX_HANDLERS);
+ irq_init_done = true;
+}
+
+void irq_end()
+{
+ _irq_free_all();
+ irq_disable_cpu_irq_exceptions();
+ irq_init_done = false;
+}
+
+void irq_wait_event(u32 irq)
+{
+ irq_disable_cpu_irq_exceptions();
+
+ _irq_enable_source(irq);
+
+ // Halt BPMP and wait for the IRQ. No need to use WAIT_EVENT + LIC_IRQ when BPMP serves the IRQ.
+ FLOW_CTLR(FLOW_CTLR_HALT_COP_EVENTS) = HALT_COP_STOP_UNTIL_IRQ;
+
+ _irq_disable_source(irq);
+ _irq_ack_source(irq);
+
+ irq_enable_cpu_irq_exceptions();
+}
+
+void irq_disable_wait_event()
+{
+ irq_enable_cpu_irq_exceptions();
+}
+
+irq_status_t irq_request(u32 irq, irq_handler_t handler, void *data, irq_flags_t flags)
+{
+ if (!irq_init_done)
+ _irq_init();
+
+ for (u32 idx = 0; idx < IRQ_MAX_HANDLERS; idx++)
+ {
+ if (irqs[idx].handler == NULL ||
+ (irqs[idx].irq == irq && irqs[idx].flags & IRQ_FLAG_REPLACEABLE))
+ {
+ DPRINTF("Registered handler, IRQ: %d, Slot: %d\n", irq, idx);
+ DPRINTF("Handler: %08p, Flags: %x\n", (u32)handler, flags);
+
+ irqs[idx].irq = irq;
+ irqs[idx].handler = handler;
+ irqs[idx].data = data;
+ irqs[idx].flags = flags;
+
+ _irq_enable_source(irq);
+
+ return IRQ_ENABLED;
+ }
+ else if (irqs[idx].irq == irq)
+ return IRQ_ALREADY_REGISTERED;
+ }
+
+ return IRQ_NO_SLOTS_AVAILABLE;
+}
+
+void __attribute__ ((target("arm"))) fiq_setup()
+{
+/*
+ asm volatile("mrs r12, cpsr\n\t"
+ "bic r12, r12, #0x1F\n\t"
+ "orr r12, r12, #0x11\n\t"
+ "msr cpsr_c, r12\n\t");
+
+ register volatile char *text asm ("r8");
+ register volatile char *uart_tx asm ("r9");
+ register int len asm ("r10");
+
+ len = 5;
+ uart_tx = (char *)0x70006040;
+ memcpy((char *)text, "FIQ\r\n", len);
+ *uart_tx = 0;
+
+ asm volatile("mrs r12, cpsr\n"
+ "orr r12, r12, #0x1F\n"
+ "msr cpsr_c, r12");
+*/
+}
+
+void __attribute__ ((target("arm"), interrupt ("FIQ"))) fiq_handler()
+{
+/*
+ register volatile char *text asm ("r8");
+ register volatile char *uart_tx asm ("r9");
+ register int len asm ("r10");
+
+ while (len)
+ {
+ *uart_tx = *text++;
+ len--;
+ }
+*/
+}
diff --git a/source/soc/irq.h b/source/soc/irq.h
new file mode 100644
index 0000000..c77d980
--- /dev/null
+++ b/source/soc/irq.h
@@ -0,0 +1,222 @@
+/*
+ * BPMP-Lite IRQ driver for Tegra X1
+ *
+ * Copyright (c) 2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef IRQ_H
+#define IRQ_H
+
+#include "../utils/types.h"
+
+#define IRQ_MAX_HANDLERS 16
+
+/* Primary interrupt controller ids */
+#define IRQ_TMR1 0
+#define IRQ_TMR2 1
+#define IRQ_RTC 2
+#define IRQ_CEC 3
+#define IRQ_SHR_SEM_INBOX_FULL 4
+#define IRQ_SHR_SEM_INBOX_EMPTY 5
+#define IRQ_SHR_SEM_OUTBOX_FULL 6
+#define IRQ_SHR_SEM_OUTBOX_EMPTY 7
+#define IRQ_NVJPEG 8
+#define IRQ_NVDEC 9
+#define IRQ_QUAD_SPI 10
+#define IRQ_DPAUX_INT1 11
+#define IRQ_SATA_RX_STAT 13
+#define IRQ_SDMMC1 14
+#define IRQ_SDMMC2 15
+#define IRQ_VGPIO_INT 16
+#define IRQ_VII2C_INT 17
+#define IRQ_SDMMC3 19
+#define IRQ_USB 20
+#define IRQ_USB2 21
+#define IRQ_SATA_CTL 23
+#define IRQ_PMC_INT 24
+#define IRQ_FC_INT 25
+#define IRQ_APB_DMA_CPU 26
+#define IRQ_ARB_SEM_GNT_COP 28
+#define IRQ_ARB_SEM_GNT_CPU 29
+#define IRQ_SDMMC4 31
+
+/* Secondary interrupt controller ids */
+#define IRQ_GPIO1 32
+#define IRQ_GPIO2 33
+#define IRQ_GPIO3 34
+#define IRQ_GPIO4 35
+#define IRQ_UARTA 36
+#define IRQ_UARTB 37
+#define IRQ_I2C 38
+#define IRQ_USB3_HOST_INT 39
+#define IRQ_USB3_HOST_SMI 40
+#define IRQ_TMR3 41
+#define IRQ_TMR4 42
+#define IRQ_USB3_HOST_PME 43
+#define IRQ_USB3_DEV_HOST 44
+#define IRQ_ACTMON 45
+#define IRQ_UARTC 46
+#define IRQ_THERMAL 48
+#define IRQ_XUSB_PADCTL 49
+#define IRQ_TSEC 50
+#define IRQ_EDP 51
+#define IRQ_I2C5 53
+#define IRQ_GPIO5 55
+#define IRQ_USB3_DEV_SMI 56
+#define IRQ_USB3_DEV_PME 57
+#define IRQ_SE 58
+#define IRQ_SPI1 59
+#define IRQ_APB_DMA_COP 60
+#define IRQ_CLDVFS 62
+#define IRQ_I2C6 63
+
+/* Tertiary interrupt controller ids */
+#define IRQ_HOST1X_SYNCPT_COP 64
+#define IRQ_HOST1X_SYNCPT_CPU 65
+#define IRQ_HOST1X_GEN_COP 66
+#define IRQ_HOST1X_GEN_CPU 67
+#define IRQ_NVENC 68
+#define IRQ_VI 69
+#define IRQ_ISPB 70
+#define IRQ_ISP 71
+#define IRQ_VIC 72
+#define IRQ_DISPLAY 73
+#define IRQ_DISPLAYB 74
+#define IRQ_SOR1 75
+#define IRQ_SOR 76
+#define IRQ_MC 77
+#define IRQ_EMC 78
+#define IRQ_TSECB 80
+#define IRQ_HDA 81
+#define IRQ_SPI2 82
+#define IRQ_SPI3 83
+#define IRQ_I2C2 84
+#define IRQ_PMU_EXT 86
+#define IRQ_GPIO6 87
+#define IRQ_GPIO7 89
+#define IRQ_UARTD 90
+#define IRQ_I2C3 92
+#define IRQ_SPI4 93
+
+/* Quaternary interrupt controller ids */
+#define IRQ_DTV 96
+#define IRQ_PCIE_INT 98
+#define IRQ_PCIE_MSI 99
+#define IRQ_AVP_CACHE 101
+#define IRQ_APE_INT1 102
+#define IRQ_APE_INT0 103
+#define IRQ_APB_DMA_CH0 104
+#define IRQ_APB_DMA_CH1 105
+#define IRQ_APB_DMA_CH2 106
+#define IRQ_APB_DMA_CH3 107
+#define IRQ_APB_DMA_CH4 108
+#define IRQ_APB_DMA_CH5 109
+#define IRQ_APB_DMA_CH6 110
+#define IRQ_APB_DMA_CH7 111
+#define IRQ_APB_DMA_CH8 112
+#define IRQ_APB_DMA_CH9 113
+#define IRQ_APB_DMA_CH10 114
+#define IRQ_APB_DMA_CH11 115
+#define IRQ_APB_DMA_CH12 116
+#define IRQ_APB_DMA_CH13 117
+#define IRQ_APB_DMA_CH14 118
+#define IRQ_APB_DMA_CH15 119
+#define IRQ_I2C4 120
+#define IRQ_TMR5 121
+#define IRQ_WDT_CPU 123
+#define IRQ_WDT_AVP 124
+#define IRQ_GPIO8 125
+#define IRQ_CAR 126
+
+/* Quinary interrupt controller ids */
+#define IRQ_APB_DMA_CH16 128
+#define IRQ_APB_DMA_CH17 129
+#define IRQ_APB_DMA_CH18 130
+#define IRQ_APB_DMA_CH19 131
+#define IRQ_APB_DMA_CH20 132
+#define IRQ_APB_DMA_CH21 133
+#define IRQ_APB_DMA_CH22 134
+#define IRQ_APB_DMA_CH23 135
+#define IRQ_APB_DMA_CH24 136
+#define IRQ_APB_DMA_CH25 137
+#define IRQ_APB_DMA_CH26 138
+#define IRQ_APB_DMA_CH27 139
+#define IRQ_APB_DMA_CH28 140
+#define IRQ_APB_DMA_CH29 141
+#define IRQ_APB_DMA_CH30 142
+#define IRQ_APB_DMA_CH31 143
+#define IRQ_CPU0_PMU_INTR 144
+#define IRQ_CPU1_PMU_INTR 145
+#define IRQ_CPU2_PMU_INTR 146
+#define IRQ_CPU3_PMU_INTR 147
+#define IRQ_SDMMC1_SYS 148
+#define IRQ_SDMMC2_SYS 149
+#define IRQ_SDMMC3_SYS 150
+#define IRQ_SDMMC4_SYS 151
+#define IRQ_TMR6 152
+#define IRQ_TMR7 153
+#define IRQ_TMR8 154
+#define IRQ_TMR9 155
+#define IRQ_TMR0 156
+#define IRQ_GPU_STALL 157
+#define IRQ_GPU_NONSTALL 158
+#define IRQ_DPAUX 159
+
+/* Senary interrupt controller ids */
+#define IRQ_MPCORE_AXIERRIRQ 160
+#define IRQ_MPCORE_INTERRIRQ 161
+#define IRQ_EVENT_GPIO_A 162
+#define IRQ_EVENT_GPIO_B 163
+#define IRQ_EVENT_GPIO_C 164
+#define IRQ_FLOW_RSM_CPU 168
+#define IRQ_FLOW_RSM_COP 169
+#define IRQ_TMR_SHARED 170
+#define IRQ_MPCORE_CTIIRQ0 171
+#define IRQ_MPCORE_CTIIRQ1 172
+#define IRQ_MPCORE_CTIIRQ2 173
+#define IRQ_MPCORE_CTIIRQ3 174
+#define IRQ_MSELECT_ERROR 175
+#define IRQ_TMR10 176
+#define IRQ_TMR11 177
+#define IRQ_TMR12 178
+#define IRQ_TMR13 179
+
+typedef int (*irq_handler_t)(u32 irq, void *data);
+
+typedef enum _irq_status_t
+{
+ IRQ_NONE = 0,
+ IRQ_HANDLED = 1,
+ IRQ_ERROR = 2,
+
+ IRQ_ENABLED = 0,
+ IRQ_NO_SLOTS_AVAILABLE = 1,
+ IRQ_ALREADY_REGISTERED = 2
+} irq_status_t;
+
+typedef enum _irq_flags_t
+{
+ IRQ_FLAG_NONE = 0,
+ IRQ_FLAG_ONE_OFF = (1 << 0),
+ IRQ_FLAG_REPLACEABLE = (1 << 1)
+} irq_flags_t;
+
+void irq_end();
+void irq_free(u32 irq);
+void irq_wait_event();
+void irq_disable_wait_event();
+irq_status_t irq_request(u32 irq, irq_handler_t handler, void *data, irq_flags_t flags);
+
+#endif
\ No newline at end of file
diff --git a/source/soc/pinmux.h b/source/soc/pinmux.h
index bb4ecb1..ca57584 100644
--- a/source/soc/pinmux.h
+++ b/source/soc/pinmux.h
@@ -62,6 +62,7 @@
#define PINMUX_AUX_LCD_BL_PWM 0x1FC
#define PINMUX_AUX_LCD_BL_EN 0x200
#define PINMUX_AUX_LCD_RST 0x204
+#define PINMUX_AUX_LCD_GPIO1 0x208
#define PINMUX_AUX_LCD_GPIO2 0x20C
#define PINMUX_AUX_TOUCH_INT 0x220
#define PINMUX_AUX_MOTION_INT 0x224
diff --git a/source/soc/pmc.h b/source/soc/pmc.h
index 8cd9161..7df7922 100644
--- a/source/soc/pmc.h
+++ b/source/soc/pmc.h
@@ -25,13 +25,23 @@
#define APBDEV_PMC_PWRGATE_TOGGLE 0x30
#define APBDEV_PMC_PWRGATE_STATUS 0x38
#define APBDEV_PMC_NO_IOPOWER 0x44
+#define PMC_NO_IOPOWER_GPIO_IO_EN (1 << 21)
+#define PMC_NO_IOPOWER_AUDIO_HV (1 << 18)
#define PMC_NO_IOPOWER_SDMMC1_IO_EN (1 << 12)
#define APBDEV_PMC_SCRATCH0 0x50
+#define PMC_SCRATCH0_MODE_RECOVERY (1 << 31)
+#define PMC_SCRATCH0_MODE_FASTBOOT (1 << 30)
+#define PMC_SCRATCH0_MODE_PAYLOAD (1 << 29)
+#define PMC_SCRATCH0_MODE_RCM (1 << 1)
+#define PMC_SCRATCH0_MODE_WARMBOOT (1 << 0)
#define APBDEV_PMC_SCRATCH1 0x54
#define APBDEV_PMC_SCRATCH20 0xA0
#define APBDEV_PMC_PWR_DET_VAL 0xE4
+#define PMC_PWR_DET_GPIO_IO_EN (1 << 21)
+#define PMC_PWR_DET_AUDIO_HV (1 << 18)
#define PMC_PWR_DET_SDMMC1_IO_EN (1 << 12)
#define APBDEV_PMC_DDR_PWR 0xE8
+#define APBDEV_PMC_USB_AO 0xF0
#define APBDEV_PMC_CRYPTO_OP 0xF4
#define PMC_CRYPTO_OP_SE_ENABLE 0
#define PMC_CRYPTO_OP_SE_DISABLE 1
@@ -39,6 +49,8 @@
#define APBDEV_PMC_SCRATCH40 0x13C
#define APBDEV_PMC_OSC_EDPD_OVER 0x1A4
#define PMC_OSC_EDPD_OVER_OSC_CTRL_OVER 0x400000
+#define APBDEV_PMC_CLK_OUT_CNTRL 0x1A8
+#define PMC_CLK_OUT_CNTRL_CLK1_FORCE_EN (1 << 2)
#define APBDEV_PMC_RST_STATUS 0x1B4
#define APBDEV_PMC_IO_DPD_REQ 0x1B8
#define APBDEV_PMC_IO_DPD2_REQ 0x1C0
diff --git a/source/soc/t210.h b/source/soc/t210.h
index 85e42f4..b45ef2a 100644
--- a/source/soc/t210.h
+++ b/source/soc/t210.h
@@ -28,9 +28,11 @@
#define VIC_BASE 0x54340000
#define TSEC_BASE 0x54500000
#define SOR1_BASE 0x54580000
+#define ICTLR_BASE 0x60004000
#define TMR_BASE 0x60005000
#define CLOCK_BASE 0x60006000
#define FLOW_CTLR_BASE 0x60007000
+#define AHBDMA_BASE 0x60008000
#define SYSREG_BASE 0x6000C000
#define SB_BASE (SYSREG_BASE + 0x200)
#define GPIO_BASE 0x6000D000
@@ -44,6 +46,7 @@
#define GPIO_8_BASE (GPIO_BASE + 0x700)
#define EXCP_VEC_BASE 0x6000F000
#define IPATCH_BASE 0x6001DC00
+#define APBDMA_BASE 0x60020000
#define APB_MISC_BASE 0x70000000
#define PINMUX_AUX_BASE 0x70003000
#define UART_BASE 0x70006000
@@ -56,10 +59,16 @@
#define SE_BASE 0x70012000
#define MC_BASE 0x70019000
#define EMC_BASE 0x7001B000
+#define EMC0_BASE 0x7001E000
+#define EMC1_BASE 0x7001F000
#define MIPI_CAL_BASE 0x700E3000
#define CL_DVFS_BASE 0x70110000
#define I2S_BASE 0x702D1000
+#define ADMA_BASE 0x702E2000
#define TZRAM_BASE 0x7C010000
+#define USB_BASE 0x7D000000
+#define USB_OTG_BASE USB_BASE
+#define USB1_BASE 0x7D004000
#define _REG(base, off) *(vu32 *)((base) + (off))
@@ -70,10 +79,12 @@
#define VIC(off) _REG(VIC_BASE, off)
#define TSEC(off) _REG(TSEC_BASE, off)
#define SOR1(off) _REG(SOR1_BASE, off)
+#define ICTLR(cidx, off) _REG(ICTLR_BASE + (0x100 * cidx), off)
#define TMR(off) _REG(TMR_BASE, off)
#define CLOCK(off) _REG(CLOCK_BASE, off)
#define FLOW_CTLR(off) _REG(FLOW_CTLR_BASE, off)
#define SYSREG(off) _REG(SYSREG_BASE, off)
+#define AHB_GIZMO(off) _REG(SYSREG_BASE, off)
#define SB(off) _REG(SB_BASE, off)
#define GPIO(off) _REG(GPIO_BASE, off)
#define GPIO_1(off) _REG(GPIO_1_BASE, off)
@@ -96,9 +107,14 @@
#define SE(off) _REG(SE_BASE, off)
#define MC(off) _REG(MC_BASE, off)
#define EMC(off) _REG(EMC_BASE, off)
+#define EMC_CH0(off) _REG(EMC0_BASE, off)
+#define EMC_CH1(off) _REG(EMC1_BASE, off)
#define MIPI_CAL(off) _REG(MIPI_CAL_BASE, off)
-#define I2S(off) _REG(I2S_BASE, off)
#define CL_DVFS(off) _REG(CL_DVFS_BASE, off)
+#define I2S(off) _REG(I2S_BASE, off)
+#define ADMA(off) _REG(ADMA_BASE, off)
+#define USB(off) _REG(USB_BASE, off)
+#define USB1(off) _REG(USB1_BASE, off)
#define TEST_REG(off) _REG(0x0, off)
/* HOST1X registers. */
@@ -116,13 +132,40 @@
#define EVP_COP_RSVD_VECTOR 0x214
#define EVP_COP_IRQ_VECTOR 0x218
#define EVP_COP_FIQ_VECTOR 0x21C
+#define EVP_COP_IRQ_STS 0x220
+
+/*! Primary Interrupt Controller registers. */
+#define PRI_ICTLR_FIR 0x14
+#define PRI_ICTLR_FIR_SET 0x18
+#define PRI_ICTLR_FIR_CLR 0x1C
+#define PRI_ICTLR_CPU_IER 0x20
+#define PRI_ICTLR_CPU_IER_SET 0x24
+#define PRI_ICTLR_CPU_IER_CLR 0x28
+#define PRI_ICTLR_CPU_IEP_CLASS 0x2C
+#define PRI_ICTLR_COP_IER 0x30
+#define PRI_ICTLR_COP_IER_SET 0x34
+#define PRI_ICTLR_COP_IER_CLR 0x38
+#define PRI_ICTLR_COP_IEP_CLASS 0x3C
+
+/*! AHB Gizmo registers. */
+#define AHB_ARBITRATION_PRIORITY_CTRL 0x8
+#define ARBITRATION_PRIORITY_CTRL_ENB_FAST_REARBITRATE (1 << 6)
+#define AHB_GIZMO_AHB_MEM 0x10
+#define AHB_MEM_ENB_FAST_REARBITRATE (1 << 2)
+#define AHB_GIZMO_USB 0x20
+#define AHB_GIZMO_USB_IMMEDIATE (1 << 18)
+#define AHB_AHB_MEM_PREFETCH_CFG1 0xF0
+#define MEM_PREFETCH_ENABLE (1 << 31)
+#define MEM_PREFETCH_AHB_MST_USB 6
/*! Misc registers. */
#define APB_MISC_PP_STRAPPING_OPT_A 0x08
#define APB_MISC_PP_PINMUX_GLOBAL 0x40
#define APB_MISC_GP_HIDREV 0x804
+#define APB_MISC_GP_AUD_MCLK_CFGPADCTRL 0x8F4
#define APB_MISC_GP_LCD_BL_PWM_CFGPADCTRL 0xA34
#define APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL 0xA98
+#define APB_MISC_GP_EMMC2_PAD_CFGPADCTRL 0xA9C
#define APB_MISC_GP_EMMC4_PAD_CFGPADCTRL 0xAB4
#define APB_MISC_GP_EMMC4_PAD_PUPD_CFGPADCTRL 0xABC
#define APB_MISC_GP_WIFI_EN_CFGPADCTRL 0xB64
@@ -170,9 +213,14 @@
/*! TMR registers. */
#define TIMERUS_CNTR_1US (0x10 + 0x0)
#define TIMERUS_USEC_CFG (0x10 + 0x4)
+#define TIMER_TMR8_TMR_PTV 0x78
#define TIMER_TMR9_TMR_PTV 0x80
-#define TIMER_EN (1 << 31)
-#define TIMER_PER_EN (1 << 30)
+#define TIMER_EN (1 << 31)
+#define TIMER_PER_EN (1 << 30)
+#define TIMER_TMR8_TMR_PCR 0x7C
+#define TIMER_TMR9_TMR_PCR 0x8C
+#define TIMER_INTR_CLR (1 << 30)
+
#define TIMER_WDT4_CONFIG (0x100 + 0x80)
#define TIMER_SRC(TMR) (TMR & 0xF)
#define TIMER_PER(PER) ((PER & 0xFF) << 4)
@@ -210,13 +258,15 @@
/*! Flow controller registers. */
#define FLOW_CTLR_HALT_COP_EVENTS 0x4
-#define HALT_COP_SEC (1 << 23)
-#define HALT_COP_MSEC (1 << 24)
-#define HALT_COP_USEC (1 << 25)
-#define HALT_COP_JTAG (1 << 28)
-#define HALT_COP_WAIT_EVENT (1 << 30)
-#define HALT_COP_WAIT_IRQ (1 << 31)
-#define HALT_COP_MAX_CNT 0xFF
+#define HALT_COP_GIC_IRQ (1 << 9)
+#define HALT_COP_LIC_IRQ (1 << 11)
+#define HALT_COP_SEC (1 << 23)
+#define HALT_COP_MSEC (1 << 24)
+#define HALT_COP_USEC (1 << 25)
+#define HALT_COP_JTAG (1 << 28)
+#define HALT_COP_WAIT_EVENT (1 << 30)
+#define HALT_COP_STOP_UNTIL_IRQ (1 << 31)
+#define HALT_COP_MAX_CNT 0xFF
#define FLOW_CTLR_HALT_CPU0_EVENTS 0x0
#define FLOW_CTLR_HALT_CPU1_EVENTS 0x14
#define FLOW_CTLR_HALT_CPU2_EVENTS 0x1C
@@ -228,4 +278,9 @@
#define FLOW_CTLR_RAM_REPAIR 0x40
#define FLOW_CTLR_BPMP_CLUSTER_CONTROL 0x98
+/*! USB controller registers. */
+#define USB1_UTMIP_BAT_CHRG_CFG0 0x830
+#define BAT_CHRG_CFG0_OP_SRC_EN (1 << 3)
+#define BAT_CHRG_CFG0_PWRDOWN_CHRG (1 << 0)
+
#endif
diff --git a/source/storage/emummc.c b/source/storage/emummc.c
index a07d9ed..eea93e5 100644
--- a/source/storage/emummc.c
+++ b/source/storage/emummc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 CTCaer
+ * Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -24,17 +24,12 @@
#include "../gfx/gfx.h"
#include "../libs/fatfs/ff.h"
#include "../mem/heap.h"
+#include "../storage/nx_sd.h"
#include "../utils/list.h"
#include "../utils/types.h"
-extern sdmmc_t sd_sdmmc;
-extern sdmmc_storage_t sd_storage;
-extern FATFS sd_fs;
-
extern hekate_config h_cfg;
-
-extern bool sd_mount();
-extern void sd_unmount();
+emummc_cfg_t emu_cfg;
bool emummc_load_cfg()
{
@@ -47,7 +42,8 @@ bool emummc_load_cfg()
emu_cfg.file_based_part_size = 0;
emu_cfg.active_part = 0;
emu_cfg.fs_ver = 0;
- emu_cfg.emummc_file_based_path = (char *)malloc(0x80);
+ if (!emu_cfg.emummc_file_based_path)
+ emu_cfg.emummc_file_based_path = (char *)malloc(0x80);
LIST_INIT(ini_sections);
if (ini_parse(&ini_sections, "emuMMC/emummc.ini", false))
@@ -94,18 +90,14 @@ static int emummc_raw_get_part_off(int part_idx)
return 2;
}
-
int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
{
FILINFO fno;
- if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
- {
- EPRINTF("Failed to init eMMC.");
+ if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400))
+ return 2;
- goto out;
- }
if (h_cfg.emummc_force_disable)
- return 1;
+ return 0;
emu_cfg.active_part = 0;
if (!sd_mount())
@@ -131,10 +123,11 @@ int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
}
emu_cfg.file_based_part_size = fno.fsize >> 9;
}
- return 1;
+
+ return 0;
out:
- return 0;
+ return 1;
}
int emummc_storage_end(sdmmc_storage_t *storage)
diff --git a/source/storage/emummc.h b/source/storage/emummc.h
index 635332f..0103841 100644
--- a/source/storage/emummc.h
+++ b/source/storage/emummc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 CTCaer
+ * Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -47,7 +47,7 @@ typedef struct _emummc_cfg_t
int fs_ver;
} emummc_cfg_t;
-emummc_cfg_t emu_cfg;
+extern emummc_cfg_t emu_cfg;
bool emummc_load_cfg();
int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc);
diff --git a/source/storage/mbr_gpt.h b/source/storage/mbr_gpt.h
new file mode 100644
index 0000000..923b6d2
--- /dev/null
+++ b/source/storage/mbr_gpt.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2018 naehrwert
+ * Copyright (c) 2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef MBR_GPT_H
+#define MBR_GPT_H
+
+#include "../utils/types.h"
+
+typedef struct _mbr_chs_t
+{
+ u8 head;
+ u8 sector;
+ u8 cylinder;
+} __attribute__((packed)) mbr_chs_t;
+
+typedef struct _mbr_part_t
+{
+ u8 status;
+ mbr_chs_t start_sct_chs;
+ u8 type;
+ mbr_chs_t end_sct_chs;
+ u32 start_sct;
+ u32 size_sct;
+} __attribute__((packed)) mbr_part_t;
+
+typedef struct _mbr_t
+{
+ u8 bootstrap[440];
+ u32 signature;
+ u16 copy_protected;
+ mbr_part_t partitions[4];
+ u16 boot_signature;
+} __attribute__((packed)) mbr_t;
+
+typedef struct _gpt_entry_t
+{
+ u8 type_guid[0x10];
+ u8 part_guid[0x10];
+ u64 lba_start;
+ u64 lba_end;
+ u64 attrs;
+ u16 name[36];
+} gpt_entry_t;
+
+typedef struct _gpt_header_t
+{
+ u64 signature; // "EFI PART"
+ u32 revision;
+ u32 size;
+ u32 crc32;
+ u32 res1;
+ u64 my_lba;
+ u64 alt_lba;
+ u64 first_use_lba;
+ u64 last_use_lba;
+ u8 disk_guid[0x10];
+ u64 part_ent_lba;
+ u32 num_part_ents;
+ u32 part_ent_size;
+ u32 part_ents_crc32;
+ u8 res2[420]; // Used as first 3 partition entries backup for HOS.
+} gpt_header_t;
+
+typedef struct _gpt_t
+{
+ gpt_header_t header;
+ gpt_entry_t entries[128];
+} gpt_t;
+
+#endif
diff --git a/source/storage/nx_emmc.c b/source/storage/nx_emmc.c
index 2cae846..f5765a1 100644
--- a/source/storage/nx_emmc.c
+++ b/source/storage/nx_emmc.c
@@ -16,6 +16,7 @@
#include
+#include "mbr_gpt.h"
#include "nx_emmc.h"
#include "emummc.h"
#include "../mem/heap.h"
@@ -23,28 +24,31 @@
void nx_emmc_gpt_parse(link_t *gpt, sdmmc_storage_t *storage)
{
- u8 *buf = (u8 *)malloc(NX_GPT_NUM_BLOCKS * NX_EMMC_BLOCKSIZE);
+ gpt_t *gpt_buf = (gpt_t *)calloc(NX_GPT_NUM_BLOCKS, NX_EMMC_BLOCKSIZE);
- emummc_storage_read(storage, NX_GPT_FIRST_LBA, NX_GPT_NUM_BLOCKS, buf);
+ emummc_storage_read(storage, NX_GPT_FIRST_LBA, NX_GPT_NUM_BLOCKS, gpt_buf);
- gpt_header_t *hdr = (gpt_header_t *)buf;
- for (u32 i = 0; i < hdr->num_part_ents; i++)
+ for (u32 i = 0; i < gpt_buf->header.num_part_ents; i++)
{
- gpt_entry_t *ent = (gpt_entry_t *)(buf + (hdr->part_ent_lba - 1) * NX_EMMC_BLOCKSIZE + i * sizeof(gpt_entry_t));
emmc_part_t *part = (emmc_part_t *)calloc(sizeof(emmc_part_t), 1);
- part->lba_start = ent->lba_start;
- part->lba_end = ent->lba_end;
- part->attrs = ent->attrs;
+
+ if (gpt_buf->entries[i].lba_start < gpt_buf->header.first_use_lba)
+ continue;
+
+ part->index = i;
+ part->lba_start = gpt_buf->entries[i].lba_start;
+ part->lba_end = gpt_buf->entries[i].lba_end;
+ part->attrs = gpt_buf->entries[i].attrs;
// ASCII conversion. Copy only the LSByte of the UTF-16LE name.
- for (u32 i = 0; i < 36; i++)
- part->name[i] = ent->name[i];
- part->name[36] = 0;
+ for (u32 j = 0; j < 36; j++)
+ part->name[j] = gpt_buf->entries[i].name[j];
+ part->name[35] = 0;
list_append(gpt, &part->link);
}
- free(buf);
+ free(gpt_buf);
}
void nx_emmc_gpt_free(link_t *gpt)
diff --git a/source/storage/nx_emmc.h b/source/storage/nx_emmc.h
index 753d5aa..19bc1ca 100644
--- a/source/storage/nx_emmc.h
+++ b/source/storage/nx_emmc.h
@@ -17,38 +17,9 @@
#ifndef _NX_EMMC_H_
#define _NX_EMMC_H_
+#include "sdmmc.h"
#include "../utils/types.h"
#include "../utils/list.h"
-#include "sdmmc.h"
-
-typedef struct _gpt_entry_t
-{
- u8 type_guid[0x10];
- u8 part_guid[0x10];
- u64 lba_start;
- u64 lba_end;
- u64 attrs;
- u16 name[36];
-} gpt_entry_t;
-
-typedef struct _gpt_header_t
-{
- u64 signature;
- u32 revision;
- u32 size;
- u32 crc32;
- u32 res1;
- u64 my_lba;
- u64 alt_lba;
- u64 first_use_lba;
- u64 last_use_lba;
- u8 disk_guid[0x10];
- u64 part_ent_lba;
- u32 num_part_ents;
- u32 part_ent_size;
- u32 part_ents_crc32;
- u8 res2[420];
-} gpt_header_t;
#define NX_GPT_FIRST_LBA 1
#define NX_GPT_NUM_BLOCKS 33
@@ -56,6 +27,7 @@ typedef struct _gpt_header_t
typedef struct _emmc_part_t
{
+ u32 index;
u32 lba_start;
u32 lba_end;
u64 attrs;
diff --git a/source/storage/nx_sd.c b/source/storage/nx_sd.c
new file mode 100644
index 0000000..0a791ad
--- /dev/null
+++ b/source/storage/nx_sd.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "nx_sd.h"
+#include "sdmmc.h"
+#include "sdmmc_driver.h"
+#include "../gfx/gfx.h"
+#include "../libs/fatfs/ff.h"
+#include "../mem/heap.h"
+
+static bool sd_mounted = false;
+static u32 sd_mode = SD_UHS_SDR82;
+
+
+sdmmc_t sd_sdmmc;
+sdmmc_storage_t sd_storage;
+FATFS sd_fs;
+
+u32 sd_get_mode()
+{
+ return sd_mode;
+}
+
+int sd_init_retry(bool power_cycle)
+{
+ u32 bus_width = SDMMC_BUS_WIDTH_4;
+ u32 type = SDHCI_TIMING_UHS_SDR82;
+
+ // Power cycle SD card.
+ if (power_cycle)
+ {
+ sd_mode--;
+ sdmmc_storage_end(&sd_storage);
+ }
+
+ // Get init parameters.
+ switch (sd_mode)
+ {
+ case SD_INIT_FAIL: // Reset to max.
+ return 0;
+ case SD_1BIT_HS25:
+ bus_width = SDMMC_BUS_WIDTH_1;
+ type = SDHCI_TIMING_SD_HS25;
+ break;
+ case SD_4BIT_HS25:
+ type = SDHCI_TIMING_SD_HS25;
+ break;
+ case SD_UHS_SDR82:
+ type = SDHCI_TIMING_UHS_SDR82;
+ break;
+ default:
+ sd_mode = SD_UHS_SDR82;
+ }
+
+ return sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, bus_width, type);
+}
+
+bool sd_initialize(bool power_cycle)
+{
+ if (power_cycle)
+ sdmmc_storage_end(&sd_storage);
+
+ int res = !sd_init_retry(false);
+
+ while (true)
+ {
+ if (!res)
+ return true;
+ else if (!sdmmc_get_sd_inserted()) // SD Card is not inserted.
+ {
+ sd_mode = SD_UHS_SDR82;
+ break;
+ }
+ else if (sd_mode == SD_INIT_FAIL)
+ break;
+ else
+ res = !sd_init_retry(true);
+ }
+
+ sdmmc_storage_end(&sd_storage);
+
+ return false;
+}
+
+bool sd_mount()
+{
+ if (sd_mounted)
+ return true;
+
+ int res = !sd_initialize(false);
+
+ if (res)
+ {
+ gfx_con.mute = false;
+ EPRINTF("Failed to init SD card.");
+ if (!sdmmc_get_sd_inserted())
+ EPRINTF("Make sure that it is inserted.");
+ else
+ EPRINTF("SD Card Reader is not properly seated!");
+ }
+ else
+ {
+ res = f_mount(&sd_fs, "", 1);
+ if (res == FR_OK)
+ {
+ sd_mounted = true;
+ return true;
+ }
+ else
+ {
+ gfx_con.mute = false;
+ EPRINTFARGS("Failed to mount SD card (FatFS Error %d).\nMake sure that a FAT partition exists..", res);
+ }
+ }
+
+ return false;
+}
+
+void sd_unmount()
+{
+ sd_mode = SD_UHS_SDR82;
+ if (sd_mounted)
+ {
+ f_mount(NULL, "", 1);
+ sdmmc_storage_end(&sd_storage);
+ sd_mounted = false;
+ }
+}
+
+void *sd_file_read(const char *path, u32 *fsize)
+{
+ FIL fp;
+ if (f_open(&fp, path, FA_READ) != FR_OK)
+ return NULL;
+
+ u32 size = f_size(&fp);
+ if (fsize)
+ *fsize = size;
+
+ void *buf = malloc(size);
+
+ if (f_read(&fp, buf, size, NULL) != FR_OK)
+ {
+ free(buf);
+ f_close(&fp);
+
+ return NULL;
+ }
+
+ f_close(&fp);
+
+ return buf;
+}
+
+int sd_save_to_file(void *buf, u32 size, const char *filename)
+{
+ FIL fp;
+ u32 res = 0;
+ res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
+ if (res)
+ {
+ EPRINTFARGS("Error (%d) creating file\n%s.\n", res, filename);
+ return res;
+ }
+
+ f_write(&fp, buf, size, NULL);
+ f_close(&fp);
+
+ return 0;
+}
diff --git a/source/storage/nx_sd.h b/source/storage/nx_sd.h
new file mode 100644
index 0000000..22e5f3b
--- /dev/null
+++ b/source/storage/nx_sd.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2019 CTCaer
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef NX_SD_H
+#define NX_SD_H
+
+#include "sdmmc.h"
+#include "sdmmc_driver.h"
+#include "../libs/fatfs/ff.h"
+
+enum
+{
+ SD_INIT_FAIL = 0,
+ SD_1BIT_HS25 = 1,
+ SD_4BIT_HS25 = 2,
+ SD_UHS_SDR82 = 3,
+};
+
+extern sdmmc_t sd_sdmmc;
+extern sdmmc_storage_t sd_storage;
+extern FATFS sd_fs;
+
+u32 sd_get_mode();
+int sd_init_retry(bool power_cycle);
+bool sd_initialize(bool power_cycle);
+bool sd_mount();
+void sd_unmount();
+void *sd_file_read(const char *path, u32 *fsize);
+int sd_save_to_file(void *buf, u32 size, const char *filename);
+
+#endif
\ No newline at end of file
diff --git a/source/storage/sd.h b/source/storage/sd.h
index fafd322..3ecfc07 100644
--- a/source/storage/sd.h
+++ b/source/storage/sd.h
@@ -106,6 +106,11 @@
#define SD_SET_CURRENT_LIMIT_600 2
#define SD_SET_CURRENT_LIMIT_800 3
+#define SD_MAX_CURRENT_200 (1 << SD_SET_CURRENT_LIMIT_200)
+#define SD_MAX_CURRENT_400 (1 << SD_SET_CURRENT_LIMIT_400)
+#define SD_MAX_CURRENT_600 (1 << SD_SET_CURRENT_LIMIT_600)
+#define SD_MAX_CURRENT_800 (1 << SD_SET_CURRENT_LIMIT_800)
+
/*
* SD_SWITCH mode
*/
diff --git a/source/storage/sdmmc.c b/source/storage/sdmmc.c
index d75e609..902d0ca 100644
--- a/source/storage/sdmmc.c
+++ b/source/storage/sdmmc.c
@@ -18,6 +18,7 @@
#include
#include "sdmmc.h"
#include "mmc.h"
+#include "nx_sd.h"
#include "sd.h"
#include "../../common/memory_map.h"
#include "../gfx/gfx.h"
@@ -135,10 +136,12 @@ static int _sdmmc_storage_check_status(sdmmc_storage_t *storage)
static int _sdmmc_storage_readwrite_ex(sdmmc_storage_t *storage, u32 *blkcnt_out, u32 sector, u32 num_sectors, void *buf, u32 is_write)
{
+ u32 tmp = 0;
sdmmc_cmd_t cmdbuf;
+ sdmmc_req_t reqbuf;
+
sdmmc_init_cmd(&cmdbuf, is_write ? MMC_WRITE_MULTIPLE_BLOCK : MMC_READ_MULTIPLE_BLOCK, sector, SDMMC_RSP_TYPE_1, 0);
- sdmmc_req_t reqbuf;
reqbuf.buf = buf;
reqbuf.num_sectors = num_sectors;
reqbuf.blksize = 512;
@@ -148,7 +151,6 @@ static int _sdmmc_storage_readwrite_ex(sdmmc_storage_t *storage, u32 *blkcnt_out
if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, blkcnt_out))
{
- u32 tmp = 0;
sdmmc_stop_transmission(storage->sdmmc, &tmp);
_sdmmc_storage_get_status(storage, &tmp, 0);
@@ -171,25 +173,42 @@ int sdmmc_storage_end(sdmmc_storage_t *storage)
static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf, u32 is_write)
{
u8 *bbuf = (u8 *)buf;
-
+ bool first_reinit = false;
while (num_sectors)
{
u32 blkcnt = 0;
- //Retry 9 times on error.
- u32 retries = 10;
+ // Retry 5 times if failed.
+ u32 retries = 5;
do
{
+reinit_try:
if (_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
goto out;
else
retries--;
- msleep(100);
+ msleep(50);
} while (retries);
+ // Disk IO failure! Reinit SD Card to a lower speed.
+ if (storage->sdmmc->id == SDMMC_1)
+ {
+ int res;
+ if (!first_reinit)
+ res = sd_initialize(true);
+ else
+ res = sd_init_retry(true);
+
+ retries = 3;
+ first_reinit = true;
+
+ if (res)
+ goto reinit_try;
+ }
+
return 0;
-out:;
+out:
DPRINTF("readwrite: %08X\n", blkcnt);
sector += blkcnt;
num_sectors -= blkcnt;
@@ -201,12 +220,34 @@ DPRINTF("readwrite: %08X\n", blkcnt);
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
{
- return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 0);
+ // Ensure that buffer resides in DRAM and it's DMA aligned.
+ if (((u32)buf >= DRAM_START) && !((u32)buf % 8))
+ return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 0);
+
+ if (num_sectors > (SDMMC_UP_BUF_SZ / 512))
+ return 0;
+
+ u8 *tmp_buf = (u8 *)SDMMC_UPPER_BUFFER;
+ if (_sdmmc_storage_readwrite(storage, sector, num_sectors, tmp_buf, 0))
+ {
+ memcpy(buf, tmp_buf, 512 * num_sectors);
+ return 1;
+ }
+ return 0;
}
int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
{
- return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 1);
+ // Ensure that buffer resides in DRAM and it's DMA aligned.
+ if (((u32)buf >= DRAM_START) && !((u32)buf % 8))
+ return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 1);
+
+ if (num_sectors > (SDMMC_UP_BUF_SZ / 512))
+ return 0;
+
+ u8 *tmp_buf = (u8 *)SDMMC_UPPER_BUFFER;
+ memcpy(tmp_buf, buf, 512 * num_sectors);
+ return _sdmmc_storage_readwrite(storage, sector, num_sectors, tmp_buf, 1);
}
/*
@@ -401,7 +442,7 @@ static int _mmc_storage_enable_HS(sdmmc_storage_t *storage, int check)
if (check && !_sdmmc_storage_check_status(storage))
return 0;
- if (!sdmmc_setup_clock(storage->sdmmc, 2))
+ if (!sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_MMC_HS52))
return 0;
DPRINTF("[MMC] switched to HS\n");
@@ -418,10 +459,10 @@ static int _mmc_storage_enable_HS200(sdmmc_storage_t *storage)
if (!_mmc_storage_switch(storage, SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS200)))
return 0;
- if (!sdmmc_setup_clock(storage->sdmmc, 3))
+ if (!sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_MMC_HS200))
return 0;
- if (!sdmmc_config_tuning(storage->sdmmc, 3, MMC_SEND_TUNING_BLOCK_HS200))
+ if (!sdmmc_tuning_execute(storage->sdmmc, SDHCI_TIMING_MMC_HS200, MMC_SEND_TUNING_BLOCK_HS200))
return 0;
DPRINTF("[MMC] switched to HS200\n");
@@ -435,7 +476,7 @@ static int _mmc_storage_enable_HS400(sdmmc_storage_t *storage)
if (!_mmc_storage_enable_HS200(storage))
return 0;
- sdmmc_get_venclkctl(storage->sdmmc);
+ sdmmc_set_tap_value(storage->sdmmc);
if (!_mmc_storage_enable_HS(storage, 0))
return 0;
@@ -446,7 +487,7 @@ static int _mmc_storage_enable_HS400(sdmmc_storage_t *storage)
if (!_mmc_storage_switch(storage, SDMMC_SWITCH(MMC_SWITCH_MODE_WRITE_BYTE, EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS400)))
return 0;
- if (!sdmmc_setup_clock(storage->sdmmc, 4))
+ if (!sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_MMC_HS400))
return 0;
DPRINTF("[MMC] switched to HS400\n");
@@ -457,22 +498,20 @@ DPRINTF("[MMC] switched to HS400\n");
static int _mmc_storage_enable_highspeed(sdmmc_storage_t *storage, u32 card_type, u32 type)
{
- //TODO: this should be a config item.
- // --v
- if (!1 || sdmmc_get_voltage(storage->sdmmc) != SDMMC_POWER_1_8)
+ if (sdmmc_get_io_power(storage->sdmmc) != SDMMC_POWER_1_8)
goto out;
if (sdmmc_get_bus_width(storage->sdmmc) == SDMMC_BUS_WIDTH_8 &&
- card_type & EXT_CSD_CARD_TYPE_HS400_1_8V && type == 4)
+ card_type & EXT_CSD_CARD_TYPE_HS400_1_8V && type == SDHCI_TIMING_MMC_HS400)
return _mmc_storage_enable_HS400(storage);
if (sdmmc_get_bus_width(storage->sdmmc) == SDMMC_BUS_WIDTH_8 ||
(sdmmc_get_bus_width(storage->sdmmc) == SDMMC_BUS_WIDTH_4
&& card_type & EXT_CSD_CARD_TYPE_HS200_1_8V
- && (type == 4 || type == 3)))
+ && (type == SDHCI_TIMING_MMC_HS400 || type == SDHCI_TIMING_MMC_HS200)))
return _mmc_storage_enable_HS200(storage);
-out:;
+out:
if (card_type & EXT_CSD_CARD_TYPE_HS_52)
return _mmc_storage_enable_HS(storage, 1);
@@ -487,13 +526,13 @@ static int _mmc_storage_enable_bkops(sdmmc_storage_t *storage)
return _sdmmc_storage_check_status(storage);
}
-int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type)
+int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 bus_width, u32 type)
{
memset(storage, 0, sizeof(sdmmc_storage_t));
storage->sdmmc = sdmmc;
storage->rca = 2; //TODO: this could be a config item.
- if (!sdmmc_init(sdmmc, id, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_1, 0, 0))
+ if (!sdmmc_init(sdmmc, SDMMC_4, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_MMC_ID, SDMMC_AUTO_CAL_DISABLE))
return 0;
DPRINTF("[MMC] after init\n");
@@ -520,7 +559,7 @@ DPRINTF("[MMC] set relative addr\n");
DPRINTF("[MMC] got csd\n");
_mmc_storage_parse_csd(storage);
- if (!sdmmc_setup_clock(storage->sdmmc, 1))
+ if (!sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_MMC_LS26))
return 0;
DPRINTF("[MMC] after setup clock\n");
@@ -544,35 +583,27 @@ DPRINTF("[MMC] set blocklen to 512\n");
return 0;
DPRINTF("[MMC] switched buswidth\n");
- u8 *ext_csd = (u8 *)malloc(512);
- if (!_mmc_storage_get_ext_csd(storage, ext_csd))
- {
- free(ext_csd);
+ if (!_mmc_storage_get_ext_csd(storage, (u8 *)SDMMC_UPPER_BUFFER))
return 0;
- }
- free(ext_csd);
DPRINTF("[MMC] got ext_csd\n");
+
_mmc_storage_parse_cid(storage); //This needs to be after csd and ext_csd
//gfx_hexdump(0, ext_csd, 512);
/* When auto BKOPS is enabled the mmc device should be powered all the time until we disable this and check status.
Disable it for now until BKOPS disable added to power down sequence at sdmmc_storage_end().
Additionally this works only when we put the device in idle mode which we don't after enabling it. */
- if (storage->ext_csd.bkops & 0x1 && !(storage->ext_csd.bkops_en & EXT_CSD_BKOPS_LEVEL_2) && 0)
+ if (0 && storage->ext_csd.bkops & 0x1 && !(storage->ext_csd.bkops_en & EXT_CSD_BKOPS_LEVEL_2))
{
_mmc_storage_enable_bkops(storage);
DPRINTF("[MMC] BKOPS enabled\n");
}
- else
- {
-DPRINTF("[MMC] BKOPS disabled\n");
- }
if (!_mmc_storage_enable_highspeed(storage, storage->ext_csd.card_type, type))
return 0;
DPRINTF("[MMC] succesfully switched to HS mode\n");
- sdmmc_sd_clock_ctrl(storage->sdmmc, 1);
+ sdmmc_card_clock_ctrl(storage->sdmmc, SDMMC_AUTO_CAL_ENABLE);
return 1;
}
@@ -656,6 +687,7 @@ static int _sd_storage_get_op_cond(sdmmc_storage_t *storage, int is_version_1, i
if (cond & SD_OCR_CCS)
storage->has_sector_access = 1;
+ // Check if card supports 1.8V signaling.
if (cond & SD_ROCR_S18A && supports_low_voltage)
{
//The low voltage regulator configuration is valid for SDMMC1 only.
@@ -804,34 +836,37 @@ int _sd_storage_switch(sdmmc_storage_t *storage, void *buf, int mode, int group,
return _sdmmc_storage_check_result(tmp);
}
-void _sd_storage_set_current_limit(sdmmc_storage_t *storage, u8 *buf)
+void _sd_storage_set_current_limit(sdmmc_storage_t *storage, u16 current_limit, u8 *buf)
{
- u32 pwr = SD_SET_CURRENT_LIMIT_800;
+ u32 pwr = SD_SET_CURRENT_LIMIT_200;
+
+ if (current_limit & SD_MAX_CURRENT_800)
+ pwr = SD_SET_CURRENT_LIMIT_800;
+ else if (current_limit & SD_MAX_CURRENT_600)
+ pwr = SD_SET_CURRENT_LIMIT_600;
+ else if (current_limit & SD_MAX_CURRENT_400)
+ pwr = SD_SET_CURRENT_LIMIT_400;
+
_sd_storage_switch(storage, buf, SD_SWITCH_SET, 3, pwr);
- while (pwr > 0)
+ if (((buf[15] >> 4) & 0x0F) == pwr)
{
- pwr--;
- _sd_storage_switch(storage, buf, SD_SWITCH_SET, 3, pwr);
- if (((buf[15] >> 4) & 0x0F) == pwr)
+ switch (pwr)
+ {
+ case SD_SET_CURRENT_LIMIT_800:
+DPRINTF("[SD] power limit raised to 800mA\n");
break;
- }
-
- switch (pwr)
- {
- case SD_SET_CURRENT_LIMIT_800:
-DPRINTF("[SD] power limit raised to 800mA\n");
- break;
- case SD_SET_CURRENT_LIMIT_600:
+ case SD_SET_CURRENT_LIMIT_600:
DPRINTF("[SD] power limit raised to 600mA\n");
- break;
- case SD_SET_CURRENT_LIMIT_400:
-DPRINTF("[SD] power limit raised to 800mA\n");
- break;
- default:
- case SD_SET_CURRENT_LIMIT_200:
+ break;
+ case SD_SET_CURRENT_LIMIT_400:
+DPRINTF("[SD] power limit raised to 400mA\n");
+ break;
+ default:
+ case SD_SET_CURRENT_LIMIT_200:
DPRINTF("[SD] power limit defaulted to 200mA\n");
- break;
+ break;
+ }
}
}
@@ -839,30 +874,33 @@ int _sd_storage_enable_highspeed(sdmmc_storage_t *storage, u32 hs_type, u8 *buf)
{
if (!_sd_storage_switch(storage, buf, SD_SWITCH_CHECK, 0, hs_type))
return 0;
-DPRINTF("[SD] SD supports switch to (U)HS check\n");
+DPRINTF("[SD] supports switch to (U)HS mode\n");
u32 type_out = buf[16] & 0xF;
if (type_out != hs_type)
return 0;
-DPRINTF("[SD] SD supports selected (U)HS mode\n");
+DPRINTF("[SD] supports selected (U)HS mode\n");
- if ((((u16)buf[0] << 8) | buf[1]) < 0x320)
+ u16 total_pwr_consumption = ((u16)buf[0] << 8) | buf[1];
+DPRINTF("[SD] total max current: %d\n", total_pwr_consumption);
+
+ if (total_pwr_consumption <= 800)
{
if (!_sd_storage_switch(storage, buf, SD_SWITCH_SET, 0, hs_type))
return 0;
if (type_out != (buf[16] & 0xF))
return 0;
- }
- return 1;
+ return 1;
+ }
+DPRINTF("[SD] card max current over limit\n");
+
+ return 0;
}
int _sd_storage_enable_uhs_low_volt(sdmmc_storage_t *storage, u32 type, u8 *buf)
{
- // Try to raise the current limit to let the card perform better.
- _sd_storage_set_current_limit(storage, buf);
-
if (sdmmc_get_bus_width(storage->sdmmc) != SDMMC_BUS_WIDTH_4)
return 0;
@@ -870,32 +908,55 @@ int _sd_storage_enable_uhs_low_volt(sdmmc_storage_t *storage, u32 type, u8 *buf)
return 0;
//gfx_hexdump(0, (u8 *)buf, 64);
+ u8 access_mode = buf[13];
+ u16 current_limit = buf[7] | buf[6] << 8;
+
+ // Try to raise the current limit to let the card perform better.
+ _sd_storage_set_current_limit(storage, current_limit, buf);
+
u32 hs_type = 0;
switch (type)
{
- case 11: // SDR104.
+ case SDHCI_TIMING_UHS_SDR104:
+ case SDHCI_TIMING_UHS_SDR82:
// Fall through if not supported.
- if (buf[13] & SD_MODE_UHS_SDR104)
+ if (access_mode & SD_MODE_UHS_SDR104)
{
- type = 11;
hs_type = UHS_SDR104_BUS_SPEED;
DPRINTF("[SD] bus speed set to SDR104\n");
- storage->csd.busspeed = 104;
+ switch (type)
+ {
+ case SDHCI_TIMING_UHS_SDR104:
+ storage->csd.busspeed = 104;
+ break;
+ case SDHCI_TIMING_UHS_SDR82:
+ storage->csd.busspeed = 82;
+ break;
+ }
break;
}
- case 10: // SDR50.
- if (buf[13] & SD_MODE_UHS_SDR50)
+ case SDHCI_TIMING_UHS_SDR50:
+ if (access_mode & SD_MODE_UHS_SDR50)
{
- type = 10;
+ type = SDHCI_TIMING_UHS_SDR50;
hs_type = UHS_SDR50_BUS_SPEED;
DPRINTF("[SD] bus speed set to SDR50\n");
storage->csd.busspeed = 50;
break;
}
- case 8: // SDR12.
- if (!(buf[13] & SD_MODE_UHS_SDR12))
+ case SDHCI_TIMING_UHS_SDR25:
+ if (access_mode & SD_MODE_UHS_SDR25)
+ {
+ type = SDHCI_TIMING_UHS_SDR25;
+ hs_type = UHS_SDR50_BUS_SPEED;
+DPRINTF("[SD] bus speed set to SDR25\n");
+ storage->csd.busspeed = 25;
+ break;
+ }
+ case SDHCI_TIMING_UHS_SDR12:
+ if (!(access_mode & SD_MODE_UHS_SDR12))
return 0;
- type = 8;
+ type = SDHCI_TIMING_UHS_SDR12;
hs_type = UHS_SDR12_BUS_SPEED;
DPRINTF("[SD] bus speed set to SDR12\n");
storage->csd.busspeed = 12;
@@ -907,11 +968,11 @@ DPRINTF("[SD] bus speed set to SDR12\n");
if (!_sd_storage_enable_highspeed(storage, hs_type, buf))
return 0;
-DPRINTF("[SD] SD card accepted UHS\n");
+DPRINTF("[SD] card accepted UHS\n");
if (!sdmmc_setup_clock(storage->sdmmc, type))
return 0;
DPRINTF("[SD] setup clock\n");
- if (!sdmmc_config_tuning(storage->sdmmc, type, MMC_SEND_TUNING_BLOCK))
+ if (!sdmmc_tuning_execute(storage->sdmmc, type, MMC_SEND_TUNING_BLOCK))
return 0;
DPRINTF("[SD] config tuning\n");
return _sdmmc_storage_check_status(storage);
@@ -922,16 +983,23 @@ int _sd_storage_enable_hs_high_volt(sdmmc_storage_t *storage, u8 *buf)
if (!_sd_storage_switch_get(storage, buf))
return 0;
//gfx_hexdump(0, (u8 *)buf, 64);
- if (!(buf[13] & SD_MODE_HIGH_SPEED))
+
+ u8 access_mode = buf[13];
+ u16 current_limit = buf[7] | buf[6] << 8;
+
+ // Try to raise the current limit to let the card perform better.
+ _sd_storage_set_current_limit(storage, current_limit, buf);
+
+ if (!(access_mode & SD_MODE_HIGH_SPEED))
return 1;
- if (!_sd_storage_enable_highspeed(storage, 1, buf))
+ if (!_sd_storage_enable_highspeed(storage, HIGH_SPEED_BUS_SPEED, buf))
return 0;
if (!_sdmmc_storage_check_status(storage))
return 0;
- return sdmmc_setup_clock(storage->sdmmc, 7);
+ return sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_SD_HS25);
}
static void _sd_storage_parse_ssr(sdmmc_storage_t *storage)
@@ -1055,6 +1123,23 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage)
}
}
+static bool _sdmmc_storage_supports_low_voltage(u32 bus_width, u32 type)
+{
+ switch (type)
+ {
+ case SDHCI_TIMING_UHS_SDR12:
+ case SDHCI_TIMING_UHS_SDR25:
+ case SDHCI_TIMING_UHS_SDR50:
+ case SDHCI_TIMING_UHS_SDR104:
+ case SDHCI_TIMING_UHS_SDR82:
+ case SDHCI_TIMING_UHS_DDR50:
+ if (bus_width == SDMMC_BUS_WIDTH_4)
+ return true;
+ default:
+ return false;
+ }
+}
+
void sdmmc_storage_init_wait_sd()
{
u32 sd_poweroff_time = (u32)get_tmr_ms() - sd_power_cycle_time_start;
@@ -1062,7 +1147,7 @@ void sdmmc_storage_init_wait_sd()
msleep(100 - sd_poweroff_time);
}
-int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type)
+int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 bus_width, u32 type)
{
int is_version_1 = 0;
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
@@ -1073,7 +1158,7 @@ int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32
memset(storage, 0, sizeof(sdmmc_storage_t));
storage->sdmmc = sdmmc;
- if (!sdmmc_init(sdmmc, id, SDMMC_POWER_3_3, SDMMC_BUS_WIDTH_1, 5, 0))
+ if (!sdmmc_init(sdmmc, SDMMC_1, SDMMC_POWER_3_3, SDMMC_BUS_WIDTH_1, SDHCI_TIMING_SD_ID, SDMMC_AUTO_CAL_DISABLE))
return 0;
DPRINTF("[SD] after init\n");
@@ -1088,7 +1173,9 @@ DPRINTF("[SD] went to idle state\n");
return 0;
DPRINTF("[SD] after send if cond\n");
- if (!_sd_storage_get_op_cond(storage, is_version_1, bus_width == SDMMC_BUS_WIDTH_4 && type == 11))
+ bool supports_low_voltage = _sdmmc_storage_supports_low_voltage(bus_width, type);
+
+ if (!_sd_storage_get_op_cond(storage, is_version_1, supports_low_voltage))
return 0;
DPRINTF("[SD] got op cond\n");
@@ -1122,7 +1209,7 @@ DPRINTF("[SD] unknown CSD structure %d\n", storage->csd.structure);
if (!storage->is_low_voltage)
{
- if (!sdmmc_setup_clock(storage->sdmmc, 6))
+ if (!sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_SD_DS12))
return 0;
DPRINTF("[SD] after setup clock\n");
}
@@ -1165,18 +1252,26 @@ DPRINTF("[SD] SD does not support wide bus width\n");
if (!_sd_storage_enable_uhs_low_volt(storage, type, buf))
return 0;
DPRINTF("[SD] enabled UHS\n");
+
+ sdmmc_card_clock_ctrl(sdmmc, SDMMC_AUTO_CAL_ENABLE);
}
- else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0)
+ else if (type != SDHCI_TIMING_SD_DS12 && (storage->scr.sda_vsn & 0xF) != 0)
{
if (!_sd_storage_enable_hs_high_volt(storage, buf))
return 0;
DPRINTF("[SD] enabled HS\n");
- storage->csd.busspeed = 25;
+ switch (bus_width)
+ {
+ case SDMMC_BUS_WIDTH_4:
+ storage->csd.busspeed = 25;
+ break;
+ case SDMMC_BUS_WIDTH_1:
+ storage->csd.busspeed = 6;
+ break;
+ }
}
- sdmmc_sd_clock_ctrl(sdmmc, 1);
-
// Parse additional card info from sd status.
if (_sd_storage_get_ssr(storage, buf))
{
@@ -1222,17 +1317,17 @@ int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
memset(storage, 0, sizeof(sdmmc_storage_t));
storage->sdmmc = sdmmc;
- if (!sdmmc_init(sdmmc, SDMMC_2, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_8, 14, 0))
+ if (!sdmmc_init(sdmmc, SDMMC_2, SDMMC_POWER_1_8, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_DDR52, SDMMC_AUTO_CAL_DISABLE))
return 0;
DPRINTF("[gc] after init\n");
usleep(1000 + (10000 + sdmmc->divisor - 1) / sdmmc->divisor);
- if (!sdmmc_config_tuning(storage->sdmmc, 14, MMC_SEND_TUNING_BLOCK_HS200))
+ if (!sdmmc_tuning_execute(storage->sdmmc, SDHCI_TIMING_MMC_DDR52, MMC_SEND_TUNING_BLOCK_HS200))
return 0;
DPRINTF("[gc] after tuning\n");
- sdmmc_sd_clock_ctrl(sdmmc, 1);
+ sdmmc_card_clock_ctrl(sdmmc, SDMMC_AUTO_CAL_ENABLE);
return 1;
}
diff --git a/source/storage/sdmmc.h b/source/storage/sdmmc.h
index c8b8f96..aacc26a 100644
--- a/source/storage/sdmmc.h
+++ b/source/storage/sdmmc.h
@@ -21,7 +21,17 @@
#include "../utils/types.h"
#include "sdmmc_driver.h"
-u32 sd_power_cycle_time_start;
+extern u32 sd_power_cycle_time_start;
+
+typedef enum _sdmmc_type
+{
+ MMC_SD = 0,
+ MMC_EMMC = 1,
+
+ EMMC_GPP = 0,
+ EMMC_BOOT0 = 1,
+ EMMC_BOOT1 = 2
+} sdmmc_type;
typedef struct _mmc_cid
{
@@ -107,10 +117,10 @@ typedef struct _sdmmc_storage_t
int sdmmc_storage_end(sdmmc_storage_t *storage);
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf);
int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf);
-int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type);
+int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 bus_width, u32 type);
int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition);
void sdmmc_storage_init_wait_sd();
-int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type);
+int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 bus_width, u32 type);
int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc);
#endif
diff --git a/source/storage/sdmmc_driver.c b/source/storage/sdmmc_driver.c
index 57d20f9..8e32f5d 100644
--- a/source/storage/sdmmc_driver.c
+++ b/source/storage/sdmmc_driver.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
- * Copyright (C) 2018 CTCaer
+ * Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -32,6 +32,8 @@
//#define DPRINTF(...) gfx_printf(__VA_ARGS__)
#define DPRINTF(...)
+u32 sd_power_cycle_time_start;
+
/*! SCMMC controller base addresses. */
static const u32 _sdmmc_bases[4] = {
0x700B0000,
@@ -40,44 +42,37 @@ static const u32 _sdmmc_bases[4] = {
0x700B0600,
};
-int sdmmc_get_voltage(sdmmc_t *sdmmc)
+int sdmmc_get_io_power(sdmmc_t *sdmmc)
{
u32 p = sdmmc->regs->pwrcon;
- if (!(p & TEGRA_MMC_PWRCTL_SD_BUS_POWER))
+ if (!(p & SDHCI_POWER_ON))
return SDMMC_POWER_OFF;
- if (p & TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8)
+ if (p & SDHCI_POWER_180)
return SDMMC_POWER_1_8;
- if (p & TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3)
+ if (p & SDHCI_POWER_330)
return SDMMC_POWER_3_3;
return -1;
}
-static int _sdmmc_set_voltage(sdmmc_t *sdmmc, u32 power)
+static int _sdmmc_set_io_power(sdmmc_t *sdmmc, u32 power)
{
- u8 pwr = 0;
-
switch (power)
{
case SDMMC_POWER_OFF:
- sdmmc->regs->pwrcon &= ~TEGRA_MMC_PWRCTL_SD_BUS_POWER;
+ sdmmc->regs->pwrcon &= ~SDHCI_POWER_ON;
break;
case SDMMC_POWER_1_8:
- sdmmc->regs->pwrcon = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8;
- pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8;
+ sdmmc->regs->pwrcon = SDHCI_POWER_180;
break;
case SDMMC_POWER_3_3:
- sdmmc->regs->pwrcon = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3;
- pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3;
+ sdmmc->regs->pwrcon = SDHCI_POWER_330;
break;
default:
return 0;
}
if (power != SDMMC_POWER_OFF)
- {
- pwr |= TEGRA_MMC_PWRCTL_SD_BUS_POWER;
- sdmmc->regs->pwrcon = pwr;
- }
+ sdmmc->regs->pwrcon |= SDHCI_POWER_ON;
return 1;
}
@@ -85,40 +80,44 @@ static int _sdmmc_set_voltage(sdmmc_t *sdmmc, u32 power)
u32 sdmmc_get_bus_width(sdmmc_t *sdmmc)
{
u32 h = sdmmc->regs->hostctl;
- if (h & TEGRA_MMC_HOSTCTL_8BIT)
+ if (h & SDHCI_CTRL_8BITBUS)
return SDMMC_BUS_WIDTH_8;
- if (h & TEGRA_MMC_HOSTCTL_4BIT)
+ if (h & SDHCI_CTRL_4BITBUS)
return SDMMC_BUS_WIDTH_4;
return SDMMC_BUS_WIDTH_1;
}
void sdmmc_set_bus_width(sdmmc_t *sdmmc, u32 bus_width)
{
+ u32 host_control = sdmmc->regs->hostctl & ~(SDHCI_CTRL_4BITBUS | SDHCI_CTRL_8BITBUS);
+
if (bus_width == SDMMC_BUS_WIDTH_1)
- sdmmc->regs->hostctl &= ~(TEGRA_MMC_HOSTCTL_4BIT | TEGRA_MMC_HOSTCTL_8BIT);
+ sdmmc->regs->hostctl = host_control;
else if (bus_width == SDMMC_BUS_WIDTH_4)
- {
- sdmmc->regs->hostctl |= TEGRA_MMC_HOSTCTL_4BIT;
- sdmmc->regs->hostctl &= ~TEGRA_MMC_HOSTCTL_8BIT;
- }
+ sdmmc->regs->hostctl = host_control | SDHCI_CTRL_4BITBUS;
else if (bus_width == SDMMC_BUS_WIDTH_8)
- sdmmc->regs->hostctl |= TEGRA_MMC_HOSTCTL_8BIT;
+ sdmmc->regs->hostctl = host_control | SDHCI_CTRL_8BITBUS;
}
-void sdmmc_get_venclkctl(sdmmc_t *sdmmc)
+void sdmmc_set_tap_value(sdmmc_t *sdmmc)
{
sdmmc->venclkctl_tap = sdmmc->regs->venclkctl >> 16;
sdmmc->venclkctl_set = 1;
}
-static int _sdmmc_config_ven_ceata_clk(sdmmc_t *sdmmc, u32 id)
+static int _sdmmc_config_tap_val(sdmmc_t *sdmmc, u32 type)
{
+ const u32 dqs_trim_val = 0x28;
+ const u32 tap_values[] = { 4, 0, 3, 0 };
+
u32 tap_val = 0;
- if (id == 4)
- sdmmc->regs->venceatactl = (sdmmc->regs->venceatactl & 0xFFFFC0FF) | 0x2800;
- sdmmc->regs->ventunctl0 &= 0xFFFDFFFF;
- if (id == 4)
+ if (type == SDHCI_TIMING_MMC_HS400)
+ sdmmc->regs->vencapover = (sdmmc->regs->vencapover & 0xFFFFC0FF) | (dqs_trim_val << 8);
+
+ sdmmc->regs->ventunctl0 &= ~TEGRA_MMC_VNDR_TUN_CTRL0_TAP_VAL_UPDATED_BY_HW;
+
+ if (type == SDHCI_TIMING_MMC_HS400)
{
if (!sdmmc->venclkctl_set)
return 0;
@@ -127,7 +126,6 @@ static int _sdmmc_config_ven_ceata_clk(sdmmc_t *sdmmc, u32 id)
}
else
{
- static const u32 tap_values[] = { 4, 0, 3, 0 };
tap_val = tap_values[sdmmc->id];
}
sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xFF00FFFF) | (tap_val << 16);
@@ -145,163 +143,250 @@ static void _sdmmc_pad_config_fallback(sdmmc_t *sdmmc, u32 power)
_sdmmc_get_clkcon(sdmmc);
switch (sdmmc->id)
{
- case SDMMC_1:
+ case SDMMC_1: // 33 Ohm 2X Driver.
if (power == SDMMC_POWER_OFF)
break;
+ u32 sdmmc1_pad_cfg = APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) & 0xF8080FFF;
if (power == SDMMC_POWER_1_8)
- APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = 0x304; // Up: 3, Dn: 4.
+ APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = sdmmc1_pad_cfg | (0xB0F << 12); // Up: 11, Dn: 15. For 33 ohm.
else if (power == SDMMC_POWER_3_3)
- APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = 0x808; // Up: 8, Dn: 8.
+ APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = sdmmc1_pad_cfg | (0xC0C << 12); // Up: 12, Dn: 12. For 33 ohm.
break;
- case SDMMC_4:
- APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0x3FFC) | 0x1040;
+ case SDMMC_2:
+ case SDMMC_4: // 50 Ohm 2X Driver. PU:16, PD:16.
+ APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0xFFFFC003) | 0x1040;
break;
}
- //TODO: load standard values for other controllers, can depend on power.
}
-static int _sdmmc_wait_type4(sdmmc_t *sdmmc)
+static void _sdmmc_autocal_execute(sdmmc_t *sdmmc, u32 power)
{
- int res = 1, should_disable_sd_clock = 0;
-
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
+ bool should_enable_sd_clock = false;
+ if (sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN)
{
- should_disable_sd_clock = 1;
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ should_enable_sd_clock = true;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
}
- sdmmc->regs->vendllcal |= 0x80000000;
- _sdmmc_get_clkcon(sdmmc);
+ // Enable E_INPUT power.
+ if (!(sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD))
+ {
+ sdmmc->regs->sdmemcmppadctl |= TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD;
+ _sdmmc_get_clkcon(sdmmc);
+ usleep(1);
+ }
- u32 timeout = get_tmr_ms() + 5;
- while (sdmmc->regs->vendllcal & 0x80000000)
+ // Enable auto calibration and start auto configuration.
+ sdmmc->regs->autocalcfg |= TEGRA_MMC_AUTOCALCFG_AUTO_CAL_ENABLE | TEGRA_MMC_AUTOCALCFG_AUTO_CAL_START;
+ _sdmmc_get_clkcon(sdmmc);
+ usleep(2);
+
+ u32 timeout = get_tmr_ms() + 10;
+ while (sdmmc->regs->autocalsts & TEGRA_MMC_AUTOCALSTS_AUTO_CAL_ACTIVE)
{
if (get_tmr_ms() > timeout)
{
- res = 0;
+ timeout = 0; // Set timeout to 0 if we timed out.
+ break;
+ }
+ }
+/*
+ // Check if PU results are inside limits.
+ // SDMMC1: CZ pads - 7-bit PU. SDMMC2/4: LV_CZ pads - 5-bit PU.
+ u8 autocal_pu_status = sdmmc->regs->autocalsts & 0x7F;
+ switch (sdmmc->id)
+ {
+ case SDMMC_1:
+ if (!autocal_pu_status || autocal_pu_status == 0x7F)
+ timeout = 0;
+ break;
+ case SDMMC_2:
+ case SDMMC_4:
+ autocal_pu_status &= 0x1F;
+ if (!autocal_pu_status || autocal_pu_status == 0x1F)
+ timeout = 0;
+ break;
+ }
+*/
+ // In case auto calibration fails, we load suggested standard values.
+ if (!timeout)
+ {
+ _sdmmc_pad_config_fallback(sdmmc, power);
+ sdmmc->regs->autocalcfg &= ~TEGRA_MMC_AUTOCALCFG_AUTO_CAL_ENABLE;
+ }
+
+ // Disable E_INPUT to conserve power.
+ sdmmc->regs->sdmemcmppadctl &= ~TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD;
+
+ if(should_enable_sd_clock)
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
+}
+
+static int _sdmmc_dll_cal_execute(sdmmc_t *sdmmc)
+{
+ int result = 1, should_disable_sd_clock = 0;
+
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
+ {
+ should_disable_sd_clock = 1;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
+ }
+
+ sdmmc->regs->vendllcalcfg |= TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE;
+ _sdmmc_get_clkcon(sdmmc);
+
+ u32 timeout = get_tmr_ms() + 5;
+ while (sdmmc->regs->vendllcalcfg & TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE)
+ {
+ if (get_tmr_ms() > timeout)
+ {
+ result = 0;
goto out;
}
}
timeout = get_tmr_ms() + 10;
- while (sdmmc->regs->dllcfgstatus & 0x80000000)
+ while (sdmmc->regs->vendllcalcfgsts & TEGRA_MMC_DLLCAL_CFG_STATUS_DLL_ACTIVE)
{
if (get_tmr_ms() > timeout)
{
- res = 0;
+ result = 0;
goto out;
}
}
out:;
if (should_disable_sd_clock)
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
- return res;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
+ return result;
+}
+
+static void _sdmmc_reset(sdmmc_t *sdmmc)
+{
+ sdmmc->regs->swrst |= SDHCI_RESET_CMD | SDHCI_RESET_DATA;
+ _sdmmc_get_clkcon(sdmmc);
+ u32 timeout = get_tmr_ms() + 2000;
+ while ((sdmmc->regs->swrst & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) && get_tmr_ms() < timeout)
+ ;
}
int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type)
{
// Disable the SD clock if it was enabled, and reenable it later.
bool should_enable_sd_clock = false;
- if (sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE)
+ if (sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN)
{
should_enable_sd_clock = true;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
}
- _sdmmc_config_ven_ceata_clk(sdmmc, type);
+ _sdmmc_config_tap_val(sdmmc, type);
+
+ _sdmmc_reset(sdmmc);
switch (type)
{
- case 0:
- case 1:
- case 5:
- case 6:
- sdmmc->regs->hostctl &= 0xFB; // Should this be 0xFFFB (~4) ?
- sdmmc->regs->hostctl2 &= SDHCI_CTRL_VDD_330;
+ case SDHCI_TIMING_MMC_ID:
+ case SDHCI_TIMING_MMC_LS26:
+ case SDHCI_TIMING_SD_ID:
+ case SDHCI_TIMING_SD_DS12:
+ sdmmc->regs->hostctl &= ~SDHCI_CTRL_HISPD;
+ sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
break;
- case 2:
- case 7:
- sdmmc->regs->hostctl |= 4;
- sdmmc->regs->hostctl2 &= SDHCI_CTRL_VDD_330;
+ case SDHCI_TIMING_MMC_HS52:
+ case SDHCI_TIMING_SD_HS25:
+ sdmmc->regs->hostctl |= SDHCI_CTRL_HISPD;
+ sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_VDD_180;
break;
- case 3:
- case 11:
- case 13:
- case 14:
+ case SDHCI_TIMING_MMC_HS200:
+ case SDHCI_TIMING_UHS_SDR50: // T210 Errata for SDR50, the host must be set to SDR104.
+ case SDHCI_TIMING_UHS_SDR104:
+ case SDHCI_TIMING_UHS_SDR82:
+ case SDHCI_TIMING_UHS_DDR50:
+ case SDHCI_TIMING_MMC_DDR52:
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR104_BUS_SPEED;
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
break;
- case 4:
+ case SDHCI_TIMING_MMC_HS400:
// Non standard.
sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | HS400_BUS_SPEED;
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
break;
- case 8:
- sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR12_BUS_SPEED;
+ case SDHCI_TIMING_UHS_SDR25:
+ sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR25_BUS_SPEED;
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
break;
- case 10:
- // T210 Errata for SDR50, the host must be set to SDR104.
- sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR104_BUS_SPEED;
+ case SDHCI_TIMING_UHS_SDR12:
+ sdmmc->regs->hostctl2 = (sdmmc->regs->hostctl2 & SDHCI_CTRL_UHS_MASK) | UHS_SDR12_BUS_SPEED;
sdmmc->regs->hostctl2 |= SDHCI_CTRL_VDD_180;
break;
}
_sdmmc_get_clkcon(sdmmc);
- u32 tmp;
+ u32 clock;
u16 divisor;
- clock_sdmmc_get_card_clock_div(&tmp, &divisor, type);
- clock_sdmmc_config_clock_source(&tmp, sdmmc->id, tmp);
- sdmmc->divisor = (tmp + divisor - 1) / divisor;
+ clock_sdmmc_get_card_clock_div(&clock, &divisor, type);
+ clock_sdmmc_config_clock_source(&clock, sdmmc->id, clock);
+ sdmmc->divisor = (clock + divisor - 1) / divisor;
//if divisor != 1 && divisor << 31 -> error
u16 div = divisor >> 1;
divisor = 0;
if (div > 0xFF)
- divisor = div >> 8;
- sdmmc->regs->clkcon = (sdmmc->regs->clkcon & 0x3F) | (div << 8) | (divisor << 6);
+ divisor = div >> SDHCI_DIVIDER_SHIFT;
+
+ sdmmc->regs->clkcon = (sdmmc->regs->clkcon & ~(SDHCI_DIV_MASK | SDHCI_DIV_HI_MASK))
+ | (div << SDHCI_DIVIDER_SHIFT) | (divisor << SDHCI_DIVIDER_HI_SHIFT);
// Enable the SD clock again.
if (should_enable_sd_clock)
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
- if (type == 4)
- return _sdmmc_wait_type4(sdmmc);
+ if (type == SDHCI_TIMING_MMC_HS400)
+ return _sdmmc_dll_cal_execute(sdmmc);
return 1;
}
-static void _sdmmc_sd_clock_enable(sdmmc_t *sdmmc)
+static void _sdmmc_card_clock_enable(sdmmc_t *sdmmc)
{
- if (!sdmmc->no_sd)
+ // Recalibrate conditionally.
+ if ((sdmmc->id == SDMMC_1) && !sdmmc->auto_cal_enabled)
+ _sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
+
+ if (!sdmmc->auto_cal_enabled)
{
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
}
- sdmmc->sd_clock_enabled = 1;
+ sdmmc->card_clock_enabled = 1;
}
static void _sdmmc_sd_clock_disable(sdmmc_t *sdmmc)
{
- sdmmc->sd_clock_enabled = 0;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->card_clock_enabled = 0;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
}
-void sdmmc_sd_clock_ctrl(sdmmc_t *sdmmc, int no_sd)
+void sdmmc_card_clock_ctrl(sdmmc_t *sdmmc, int auto_cal_enable)
{
- sdmmc->no_sd = no_sd;
- if (no_sd)
+ // Recalibrate periodically for SDMMC1.
+ if ((sdmmc->id == SDMMC_1) && !auto_cal_enable && sdmmc->card_clock_enabled)
+ _sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
+
+ sdmmc->auto_cal_enabled = auto_cal_enable;
+ if (auto_cal_enable)
{
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
return;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
return;
}
- if (sdmmc->sd_clock_enabled)
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+
+ if (sdmmc->card_clock_enabled)
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
}
static int _sdmmc_cache_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
@@ -383,22 +468,12 @@ int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type)
return 1;
}
-static void _sdmmc_reset(sdmmc_t *sdmmc)
-{
- sdmmc->regs->swrst |=
- TEGRA_MMC_SWRST_SW_RESET_FOR_CMD_LINE | TEGRA_MMC_SWRST_SW_RESET_FOR_DAT_LINE;
- _sdmmc_get_clkcon(sdmmc);
- u32 timeout = get_tmr_ms() + 2000;
- while (sdmmc->regs->swrst << 29 >> 30 && get_tmr_ms() < timeout)
- ;
-}
-
-static int _sdmmc_wait_prnsts_type0(sdmmc_t *sdmmc, u32 wait_dat)
+static int _sdmmc_wait_cmd_data_inhibit(sdmmc_t *sdmmc, bool wait_dat)
{
_sdmmc_get_clkcon(sdmmc);
u32 timeout = get_tmr_ms() + 2000;
- while(sdmmc->regs->prnsts & 1) // CMD inhibit.
+ while(sdmmc->regs->prnsts & SDHCI_CMD_INHIBIT)
if (get_tmr_ms() > timeout)
{
_sdmmc_reset(sdmmc);
@@ -408,7 +483,7 @@ static int _sdmmc_wait_prnsts_type0(sdmmc_t *sdmmc, u32 wait_dat)
if (wait_dat)
{
timeout = get_tmr_ms() + 2000;
- while (sdmmc->regs->prnsts & 2) // DAT inhibit.
+ while (sdmmc->regs->prnsts & SDHCI_DATA_INHIBIT)
if (get_tmr_ms() > timeout)
{
_sdmmc_reset(sdmmc);
@@ -419,12 +494,12 @@ static int _sdmmc_wait_prnsts_type0(sdmmc_t *sdmmc, u32 wait_dat)
return 1;
}
-static int _sdmmc_wait_prnsts_type1(sdmmc_t *sdmmc)
+static int _sdmmc_wait_card_busy(sdmmc_t *sdmmc)
{
_sdmmc_get_clkcon(sdmmc);
u32 timeout = get_tmr_ms() + 2000;
- while (!(sdmmc->regs->prnsts & 0x100000)) // DAT0 line level.
+ while (!(sdmmc->regs->prnsts & SDHCI_DATA_0_LVL_MASK))
if (get_tmr_ms() > timeout)
{
_sdmmc_reset(sdmmc);
@@ -442,21 +517,21 @@ static int _sdmmc_setup_read_small_block(sdmmc_t *sdmmc)
return 0;
break;
case SDMMC_BUS_WIDTH_4:
- sdmmc->regs->blksize = 0x40;
+ sdmmc->regs->blksize = 64;
break;
case SDMMC_BUS_WIDTH_8:
- sdmmc->regs->blksize = 0x80;
+ sdmmc->regs->blksize = 128;
break;
}
sdmmc->regs->blkcnt = 1;
- sdmmc->regs->trnmod = TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
+ sdmmc->regs->trnmod = SDHCI_TRNS_READ;
return 1;
}
-static int _sdmmc_parse_cmdbuf(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_present)
+static int _sdmmc_send_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_present)
{
u16 cmdflags = 0;
-
+
switch (cmd->rsp_type)
{
case SDMMC_RSP_TYPE_0:
@@ -465,20 +540,15 @@ static int _sdmmc_parse_cmdbuf(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_pr
case SDMMC_RSP_TYPE_4:
case SDMMC_RSP_TYPE_5:
if (cmd->check_busy)
- cmdflags = TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48_BUSY |
- TEGRA_MMC_TRNMOD_CMD_INDEX_CHECK |
- TEGRA_MMC_TRNMOD_CMD_CRC_CHECK;
+ cmdflags = SDHCI_CMD_RESP_LEN48_BUSY | SDHCI_CMD_INDEX | SDHCI_CMD_CRC;
else
- cmdflags = TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48 |
- TEGRA_MMC_TRNMOD_CMD_INDEX_CHECK |
- TEGRA_MMC_TRNMOD_CMD_CRC_CHECK;
+ cmdflags = SDHCI_CMD_RESP_LEN48 | SDHCI_CMD_INDEX | SDHCI_CMD_CRC;
break;
case SDMMC_RSP_TYPE_2:
- cmdflags = TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_136 |
- TEGRA_MMC_TRNMOD_CMD_CRC_CHECK;
+ cmdflags = SDHCI_CMD_RESP_LEN136 | SDHCI_CMD_CRC;
break;
case SDMMC_RSP_TYPE_3:
- cmdflags = TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48;
+ cmdflags = SDHCI_CMD_RESP_LEN48;
break;
default:
return 0;
@@ -486,52 +556,52 @@ static int _sdmmc_parse_cmdbuf(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, bool is_data_pr
}
if (is_data_present)
- cmdflags |= TEGRA_MMC_TRNMOD_DATA_PRESENT_SELECT_DATA_TRANSFER;
+ cmdflags |= SDHCI_CMD_DATA;
sdmmc->regs->argument = cmd->arg;
sdmmc->regs->cmdreg = (cmd->cmd << 8) | cmdflags;
return 1;
}
-static void _sdmmc_parse_cmd_48(sdmmc_t *sdmmc, u32 cmd)
+static void _sdmmc_send_tuning_cmd(sdmmc_t *sdmmc, u32 cmd)
{
sdmmc_cmd_t cmdbuf;
cmdbuf.cmd = cmd;
cmdbuf.arg = 0;
cmdbuf.rsp_type = SDMMC_RSP_TYPE_1;
cmdbuf.check_busy = 0;
- _sdmmc_parse_cmdbuf(sdmmc, &cmdbuf, true);
+ _sdmmc_send_cmd(sdmmc, &cmdbuf, true);
}
-static int _sdmmc_config_tuning_once(sdmmc_t *sdmmc, u32 cmd)
+static int _sdmmc_tuning_execute_once(sdmmc_t *sdmmc, u32 cmd)
{
- if (sdmmc->no_sd)
+ if (sdmmc->auto_cal_enabled)
return 0;
- if (!_sdmmc_wait_prnsts_type0(sdmmc, 1))
+ if (!_sdmmc_wait_cmd_data_inhibit(sdmmc, true))
return 0;
_sdmmc_setup_read_small_block(sdmmc);
- sdmmc->regs->norintstsen |= TEGRA_MMC_NORINTSTSEN_BUFFER_READ_READY;
+ sdmmc->regs->norintstsen |= SDHCI_INT_DATA_AVAIL;
sdmmc->regs->norintsts = sdmmc->regs->norintsts;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
- _sdmmc_parse_cmd_48(sdmmc, cmd);
+ _sdmmc_send_tuning_cmd(sdmmc, cmd);
_sdmmc_get_clkcon(sdmmc);
usleep(1);
_sdmmc_reset(sdmmc);
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
_sdmmc_get_clkcon(sdmmc);
u32 timeout = get_tmr_us() + 5000;
while (get_tmr_us() < timeout)
{
- if (sdmmc->regs->norintsts & 0x20)
+ if (sdmmc->regs->norintsts & SDHCI_INT_DATA_AVAIL)
{
- sdmmc->regs->norintsts = 0x20;
- sdmmc->regs->norintstsen &= 0xFFDF;
+ sdmmc->regs->norintsts = SDHCI_INT_DATA_AVAIL;
+ sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
_sdmmc_get_clkcon(sdmmc);
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
return 1;
@@ -540,44 +610,49 @@ static int _sdmmc_config_tuning_once(sdmmc_t *sdmmc, u32 cmd)
_sdmmc_reset(sdmmc);
- sdmmc->regs->norintstsen &= 0xFFDF;
+ sdmmc->regs->norintstsen &= ~SDHCI_INT_DATA_AVAIL;
_sdmmc_get_clkcon(sdmmc);
usleep((1000 * 8 + sdmmc->divisor - 1) / sdmmc->divisor);
return 0;
}
-int sdmmc_config_tuning(sdmmc_t *sdmmc, u32 type, u32 cmd)
+int sdmmc_tuning_execute(sdmmc_t *sdmmc, u32 type, u32 cmd)
{
u32 max = 0, flag = 0;
- sdmmc->regs->field_1C4 = 0;
switch (type)
{
- case 3:
- case 4:
- case 11:
- max = 0x80;
- flag = 0x4000;
+ case SDHCI_TIMING_MMC_HS200:
+ case SDHCI_TIMING_MMC_HS400:
+ case SDHCI_TIMING_UHS_SDR104:
+ case SDHCI_TIMING_UHS_SDR82:
+ max = 128;
+ flag = (2 << 13); // 128 iterations.
break;
- case 10:
- case 13:
- case 14:
- max = 0x100;
- flag = 0x8000;
+ case SDHCI_TIMING_UHS_SDR50:
+ case SDHCI_TIMING_UHS_DDR50:
+ case SDHCI_TIMING_MMC_DDR52:
+ max = 256;
+ flag = (4 << 13); // 256 iterations.
break;
+ case SDHCI_TIMING_UHS_SDR12:
+ case SDHCI_TIMING_UHS_SDR25:
+ return 1;
default:
return 0;
}
+ sdmmc->regs->ventunctl1 = 0; // step_size 1.
+
sdmmc->regs->ventunctl0 = (sdmmc->regs->ventunctl0 & 0xFFFF1FFF) | flag; // Tries.
- sdmmc->regs->ventunctl0 = (sdmmc->regs->ventunctl0 & 0xFFFFE03F) | 0x40; // Multiplier.
- sdmmc->regs->ventunctl0 |= 0x20000;
- sdmmc->regs->hostctl2 |= SDHCI_CTRL_EXEC_TUNING;
+ sdmmc->regs->ventunctl0 = (sdmmc->regs->ventunctl0 & 0xFFFFE03F) | (1 << 6); // 1x Multiplier.
+ sdmmc->regs->ventunctl0 |= TEGRA_MMC_VNDR_TUN_CTRL0_TAP_VAL_UPDATED_BY_HW;
+ sdmmc->regs->hostctl2 |= SDHCI_CTRL_EXEC_TUNING;
for (u32 i = 0; i < max; i++)
{
- _sdmmc_config_tuning_once(sdmmc, cmd);
+ _sdmmc_tuning_execute_once(sdmmc, cmd);
if (!(sdmmc->regs->hostctl2 & SDHCI_CTRL_EXEC_TUNING))
break;
}
@@ -591,24 +666,24 @@ int sdmmc_config_tuning(sdmmc_t *sdmmc, u32 type, u32 cmd)
static int _sdmmc_enable_internal_clock(sdmmc_t *sdmmc)
{
//Enable internal clock and wait till it is stable.
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_INTERNAL_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_INT_EN;
_sdmmc_get_clkcon(sdmmc);
u32 timeout = get_tmr_ms() + 2000;
- while (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_INTERNAL_CLOCK_STABLE))
+ while (!(sdmmc->regs->clkcon & SDHCI_CLOCK_INT_STABLE))
{
if (get_tmr_ms() > timeout)
return 0;
}
sdmmc->regs->hostctl2 &= ~SDHCI_CTRL_PRESET_VAL_EN;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_CLKGEN_SELECT;
+ sdmmc->regs->clkcon &= ~SDHCI_PROG_CLOCK_MODE;
sdmmc->regs->hostctl2 |= SDHCI_HOST_VERSION_4_EN;
- if (!(sdmmc->regs->capareg & 0x10000000))
+ if (!(sdmmc->regs->capareg & SDHCI_CAN_64BIT))
return 0;
sdmmc->regs->hostctl2 |= SDHCI_ADDRESSING_64BIT_EN;
- sdmmc->regs->hostctl &= 0xE7;
+ sdmmc->regs->hostctl &= ~SDHCI_CTRL_DMA_MASK;
sdmmc->regs->timeoutcon = (sdmmc->regs->timeoutcon & 0xF0) | 0xE;
return 1;
@@ -645,60 +720,22 @@ static int _sdmmc_autocal_config_offset(sdmmc_t *sdmmc, u32 power)
break;
}
- sdmmc->regs->autocalcfg = (((sdmmc->regs->autocalcfg & 0xFFFF80FF) | (off_pd << 8)) >> 7 << 7) | off_pu;
+ sdmmc->regs->autocalcfg = (sdmmc->regs->autocalcfg & 0xFFFF8080) | (off_pd << 8) | off_pu;
return 1;
}
-static void _sdmmc_autocal_execute(sdmmc_t *sdmmc, u32 power)
-{
- bool should_enable_sd_clock = false;
- if (sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE)
- {
- should_enable_sd_clock = true;
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
- }
-
- if (!(sdmmc->regs->sdmemcmppadctl & 0x80000000))
- {
- sdmmc->regs->sdmemcmppadctl |= 0x80000000;
- _sdmmc_get_clkcon(sdmmc);
- usleep(1);
- }
-
- sdmmc->regs->autocalcfg |= 0xA0000000;
- _sdmmc_get_clkcon(sdmmc);
- usleep(1);
-
- u32 timeout = get_tmr_ms() + 10;
- while (sdmmc->regs->autocalcfg & 0x80000000)
- {
- if (get_tmr_ms() > timeout)
- {
- // In case autocalibration fails, we load suggested standard values.
- _sdmmc_pad_config_fallback(sdmmc, power);
- sdmmc->regs->autocalcfg &= 0xDFFFFFFF;
- break;
- }
- }
-
- sdmmc->regs->sdmemcmppadctl &= 0x7FFFFFFF;
-
- if(should_enable_sd_clock)
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
-}
-
static void _sdmmc_enable_interrupts(sdmmc_t *sdmmc)
{
- sdmmc->regs->norintstsen |= 0xB;
- sdmmc->regs->errintstsen |= 0x17F;
+ sdmmc->regs->norintstsen |= SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE;
+ sdmmc->regs->errintstsen |= SDHCI_ERR_INT_ALL_EXCEPT_ADMA_BUSPWR;
sdmmc->regs->norintsts = sdmmc->regs->norintsts;
sdmmc->regs->errintsts = sdmmc->regs->errintsts;
}
static void _sdmmc_mask_interrupts(sdmmc_t *sdmmc)
{
- sdmmc->regs->errintstsen &= 0xFE80;
- sdmmc->regs->norintstsen &= 0xFFF4;
+ sdmmc->regs->errintstsen &= ~SDHCI_ERR_INT_ALL_EXCEPT_ADMA_BUSPWR;
+ sdmmc->regs->norintstsen &= ~(SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE);
}
static int _sdmmc_check_mask_interrupt(sdmmc_t *sdmmc, u16 *pout, u16 mask)
@@ -706,13 +743,13 @@ static int _sdmmc_check_mask_interrupt(sdmmc_t *sdmmc, u16 *pout, u16 mask)
u16 norintsts = sdmmc->regs->norintsts;
u16 errintsts = sdmmc->regs->errintsts;
- DPRINTF("norintsts %08X; errintsts %08X\n", norintsts, errintsts);
+DPRINTF("norintsts %08X; errintsts %08X\n", norintsts, errintsts);
if (pout)
*pout = norintsts;
// Check for error interrupt.
- if (norintsts & TEGRA_MMC_NORINTSTS_ERR_INTERRUPT)
+ if (norintsts & SDHCI_INT_ERROR)
{
sdmmc->regs->errintsts = errintsts;
return SDMMC_MASKINT_ERROR;
@@ -726,17 +763,17 @@ static int _sdmmc_check_mask_interrupt(sdmmc_t *sdmmc, u16 *pout, u16 mask)
return SDMMC_MASKINT_NOERROR;
}
-static int _sdmmc_wait_request(sdmmc_t *sdmmc)
+static int _sdmmc_wait_response(sdmmc_t *sdmmc)
{
_sdmmc_get_clkcon(sdmmc);
u32 timeout = get_tmr_ms() + 2000;
- while (1)
+ while (true)
{
- int res = _sdmmc_check_mask_interrupt(sdmmc, 0, TEGRA_MMC_NORINTSTS_CMD_COMPLETE);
- if (res == SDMMC_MASKINT_MASKED)
+ int result = _sdmmc_check_mask_interrupt(sdmmc, NULL, SDHCI_INT_RESPONSE);
+ if (result == SDMMC_MASKINT_MASKED)
break;
- if (res != SDMMC_MASKINT_NOERROR || get_tmr_ms() > timeout)
+ if (result != SDMMC_MASKINT_NOERROR || get_tmr_ms() > timeout)
{
_sdmmc_reset(sdmmc);
return 0;
@@ -750,7 +787,7 @@ static int _sdmmc_stop_transmission_inner(sdmmc_t *sdmmc, u32 *rsp)
{
sdmmc_cmd_t cmd;
- if (!_sdmmc_wait_prnsts_type0(sdmmc, 0))
+ if (!_sdmmc_wait_cmd_data_inhibit(sdmmc, false))
return 0;
_sdmmc_enable_interrupts(sdmmc);
@@ -760,40 +797,44 @@ static int _sdmmc_stop_transmission_inner(sdmmc_t *sdmmc, u32 *rsp)
cmd.rsp_type = SDMMC_RSP_TYPE_1;
cmd.check_busy = 1;
- _sdmmc_parse_cmdbuf(sdmmc, &cmd, false);
+ _sdmmc_send_cmd(sdmmc, &cmd, false);
- int res = _sdmmc_wait_request(sdmmc);
+ int result = _sdmmc_wait_response(sdmmc);
_sdmmc_mask_interrupts(sdmmc);
- if (!res)
+ if (!result)
return 0;
_sdmmc_cache_rsp(sdmmc, rsp, 4, SDMMC_RSP_TYPE_1);
- return _sdmmc_wait_prnsts_type1(sdmmc);
+ return _sdmmc_wait_card_busy(sdmmc);
}
int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp)
{
- if (!sdmmc->sd_clock_enabled)
+ if (!sdmmc->card_clock_enabled)
return 0;
+ // Recalibrate periodically for SDMMC1.
+ if ((sdmmc->id == SDMMC_1) && sdmmc->auto_cal_enabled)
+ _sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
+
bool should_disable_sd_clock = false;
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
{
should_disable_sd_clock = true;
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
_sdmmc_get_clkcon(sdmmc);
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
}
- int res = _sdmmc_stop_transmission_inner(sdmmc, rsp);
+ int result = _sdmmc_stop_transmission_inner(sdmmc, rsp);
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
if (should_disable_sd_clock)
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
- return res;
+ return result;
}
static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
@@ -807,7 +848,7 @@ static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
u32 admaaddr = (u32)req->buf;
// Check alignment.
- if (admaaddr << 29)
+ if (admaaddr & 7)
return 0;
sdmmc->regs->admaaddr = admaaddr;
@@ -815,22 +856,20 @@ static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
sdmmc->dma_addr_next = (admaaddr + 0x80000) & 0xFFF80000;
- sdmmc->regs->blksize = req->blksize | 0x7000;
+ sdmmc->regs->blksize = req->blksize | 0x7000; // DMA 512KB (Detects A18 carry out).
sdmmc->regs->blkcnt = blkcnt;
if (blkcnt_out)
*blkcnt_out = blkcnt;
- u32 trnmode = TEGRA_MMC_TRNMOD_DMA_ENABLE;
+ u32 trnmode = SDHCI_TRNS_DMA;
if (req->is_multi_block)
- trnmode = TEGRA_MMC_TRNMOD_MULTI_BLOCK_SELECT |
- TEGRA_MMC_TRNMOD_BLOCK_COUNT_ENABLE |
- TEGRA_MMC_TRNMOD_DMA_ENABLE;
+ trnmode = SDHCI_TRNS_MULTI | SDHCI_TRNS_BLK_CNT_EN | SDHCI_TRNS_DMA;
if (!req->is_write)
- trnmode |= TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ;
+ trnmode |= SDHCI_TRNS_READ;
if (req->is_auto_cmd12)
- trnmode = (trnmode & 0xFFF3) | TEGRA_MMC_TRNMOD_AUTO_CMD12;
- bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
+ trnmode = (trnmode & ~(SDHCI_TRNS_AUTO_CMD12 | SDHCI_TRNS_AUTO_CMD23)) | SDHCI_TRNS_AUTO_CMD12;
+
sdmmc->regs->trnmod = trnmode;
return 1;
@@ -845,20 +884,19 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
u32 timeout = get_tmr_ms() + 1500;
do
{
- int res = 0;
- while (1)
+ int result = 0;
+ while (true)
{
u16 intr = 0;
- res = _sdmmc_check_mask_interrupt(sdmmc, &intr,
- TEGRA_MMC_NORINTSTS_XFER_COMPLETE | TEGRA_MMC_NORINTSTS_DMA_INTERRUPT);
- if (res < 0)
+ result = _sdmmc_check_mask_interrupt(sdmmc, &intr,
+ SDHCI_INT_DATA_END | SDHCI_INT_DMA_END);
+ if (result < 0)
break;
- if (intr & TEGRA_MMC_NORINTSTS_XFER_COMPLETE)
- {
- bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
+
+ if (intr & SDHCI_INT_DATA_END)
return 1; // Transfer complete.
- }
- if (intr & TEGRA_MMC_NORINTSTS_DMA_INTERRUPT)
+
+ if (intr & SDHCI_INT_DMA_END)
{
// Update DMA.
sdmmc->regs->admaaddr = sdmmc->dma_addr_next;
@@ -866,8 +904,9 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
sdmmc->dma_addr_next += 0x80000;
}
}
- if (res != SDMMC_MASKINT_NOERROR)
+ if (result != SDMMC_MASKINT_NOERROR)
{
+ DPRINTF("%08X!\n", result);
_sdmmc_reset(sdmmc);
return 0;
}
@@ -881,45 +920,72 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out)
{
int has_req_or_check_busy = req || cmd->check_busy;
- if (!_sdmmc_wait_prnsts_type0(sdmmc, has_req_or_check_busy))
+ if (!_sdmmc_wait_cmd_data_inhibit(sdmmc, has_req_or_check_busy))
return 0;
u32 blkcnt = 0;
bool is_data_present = false;
if (req)
{
- _sdmmc_config_dma(sdmmc, &blkcnt, req);
- _sdmmc_enable_interrupts(sdmmc);
+ if (!_sdmmc_config_dma(sdmmc, &blkcnt, req))
+ {
+ DPRINTF("SDMMC: DMA Wrong cfg!\n");
+ return 0;
+ }
+
+ // Flush cache before starting the transfer.
+ bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
+
is_data_present = true;
}
else
- {
- _sdmmc_enable_interrupts(sdmmc);
is_data_present = false;
+
+ _sdmmc_enable_interrupts(sdmmc);
+
+ if (!_sdmmc_send_cmd(sdmmc, cmd, is_data_present))
+ {
+ DPRINTF("SDMMC: Wrong Response type %08X!\n", cmd->rsp_type);
+ return 0;
}
- _sdmmc_parse_cmdbuf(sdmmc, cmd, is_data_present);
-
- int res = _sdmmc_wait_request(sdmmc);
- DPRINTF("rsp(%d): %08X, %08X, %08X, %08X\n", res,
+ int result = _sdmmc_wait_response(sdmmc);
+ if (!result)
+ {
+ DPRINTF("SDMMC: Transfer timeout!\n");
+ }
+ DPRINTF("rsp(%d): %08X, %08X, %08X, %08X\n", result,
sdmmc->regs->rspreg0, sdmmc->regs->rspreg1, sdmmc->regs->rspreg2, sdmmc->regs->rspreg3);
- if (res)
+ if (result)
{
if (cmd->rsp_type)
{
sdmmc->expected_rsp_type = cmd->rsp_type;
- _sdmmc_cache_rsp(sdmmc, sdmmc->rsp, 0x10, cmd->rsp_type);
+ result = _sdmmc_cache_rsp(sdmmc, sdmmc->rsp, 0x10, cmd->rsp_type);
+ if (!result)
+ {
+ DPRINTF("SDMMC: Unknown response %08X!\n", sdmmc->rsp[0]);
+ }
+ }
+ if (req && result)
+ {
+ result = _sdmmc_update_dma(sdmmc);
+ if (!result)
+ {
+ DPRINTF("SDMMC: DMA Update failed!\n");
+ }
}
- if (req)
- _sdmmc_update_dma(sdmmc);
}
_sdmmc_mask_interrupts(sdmmc);
- if (res)
+ if (result)
{
if (req)
{
+ // Flush cache after transfer.
+ bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
+
if (blkcnt_out)
*blkcnt_out = blkcnt;
@@ -928,30 +994,42 @@ static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_
}
if (cmd->check_busy || req)
- return _sdmmc_wait_prnsts_type1(sdmmc);
+ {
+ result = _sdmmc_wait_card_busy(sdmmc);
+ if (!result)
+ {
+ DPRINTF("SDMMC: Busy timeout!\n");
+ }
+ return result;
+ }
}
- return res;
+ return result;
+}
+
+bool sdmmc_get_sd_inserted()
+{
+ return (!gpio_read(GPIO_PORT_Z, GPIO_PIN_1));
}
static int _sdmmc_config_sdmmc1()
{
// Configure SD card detect.
- PINMUX_AUX(PINMUX_AUX_GPIO_PZ1) = PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 1; //GPIO control, pull up.
+ PINMUX_AUX(PINMUX_AUX_GPIO_PZ1) = PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 2; // GPIO control, pull up.
APB_MISC(APB_MISC_GP_VGPIO_GPIO_MUX_SEL) = 0;
gpio_config(GPIO_PORT_Z, GPIO_PIN_1, GPIO_MODE_GPIO);
gpio_output_enable(GPIO_PORT_Z, GPIO_PIN_1, GPIO_OUTPUT_DISABLE);
usleep(100);
// Check if SD card is inserted.
- if(!!gpio_read(GPIO_PORT_Z, GPIO_PIN_1))
+ if(!sdmmc_get_sd_inserted())
return 0;
/*
* Pinmux config:
* DRV_TYPE = DRIVE_2X
- * E_SCHMT = ENABLE (for 1.8V), DISABLE (for 3.3V)
- * E_INPUT = ENABLE
+ * E_SCHMT = ENABLE (for 1.8V), DISABLE (for 3.3V)
+ * E_INPUT = ENABLE
* TRISTATE = PASSTHROUGH
* APB_MISC_GP_SDMMCx_CLK_LPBK_CONTROL = SDMMCx_CLK_PAD_E_LPBK for CLK
*/
@@ -966,47 +1044,78 @@ static int _sdmmc_config_sdmmc1()
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
// Make sure the SDMMC1 controller is powered.
- PMC(APBDEV_PMC_NO_IOPOWER) &= ~(1 << 12);
- // Assume 3.3V SD card voltage.
- PMC(APBDEV_PMC_PWR_DET_VAL) |= (1 << 12);
+ PMC(APBDEV_PMC_NO_IOPOWER) |= PMC_NO_IOPOWER_SDMMC1_IO_EN;
+ usleep(1000);
+ PMC(APBDEV_PMC_NO_IOPOWER) &= ~(PMC_NO_IOPOWER_SDMMC1_IO_EN);
+
+ // Inform IO pads that voltage is gonna be 3.3V.
+ PMC(APBDEV_PMC_PWR_DET_VAL) |= PMC_PWR_DET_SDMMC1_IO_EN;
// Set enable SD card power.
- PINMUX_AUX(PINMUX_AUX_DMIC3_CLK) = PINMUX_INPUT_ENABLE | PINMUX_PULL_DOWN | 1; //GPIO control, pull down.
+ PINMUX_AUX(PINMUX_AUX_DMIC3_CLK) = PINMUX_PULL_DOWN | 2; // Pull down.
gpio_config(GPIO_PORT_E, GPIO_PIN_4, GPIO_MODE_GPIO);
gpio_write(GPIO_PORT_E, GPIO_PIN_4, GPIO_HIGH);
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_ENABLE);
-
usleep(1000);
// Enable SD card power.
max77620_regulator_set_voltage(REGULATOR_LDO2, 3300000);
max77620_regulator_enable(REGULATOR_LDO2, 1);
-
usleep(1000);
- // For good measure.
- APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = 0x10000000;
-
+ // Set pad slew codes to get good quality clock.
+ APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) & 0xFFFFFFF) | 0x50000000;
usleep(1000);
return 1;
}
-int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int no_sd)
+static void _sdmmc_config_emmc(u32 id)
{
+ switch (id)
+ {
+ case SDMMC_2:
+ // Unset park for pads.
+ APB_MISC(APB_MISC_GP_EMMC2_PAD_CFGPADCTRL) &= 0xF8003FFF;
+ break;
+ case SDMMC_4:
+ // Unset park for pads.
+ APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) &= 0xF8003FFF;
+ // Set default pad cfg.
+ APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0xFFFFC003) | 0x1040;
+
+ // Enabled schmitt trigger.
+ APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) |= 1; // Enable Schmitt trigger.
+ break;
+ }
+}
+
+int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int auto_cal_enable)
+{
+ const u32 trim_values[] = { 2, 8, 3, 8 };
+
if (id > SDMMC_4)
return 0;
- if (id == SDMMC_1)
- if (!_sdmmc_config_sdmmc1())
- return 0;
-
memset(sdmmc, 0, sizeof(sdmmc_t));
sdmmc->regs = (t210_sdmmc_t *)_sdmmc_bases[id];
sdmmc->id = id;
sdmmc->clock_stopped = 1;
+ // Do specific SDMMC HW configuration.
+ switch (id)
+ {
+ case SDMMC_1:
+ if (!_sdmmc_config_sdmmc1())
+ return 0;
+ break;
+ case SDMMC_2:
+ case SDMMC_4:
+ _sdmmc_config_emmc(id);
+ break;
+ }
+
if (clock_sdmmc_is_not_reset_and_enabled(id))
{
_sdmmc_sd_clock_disable(sdmmc);
@@ -1021,11 +1130,12 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int n
sdmmc->clock_stopped = 0;
//TODO: make this skip-able.
- sdmmc->regs->iospare |= 0x80000;
- sdmmc->regs->veniotrimctl &= 0xFFFFFFFB;
- static const u32 trim_values[] = { 2, 8, 3, 8 };
- sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFF) | (trim_values[sdmmc->id] << 24);
- sdmmc->regs->sdmemcmppadctl = (sdmmc->regs->sdmemcmppadctl & 0xF) | 7;
+ sdmmc->regs->iospare |= 0x80000; // Enable muxing.
+ sdmmc->regs->veniotrimctl &= 0xFFFFFFFB; // Set Band Gap VREG to supply DLL.
+ sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFB) | (trim_values[sdmmc->id] << 24);
+ sdmmc->regs->sdmemcmppadctl =
+ (sdmmc->regs->sdmemcmppadctl & TEGRA_MMC_SDMEMCOMPPADCTRL_COMP_VREF_SEL_MASK) | 7;
+
if (!_sdmmc_autocal_config_offset(sdmmc, power))
return 0;
@@ -1034,12 +1144,12 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int n
if (_sdmmc_enable_internal_clock(sdmmc))
{
sdmmc_set_bus_width(sdmmc, bus_width);
- _sdmmc_set_voltage(sdmmc, power);
+ _sdmmc_set_io_power(sdmmc, power);
if (sdmmc_setup_clock(sdmmc, type))
{
- sdmmc_sd_clock_ctrl(sdmmc, no_sd);
- _sdmmc_sd_clock_enable(sdmmc);
+ sdmmc_card_clock_ctrl(sdmmc, auto_cal_enable);
+ _sdmmc_card_clock_enable(sdmmc);
_sdmmc_get_clkcon(sdmmc);
return 1;
@@ -1056,14 +1166,18 @@ void sdmmc_end(sdmmc_t *sdmmc)
{
_sdmmc_sd_clock_disable(sdmmc);
// Disable SDMMC power.
- _sdmmc_set_voltage(sdmmc, SDMMC_POWER_OFF);
+ _sdmmc_set_io_power(sdmmc, SDMMC_POWER_OFF);
// Disable SD card power.
if (sdmmc->id == SDMMC_1)
{
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_DISABLE);
max77620_regulator_enable(REGULATOR_LDO2, 0);
- sd_power_cycle_time_start = get_tmr_ms(); // Some sandisc U1 cards need 100ms for a power cycle.
+
+ // Inform IO pads that next voltage might be 3.3V.
+ PMC(APBDEV_PMC_PWR_DET_VAL) |= PMC_PWR_DET_SDMMC1_IO_EN;
+
+ sd_power_cycle_time_start = get_tmr_ms(); // Some SanDisk U1 cards need 100ms for a power cycle.
usleep(1000); // To power cycle, min 1ms without power is needed.
}
@@ -1083,29 +1197,29 @@ void sdmmc_init_cmd(sdmmc_cmd_t *cmdbuf, u16 cmd, u32 arg, u32 rsp_type, u32 che
int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out)
{
- if (!sdmmc->sd_clock_enabled)
+ if (!sdmmc->card_clock_enabled)
return 0;
// Recalibrate periodically for SDMMC1.
- if (sdmmc->id == SDMMC_1 && sdmmc->no_sd)
- _sdmmc_autocal_execute(sdmmc, sdmmc_get_voltage(sdmmc));
+ if (sdmmc->id == SDMMC_1 && sdmmc->auto_cal_enabled)
+ _sdmmc_autocal_execute(sdmmc, sdmmc_get_io_power(sdmmc));
int should_disable_sd_clock = 0;
- if (!(sdmmc->regs->clkcon & TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE))
+ if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN))
{
should_disable_sd_clock = 1;
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
_sdmmc_get_clkcon(sdmmc);
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
}
- int res = _sdmmc_execute_cmd_inner(sdmmc, cmd, req, blkcnt_out);
+ int result = _sdmmc_execute_cmd_inner(sdmmc, cmd, req, blkcnt_out);
usleep((8000 + sdmmc->divisor - 1) / sdmmc->divisor);
if (should_disable_sd_clock)
- sdmmc->regs->clkcon &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN;
- return res;
+ return result;
}
int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
@@ -1113,11 +1227,18 @@ int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
if(sdmmc->id != SDMMC_1)
return 0;
- if (!sdmmc_setup_clock(sdmmc, 8))
+ if (!sdmmc_setup_clock(sdmmc, SDHCI_TIMING_UHS_SDR12))
return 0;
_sdmmc_get_clkcon(sdmmc);
+ // Switch to 1.8V and wait for regulator to stabilize. Assume max possible wait needed.
+ max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000);
+ usleep(300);
+
+ // Inform IO pads that we switched to 1.8V.
+ PMC(APBDEV_PMC_PWR_DET_VAL) &= ~(PMC_PWR_DET_SDMMC1_IO_EN);
+
// Enable schmitt trigger for better duty cycle and low jitter clock.
PINMUX_AUX(PINMUX_AUX_SDMMC1_CLK) |= PINMUX_SCHMT;
PINMUX_AUX(PINMUX_AUX_SDMMC1_CMD) |= PINMUX_SCHMT;
@@ -1126,18 +1247,16 @@ int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT1) |= PINMUX_SCHMT;
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) |= PINMUX_SCHMT;
- max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000);
- PMC(APBDEV_PMC_PWR_DET_VAL) &= ~(1 << 12);
-
_sdmmc_autocal_config_offset(sdmmc, SDMMC_POWER_1_8);
_sdmmc_autocal_execute(sdmmc, SDMMC_POWER_1_8);
- _sdmmc_set_voltage(sdmmc, SDMMC_POWER_1_8);
+ _sdmmc_set_io_power(sdmmc, SDMMC_POWER_1_8);
_sdmmc_get_clkcon(sdmmc);
- msleep(5);
+ msleep(5); // Wait minimum 5ms before turning on the card clock.
+ // Turn on SDCLK.
if (sdmmc->regs->hostctl2 & SDHCI_CTRL_VDD_180)
{
- sdmmc->regs->clkcon |= TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+ sdmmc->regs->clkcon |= SDHCI_CLOCK_CARD_EN;
_sdmmc_get_clkcon(sdmmc);
usleep(1000);
if ((sdmmc->regs->prnsts & 0xF00000) == 0xF00000)
diff --git a/source/storage/sdmmc_driver.h b/source/storage/sdmmc_driver.h
index cf9b9e1..736faa8 100644
--- a/source/storage/sdmmc_driver.h
+++ b/source/storage/sdmmc_driver.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -49,24 +50,158 @@
#define SDMMC_MASKINT_NOERROR -1
#define SDMMC_MASKINT_ERROR -2
-/*! SDMMC host control 2 */
-#define SDHCI_CTRL_UHS_MASK 0xFFF8
-#define SDHCI_CTRL_VDD_330 0xFFF7
-#define SDHCI_CTRL_VDD_180 8
-#define SDHCI_CTRL_EXEC_TUNING 0x40
-#define SDHCI_CTRL_TUNED_CLK 0x80
-#define SDHCI_HOST_VERSION_4_EN 0x1000
-#define SDHCI_ADDRESSING_64BIT_EN 0x2000
-#define SDHCI_CTRL_PRESET_VAL_EN 0x8000
+/*! SDMMC present state. */
+#define SDHCI_CMD_INHIBIT 0x1
+#define SDHCI_DATA_INHIBIT 0x2
+#define SDHCI_DOING_WRITE 0x100
+#define SDHCI_DOING_READ 0x200
+#define SDHCI_SPACE_AVAILABLE 0x400
+#define SDHCI_DATA_AVAILABLE 0x800
+#define SDHCI_CARD_PRESENT 0x10000
+#define SDHCI_CD_STABLE 0x20000
+#define SDHCI_CD_LVL 0x40000
+#define SDHCI_WRITE_PROTECT 0x80000
+#define SDHCI_DATA_LVL_MASK 0xF00000
+#define SDHCI_DATA_0_LVL_MASK 0x100000
+#define SDHCI_CMD_LVL 0x1000000
+
+/*! SDMMC transfer mode. */
+#define SDHCI_TRNS_DMA 0x01
+#define SDHCI_TRNS_BLK_CNT_EN 0x02
+#define SDHCI_TRNS_AUTO_CMD12 0x04
+#define SDHCI_TRNS_AUTO_CMD23 0x08
+#define SDHCI_TRNS_AUTO_SEL 0x0C
+#define SDHCI_TRNS_WRITE 0x00
+#define SDHCI_TRNS_READ 0x10
+#define SDHCI_TRNS_MULTI 0x20
+
+/*! SDMMC command. */
+#define SDHCI_CMD_RESP_MASK 0x3
+#define SDHCI_CMD_RESP_NO_RESP 0x0
+#define SDHCI_CMD_RESP_LEN136 0x1
+#define SDHCI_CMD_RESP_LEN48 0x2
+#define SDHCI_CMD_RESP_LEN48_BUSY 0x3
+#define SDHCI_CMD_CRC 0x08
+#define SDHCI_CMD_INDEX 0x10
+#define SDHCI_CMD_DATA 0x20
+#define SDHCI_CMD_ABORTCMD 0xC0
+
+/*! SDMMC host control. */
+#define SDHCI_CTRL_LED 0x01
+#define SDHCI_CTRL_4BITBUS 0x02
+#define SDHCI_CTRL_HISPD 0x04
+#define SDHCI_CTRL_DMA_MASK 0x18
+#define SDHCI_CTRL_SDMA 0x00
+#define SDHCI_CTRL_ADMA1 0x08
+#define SDHCI_CTRL_ADMA32 0x10
+#define SDHCI_CTRL_ADMA64 0x18
+#define SDHCI_CTRL_8BITBUS 0x20
+#define SDHCI_CTRL_CDTEST_INS 0x40
+#define SDHCI_CTRL_CDTEST_EN 0x80
+
+/*! SDMMC host control 2. */
+#define SDHCI_CTRL_UHS_MASK 0xFFF8
+#define SDHCI_CTRL_VDD_180 8
+#define SDHCI_CTRL_DRV_TYPE_B 0x00
+#define SDHCI_CTRL_DRV_TYPE_A 0x10
+#define SDHCI_CTRL_DRV_TYPE_C 0x20
+#define SDHCI_CTRL_DRV_TYPE_D 0x30
+#define SDHCI_CTRL_EXEC_TUNING 0x40
+#define SDHCI_CTRL_TUNED_CLK 0x80
+#define SDHCI_HOST_VERSION_4_EN 0x1000
+#define SDHCI_ADDRESSING_64BIT_EN 0x2000
+#define SDHCI_CTRL_PRESET_VAL_EN 0x8000
+
+/*! SDMMC power control. */
+#define SDHCI_POWER_ON 0x01
+#define SDHCI_POWER_180 0x0A
+#define SDHCI_POWER_300 0x0C
+#define SDHCI_POWER_330 0x0E
+#define SDHCI_POWER_MASK 0xF1
+
+// /*! SDMMC max current. */
+// #define SDHCI_MAX_CURRENT_330_MASK 0xFF
+// #define SDHCI_MAX_CURRENT_180_MASK 0xFF0000
+// #define SDHCI_MAX_CURRENT_MULTIPLIER 4
+
+/*! SDMMC clock control. */
+#define SDHCI_DIVIDER_SHIFT 8
+#define SDHCI_DIVIDER_HI_SHIFT 6
+#define SDHCI_DIV_MASK 0xFF00
+#define SDHCI_DIV_HI_MASK 0xC0
+#define SDHCI_PROG_CLOCK_MODE 0x20
+#define SDHCI_CLOCK_CARD_EN 0x4
+#define SDHCI_CLOCK_INT_STABLE 0x2
+#define SDHCI_CLOCK_INT_EN 0x1
+
+/*! SDMMC software reset. */
+#define SDHCI_RESET_ALL 0x01
+#define SDHCI_RESET_CMD 0x02
+#define SDHCI_RESET_DATA 0x04
+
+/*! SDMMC interrupt status and control. */
+#define SDHCI_INT_RESPONSE 0x1
+#define SDHCI_INT_DATA_END 0x2
+#define SDHCI_INT_BLK_GAP 0x4
+#define SDHCI_INT_DMA_END 0x8
+#define SDHCI_INT_SPACE_AVAIL 0x10
+#define SDHCI_INT_DATA_AVAIL 0x20
+#define SDHCI_INT_CARD_INSERT 0x40
+#define SDHCI_INT_CARD_REMOVE 0x80
+#define SDHCI_INT_CARD_INT 0x100
+#define SDHCI_INT_RETUNE 0x1000
+#define SDHCI_INT_CQE 0x4000
+#define SDHCI_INT_ERROR 0x8000
+
+/*! SDMMC error interrupt status and control. */
+#define SDHCI_ERR_INT_TIMEOUT 0x1
+#define SDHCI_ERR_INT_CRC 0x2
+#define SDHCI_ERR_INT_END_BIT 0x4
+#define SDHCI_ERR_INT_INDEX 0x8
+#define SDHCI_ERR_INT_DATA_TIMEOUT 0x10
+#define SDHCI_ERR_INT_DATA_CRC 0x20
+#define SDHCI_ERR_INT_DATA_END_BIT 0x40
+#define SDHCI_ERR_INT_BUS_POWER 0x80
+#define SDHCI_ERR_INT_AUTO_CMD_ERR 0x100
+#define SDHCI_ERR_INT_ADMA_ERROR 0x200
+
+#define SDHCI_ERR_INT_ALL_EXCEPT_ADMA_BUSPWR \
+ (SDHCI_ERR_INT_AUTO_CMD_ERR | SDHCI_ERR_INT_DATA_END_BIT | \
+ SDHCI_ERR_INT_DATA_CRC | SDHCI_ERR_INT_DATA_TIMEOUT | \
+ SDHCI_ERR_INT_INDEX | SDHCI_ERR_INT_END_BIT | \
+ SDHCI_ERR_INT_CRC | SDHCI_ERR_INT_TIMEOUT)
/*! SD bus speeds. */
-#define UHS_SDR12_BUS_SPEED 0
-#define HIGH_SPEED_BUS_SPEED 1
-#define UHS_SDR25_BUS_SPEED 1
-#define UHS_SDR50_BUS_SPEED 2
-#define UHS_SDR104_BUS_SPEED 3
-#define UHS_DDR50_BUS_SPEED 4
-#define HS400_BUS_SPEED 5
+#define UHS_SDR12_BUS_SPEED 0
+#define HIGH_SPEED_BUS_SPEED 1
+#define UHS_SDR25_BUS_SPEED 1
+#define UHS_SDR50_BUS_SPEED 2
+#define UHS_SDR104_BUS_SPEED 3
+#define UHS_DDR50_BUS_SPEED 4
+#define HS400_BUS_SPEED 5
+
+/*! SDMMC timmings. */
+#define SDHCI_TIMING_MMC_ID 0
+#define SDHCI_TIMING_MMC_LS26 1
+#define SDHCI_TIMING_MMC_HS52 2
+#define SDHCI_TIMING_MMC_HS200 3
+#define SDHCI_TIMING_MMC_HS400 4
+#define SDHCI_TIMING_SD_ID 5
+#define SDHCI_TIMING_SD_DS12 6
+#define SDHCI_TIMING_SD_HS25 7
+#define SDHCI_TIMING_UHS_SDR12 8
+#define SDHCI_TIMING_UHS_SDR25 9
+#define SDHCI_TIMING_UHS_SDR50 10
+#define SDHCI_TIMING_UHS_SDR104 11
+#define SDHCI_TIMING_UHS_SDR82 12 // SDR104 with a 163.2MHz -> 81.6MHz clock.
+#define SDHCI_TIMING_UHS_DDR50 13
+#define SDHCI_TIMING_MMC_DDR52 14
+
+#define SDHCI_CAN_64BIT 0x10000000
+
+/*! SDMMC Low power features. */
+#define SDMMC_AUTO_CAL_DISABLE 0
+#define SDMMC_AUTO_CAL_ENABLE 1
/*! Helper for SWITCH command argument. */
#define SDMMC_SWITCH(mode, index, value) (((mode) << 24) | ((index) << 16) | ((value) << 8))
@@ -78,8 +213,8 @@ typedef struct _sdmmc_t
u32 id;
u32 divisor;
u32 clock_stopped;
- int no_sd;
- int sd_clock_enabled;
+ int auto_cal_enabled;
+ int card_clock_enabled;
int venclkctl_set;
u32 venclkctl_tap;
u32 expected_rsp_type;
@@ -108,19 +243,20 @@ typedef struct _sdmmc_req_t
int is_auto_cmd12;
} sdmmc_req_t;
-int sdmmc_get_voltage(sdmmc_t *sdmmc);
-u32 sdmmc_get_bus_width(sdmmc_t *sdmmc);
+int sdmmc_get_io_power(sdmmc_t *sdmmc);
+u32 sdmmc_get_bus_width(sdmmc_t *sdmmc);
void sdmmc_set_bus_width(sdmmc_t *sdmmc, u32 bus_width);
-void sdmmc_get_venclkctl(sdmmc_t *sdmmc);
-int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type);
-void sdmmc_sd_clock_ctrl(sdmmc_t *sdmmc, int no_sd);
-int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type);
-int sdmmc_config_tuning(sdmmc_t *sdmmc, u32 type, u32 cmd);
-int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp);
-int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int no_sd);
+void sdmmc_set_tap_value(sdmmc_t *sdmmc);
+int sdmmc_setup_clock(sdmmc_t *sdmmc, u32 type);
+void sdmmc_card_clock_ctrl(sdmmc_t *sdmmc, int auto_cal_enable);
+int sdmmc_get_rsp(sdmmc_t *sdmmc, u32 *rsp, u32 size, u32 type);
+int sdmmc_tuning_execute(sdmmc_t *sdmmc, u32 type, u32 cmd);
+int sdmmc_stop_transmission(sdmmc_t *sdmmc, u32 *rsp);
+bool sdmmc_get_sd_inserted();
+int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int auto_cal_enable);
void sdmmc_end(sdmmc_t *sdmmc);
void sdmmc_init_cmd(sdmmc_cmd_t *cmdbuf, u16 cmd, u32 arg, u32 rsp_type, u32 check_busy);
-int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out);
-int sdmmc_enable_low_voltage(sdmmc_t *sdmmc);
+int sdmmc_execute_cmd(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_t *req, u32 *blkcnt_out);
+int sdmmc_enable_low_voltage(sdmmc_t *sdmmc);
#endif
diff --git a/source/storage/sdmmc_t210.h b/source/storage/sdmmc_t210.h
index e11c3ff..eb17714 100644
--- a/source/storage/sdmmc_t210.h
+++ b/source/storage/sdmmc_t210.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 naehrwert
+ * Copyright (c) 2018-2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -19,49 +20,14 @@
#include "../utils/types.h"
-#define TEGRA_MMC_PWRCTL_SD_BUS_POWER 0x1
-#define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8 0xA
-#define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_0 0xC
-#define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3 0xE
-#define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_MASK 0xF1
-
-#define TEGRA_MMC_HOSTCTL_1BIT 0x00
-#define TEGRA_MMC_HOSTCTL_4BIT 0x02
-#define TEGRA_MMC_HOSTCTL_8BIT 0x20
-
-#define TEGRA_MMC_CLKCON_INTERNAL_CLOCK_ENABLE 0x1
-#define TEGRA_MMC_CLKCON_INTERNAL_CLOCK_STABLE 0x2
-#define TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE 0x4
-#define TEGRA_MMC_CLKCON_CLKGEN_SELECT 0x20
-
-#define TEGRA_MMC_SWRST_SW_RESET_FOR_ALL 0x1
-#define TEGRA_MMC_SWRST_SW_RESET_FOR_CMD_LINE 0x2
-#define TEGRA_MMC_SWRST_SW_RESET_FOR_DAT_LINE 0x4
-
-#define TEGRA_MMC_TRNMOD_DMA_ENABLE 0x1
-#define TEGRA_MMC_TRNMOD_BLOCK_COUNT_ENABLE 0x2
-#define TEGRA_MMC_TRNMOD_AUTO_CMD12 0x4
-#define TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_WRITE 0x0
-#define TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ 0x10
-#define TEGRA_MMC_TRNMOD_MULTI_BLOCK_SELECT 0x20
-
-#define TEGRA_MMC_TRNMOD_CMD_CRC_CHECK 0x8
-#define TEGRA_MMC_TRNMOD_CMD_INDEX_CHECK 0x10
-#define TEGRA_MMC_TRNMOD_DATA_PRESENT_SELECT_DATA_TRANSFER 0x20
-
-#define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_MASK 0x3
-#define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_NO_RESPONSE 0x0
-#define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_136 0x1
-#define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48 0x2
-#define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48_BUSY 0x3
-
-#define TEGRA_MMC_NORINTSTS_CMD_COMPLETE 0x1
-#define TEGRA_MMC_NORINTSTS_XFER_COMPLETE 0x2
-#define TEGRA_MMC_NORINTSTS_DMA_INTERRUPT 0x8
-#define TEGRA_MMC_NORINTSTS_ERR_INTERRUPT 0x8000
-#define TEGRA_MMC_NORINTSTS_CMD_TIMEOUT 0x10000
-
-#define TEGRA_MMC_NORINTSTSEN_BUFFER_READ_READY 0x20
+#define TEGRA_MMC_VNDR_TUN_CTRL0_TAP_VAL_UPDATED_BY_HW 0x20000
+#define TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE 0x80000000
+#define TEGRA_MMC_DLLCAL_CFG_STATUS_DLL_ACTIVE 0x80000000
+#define TEGRA_MMC_SDMEMCOMPPADCTRL_PAD_E_INPUT_PWRD 0x80000000
+#define TEGRA_MMC_SDMEMCOMPPADCTRL_COMP_VREF_SEL_MASK 0xFFFFFFF0
+#define TEGRA_MMC_AUTOCALCFG_AUTO_CAL_ENABLE 0x20000000
+#define TEGRA_MMC_AUTOCALCFG_AUTO_CAL_START 0x80000000
+#define TEGRA_MMC_AUTOCALSTS_AUTO_CAL_ACTIVE 0x80000000
typedef struct _t210_sdmmc_t
{
@@ -77,56 +43,66 @@ typedef struct _t210_sdmmc_t
vu32 rspreg3;
vu32 bdata;
vu32 prnsts;
- vu8 hostctl;
- vu8 pwrcon;
- vu8 blkgap;
- vu8 wakcon;
+ vu8 hostctl;
+ vu8 pwrcon;
+ vu8 blkgap;
+ vu8 wakcon;
vu16 clkcon;
- vu8 timeoutcon;
- vu8 swrst;
+ vu8 timeoutcon;
+ vu8 swrst;
vu16 norintsts;
vu16 errintsts;
- vu16 norintstsen;
- vu16 errintstsen;
- vu16 norintsigen;
- vu16 errintsigen;
+ vu16 norintstsen; // Enable irq status.
+ vu16 errintstsen; // Enable irq status.
+ vu16 norintsigen; // Enable irq signal to LIC/GIC.
+ vu16 errintsigen; // Enable irq signal to LIC/GIC.
vu16 acmd12errsts;
vu16 hostctl2;
vu32 capareg;
vu32 capareg_1;
vu32 maxcurr;
- vu8 res3[4];
+ vu8 rsvd0[4]; // 4C-4F reserved for more max current.
vu16 setacmd12err;
vu16 setinterr;
- vu8 admaerr;
- vu8 res4[3];
+ vu8 admaerr;
+ vu8 rsvd1[3]; // 55-57 reserved.
vu32 admaaddr;
vu32 admaaddr_hi;
- vu8 res5[156];
- vu16 slotintstatus;
+ vu8 rsvd2[156]; // 60-FB reserved.
+ vu16 slotintsts;
vu16 hcver;
vu32 venclkctl;
- vu32 venspictl;
- vu32 venspiintsts;
- vu32 venceatactl;
+ vu32 vensysswctl;
+ vu32 venerrintsts;
+ vu32 vencapover;
vu32 venbootctl;
vu32 venbootacktout;
vu32 venbootdattout;
vu32 vendebouncecnt;
vu32 venmiscctl;
- vu32 res6[34];
+ vu32 maxcurrover;
+ vu32 maxcurrover_hi;
+ vu32 unk0[32]; // 0x12C
vu32 veniotrimctl;
- vu32 vendllcal;
- vu8 res7[8];
- vu32 dllcfgstatus;
+ vu32 vendllcalcfg;
+ vu32 vendllctl0;
+ vu32 vendllctl1;
+ vu32 vendllcalcfgsts;
vu32 ventunctl0;
- vu32 field_1C4;
- vu8 field_1C8[24];
+ vu32 ventunctl1;
+ vu32 ventunsts0;
+ vu32 ventunsts1;
+ vu32 venclkgatehystcnt;
+ vu32 venpresetval0;
+ vu32 venpresetval1;
+ vu32 venpresetval2;
vu32 sdmemcmppadctl;
vu32 autocalcfg;
vu32 autocalintval;
vu32 autocalsts;
vu32 iospare;
+ vu32 mcciffifoctl;
+ vu32 timeoutwcoal;
} t210_sdmmc_t;
#endif
diff --git a/source/utils/types.h b/source/utils/types.h
index 544e059..7a7d847 100644
--- a/source/utils/types.h
+++ b/source/utils/types.h
@@ -27,20 +27,20 @@
#define OFFSET_OF(t, m) ((u32)&((t *)NULL)->m)
#define CONTAINER_OF(mp, t, mn) ((t *)((u32)mp - OFFSET_OF(t, mn)))
-#define KB_FIRMWARE_VERSION_100_200 0
-#define KB_FIRMWARE_VERSION_300 1
-#define KB_FIRMWARE_VERSION_301 2
-#define KB_FIRMWARE_VERSION_400 3
-#define KB_FIRMWARE_VERSION_500 4
-#define KB_FIRMWARE_VERSION_600 5
-#define KB_FIRMWARE_VERSION_620 6
-#define KB_FIRMWARE_VERSION_700 7
-#define KB_FIRMWARE_VERSION_810 8
-#define KB_FIRMWARE_VERSION_900 9
-#define KB_FIRMWARE_VERSION_910 10
-#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_910
+// #define KB_FIRMWARE_VERSION_100_200 0
+// #define KB_FIRMWARE_VERSION_300 1
+// #define KB_FIRMWARE_VERSION_301 2
+// #define KB_FIRMWARE_VERSION_400 3
+// #define KB_FIRMWARE_VERSION_500 4
+// #define KB_FIRMWARE_VERSION_600 5
+// #define KB_FIRMWARE_VERSION_620 6
+// #define KB_FIRMWARE_VERSION_700 7
+// #define KB_FIRMWARE_VERSION_810 8
+// #define KB_FIRMWARE_VERSION_900 9
+// #define KB_FIRMWARE_VERSION_910 10
+// #define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_910
-#define HOS_PKG11_MAGIC 0x31314B50
+// #define HOS_PKG11_MAGIC 0x31314B50
#define COLOR_RED 0xFFE70000
#define COLOR_ORANGE 0xFFFF8C00
diff --git a/source/utils/util.c b/source/utils/util.c
index cae1981..a6455fe 100644
--- a/source/utils/util.c
+++ b/source/utils/util.c
@@ -17,6 +17,7 @@
#include "util.h"
#include "../gfx/di.h"
+#include "../mem/heap.h"
#include "../mem/minerva.h"
#include "../power/max77620.h"
#include "../rtc/max77620-rtc.h"
@@ -24,13 +25,12 @@
#include "../soc/i2c.h"
#include "../soc/pmc.h"
#include "../soc/t210.h"
+#include "../storage/nx_sd.h"
#define USE_RTC_TIMER
extern volatile nyx_storage_t *nyx_str;
-extern void sd_unmount();
-
u32 get_tmr_s()
{
return RTC(APBDEV_RTC_SECONDS);
@@ -82,6 +82,43 @@ void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops)
base[ops[i].off] = ops[i].val;
}
+u32 crc32_calc(u32 crc, const u8 *buf, u32 len)
+{
+ const u8 *p, *q;
+ static u32 *table = NULL;
+
+ // Calculate CRC table.
+ if (!table)
+ {
+ table = calloc(256, sizeof(u32));
+ for (u32 i = 0; i < 256; i++)
+ {
+ u32 rem = i;
+ for (u32 j = 0; j < 8; j++)
+ {
+ if (rem & 1)
+ {
+ rem >>= 1;
+ rem ^= 0xedb88320;
+ }
+ else
+ rem >>= 1;
+ }
+ table[i] = rem;
+ }
+ }
+
+ crc = ~crc;
+ q = buf + len;
+ for (p = buf; p < q; p++)
+ {
+ u8 oct = *p;
+ crc = (crc >> 8) ^ table[(crc & 0xff) ^ oct];
+ }
+
+ return ~crc;
+}
+
void panic(u32 val)
{
// Set panic code.
@@ -117,7 +154,7 @@ void reboot_rcm()
nyx_str->mtc_cfg.init_done = 0;
- PMC(APBDEV_PMC_SCRATCH0) = 2; // Reboot into rcm.
+ PMC(APBDEV_PMC_SCRATCH0) = PMC_SCRATCH0_MODE_RCM;
PMC(APBDEV_PMC_CNTRL) |= PMC_CNTRL_MAIN_RST;
while (true)
@@ -128,6 +165,8 @@ void power_off()
{
sd_unmount();
display_end();
+
+ nyx_str->mtc_cfg.init_done = 0;
// Stop the alarm, in case we injected and powered off too fast.
max77620_rtc_stop_alarm();
diff --git a/source/utils/util.h b/source/utils/util.h
index 9ee1a74..d918194 100644
--- a/source/utils/util.h
+++ b/source/utils/util.h
@@ -21,8 +21,19 @@
#include "types.h"
#include "../mem/minerva.h"
-#define NYX_CFG_DUMP (1 << 7)
-#define NYX_CFG_MINERVA (1 << 8)
+typedef enum
+{
+ NYX_CFG_UMS = (1 << 6),
+ NYX_CFG_DUMP = (1 << 7),
+} nyx_cfg_t;
+
+typedef enum
+{
+ ERR_LIBSYS_LP0 = (1 << 0),
+ ERR_SYSOLD_NYX = (1 << 1),
+ ERR_SYSOLD_MTC = (1 << 2),
+ ERR_EXCEPT_ENB = (1 << 31),
+} hekate_errors_t;
#define byte_swap_32(num) (((num >> 24) & 0xff) | ((num << 8) & 0xff0000) | \
((num >> 8 )& 0xff00) | ((num << 24) & 0xff000000))
@@ -35,7 +46,7 @@ typedef struct _cfg_op_t
typedef struct _nyx_info_t
{
- u32 rsvd;
+ u32 disp_id;
u32 errors;
} nyx_info_t;
@@ -61,5 +72,6 @@ void reboot_normal();
void reboot_rcm();
void power_off();
void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops);
+u32 crc32_calc(u32 crc, const u8 *buf, u32 len);
#endif