From 53c684a17af834d91cb0265e31ba3736a11dbe61 Mon Sep 17 00:00:00 2001 From: hexkyz Date: Fri, 4 Dec 2020 16:29:30 +0000 Subject: [PATCH] fusee/sept: delegate SoC selection to individual components and keep common code SoC-agnostic --- .../fusee-primary/fusee-primary-main/src/di.c | 30 ++++++++++++-- .../fusee-primary/fusee-primary-main/src/di.h | 6 +-- .../fusee-primary-main/src/hwinit.c | 25 ++++++++--- .../fusee-primary-main/src/hwinit.h | 3 +- .../fusee-primary-main/src/main.c | 18 ++------ .../fusee-primary-main/src/panic.c | 12 +----- .../fusee-primary-main/src/sdram.c | 41 ++++++++++++++++--- .../fusee-primary-main/src/sdram.h | 9 ++-- .../fusee-primary-main/src/utils.c | 6 +-- fusee/fusee-secondary/src/console.c | 12 +----- fusee/fusee-secondary/src/di.c | 30 ++++++++++++-- fusee/fusee-secondary/src/di.h | 6 +-- fusee/fusee-secondary/src/panic.c | 6 +-- sept/sept-secondary/src/di.c | 30 ++++++++++++-- sept/sept-secondary/src/di.h | 6 +-- sept/sept-secondary/src/hwinit.c | 25 ++++++++--- sept/sept-secondary/src/hwinit.h | 3 +- sept/sept-secondary/src/main.c | 6 +-- sept/sept-secondary/src/sdram.c | 41 ++++++++++++++++--- sept/sept-secondary/src/sdram.h | 9 ++-- 20 files changed, 212 insertions(+), 112 deletions(-) diff --git a/fusee/fusee-primary/fusee-primary-main/src/di.c b/fusee/fusee-primary/fusee-primary-main/src/di.c index 902b06f03..dc7ec11df 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/di.c +++ b/fusee/fusee-primary/fusee-primary-main/src/di.c @@ -19,6 +19,7 @@ #include #include "di.h" +#include "fuse.h" #include "timers.h" #include "i2c.h" #include "pmc.h" @@ -32,6 +33,11 @@ static uint32_t g_lcd_vendor = 0; +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void do_dsi_sleep_or_register_writes(const dsi_sleep_or_register_write_t *writes, uint32_t num_writes) { for (uint32_t i = 0; i < num_writes; i++) { if (writes[i].kind == 1) { @@ -56,7 +62,7 @@ static void dsi_wait(uint32_t timeout, uint32_t offset, uint32_t mask, uint32_t udelay(delay); } -void display_init_erista(void) { +static void display_init_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -206,7 +212,7 @@ void display_init_erista(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_init_mariko(void) { +static void display_init_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -366,7 +372,7 @@ void display_init_mariko(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_end_erista(void) { +static void display_end_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -448,7 +454,7 @@ void display_end_erista(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } -void display_end_mariko(void) { +static void display_end_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -530,6 +536,22 @@ void display_end_mariko(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } +void display_init(void) { + if (is_soc_mariko()) { + display_init_mariko(); + } else { + display_init_erista(); + } +} + +void display_end(void) { + if (is_soc_mariko()) { + display_end_mariko(); + } else { + display_end_erista(); + } +} + void display_backlight(bool enable) { /* Enable Backlight PWM. */ gpio_write(GPIO_LCD_BL_PWM, enable ? GPIO_LEVEL_HIGH : GPIO_LEVEL_LOW); diff --git a/fusee/fusee-primary/fusee-primary-main/src/di.h b/fusee/fusee-primary/fusee-primary-main/src/di.h index 6f525fbe2..672698a69 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/di.h +++ b/fusee/fusee-primary/fusee-primary-main/src/di.h @@ -382,10 +382,8 @@ #define MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2 0x70 #define MIPI_CAL_DSID_MIPI_CAL_CONFIG_2 0x74 -void display_init_erista(void); -void display_init_mariko(void); -void display_end_erista(void); -void display_end_mariko(void); +void display_init(void); +void display_end(void); /* Switches screen backlight ON/OFF. */ void display_backlight(bool enable); diff --git a/fusee/fusee-primary/fusee-primary-main/src/hwinit.c b/fusee/fusee-primary/fusee-primary-main/src/hwinit.c index 3f922fb77..70671afc4 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/hwinit.c +++ b/fusee/fusee-primary/fusee-primary-main/src/hwinit.c @@ -34,6 +34,11 @@ #include "timers.h" #include "uart.h" +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void config_oscillators(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -209,7 +214,7 @@ static void config_se_brom(void) { pmc->rst_status = 0; } -void nx_hwinit_erista(bool enable_log) { +static void nx_hwinit_erista(bool enable_log) { volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_car_t *car = car_get_regs(); @@ -320,13 +325,13 @@ void nx_hwinit_erista(bool enable_log) { /* mc_config_carveout(); */ /* Save SDRAM parameters to scratch. */ - sdram_save_params_erista(sdram_get_params_erista(fuse_get_dram_id())); + sdram_save_params(sdram_get_params(fuse_get_dram_id())); /* Initialize SDRAM. */ - sdram_init_erista(); + sdram_init(); } -void nx_hwinit_mariko(bool enable_log) { +static void nx_hwinit_mariko(bool enable_log) { volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_car_t *car = car_get_regs(); @@ -397,8 +402,16 @@ void nx_hwinit_mariko(bool enable_log) { pmc->tzram_sec_disable = 0x3; /* Save SDRAM parameters to scratch. */ - sdram_save_params_mariko(sdram_get_params_mariko(fuse_get_dram_id())); + sdram_save_params(sdram_get_params(fuse_get_dram_id())); /* Initialize SDRAM. */ - sdram_init_mariko(); + sdram_init(); +} + +void nx_hwinit(bool enable_log) { + if (is_soc_mariko()) { + nx_hwinit_mariko(enable_log); + } else { + nx_hwinit_erista(enable_log); + } } \ No newline at end of file diff --git a/fusee/fusee-primary/fusee-primary-main/src/hwinit.h b/fusee/fusee-primary/fusee-primary-main/src/hwinit.h index 7388813cd..b01a34c0b 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/hwinit.h +++ b/fusee/fusee-primary/fusee-primary-main/src/hwinit.h @@ -24,7 +24,6 @@ #define I2S_BASE 0x702D1000 #define MAKE_I2S_REG(n) MAKE_REG32(I2S_BASE + n) -void nx_hwinit_erista(bool enable_log); -void nx_hwinit_mariko(bool enable_log); +void nx_hwinit(bool enable_log); #endif diff --git a/fusee/fusee-primary/fusee-primary-main/src/main.c b/fusee/fusee-primary/fusee-primary-main/src/main.c index 388943b92..88914bda4 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/main.c +++ b/fusee/fusee-primary/fusee-primary-main/src/main.c @@ -99,11 +99,7 @@ static void setup_display(void) { video_init(g_framebuffer); /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Set the framebuffer. */ display_init_framebuffer(g_framebuffer); @@ -118,20 +114,12 @@ static void cleanup_display(void) { display_backlight(false); /* Terminate the display. */ - if (fuse_get_soc_type() == 1) { - display_end_mariko(); - } else { - display_end_erista(); - } + display_end(); } static void setup_env(void) { /* Initialize hardware. */ - if (fuse_get_soc_type() == 1) { - nx_hwinit_mariko(false); - } else { - nx_hwinit_erista(false); - } + nx_hwinit(false); /* Set up the exception handlers. */ setup_exception_handlers(); diff --git a/fusee/fusee-primary/fusee-primary-main/src/panic.c b/fusee/fusee-primary/fusee-primary-main/src/panic.c index b51415499..a25ee8521 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/panic.c +++ b/fusee/fusee-primary/fusee-primary-main/src/panic.c @@ -125,11 +125,7 @@ static void _check_and_display_atmosphere_fatal_error(void) { video_init((void *)0xC0000000); /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Set the framebuffer. */ display_init_framebuffer((void *)0xC0000000); @@ -225,11 +221,7 @@ void check_and_display_panic(void) { } /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Fill the screen. */ display_color_screen(color); diff --git a/fusee/fusee-primary/fusee-primary-main/src/sdram.c b/fusee/fusee-primary/fusee-primary-main/src/sdram.c index 00c1b632d..9fd7201bd 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/sdram.c +++ b/fusee/fusee-primary/fusee-primary-main/src/sdram.c @@ -35,6 +35,11 @@ #include "sdram.inl" #endif +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void sdram_config_erista(const sdram_params_erista_t *params) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -1050,7 +1055,7 @@ static void sdram_config_mariko(const sdram_params_mariko_t *params) { AHB_ARBITRATION_XBAR_CTRL_0 = ((AHB_ARBITRATION_XBAR_CTRL_0 & 0xFFFEFFFF) | ((params->AhbArbitrationXbarCtrlMemInitDone & 0xFFFF) << 16)); } -const void *sdram_get_params_erista(uint32_t dram_id) { +static const void *sdram_get_params_erista(uint32_t dram_id) { uint32_t sdram_params_index = sdram_params_index_table_erista[dram_id]; #ifdef CONFIG_SDRAM_COMPRESS uint8_t *buf = (uint8_t *)0x40030000; @@ -1061,7 +1066,7 @@ const void *sdram_get_params_erista(uint32_t dram_id) { #endif } -const void *sdram_get_params_mariko(uint32_t dram_id) { +static const void *sdram_get_params_mariko(uint32_t dram_id) { uint32_t sdram_params_index = sdram_params_index_table_mariko[dram_id]; #ifdef CONFIG_SDRAM_COMPRESS uint8_t *buf = (uint8_t *)0x40030000; @@ -1072,7 +1077,7 @@ const void *sdram_get_params_mariko(uint32_t dram_id) { #endif } -void sdram_init_erista(void) { +static void sdram_init_erista(void) { volatile tegra_pmc_t *pmc = pmc_get_regs(); const sdram_params_erista_t *params = (const sdram_params_erista_t *)sdram_get_params_erista(fuse_get_dram_id()); @@ -1096,7 +1101,7 @@ void sdram_init_erista(void) { sdram_config_erista(params); } -void sdram_init_mariko(void) { +static void sdram_init_mariko(void) { volatile tegra_pmc_t *pmc = pmc_get_regs(); const sdram_params_mariko_t *params = (const sdram_params_mariko_t *)sdram_get_params_mariko(fuse_get_dram_id()); @@ -1117,7 +1122,7 @@ void sdram_init_mariko(void) { sdram_config_mariko(params); } -void sdram_save_params_erista(const void *save_params) { +static void sdram_save_params_erista(const void *save_params) { const sdram_params_erista_t *params = (const sdram_params_erista_t *)save_params; volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -2218,7 +2223,7 @@ void sdram_save_params_erista(const void *save_params) { s(PllMStableTime, 9:0, scratch4, 9:0); } -void sdram_save_params_mariko(const void *save_params) { +static void sdram_save_params_mariko(const void *save_params) { const sdram_params_mariko_t *params = (const sdram_params_mariko_t *)save_params; volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -3333,4 +3338,28 @@ void sdram_save_params_mariko(const void *save_params) { c32(0, scratch4); s(PllMStableTime, 19:0, scratch4, 19:0); +} + +void sdram_init(void) { + if (is_soc_mariko()) { + sdram_init_mariko(); + } else { + sdram_init_erista(); + } +} + +const void *sdram_get_params(uint32_t dram_id) { + if (is_soc_mariko()) { + return sdram_get_params_mariko(dram_id); + } else { + return sdram_get_params_erista(dram_id); + } +} + +void sdram_save_params(const void *save_params) { + if (is_soc_mariko()) { + sdram_save_params_mariko(save_params); + } else { + sdram_save_params_erista(save_params); + } } \ No newline at end of file diff --git a/fusee/fusee-primary/fusee-primary-main/src/sdram.h b/fusee/fusee-primary/fusee-primary-main/src/sdram.h index 5e81ac279..38f725579 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/sdram.h +++ b/fusee/fusee-primary/fusee-primary-main/src/sdram.h @@ -18,11 +18,8 @@ #ifndef FUSEE_SDRAM_H_ #define FUSEE_SDRAM_H_ -void sdram_init_erista(void); -void sdram_init_mariko(void); -const void *sdram_get_params_erista(uint32_t dram_id); -const void *sdram_get_params_mariko(uint32_t dram_id); -void sdram_save_params_erista(const void *save_params); -void sdram_save_params_mariko(const void *save_params); +void sdram_init(void); +const void *sdram_get_params(uint32_t dram_id); +void sdram_save_params(const void *save_params); #endif diff --git a/fusee/fusee-primary/fusee-primary-main/src/utils.c b/fusee/fusee-primary/fusee-primary-main/src/utils.c index 77f8da91d..96eb0591b 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/utils.c +++ b/fusee/fusee-primary/fusee-primary-main/src/utils.c @@ -130,11 +130,7 @@ __attribute__((noreturn)) void fatal_error(const char *fmt, ...) { video_init((void *)0xC0000000); /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Set the framebuffer. */ display_init_framebuffer((void *)0xC0000000); diff --git a/fusee/fusee-secondary/src/console.c b/fusee/fusee-secondary/src/console.c index c389cdf22..b3d8f0d18 100644 --- a/fusee/fusee-secondary/src/console.c +++ b/fusee/fusee-secondary/src/console.c @@ -98,11 +98,7 @@ static ssize_t decode_utf8(uint32_t *out, const uint8_t *in) { static void console_init_display(void) { /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Set the framebuffer. */ display_init_framebuffer(g_framebuffer); @@ -202,11 +198,7 @@ int console_end(void) { display_backlight(false); /* Terminate the display. */ - if (fuse_get_soc_type() == 1) { - display_end_mariko(); - } else { - display_end_erista(); - } + display_end(); /* Display is terminated. */ g_display_initialized = false; diff --git a/fusee/fusee-secondary/src/di.c b/fusee/fusee-secondary/src/di.c index 902b06f03..dc7ec11df 100644 --- a/fusee/fusee-secondary/src/di.c +++ b/fusee/fusee-secondary/src/di.c @@ -19,6 +19,7 @@ #include #include "di.h" +#include "fuse.h" #include "timers.h" #include "i2c.h" #include "pmc.h" @@ -32,6 +33,11 @@ static uint32_t g_lcd_vendor = 0; +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void do_dsi_sleep_or_register_writes(const dsi_sleep_or_register_write_t *writes, uint32_t num_writes) { for (uint32_t i = 0; i < num_writes; i++) { if (writes[i].kind == 1) { @@ -56,7 +62,7 @@ static void dsi_wait(uint32_t timeout, uint32_t offset, uint32_t mask, uint32_t udelay(delay); } -void display_init_erista(void) { +static void display_init_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -206,7 +212,7 @@ void display_init_erista(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_init_mariko(void) { +static void display_init_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -366,7 +372,7 @@ void display_init_mariko(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_end_erista(void) { +static void display_end_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -448,7 +454,7 @@ void display_end_erista(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } -void display_end_mariko(void) { +static void display_end_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -530,6 +536,22 @@ void display_end_mariko(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } +void display_init(void) { + if (is_soc_mariko()) { + display_init_mariko(); + } else { + display_init_erista(); + } +} + +void display_end(void) { + if (is_soc_mariko()) { + display_end_mariko(); + } else { + display_end_erista(); + } +} + void display_backlight(bool enable) { /* Enable Backlight PWM. */ gpio_write(GPIO_LCD_BL_PWM, enable ? GPIO_LEVEL_HIGH : GPIO_LEVEL_LOW); diff --git a/fusee/fusee-secondary/src/di.h b/fusee/fusee-secondary/src/di.h index 6f525fbe2..672698a69 100644 --- a/fusee/fusee-secondary/src/di.h +++ b/fusee/fusee-secondary/src/di.h @@ -382,10 +382,8 @@ #define MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2 0x70 #define MIPI_CAL_DSID_MIPI_CAL_CONFIG_2 0x74 -void display_init_erista(void); -void display_init_mariko(void); -void display_end_erista(void); -void display_end_mariko(void); +void display_init(void); +void display_end(void); /* Switches screen backlight ON/OFF. */ void display_backlight(bool enable); diff --git a/fusee/fusee-secondary/src/panic.c b/fusee/fusee-secondary/src/panic.c index d1432f4b9..37c0a5a8e 100644 --- a/fusee/fusee-secondary/src/panic.c +++ b/fusee/fusee-secondary/src/panic.c @@ -70,11 +70,7 @@ void check_and_display_panic(void) { } /* Initialize the display. */ - if (fuse_get_soc_type() == 1) { - display_init_mariko(); - } else { - display_init_erista(); - } + display_init(); /* Fill the screen. */ display_color_screen(color); diff --git a/sept/sept-secondary/src/di.c b/sept/sept-secondary/src/di.c index 902b06f03..dc7ec11df 100644 --- a/sept/sept-secondary/src/di.c +++ b/sept/sept-secondary/src/di.c @@ -19,6 +19,7 @@ #include #include "di.h" +#include "fuse.h" #include "timers.h" #include "i2c.h" #include "pmc.h" @@ -32,6 +33,11 @@ static uint32_t g_lcd_vendor = 0; +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void do_dsi_sleep_or_register_writes(const dsi_sleep_or_register_write_t *writes, uint32_t num_writes) { for (uint32_t i = 0; i < num_writes; i++) { if (writes[i].kind == 1) { @@ -56,7 +62,7 @@ static void dsi_wait(uint32_t timeout, uint32_t offset, uint32_t mask, uint32_t udelay(delay); } -void display_init_erista(void) { +static void display_init_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -206,7 +212,7 @@ void display_init_erista(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_init_mariko(void) { +static void display_init_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -366,7 +372,7 @@ void display_init_mariko(void) { do_register_writes(DI_BASE, display_config_dc_02, 113); } -void display_end_erista(void) { +static void display_end_erista(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -448,7 +454,7 @@ void display_end_erista(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } -void display_end_mariko(void) { +static void display_end_mariko(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pinmux_t *pinmux = pinmux_get_regs(); @@ -530,6 +536,22 @@ void display_end_mariko(void) { pinmux->lcd_bl_pwm = (((pinmux->lcd_bl_pwm >> 2) << 2) | 1); } +void display_init(void) { + if (is_soc_mariko()) { + display_init_mariko(); + } else { + display_init_erista(); + } +} + +void display_end(void) { + if (is_soc_mariko()) { + display_end_mariko(); + } else { + display_end_erista(); + } +} + void display_backlight(bool enable) { /* Enable Backlight PWM. */ gpio_write(GPIO_LCD_BL_PWM, enable ? GPIO_LEVEL_HIGH : GPIO_LEVEL_LOW); diff --git a/sept/sept-secondary/src/di.h b/sept/sept-secondary/src/di.h index 6f525fbe2..672698a69 100644 --- a/sept/sept-secondary/src/di.h +++ b/sept/sept-secondary/src/di.h @@ -382,10 +382,8 @@ #define MIPI_CAL_DSIC_MIPI_CAL_CONFIG_2 0x70 #define MIPI_CAL_DSID_MIPI_CAL_CONFIG_2 0x74 -void display_init_erista(void); -void display_init_mariko(void); -void display_end_erista(void); -void display_end_mariko(void); +void display_init(void); +void display_end(void); /* Switches screen backlight ON/OFF. */ void display_backlight(bool enable); diff --git a/sept/sept-secondary/src/hwinit.c b/sept/sept-secondary/src/hwinit.c index 3f922fb77..70671afc4 100644 --- a/sept/sept-secondary/src/hwinit.c +++ b/sept/sept-secondary/src/hwinit.c @@ -34,6 +34,11 @@ #include "timers.h" #include "uart.h" +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void config_oscillators(void) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -209,7 +214,7 @@ static void config_se_brom(void) { pmc->rst_status = 0; } -void nx_hwinit_erista(bool enable_log) { +static void nx_hwinit_erista(bool enable_log) { volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_car_t *car = car_get_regs(); @@ -320,13 +325,13 @@ void nx_hwinit_erista(bool enable_log) { /* mc_config_carveout(); */ /* Save SDRAM parameters to scratch. */ - sdram_save_params_erista(sdram_get_params_erista(fuse_get_dram_id())); + sdram_save_params(sdram_get_params(fuse_get_dram_id())); /* Initialize SDRAM. */ - sdram_init_erista(); + sdram_init(); } -void nx_hwinit_mariko(bool enable_log) { +static void nx_hwinit_mariko(bool enable_log) { volatile tegra_pmc_t *pmc = pmc_get_regs(); volatile tegra_car_t *car = car_get_regs(); @@ -397,8 +402,16 @@ void nx_hwinit_mariko(bool enable_log) { pmc->tzram_sec_disable = 0x3; /* Save SDRAM parameters to scratch. */ - sdram_save_params_mariko(sdram_get_params_mariko(fuse_get_dram_id())); + sdram_save_params(sdram_get_params(fuse_get_dram_id())); /* Initialize SDRAM. */ - sdram_init_mariko(); + sdram_init(); +} + +void nx_hwinit(bool enable_log) { + if (is_soc_mariko()) { + nx_hwinit_mariko(enable_log); + } else { + nx_hwinit_erista(enable_log); + } } \ No newline at end of file diff --git a/sept/sept-secondary/src/hwinit.h b/sept/sept-secondary/src/hwinit.h index 7388813cd..b01a34c0b 100644 --- a/sept/sept-secondary/src/hwinit.h +++ b/sept/sept-secondary/src/hwinit.h @@ -24,7 +24,6 @@ #define I2S_BASE 0x702D1000 #define MAKE_I2S_REG(n) MAKE_REG32(I2S_BASE + n) -void nx_hwinit_erista(bool enable_log); -void nx_hwinit_mariko(bool enable_log); +void nx_hwinit(bool enable_log); #endif diff --git a/sept/sept-secondary/src/main.c b/sept/sept-secondary/src/main.c index 2381ca541..14896b0f9 100644 --- a/sept/sept-secondary/src/main.c +++ b/sept/sept-secondary/src/main.c @@ -108,13 +108,13 @@ static void setup_env(void) { g_framebuffer = (void *)0xC0000000; /* Initialize hardware. */ - nx_hwinit_erista(false); + nx_hwinit(false); /* Zero-fill the framebuffer and register it as printk provider. */ video_init(g_framebuffer); /* Initialize the display. */ - display_init_erista(); + display_init(); /* Set the framebuffer. */ display_init_framebuffer(g_framebuffer); @@ -131,7 +131,7 @@ static void cleanup_env(void) { unmount_sd(); /* Terminate the display. */ - display_end_erista(); + display_end(); } static void exit_callback(int rc) { diff --git a/sept/sept-secondary/src/sdram.c b/sept/sept-secondary/src/sdram.c index 00c1b632d..9fd7201bd 100644 --- a/sept/sept-secondary/src/sdram.c +++ b/sept/sept-secondary/src/sdram.c @@ -35,6 +35,11 @@ #include "sdram.inl" #endif +/* Determine the current SoC for Mariko specific code. */ +static bool is_soc_mariko() { + return (fuse_get_soc_type() == 1); +} + static void sdram_config_erista(const sdram_params_erista_t *params) { volatile tegra_car_t *car = car_get_regs(); volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -1050,7 +1055,7 @@ static void sdram_config_mariko(const sdram_params_mariko_t *params) { AHB_ARBITRATION_XBAR_CTRL_0 = ((AHB_ARBITRATION_XBAR_CTRL_0 & 0xFFFEFFFF) | ((params->AhbArbitrationXbarCtrlMemInitDone & 0xFFFF) << 16)); } -const void *sdram_get_params_erista(uint32_t dram_id) { +static const void *sdram_get_params_erista(uint32_t dram_id) { uint32_t sdram_params_index = sdram_params_index_table_erista[dram_id]; #ifdef CONFIG_SDRAM_COMPRESS uint8_t *buf = (uint8_t *)0x40030000; @@ -1061,7 +1066,7 @@ const void *sdram_get_params_erista(uint32_t dram_id) { #endif } -const void *sdram_get_params_mariko(uint32_t dram_id) { +static const void *sdram_get_params_mariko(uint32_t dram_id) { uint32_t sdram_params_index = sdram_params_index_table_mariko[dram_id]; #ifdef CONFIG_SDRAM_COMPRESS uint8_t *buf = (uint8_t *)0x40030000; @@ -1072,7 +1077,7 @@ const void *sdram_get_params_mariko(uint32_t dram_id) { #endif } -void sdram_init_erista(void) { +static void sdram_init_erista(void) { volatile tegra_pmc_t *pmc = pmc_get_regs(); const sdram_params_erista_t *params = (const sdram_params_erista_t *)sdram_get_params_erista(fuse_get_dram_id()); @@ -1096,7 +1101,7 @@ void sdram_init_erista(void) { sdram_config_erista(params); } -void sdram_init_mariko(void) { +static void sdram_init_mariko(void) { volatile tegra_pmc_t *pmc = pmc_get_regs(); const sdram_params_mariko_t *params = (const sdram_params_mariko_t *)sdram_get_params_mariko(fuse_get_dram_id()); @@ -1117,7 +1122,7 @@ void sdram_init_mariko(void) { sdram_config_mariko(params); } -void sdram_save_params_erista(const void *save_params) { +static void sdram_save_params_erista(const void *save_params) { const sdram_params_erista_t *params = (const sdram_params_erista_t *)save_params; volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -2218,7 +2223,7 @@ void sdram_save_params_erista(const void *save_params) { s(PllMStableTime, 9:0, scratch4, 9:0); } -void sdram_save_params_mariko(const void *save_params) { +static void sdram_save_params_mariko(const void *save_params) { const sdram_params_mariko_t *params = (const sdram_params_mariko_t *)save_params; volatile tegra_pmc_t *pmc = pmc_get_regs(); @@ -3333,4 +3338,28 @@ void sdram_save_params_mariko(const void *save_params) { c32(0, scratch4); s(PllMStableTime, 19:0, scratch4, 19:0); +} + +void sdram_init(void) { + if (is_soc_mariko()) { + sdram_init_mariko(); + } else { + sdram_init_erista(); + } +} + +const void *sdram_get_params(uint32_t dram_id) { + if (is_soc_mariko()) { + return sdram_get_params_mariko(dram_id); + } else { + return sdram_get_params_erista(dram_id); + } +} + +void sdram_save_params(const void *save_params) { + if (is_soc_mariko()) { + sdram_save_params_mariko(save_params); + } else { + sdram_save_params_erista(save_params); + } } \ No newline at end of file diff --git a/sept/sept-secondary/src/sdram.h b/sept/sept-secondary/src/sdram.h index 5e81ac279..38f725579 100644 --- a/sept/sept-secondary/src/sdram.h +++ b/sept/sept-secondary/src/sdram.h @@ -18,11 +18,8 @@ #ifndef FUSEE_SDRAM_H_ #define FUSEE_SDRAM_H_ -void sdram_init_erista(void); -void sdram_init_mariko(void); -const void *sdram_get_params_erista(uint32_t dram_id); -const void *sdram_get_params_mariko(uint32_t dram_id); -void sdram_save_params_erista(const void *save_params); -void sdram_save_params_mariko(const void *save_params); +void sdram_init(void); +const void *sdram_get_params(uint32_t dram_id); +void sdram_save_params(const void *save_params); #endif