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
commit 9659eb46af
17 changed files with 211 additions and 35 deletions

View File

@ -32,6 +32,7 @@
adc@12D10000 {
u-boot,dm-pre-reloc;
vdd-supply = <&ldo4_reg>;
status = "okay";
};
@ -44,6 +45,7 @@
regulator-name = "vdd_ldo1";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -51,18 +53,21 @@
regulator-name = "vddq_mmc0";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
};
ldo4_reg: LDO4 {
regulator-name = "vdd_adc";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
};
ldo5_reg: LDO5 {
regulator-name = "vdd_ldo5";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -70,6 +75,7 @@
regulator-name = "vdd_ldo6";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -77,6 +83,7 @@
regulator-name = "vdd_ldo7";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -84,6 +91,7 @@
regulator-name = "vdd_ldo8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -91,6 +99,7 @@
regulator-name = "vdd_ldo9";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -98,6 +107,7 @@
regulator-name = "vdd_ldo10";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -105,6 +115,7 @@
regulator-name = "vdd_ldo11";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -112,6 +123,7 @@
regulator-name = "vdd_ldo12";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -119,12 +131,14 @@
regulator-name = "vddq_mmc2";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-ramp-delay = <12000>;
};
ldo15_reg: LDO15 {
regulator-name = "vdd_ldo15";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -132,6 +146,7 @@
regulator-name = "vdd_ldo16";
regulator-min-microvolt = <2200000>;
regulator-max-microvolt = <2200000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -139,6 +154,7 @@
regulator-name = "vdd_ldo17";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -146,18 +162,21 @@
regulator-name = "vdd_emmc_1V8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <12000>;
};
ldo19_reg: LDO19 {
regulator-name = "vdd_sd";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-ramp-delay = <12000>;
};
ldo24_reg: LDO24 {
regulator-name = "tsp_io";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -165,6 +184,7 @@
regulator-name = "vdd_ldo26";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-ramp-delay = <12000>;
regulator-always-on;
};
@ -256,7 +276,7 @@
};
serial@12C20000 {
status="okay";
status = "okay";
};
mmc@12200000 {

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

View File

@ -10,6 +10,8 @@ CONFIG_FIT=y
CONFIG_FIT_BEST_MATCH=y
CONFIG_SILENT_CONSOLE=y
CONFIG_CONSOLE_MUX=y
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_MISC_INIT_R=y
CONFIG_BOARD_TYPES=y
CONFIG_SYS_PROMPT="ODROID-XU3 # "
@ -33,6 +35,7 @@ CONFIG_ADC=y
CONFIG_ADC_EXYNOS=y
CONFIG_DFU_MMC=y
CONFIG_MMC_DW=y
CONFIG_SYS_I2C_S3C24X0=y
CONFIG_SMC911X=y
CONFIG_SMC911X_BASE=0x5000000
CONFIG_DM_PMIC=y

View File

@ -35,6 +35,7 @@ Optional properties:
- regulator-max-microamp: a maximum allowed Current value
- regulator-always-on: regulator should never be disabled
- regulator-boot-on: enabled by bootloader/firmware
- regulator-ramp-delay: ramp delay for regulator (in uV/us)
Note
The "regulator-name" constraint is used for setting the device's uclass
@ -60,4 +61,5 @@ ldo0 {
regulator-max-microamp = <100000>;
regulator-always-on;
regulator-boot-on;
regulator-ramp-delay = <12000>;
};

View File

@ -62,7 +62,7 @@ int exynos_adc_stop(struct udevice *dev)
/* Stop conversion */
cfg = readl(&regs->con1);
cfg |= ~ADC_V2_CON1_STC_EN;
cfg &= ~ADC_V2_CON1_STC_EN;
writel(cfg, &regs->con1);

View File

@ -35,10 +35,22 @@ int regulator_get_value(struct udevice *dev)
return ops->get_value(dev);
}
static void regulator_set_value_ramp_delay(struct udevice *dev, int old_uV,
int new_uV, unsigned int ramp_delay)
{
int delay = DIV_ROUND_UP(abs(new_uV - old_uV), ramp_delay);
debug("regulator %s: delay %u us (%d uV -> %d uV)\n", dev->name, delay,
old_uV, new_uV);
udelay(delay);
}
int regulator_set_value(struct udevice *dev, int uV)
{
const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
struct dm_regulator_uclass_platdata *uc_pdata;
int ret, old_uV = uV, is_enabled = 0;
uc_pdata = dev_get_uclass_platdata(dev);
if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV)
@ -49,7 +61,20 @@ int regulator_set_value(struct udevice *dev, int uV)
if (!ops || !ops->set_value)
return -ENOSYS;
return ops->set_value(dev, uV);
if (uc_pdata->ramp_delay) {
is_enabled = regulator_get_enable(dev);
old_uV = regulator_get_value(dev);
}
ret = ops->set_value(dev, uV);
if (!ret) {
if (uc_pdata->ramp_delay && old_uV > 0 && is_enabled)
regulator_set_value_ramp_delay(dev, old_uV, uV,
uc_pdata->ramp_delay);
}
return ret;
}
/*
@ -107,6 +132,7 @@ int regulator_set_enable(struct udevice *dev, bool enable)
{
const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
struct dm_regulator_uclass_platdata *uc_pdata;
int ret, old_enable = 0;
if (!ops || !ops->set_enable)
return -ENOSYS;
@ -115,7 +141,22 @@ int regulator_set_enable(struct udevice *dev, bool enable)
if (!enable && uc_pdata->always_on)
return -EACCES;
return ops->set_enable(dev, enable);
if (uc_pdata->ramp_delay)
old_enable = regulator_get_enable(dev);
ret = ops->set_enable(dev, enable);
if (!ret) {
if (uc_pdata->ramp_delay && !old_enable && enable) {
int uV = regulator_get_value(dev);
if (uV > 0) {
regulator_set_value_ramp_delay(dev, 0, uV,
uc_pdata->ramp_delay);
}
}
}
return ret;
}
int regulator_set_enable_if_allowed(struct udevice *dev, bool enable)
@ -335,6 +376,8 @@ static int regulator_pre_probe(struct udevice *dev)
-ENODATA);
uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on");
uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on");
uc_pdata->ramp_delay = dev_read_u32_default(dev, "regulator-ramp-delay",
0);
/* Those values are optional (-ENODATA if unset) */
if ((uc_pdata->min_uV != -ENODATA) &&

View File

@ -346,6 +346,8 @@ static int s2mps11_ldo_hex2volt(int ldo, int hex)
case 11:
case 22:
case 23:
case 27:
case 35:
uV = hex * S2MPS11_LDO_STEP + S2MPS11_LDO_UV_MIN;
break;
default:
@ -366,6 +368,8 @@ static int s2mps11_ldo_volt2hex(int ldo, int uV)
case 11:
case 22:
case 23:
case 27:
case 35:
hex = (uV - S2MPS11_LDO_UV_MIN) / S2MPS11_LDO_STEP;
break;
default:
@ -547,7 +551,16 @@ static int ldo_get_enable(struct udevice *dev)
static int ldo_set_enable(struct udevice *dev, bool enable)
{
return s2mps11_ldo_enable(dev, PMIC_OP_SET, &enable);
int ret;
ret = s2mps11_ldo_enable(dev, PMIC_OP_SET, &enable);
if (ret)
return ret;
/* Wait the "enable delay" for voltage to start to rise */
udelay(15);
return 0;
}
static int ldo_get_mode(struct udevice *dev)

View File

@ -21,8 +21,6 @@
/* select serial console configuration */
#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0"
#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0"
/* DRAM Memory Banks */
#define SDRAM_BANK_SIZE (256UL << 20UL) /* 256 MB */

View File

@ -132,7 +132,7 @@
"setenv kernelname Image.itb;" \
"run loadkernel;" \
"run kernel_args;" \
"bootm ${kernel_addr_r}#${boardname}\0" \
"bootm ${kernel_addr_r}#${board_name}\0" \
"boot_uimg=" \
"setenv kernelname uImage;" \
"run check_dtb;" \

View File

@ -7,7 +7,7 @@
#ifndef __CONFIG_ODROID_XU3_H
#define __CONFIG_ODROID_XU3_H
#include "exynos5420-common.h"
#include <configs/exynos5420-common.h>
#include <configs/exynos5-common.h>
#define CONFIG_BOARD_COMMON
@ -18,7 +18,7 @@
#define TZPC_BASE_OFFSET 0x10000
#define SDRAM_BANK_SIZE (256UL << 20UL) /* 256 MB */
#define SDRAM_BANK_SIZE (256UL << 20UL) /* 256 MB */
/* Reserve the last 22 MiB for the secure firmware */
#define CONFIG_SYS_MEM_TOP_HIDE (22UL << 20UL)
#define CONFIG_TZSW_RESERVED_DRAM_SIZE CONFIG_SYS_MEM_TOP_HIDE
@ -28,7 +28,7 @@
#define CONFIG_ENV_SIZE (SZ_1K * 16)
#define CONFIG_ENV_OFFSET (SZ_1K * 3136) /* ~3 MiB offset */
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR - 0x1000000)
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR - 0x1000000)
#define CONFIG_DEFAULT_CONSOLE "console=ttySAC2,115200n8\0"
@ -38,7 +38,7 @@
/* DFU */
#define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_32M
#define DFU_DEFAULT_POLL_TIMEOUT 300
#define DFU_MANIFEST_POLL_TIMEOUT 25000
#define DFU_MANIFEST_POLL_TIMEOUT 25000
/* THOR */
#define CONFIG_G_DNL_THOR_VENDOR_NUM CONFIG_USB_GADGET_VENDOR_NUM
@ -84,12 +84,16 @@
#define CONFIG_SET_DFU_ALT_INFO
#define CONFIG_SET_DFU_ALT_BUF_LEN (SZ_1K)
/* Set soc_rev, soc_id, board_rev, boardname, fdtfile */
#define CONFIG_ODROID_REV_AIN 9
/* Set soc_rev, soc_id, board_rev, board_name, fdtfile */
#define CONFIG_ODROID_REV_AIN 9
#define CONFIG_REVISION_TAG
/*
* Need to override existing one (smdk5420) with odroid so set_board_info will
* use proper prefix when creating full board_name (SYS_BOARD + type)
*/
#undef CONFIG_SYS_BOARD
#define CONFIG_SYS_BOARD "odroid"
#define CONFIG_SYS_BOARD "odroid"
/* Define new extra env settings, including DFU settings */
#undef CONFIG_EXTRA_ENV_SETTINGS
@ -101,7 +105,7 @@
"rootfstype=ext4\0" \
"console=" CONFIG_DEFAULT_CONSOLE \
"fdtfile=exynos5422-odroidxu3.dtb\0" \
"boardname=odroidxu3\0" \
"board_name=odroidxu3\0" \
"mmcbootdev=0\0" \
"mmcrootdev=0\0" \
"mmcbootpart=1\0" \

View File

@ -150,6 +150,7 @@ enum regulator_flag {
* @always_on* - bool type, true or false
* @boot_on* - bool type, true or false
* TODO(sjg@chromium.org): Consider putting the above two into @flags
* @ramp_delay - Time to settle down after voltage change (unit: uV/us)
* @flags: - flags value (see REGULATOR_FLAG_...)
* @name** - fdt regulator name - should be taken from the device tree
* ctrl_reg: - Control register offset used to enable/disable regulator
@ -169,6 +170,7 @@ struct dm_regulator_uclass_platdata {
int max_uV;
int min_uA;
int max_uA;
unsigned int ramp_delay;
bool always_on;
bool boot_on;
const char *name;

View File

@ -33,6 +33,7 @@ char *get_dfu_alt_system(char *interface, char *devstr);
char *get_dfu_alt_boot(char *interface, char *devstr);
#endif
void set_board_type(void);
void set_board_revision(void);
const char *get_board_type(void);
#endif /* __SAMSUNG_MISC_COMMON_H__ */