aboutsummaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorTom Rini2019-03-14 11:37:11 -0400
committerTom Rini2019-03-14 11:37:11 -0400
commit9659eb46af6249b6e4b3712e60a1eb2e87fc48a1 (patch)
tree2d7e7149804ddbf6d0bc5e6cb3dd20706be45809 /board
parent7f295ffed6f3c62bf15a48bb12b5757f4716f789 (diff)
parent1411298cbca83a8527d2c1b5c4d299871fc34cf1 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-samsung
Diffstat (limited to 'board')
-rw-r--r--board/samsung/arndale/MAINTAINERS2
-rw-r--r--board/samsung/common/board.c25
-rw-r--r--board/samsung/common/bootscripts/autoboot.cmd10
-rw-r--r--board/samsung/common/exynos5-dt-types.c54
-rw-r--r--board/samsung/common/misc.c2
-rw-r--r--board/samsung/odroid/odroid.c35
6 files changed, 109 insertions, 19 deletions
diff --git a/board/samsung/arndale/MAINTAINERS b/board/samsung/arndale/MAINTAINERS
index 7dc17854d1b..aa64c7a1874 100644
--- a/board/samsung/arndale/MAINTAINERS
+++ b/board/samsung/arndale/MAINTAINERS
@@ -1,5 +1,5 @@
ARNDALE BOARD
-M: Chander Kashyap <k.chander@samsung.com>
+M: Krzysztof Kozlowski <krzk@kernel.org>
S: Maintained
F: board/samsung/arndale/
F: include/configs/arndale.h
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 96228a86a11..9adbd1e2cf9 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -249,11 +249,22 @@ int board_eth_init(bd_t *bis)
return 0;
}
-#ifdef CONFIG_DISPLAY_BOARDINFO
+#if defined(CONFIG_DISPLAY_BOARDINFO) || defined(CONFIG_DISPLAY_BOARDINFO_LATE)
int checkboard(void)
{
if (IS_ENABLED(CONFIG_BOARD_TYPES)) {
- const char *board_info = get_board_type();
+ const char *board_info;
+
+ if (IS_ENABLED(CONFIG_DISPLAY_BOARDINFO_LATE)) {
+ /*
+ * Printing type requires having revision, although
+ * this will succeed only if done late.
+ * Otherwise revision will be set in misc_init_r().
+ */
+ set_board_revision();
+ }
+
+ board_info = get_board_type();
if (board_info)
printf("Type: %s\n", board_info);
@@ -287,6 +298,16 @@ int board_late_init(void)
#ifdef CONFIG_MISC_INIT_R
int misc_init_r(void)
{
+ if (IS_ENABLED(CONFIG_BOARD_TYPES) &&
+ !IS_ENABLED(CONFIG_DISPLAY_BOARDINFO_LATE)) {
+ /*
+ * If revision was not set by late display boardinfo,
+ * set it here. At this point regulators should be already
+ * available.
+ */
+ set_board_revision();
+ }
+
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
set_board_info();
#endif
diff --git a/board/samsung/common/bootscripts/autoboot.cmd b/board/samsung/common/bootscripts/autoboot.cmd
index 11c724c4e09..d66bcccf5d1 100644
--- a/board/samsung/common/bootscripts/autoboot.cmd
+++ b/board/samsung/common/bootscripts/autoboot.cmd
@@ -3,7 +3,7 @@
# ./tools/mkimage -c none -A arm -T script -d autoboot.cmd boot.scr
#
# It requires a list of environment variables to be defined before load:
-# platform dependent: boardname, fdtfile, console
+# platform dependent: board_name, fdtfile, console
# system dependent: mmcbootdev, mmcbootpart, mmcrootdev, mmcrootpart, rootfstype
#
setenv fdtaddr "40800000"
@@ -35,17 +35,17 @@ else
setenv initrd_addr -;
fi;"
-#### Routine: boot_fit - check that env $boardname is set and boot proper config of ITB image
+#### Routine: boot_fit - check that env $board_name is set and boot proper config of ITB image
setenv setboot_fit "
-if test -e '${boardname}'; then
+if test -e '${board_name}'; then
setenv fdt_addr ;
setenv initrd_addr ;
setenv kerneladdr 0x42000000;
setenv kernelname Image.itb;
- setenv itbcfg "\"#${boardname}\"";
+ setenv itbcfg "\"#${board_name}\"";
setenv imgbootcmd bootm;
else
- echo Warning! Variable: \$boardname is undefined!;
+ echo Warning! Variable: \$board_name is undefined!;
fi"
#### Routine: setboot_uimg - prepare env to boot uImage
diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c
index 7a86e918776..516c32923e4 100644
--- a/board/samsung/common/exynos5-dt-types.c
+++ b/board/samsung/common/exynos5-dt-types.c
@@ -57,12 +57,48 @@ static unsigned int odroid_get_rev(void)
return 0;
}
+/*
+ * Read ADC at least twice and check the resuls. If regulator providing voltage
+ * on to measured point was just turned on, first reads might require time
+ * to stabilize.
+ */
+static int odroid_get_adc_val(unsigned int *adcval)
+{
+ unsigned int adcval_prev = 0;
+ int ret, retries = 20;
+
+ ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN,
+ &adcval_prev);
+ if (ret)
+ return ret;
+
+ while (retries--) {
+ mdelay(5);
+
+ ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN,
+ adcval);
+ if (ret)
+ return ret;
+
+ /*
+ * If difference between ADC reads is less than 3%,
+ * accept the result
+ */
+ if ((100 * abs(*adcval - adcval_prev) / adcval_prev) < 3)
+ return ret;
+
+ adcval_prev = *adcval;
+ }
+
+ return ret;
+}
+
static int odroid_get_board_type(void)
{
unsigned int adcval;
int ret, i;
- ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, &adcval);
+ ret = odroid_get_adc_val(&adcval);
if (ret)
goto rev_default;
@@ -192,8 +228,11 @@ const char *get_board_type(void)
/**
* 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.
+ * As default type set EXYNOS5_BOARD_GENERIC. If Odroid is detected,
+ * set its proper type based on device tree.
+ *
+ * This might be called early when some more specific ways to detect revision
+ * are not yet available.
*/
void set_board_type(void)
{
@@ -211,8 +250,15 @@ void set_board_type(void)
gd->board_type = of_match->data;
break;
}
+}
- /* If Odroid, then check its revision */
+/**
+ * set_board_revision() - set detailed board type in gd->board_type.
+ * Should be called when resources (e.g. regulators) are available
+ * so ADC can be used to detect the specific revision of a board.
+ */
+void set_board_revision(void)
+{
if (board_is_odroidxu3())
gd->board_type = odroid_get_board_type();
}
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index 05243fc8965..53cd1b29070 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -101,7 +101,7 @@ void set_board_info(void)
bdtype = "";
sprintf(info, "%s%s", bdname, bdtype);
- env_set("boardname", info);
+ env_set("board_name", info);
#endif
snprintf(info, ARRAY_SIZE(info), "%s%x-%s%s.dtb",
CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype);
diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 552333fe869..3e594fd8501 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -54,6 +54,14 @@ void set_board_type(void)
gd->board_type = ODROID_TYPE_U3;
}
+void set_board_revision(void)
+{
+ /*
+ * Revision already set by set_board_type() because it can be
+ * executed early.
+ */
+}
+
const char *get_board_type(void)
{
const char *board_type[] = {"u3", "x2"};
@@ -462,18 +470,33 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
+static void set_usb3503_ref_clk(void)
+{
+#ifdef CONFIG_BOARD_TYPES
+ /*
+ * gpx3-0 chooses primary (low) or secondary (high) reference clock
+ * frequencies table. The choice of clock is done through hard-wired
+ * REF_SEL pins.
+ * The Odroid Us have reference clock at 24 MHz (00 entry from secondary
+ * table) and Odroid Xs have it at 26 MHz (01 entry from primary table).
+ */
+ if (gd->board_type == ODROID_TYPE_U3)
+ gpio_direction_output(EXYNOS4X12_GPIO_X30, 0);
+ else
+ gpio_direction_output(EXYNOS4X12_GPIO_X30, 1);
+#else
+ /* Choose Odroid Xs frequency without board types */
+ gpio_direction_output(EXYNOS4X12_GPIO_X30, 1);
+#endif /* CONFIG_BOARD_TYPES */
+}
+
int board_usb_init(int index, enum usb_init_type init)
{
#ifdef CONFIG_CMD_USB
struct udevice *dev;
int ret;
- /* Set Ref freq 0 => 24MHz, 1 => 26MHz*/
- /* Odroid Us have it at 24MHz, Odroid Xs at 26MHz */
- if (gd->board_type == ODROID_TYPE_U3)
- gpio_direction_output(EXYNOS4X12_GPIO_X30, 0);
- else
- gpio_direction_output(EXYNOS4X12_GPIO_X30, 1);
+ set_usb3503_ref_clk();
/* Disconnect, Reset, Connect */
gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);