pico-imx7d: replace nested if statements to switch case in revision detection

Co-Authored-By: fabioestevam <1044841+fabioestevam@users.noreply.github.com>
This commit is contained in:
Benjamin Szőke 2023-01-11 23:58:03 +01:00
parent c54cd92fcf
commit 3be0b09ea9

View File

@ -112,30 +112,30 @@ static void gpr_init(void)
* 1 0 512MB DDR3
*
***********************************************/
static bool is_gpio1_12_low(void)
{
gpio_direction_input(IMX_GPIO_NR(1, 12));
return !gpio_get_value(IMX_GPIO_NR(1, 12));
}
static bool is_gpio1_13_high(void)
{
static int imx7d_pico_detect_board(void)
{
gpio_direction_input(IMX_GPIO_NR(1, 12));
gpio_direction_input(IMX_GPIO_NR(1, 13));
return gpio_get_value(IMX_GPIO_NR(1, 13));
return gpio_get_value(IMX_GPIO_NR(1, 12)) << 1 |
gpio_get_value(IMX_GPIO_NR(1, 13));
}
static void ddr_init(void)
{
if (is_gpio1_12_low()) {
if (is_gpio1_13_high()) {
ddrc_regs_val.addrmap0 = 0x0000001f;
ddrc_regs_val.addrmap1 = 0x00181818;
ddrc_regs_val.addrmap4 = 0x00000f0f;
ddrc_regs_val.addrmap5 = 0x04040404;
ddrc_regs_val.addrmap6 = 0x04040404;
} else
ddrc_regs_val.addrmap6 = 0x0f070707;
switch (imx7d_pico_detect_board()) {
case 0:
ddrc_regs_val.addrmap6 = 0x0f070707;
break;
case 1:
ddrc_regs_val.addrmap0 = 0x0000001f;
ddrc_regs_val.addrmap1 = 0x00181818;
ddrc_regs_val.addrmap4 = 0x00000f0f;
ddrc_regs_val.addrmap5 = 0x04040404;
ddrc_regs_val.addrmap6 = 0x04040404;
break;
}
mx7_dram_cfg(&ddrc_regs_val, &ddrc_mp_val, &ddr_phy_regs_val,
&calib_param);
}