From 7406ebe7fe472097d203325e92a637fad89e9ccc Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Fri, 23 Feb 2018 08:31:41 +0100 Subject: [PATCH] nrhw20: cleanup board file --- board/nm/nrhw20/board.c | 45 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/board/nm/nrhw20/board.c b/board/nm/nrhw20/board.c index be2d131701..68fde50e24 100644 --- a/board/nm/nrhw20/board.c +++ b/board/nm/nrhw20/board.c @@ -144,6 +144,7 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; #endif +#define I2C_BD_EEPROM_BUS (2) #define BD_EEPROM_ADDR (0x50) /* CPU BD EEPROM (8kByte) is at 50 (A0) */ #define BD_ADDRESS (0x0000) /* Board descriptor at beginning of EEPROM */ #define PD_ADDRESS (0x0200) /* Product descriptor */ @@ -159,9 +160,8 @@ static int _bd_init(void) { int old_bus; - /* TODO: Use a define for bus number */ old_bus = i2c_get_bus_num(); - i2c_set_bus_num(2); + i2c_set_bus_num(I2C_BD_EEPROM_BUS); if (bd_get_context(&bdctx[0], BD_EEPROM_ADDR, BD_ADDRESS) != 0) { printf("%s() no valid bd found\n", __func__); @@ -215,6 +215,7 @@ static void set_indicator(unsigned led, int red, int green) if (!red) led_val |= led_red_mask; + if (!green) led_val |= led_green_mask; @@ -283,9 +284,9 @@ static struct emif_regs ddr3_emif_reg_data = { #define OSC (V_OSCK/1000000) -/* TODO: Rename */ -struct dpll_params dpll_ddr_nbhw16= { - DDR3_CLOCK_FREQUENCY, OSC-1, 1, -1, -1, -1, -1}; +struct dpll_params dpll_ddr_nrhw20 = { + DDR3_CLOCK_FREQUENCY, OSC-1, 1, -1, -1, -1, -1 +}; void am33xx_spl_board_init(void) @@ -317,8 +318,8 @@ void am33xx_spl_board_init(void) const struct dpll_params *get_dpll_ddr_params(void) { - dpll_ddr_nbhw16.n = (get_osclk() / 1000000) - 1; - return &dpll_ddr_nbhw16; + dpll_ddr_nrhw20.n = (get_osclk() / 1000000) - 1; + return &dpll_ddr_nrhw20; } void set_uart_mux_conf(void) @@ -673,15 +674,6 @@ int board_init(void) mdelay(1200); gpio_set_value(NETBIRD_GPIO_PWR_GSM, 0); -#if 0 - /* TODO: Move to pinmux? Required??? RMII2 not used! */ - /* There are two functions on the same mux mode for MMC2_DAT7 we want - * to use RMII2_CRS_DV so we need to set SMA2 Register to 1 - * See SPRS717J site 49 (10)*/ - #define SMA2_REGISTER (CTRL_BASE + 0x1320) - writel(0x01, SMA2_REGISTER); /* Select RMII2_CRS_DV instead of MMC2_DAT7 */ -#endif - printf("OSC: %lu MHz\n", get_osclk()/1000000); return 0; @@ -727,8 +719,7 @@ static void set_devicetree_name(void) /* add hardware versions to environment */ if (bd_get_devicetree(devicetreename, sizeof(devicetreename)) != 0) { - printf("Devicetree name not found, using legacy name\n"); - /* TODO: Check naming convention */ + printf("Devicetree name not found, using default name\n"); strcpy(devicetreename, "am335x-nrhw20-prod1.dtb"); } @@ -739,12 +730,12 @@ static void get_hw_version(void) { int hw_ver, hw_rev; char hw_versions[16]; - char new_env[256]; /* TODO: Check size, have also seen 512 */ + char new_env[256]; /* current bootargs = 84 bytes */ - /* add hardware versions to environment */ bd_get_hw_version(&hw_ver, &hw_rev); printf("HW20: V%d.%d\n", hw_ver, hw_rev); + /* add hardware versions to environment */ snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev); snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions); setenv("add_version_bootargs", new_env); @@ -757,14 +748,21 @@ static void check_fct(void) * Clear the bootcmd, so that test system can easily connect. */ + int old_bus; + + old_bus = i2c_get_bus_num(); + i2c_set_bus_num(I2C_BD_EEPROM_BUS); + /* If probe fails we are sure no eeprom is connected */ if (i2c_probe(0x51) == 0) { printf("Entering fct mode\n"); setenv ("bootcmd", ""); } - /* TODO: needs to test on bus 2 ! */ + + i2c_set_bus_num(old_bus); } + static void set_fdtshieldcmd(const char *fdt_cmd) { setenv("fdtshieldcmd", fdt_cmd); @@ -838,8 +836,9 @@ static void shield_config(void) cmd->init(); shieldcmd = cmd->default_shieldcmd; - /* If a shield configuration set by linux take it without bd check, we asume that Linux knows - * what to do. */ + /* If a shield configuration is set by Linux, take it without bd check. + * We asume that Linux knows what to do. + */ len = read_file("/root/boot/shieldcmd", shieldcmd_linux, MAX_SHIELD_CMD_LEN); if (len > 0) { debug("Shield command found in file, using it\n");