From e3ee4be3210a79e39af9b15077f0b119095ee52f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 6 Mar 2019 19:37:51 +0100 Subject: arm: exynos: Detect revision later, when all resources are ready Detection of board revision is done early - before power setup. In case of Odroid XU3/XU4/HC1 family, the detection is done using ADC which is supplied by LDO4/VDD_ADC regulator. This regulator could be turned off (e.g. by kernel before reboot). If ADC is used early, the regulators are not yet available and the detection won't work. Split the revision detection out of set_board_type() into separate function called later - either when displaying board info (in late mode) or during misc_init_r. The idea is that set_board_type() will be called early so its method of detection are limited to flattened device tree (exynos5-dt-types.c for Exynos5) or GPIO (odroid.c for Exynos4412). The newly added set_board_revision() can be called only later, when resources like regulator are available. This is necessary to fix the detection of Odroid HC1 after reboot, if kernel turned off the LDO4 regulator. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Lukasz Majewski Tested-by: Anand Moon Signed-off-by: Minkyu Kang --- board/samsung/odroid/odroid.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'board/samsung/odroid/odroid.c') diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c index 552333fe86..4be8cc9826 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"}; -- cgit From 5d331905273dbdbf31bbbcd7d399404c1c3c9396 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 6 Mar 2019 10:23:09 +0100 Subject: arm: exynos: odroid: Fix build if BOARD_TYPES are not set CONFIG_BOARD_TYPES is necessary for Odroid X/X2/U3 boards to detect proper revision. However building should succeed even without it. While moving code around, document also the reference clock selection. This fixes the build error without CONFIG_BOARD_TYPES: board/samsung/odroid/odroid.c: In function 'board_usb_init': board/samsung/odroid/odroid.c:473:8: error: 'gd_t' {aka 'volatile struct global_data'} has no member named 'board_type' if (gd->board_type == ODROID_TYPE_U3) ^~ Signed-off-by: Krzysztof Kozlowski Signed-off-by: Minkyu Kang --- board/samsung/odroid/odroid.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'board/samsung/odroid/odroid.c') diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c index 4be8cc9826..3e594fd850 100644 --- a/board/samsung/odroid/odroid.c +++ b/board/samsung/odroid/odroid.c @@ -470,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); -- cgit