Merge branch 'master' of git://git.denx.de/u-boot-samsung

This commit is contained in:
Tom Rini
2019-03-14 11:37:11 -04:00
17 changed files with 211 additions and 35 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);