From bc3f39ea0d3c9339b7f09b1d766b6a62e1921033 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Tue, 27 Oct 2015 13:07:54 +0100 Subject: samsung: board/misc: check returned pointer for get_board_type() calls The function get_board_type() is called in two places by common code, but the returned pointer was never check. This commit adds checking the returned pointer, before use it. Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Reviewed-by: Simon Glass Tested-by: Anand Moon Signed-off-by: Minkyu Kang --- board/samsung/common/board.c | 4 ++-- board/samsung/common/misc.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'board') diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index d32c75de50..1334c22ddd 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -304,8 +304,8 @@ int checkboard(void) printf("Board: %s\n", board_info ? board_info : "unknown"); #ifdef CONFIG_BOARD_TYPES board_info = get_board_type(); - - printf("Model: %s\n", board_info ? board_info : "unknown"); + if (board_info) + printf("Type: %s\n", board_info); #endif return 0; } diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index e0e2c48632..c8316d854f 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -85,6 +85,9 @@ void set_board_info(void) #ifdef CONFIG_BOARD_TYPES bdtype = get_board_type(); + if (!bdtype) + bdtype = ""; + sprintf(info, "%s%s", bdname, bdtype); setenv("boardname", info); #endif -- cgit v1.2.1 From 1611c8cbcfe2ee50cc5e96f3a5c666c99d235107 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Tue, 27 Oct 2015 13:08:05 +0100 Subject: exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4. This commit adds additional file with implementation of board detection code for Odroid-XU3/XU4. The detection depends on compatible found in fdt: - "samsung,exynos5" - uses Exynos5 generic code - "samsung,odroidxu3" - try detect XU3 revision There are few revisions of Odroid XU3/XU4, each can be detected by checking the value of channel 9 of built-in ADC: Rev ADC Board 0.1 0 XU3 0.1 0.2 372 XU3 0.2 | XU3L - no DISPLAYPORT 0.3 1280 XU4 0.1 The detection code depends on the ADC+10% value. Implementation of functions: - set_board_type() - read ADC and set type - get_board_rev() - returns board revision: 1..3 - get_board_type() - returns board type string Additional functions with return values of bool: - board_is_generic() - true if found compatible "samsung,exynos5" but not "samsung,odroidxu3" - board_is_odroidxu3() - true if found compatible "samsung,odroidxu3" and one of XU3 revision. - board_is_odroidxu4() - true if found compatible "samsung,odroidxu3" and XU4 revision. After I2C controller init, the get_board_type() can check if the XU3 board is a "Lite" variant, by probing chip 0x40 on I2C0 (INA231 - exists only on non-lite). This is useful for setting fdt file name at misc_init_r(). Enabled configs: - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - CONFIG_ODROID_REV_AIN - CONFIG_REVISION_TAG - CONFIG_BOARD_TYPES Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Cc: Simon Glass Tested-by: Anand Moon Signed-off-by: Minkyu Kang --- board/samsung/common/Makefile | 5 +- board/samsung/common/exynos5-dt-types.c | 196 ++++++++++++++++++++++++++++++++ board/samsung/common/exynos5-dt.c | 12 ++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 board/samsung/common/exynos5-dt-types.c (limited to 'board') diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile index 6cbd90661b..ef1a8f318f 100644 --- a/board/samsung/common/Makefile +++ b/board/samsung/common/Makefile @@ -11,5 +11,8 @@ obj-$(CONFIG_MISC_COMMON) += misc.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_BOARD_COMMON) += board.o -obj-$(CONFIG_EXYNOS5_DT) += exynos5-dt.o +ifdef CONFIG_EXYNOS5_DT +obj-y += exynos5-dt.o +obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o +endif endif diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c new file mode 100644 index 0000000000..48fd1f7d96 --- /dev/null +++ b/board/samsung/common/exynos5-dt-types.c @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2015 Samsung Electronics + * Przemyslaw Marczak + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const struct udevice_id board_ids[] = { + { .compatible = "samsung,odroidxu3", .data = EXYNOS5_BOARD_ODROID_XU3 }, + { .compatible = "samsung,exynos5", .data = EXYNOS5_BOARD_GENERIC }, + { }, +}; + +/** + * Odroix XU3/4 board revisions: + * Rev ADCmax Board + * 0.1 0 XU3 0.1 + * 0.2 410 XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / INA231) + * 0.3 1408 XU4 0.1 + * Use +10 % for ADC value tolerance. + */ +struct odroid_rev_info odroid_info[] = { + { EXYNOS5_BOARD_ODROID_XU3_REV01, 1, 10, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU3_REV02, 2, 410, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU4_REV01, 1, 1408, "xu4" }, + { EXYNOS5_BOARD_ODROID_UNKNOWN, 0, 4095, "unknown" }, +}; + +static unsigned int odroid_get_rev(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + if (odroid_info[i].board_type == gd->board_type) + return odroid_info[i].board_rev; + } + + return 0; +} + +static int odroid_get_board_type(void) +{ + unsigned int adcval; + int ret, i; + + ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, &adcval); + if (ret) + goto rev_default; + + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + /* ADC tolerance: +20 % */ + if (adcval < odroid_info[i].adc_val) + return odroid_info[i].board_type; + } + +rev_default: + return EXYNOS5_BOARD_ODROID_XU3; +} + +/** + * odroid_get_type_str - returns pointer to one of the board type string. + * Board types: "xu3", "xu3-lite", "xu4". However the "xu3lite" can be + * detected only when the i2c controller is ready to use. Fortunately, + * XU3 and XU3L are compatible, and the information about board lite + * revision is needed before booting the linux, to set proper environment + * variable: $fdtfile. + */ +static const char *odroid_get_type_str(void) +{ + const char *type_xu3l = "xu3-lite"; + struct udevice *dev, *chip; + int i, ret; + + if (gd->board_type != EXYNOS5_BOARD_ODROID_XU3_REV02) + goto exit; + + ret = pmic_get("s2mps11", &dev); + if (ret) + goto exit; + + /* Enable LDO26: 3.0V */ + ret = pmic_reg_write(dev, S2MPS11_REG_L26CTRL, + S2MPS11_LDO26_ENABLE); + if (ret) + goto exit; + + /* Check XU3Lite by probe INA231 I2C0:0x40 */ + ret = uclass_get_device(UCLASS_I2C, 0, &dev); + if (ret) + goto exit; + + ret = dm_i2c_probe(dev, 0x40, 0x0, &chip); + if (ret) + return type_xu3l; + +exit: + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + if (odroid_info[i].board_type == gd->board_type) + return odroid_info[i].name; + } + + return NULL; +} + +bool board_is_odroidxu3(void) +{ + if (gd->board_type >= EXYNOS5_BOARD_ODROID_XU3 && + gd->board_type <= EXYNOS5_BOARD_ODROID_XU3_REV02) + return true; + + return false; +} + +bool board_is_odroidxu4(void) +{ + if (gd->board_type == EXYNOS5_BOARD_ODROID_XU4_REV01) + return true; + + return false; +} + +bool board_is_generic(void) +{ + if (gd->board_type == EXYNOS5_BOARD_GENERIC) + return true; + + return false; +} + +/** + * get_board_rev() - return detected board revision. + * + * @return: return board revision number for XU3 or 0 for generic + */ +u32 get_board_rev(void) +{ + if (board_is_generic()) + return 0; + + return odroid_get_rev(); +} + +/** + * get_board_type() - returns board type string. + * + * @return: return board type string for XU3 or empty string for generic + */ +const char *get_board_type(void) +{ + const char *generic = ""; + + if (board_is_generic()) + return generic; + + return odroid_get_type_str(); +} + +/** + * set_board_type() - set board type in gd->board_type. + * As default type set EXYNOS5_BOARD_GENERIC, if detect Odroid, + * then set its proper type. + */ +void set_board_type(void) +{ + const struct udevice_id *of_match = board_ids; + int ret; + + gd->board_type = EXYNOS5_BOARD_GENERIC; + + while (of_match->compatible) { + ret = fdt_node_check_compatible(gd->fdt_blob, 0, + of_match->compatible); + if (ret) + of_match++; + + gd->board_type = of_match->data; + break; + } + + /* If Odroid, then check its revision */ + if (board_is_odroidxu3()) + gd->board_type = odroid_get_board_type(); +} diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c index 4250f722da..4d9e151756 100644 --- a/board/samsung/common/exynos5-dt.c +++ b/board/samsung/common/exynos5-dt.c @@ -27,7 +27,10 @@ #include #include #include +#include #include +#include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -335,15 +338,24 @@ int board_usb_init(int index, enum usb_init_type init) #ifdef CONFIG_SET_DFU_ALT_INFO char *get_dfu_alt_system(char *interface, char *devstr) { + char *info = "Not supported!"; + + if (board_is_odroidxu4()) + return info; + return getenv("dfu_alt_system"); } char *get_dfu_alt_boot(char *interface, char *devstr) { + char *info = "Not supported!"; struct mmc *mmc; char *alt_boot; int dev_num; + if (board_is_odroidxu4()) + return info; + dev_num = simple_strtoul(devstr, NULL, 10); mmc = find_mmc_device(dev_num); -- cgit v1.2.1 From 6b949ba8243342906a1f4a2e6f1f8c307de40ffd Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 23 Oct 2015 15:59:37 +0900 Subject: smdkv310: clean up checkpatch issues This patch will fix these checkpatch issues. WARNING: Avoid unnecessary line continuations + gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \ WARNING: Avoid unnecessary line continuations + gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \ WARNING: Avoid unnecessary line continuations + gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \ WARNING: Avoid unnecessary line continuations + gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \ Signed-off-by: Minkyu Kang --- board/samsung/smdkv310/smdkv310.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'board') diff --git a/board/samsung/smdkv310/smdkv310.c b/board/samsung/smdkv310/smdkv310.c index cb7f9b0ac8..fc0e8d252b 100644 --- a/board/samsung/smdkv310/smdkv310.c +++ b/board/samsung/smdkv310/smdkv310.c @@ -55,16 +55,16 @@ int dram_init(void) void dram_init_banksize(void) { gd->bd->bi_dram[0].start = PHYS_SDRAM_1; - gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \ + gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); gd->bd->bi_dram[1].start = PHYS_SDRAM_2; - gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \ + gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE); gd->bd->bi_dram[2].start = PHYS_SDRAM_3; - gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \ + gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE); gd->bd->bi_dram[3].start = PHYS_SDRAM_4; - gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \ + gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE); } -- cgit v1.2.1 From 9eae8441251188287ddd706196596a3117802449 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 23 Oct 2015 16:12:28 +0900 Subject: smdk2410: clean up checkpatch issues This patch will fix these checkpatch issues. ERROR: spaces required around that '==' (ctx:VxV) +#if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */ ERROR: spaces required around that '==' (ctx:VxV) +#elif FCLK_SPEED==1 /* Fout = 202.8MHz */ ERROR: spaces required around that '==' (ctx:VxV) +#if USB_CLOCK==0 ERROR: spaces required around that '==' (ctx:VxV) +#elif USB_CLOCK==1 CHECK: spaces required around that ':' (ctx:VxV) + "bne 1b":"=r" (loops):"0" (loops)); Signed-off-by: Minkyu Kang --- board/samsung/smdk2410/smdk2410.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'board') diff --git a/board/samsung/smdk2410/smdk2410.c b/board/samsung/smdk2410/smdk2410.c index b75a0e34dd..6e678c744b 100644 --- a/board/samsung/smdk2410/smdk2410.c +++ b/board/samsung/smdk2410/smdk2410.c @@ -18,11 +18,11 @@ DECLARE_GLOBAL_DATA_PTR; #define FCLK_SPEED 1 -#if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */ +#if (FCLK_SPEED == 0) /* Fout = 203MHz, Fin = 12MHz for Audio */ #define M_MDIV 0xC3 #define M_PDIV 0x4 #define M_SDIV 0x1 -#elif FCLK_SPEED==1 /* Fout = 202.8MHz */ +#elif (FCLK_SPEED == 1) /* Fout = 202.8MHz */ #define M_MDIV 0xA1 #define M_PDIV 0x3 #define M_SDIV 0x1 @@ -30,11 +30,11 @@ DECLARE_GLOBAL_DATA_PTR; #define USB_CLOCK 1 -#if USB_CLOCK==0 +#if (USB_CLOCK == 0) #define U_M_MDIV 0xA1 #define U_M_PDIV 0x3 #define U_M_SDIV 0x1 -#elif USB_CLOCK==1 +#elif (USB_CLOCK == 1) #define U_M_MDIV 0x48 #define U_M_PDIV 0x3 #define U_M_SDIV 0x2 @@ -44,7 +44,7 @@ static inline void pll_delay(unsigned long loops) { __asm__ volatile ("1:\n" "subs %0, %1, #1\n" - "bne 1b":"=r" (loops):"0" (loops)); + "bne 1b" : "=r" (loops) : "0" (loops)); } /* -- cgit v1.2.1 From 1d83970f6f6003276373843b8e2fd75f78f1caf3 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 23 Oct 2015 16:15:04 +0900 Subject: odroid: clean up checkpatch issues This patch will fix these checkpatch issues. +static const char *mmc_regulators[] = { CHECK: Blank lines aren't necessary before a close brace '}' + +} Signed-off-by: Minkyu Kang --- board/samsung/odroid/odroid.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'board') diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c index 32155f1184..36d493d514 100644 --- a/board/samsung/odroid/odroid.c +++ b/board/samsung/odroid/odroid.c @@ -33,13 +33,6 @@ enum { ODROID_TYPES, }; -static const char *mmc_regulators[] = { - "VDDQ_EMMC_1.8V", - "VDDQ_EMMC_2.8V", - "TFLASH_2.8V", - NULL, -}; - void set_board_type(void) { /* Set GPA1 pin 1 to HI - enable XCL205 output */ @@ -428,6 +421,13 @@ int exynos_init(void) int exynos_power_init(void) { + const char *mmc_regulators[] = { + "VDDQ_EMMC_1.8V", + "VDDQ_EMMC_2.8V", + "TFLASH_2.8V", + NULL, + }; + if (regulator_list_autoset(mmc_regulators, NULL, true)) error("Unable to init all mmc regulators"); @@ -450,7 +450,6 @@ static int s5pc210_phy_control(int on) return regulator_set_mode(dev, OPMODE_ON); else return regulator_set_mode(dev, OPMODE_LPM); - } struct s3c_plat_otg_data s5pc210_otg_data = { -- cgit v1.2.1 From de5f9733f653091d4b227914d04432099a6448dc Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 23 Oct 2015 16:21:20 +0900 Subject: samsung: clean up checkpatch issues This patch will fix these checkpatch issues. CHECK: Alignment should match open parenthesis + printf("Enter: %s %s\n", mode_name[mode][0], + mode_info[mode]); CHECK: Alignment should match open parenthesis + lcd_printf("\n\n\t%s %s\n", mode_name[mode][0], + mode_info[mode]); CHECK: Alignment should match open parenthesis + lcd_printf("\t%s %s - %s\n\n", selection[i], + mode_name[i][0], Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'board') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index c8316d854f..da0d4db1f9 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -259,9 +259,9 @@ static int mode_leave_menu(int mode) cmd = find_cmd(mode_name[mode][1]); if (cmd) { printf("Enter: %s %s\n", mode_name[mode][0], - mode_info[mode]); + mode_info[mode]); lcd_printf("\n\n\t%s %s\n", mode_name[mode][0], - mode_info[mode]); + mode_info[mode]); lcd_puts("\n\tDo not turn off device before finish!\n"); cmd_result = run_command(mode_cmd[mode], 0); @@ -318,8 +318,7 @@ static void display_download_menu(int mode) for (i = 0; i <= BOOT_MODE_EXIT; i++) lcd_printf("\t%s %s - %s\n\n", selection[i], - mode_name[i][0], - mode_info[i]); + mode_name[i][0], mode_info[i]); } static void download_menu(void) -- cgit v1.2.1