From 7ca0d3dde177fa4245f4a6174c577a58c8a3051d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 10 May 2017 15:20:16 -0400 Subject: mmc: Change 'part_config' to be a u8 not char. In some places we check if part_config is set to MMCPART_NOAVAILABLE (0xff). With part_config being a char this is always false. We should be using a u8 to store this value instead, after a quick consultation with the Linux Kernel. Reported by clang-3.8. Cc: Jaehoon Chung Signed-off-by: Tom Rini diff --git a/include/mmc.h b/include/mmc.h index 8346b0e..6a0ea0a 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -430,7 +430,7 @@ struct mmc { u8 part_support; u8 part_attr; u8 wr_rel_set; - char part_config; + u8 part_config; uint tran_speed; uint read_bl_len; uint write_bl_len; -- cgit v0.10.2 From aae78fa774bf5da8d5ac0f80773283196bcb0e24 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 10 May 2017 15:20:17 -0400 Subject: drivers/power/regulator/max77686.c: Fix comparisons of unsigned expressions Inside of max77686_buck_volt2hex/max77686_buck_hex2volt/max77686_ldo_volt2hex we check that the value we calculate is >= 0 however we declare 'hex' as unsigned int making these always true. Mark these as 'int' instead. We also move hex_max to int as they are constants that are 0x3f/0xff. Given that the above functions are marked as returning an int, make the variables we assign their return value to also be int to be able to catch the error condition now. Reported by clang-3.8. Cc: Jaehoon Chung Signed-off-by: Tom Rini diff --git a/drivers/power/regulator/max77686.c b/drivers/power/regulator/max77686.c index 7479af7..5e5815f 100644 --- a/drivers/power/regulator/max77686.c +++ b/drivers/power/regulator/max77686.c @@ -71,8 +71,8 @@ static const char max77686_buck_out[] = { static int max77686_buck_volt2hex(int buck, int uV) { - unsigned int hex = 0; - unsigned int hex_max = 0; + int hex = 0; + int hex_max = 0; switch (buck) { case 2: @@ -105,7 +105,7 @@ static int max77686_buck_volt2hex(int buck, int uV) static int max77686_buck_hex2volt(int buck, int hex) { unsigned uV = 0; - unsigned int hex_max = 0; + int hex_max = 0; if (hex < 0) goto bad_hex; @@ -140,7 +140,7 @@ bad_hex: static int max77686_ldo_volt2hex(int ldo, int uV) { - unsigned int hex = 0; + int hex = 0; switch (ldo) { case 1: @@ -319,9 +319,9 @@ static int max77686_ldo_modes(int ldo, struct dm_regulator_mode **modesp, static int max77686_ldo_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; + unsigned int adr; unsigned char val; - int ldo, ret; + int hex, ldo, ret; if (op == PMIC_OP_GET) *uV = 0; @@ -360,9 +360,9 @@ static int max77686_ldo_val(struct udevice *dev, int op, int *uV) static int max77686_buck_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, mask, adr; + unsigned int mask, adr; unsigned char val; - int buck, ret; + int hex, buck, ret; buck = dev->driver_data; if (buck < 1 || buck > MAX77686_BUCK_NUM) { -- cgit v0.10.2 From f98205c7e44ad6919cc22451cf25eb216d14d25e Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Fri, 14 Apr 2017 10:10:19 +0200 Subject: mmc: meson: increase max block number per request Number of blocks is a 9 bit field where 0 stands for a unlimited number of blocks. Therefore the max number of blocks which can be set is 511. Signed-off-by: Heiner Kallweit diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index 8e28ab7..2dda1b7 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -244,7 +244,7 @@ static int meson_mmc_probe(struct udevice *dev) MMC_MODE_HS_52MHz | MMC_MODE_HS; cfg->f_min = DIV_ROUND_UP(SD_EMMC_CLKSRC_24M, CLK_MAX_DIV); cfg->f_max = 100000000; /* 100 MHz */ - cfg->b_max = 256; /* max 256 blocks */ + cfg->b_max = 511; /* max 512 - 1 blocks */ cfg->name = dev->name; mmc->priv = pdata; -- cgit v0.10.2 From 6183b29559107650cb38f905e069a93ff9da1d7d Mon Sep 17 00:00:00 2001 From: Keerthy Date: Wed, 24 May 2017 10:19:27 +0530 Subject: power: pmic: tps65218: Fix tps65218_voltage_update function Currently while setting the vsel value for dcdc1 and dcdc2 the driver is wrongly masking the entire 8 bits in the process clearing PFM (bit7) field as well. Hence describe an appropriate mask for vsel field and modify only those bits in the vsel mask. Source: http://www.ti.com/lit/ds/symlink/tps65218.pdf Signed-off-by: Keerthy Fixes: 86db550b38 ("power: Add support for the TPS65218 PMIC") Reviewed-by: Jaehoon Chung diff --git a/drivers/power/pmic/pmic_tps65218.c b/drivers/power/pmic/pmic_tps65218.c index f32fa40..c5e768a 100644 --- a/drivers/power/pmic/pmic_tps65218.c +++ b/drivers/power/pmic/pmic_tps65218.c @@ -101,7 +101,7 @@ int tps65218_voltage_update(uchar dc_cntrl_reg, uchar volt_sel) /* set voltage level */ if (tps65218_reg_write(TPS65218_PROT_LEVEL_2, dc_cntrl_reg, volt_sel, - TPS65218_MASK_ALL_BITS)) + TPS65218_DCDC_VSEL_MASK)) return 1; /* set GO bit to initiate voltage transition */ diff --git a/include/power/tps65218.h b/include/power/tps65218.h index 4d68faa..e3538e2 100644 --- a/include/power/tps65218.h +++ b/include/power/tps65218.h @@ -56,6 +56,8 @@ enum { #define TPS65218_MASK_ALL_BITS 0xFF +#define TPS65218_DCDC_VSEL_MASK 0x3F + #define TPS65218_DCDC_VOLT_SEL_0950MV 0x0a #define TPS65218_DCDC_VOLT_SEL_1100MV 0x19 #define TPS65218_DCDC_VOLT_SEL_1200MV 0x23 -- cgit v0.10.2 From f8b8a554633f61c3a3e8dde3236917372edc977f Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Tue, 16 May 2017 00:16:31 +0200 Subject: env_mmc: configure environment offsets via device tree This introduces the ability to override the environment offets from the device tree by setting the following nodes in '/config': 'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET 'u-boot,mmc-env-offset-redundant' - overrides CONFIG_ENV_OFFSET_REDUND To keep with the previous logic, the CONFIG_* defines still need to be available and the statically defined values become the defaults, when the corresponding properties are not set in the device-tree. Signed-off-by: Philipp Tomsich Acked-by: Simon Glass diff --git a/common/env_mmc.c b/common/env_mmc.c index a5d14d4..45d95a1 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -36,15 +37,37 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_ENV_OFFSET 0 #endif -__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) +#if CONFIG_IS_ENABLED(OF_CONTROL) +static inline s64 mmc_offset(int copy) { - s64 offset; + const char *propname = "u-boot,mmc-env-offset"; + s64 defvalue = CONFIG_ENV_OFFSET; - offset = CONFIG_ENV_OFFSET; -#ifdef CONFIG_ENV_OFFSET_REDUND +#if defined(CONFIG_ENV_OFFSET_REDUND) + if (copy) { + propname = "u-boot,mmc-env-offset-redundant"; + defvalue = CONFIG_ENV_OFFSET_REDUND; + } +#endif + + return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue); +} +#else +static inline s64 mmc_offset(int copy) +{ + s64 offset = CONFIG_ENV_OFFSET; + +#if defined(CONFIG_ENV_OFFSET_REDUND) if (copy) offset = CONFIG_ENV_OFFSET_REDUND; #endif + return offset; +} +#endif + +__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) +{ + s64 offset = mmc_offset(copy); if (offset < 0) offset += mmc->capacity; -- cgit v0.10.2 From de59d10cd0a4e79c85e4f791fb8f023164d0890e Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Tue, 16 May 2017 00:16:32 +0200 Subject: doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund Adding documentation on the new config properties: 'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET 'u-boot,mmc-env-offset-redundant' - overrides CONFIG_ENV_OFFSET_REDUND Signed-off-by: Philipp Tomsich Reviewed-by: Jaehoon Chung diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index d4bc1df..fe0e04a 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -21,6 +21,18 @@ u-boot,efi-partition-entries-offset This setting will override any values configured via Kconfig. +u-boot,mmc-env-offset +u-boot,mmc-env-offset-redundant + If present, the values of the 'u-boot,mmc-env-offset' and/or + of the u-boot,mmc-env-offset-redundant' properties overrides + CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND, respectively, + for SD/MMC devices. + + Values are interpreted as the offset from the start of the + device, specified in bytes. It is assumed that the setting + will point at the beginning of a LBA and values that are not + LBA-aligned will be rounded up to the next LBA address. + u-boot,spl-payload-offset If present (and SPL is controlled by the device-tree), this allows to override the CONFIG_SYS_SPI_U_BOOT_OFFS setting using a value -- cgit v0.10.2