From 48cf9930c5b1a2369bc99d1f770972e471d491a3 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Fri, 22 Jun 2018 13:27:55 +0200 Subject: [PATCH] hancock: set SIM mux default configuration --- board/nm/hancock/board.c | 60 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/board/nm/hancock/board.c b/board/nm/hancock/board.c index c2861d49b2..095ef401a9 100644 --- a/board/nm/hancock/board.c +++ b/board/nm/hancock/board.c @@ -170,15 +170,12 @@ static void request_and_set_gpio(int gpio, const char *name, int value) return; } - /* TODO: Set value here, remove later call gpio_set_value */ - ret = gpio_direction_output(gpio, 0); + ret = gpio_direction_output(gpio, value); if (ret < 0) { printf("%s: Unable to set %s as output\n", __func__, name); goto err_free_gpio; } - gpio_set_value(gpio, value); - return; err_free_gpio: @@ -302,9 +299,12 @@ static inline int __maybe_unused read_eeprom(void) */ struct serial_device *default_serial_console(void) { - /* TODO: Remove later */ enable_uart2_pin_mux(); + + /* Provide UART on UART2 regardless of boot mode */ return &eserial3_device; + + /* TODO: Shall we keep this? */ #if 0 if (spl_boot_device() == BOOT_DEVICE_UART) { /* SPL Boot -> UART0 (later used for SPI) */ @@ -323,10 +323,11 @@ struct serial_device *default_serial_console(void) static const struct ddr_data ddr3_data = { /* Ratios were optimized by DDR3 training software from TI */ - .datardsratio0 = 0x39, - .datawdsratio0 = 0x3f, - .datafwsratio0 = 0x98, - .datawrsratio0 = 0x7d, + /* TODO: Evaluate new values and update */ + .datardsratio0 = 0x39, /* 0x39 */ + .datawdsratio0 = 0x3f, /* 0x40 */ + .datafwsratio0 = 0x98, /* 0x96 */ + .datawrsratio0 = 0x7d, /* 0x7d */ }; static const struct cmd_control ddr3_cmd_ctrl_data = { @@ -369,14 +370,7 @@ void am33xx_spl_board_init(void) /* Configure I2C busses */ init_i2c(); - /* Configure default PMIC current limits. Will be overridden in Linux. - * MEM = 1.5A (0.55A) - * IO = 1.5A (0.5A) - * PERI = 2.0A (1.0A) - * PRO = 0.5A (unused) - * CORE2 = 2.0A (0.55A) - * CORE1 = 2.0A (0.25A, seems too low) - */ + /* PMIC basic configuration */ da9063_init(CONFIG_PMIC_I2C_BUS); /* Enable +3V3_SENSOR (LDO3) */ @@ -503,10 +497,13 @@ static void init_user_module(void) { /* TODO: Open Drain as UM can drive against mainboard */ /* TODO: Check whether reset shall be driven by mainboard at all */ + /* REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_RST_PHY_N); */ + /* OMAP3 does not feature open drain pins, thus configure pin as input */ + /* gpio_direction_input(NETBIRD_GPIO_RST_PHY_N); */ puts("UM: "); - REQUEST_AND_SET_GPIO(GPIO_RST_UM_N); /* Assert reset (active high) */ + REQUEST_AND_CLEAR_GPIO(GPIO_RST_UM_N); /* Assert reset (active low) */ REQUEST_AND_CLEAR_GPIO(GPIO_CTRL_WDIS_N) /* TODO: CHECK */ da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 0); /* Switch Supply off */ @@ -514,14 +511,23 @@ static void init_user_module(void) da9063_set_gpio(PMIC_UM_SUPPLY_VSEL_IO, 0); /* Set voltage to 3.3V */ mdelay(1); - da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 1); /* Enable Supply */ - mdelay(10); /* */ - gpio_set_value(GPIO_RST_UM_N, 0); /* Release reset */ + da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 1); /* Enable Supply */ + mdelay(10); + + gpio_direction_input(GPIO_RST_UM_N); /* Release reset (open drain) */ puts("ready\n"); } +static void init_sim_mux(void) +{ + /* + * Switch onboard SIM to onboard modem (Mux = 1) + */ + REQUEST_AND_SET_GPIO(GPIO_SIM_SEL); +} + static void init_gsm(void) { /* @@ -592,7 +598,7 @@ int board_init(void) /* Let user know we're starting */ init_leds(); - /* TODO: LEDs broken, use indicator led of #2 */ + /* FIXME: LEDs broken, use indicator led of #2 */ set_status_led(1, 1); /* Orange */ set_indicator_led(0, 0); /* Off */ set_status_led(0, 0); /* Off */ @@ -773,8 +779,9 @@ static void check_reset_button(void) int board_late_init(void) { #if !defined(CONFIG_SPL_BUILD) - if (read_eeprom() < 0) + if (read_eeprom() < 0) { puts("Could not get board ID.\n"); + } get_hw_version(); get_pmic_version(); @@ -788,7 +795,6 @@ int board_late_init(void) REQUEST_AND_SET_GPIO(CAN0_TERM_N); REQUEST_AND_SET_GPIO(CAN1_TERM_N); - REQUEST_AND_CLEAR_GPIO(GPIO_SIM_SEL); REQUEST_AND_CLEAR_GPIO(GPIO_RST_UI_N); /* FIXME: Problem switch reset lines of switch and PHY @@ -809,13 +815,10 @@ int board_late_init(void) init_usb_hub(); init_user_module(); + init_sim_mux(); init_gsm(); init_gnss(); - /* TODO: Change for battery operation */ - /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ - /*(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF);*/ - /* check_reset_button(); set_console(); @@ -828,7 +831,6 @@ int board_late_init(void) /* check_fct(); */ - #endif return 0;