[U-Boot] [GIT PULL V2] Please pull u-boot-mmc master

2017-07-31 Thread Jaehoon Chung
Dear Tom,

Could you pull these patches into u-boot/master?
(Have tested the buildman.)

Changelog on V2:
- Drop the Jean-Jacques's patches. After fixing it, will apply.

The following changes since commit 6364a5d4bd55beeedc11171419acd0bdff17a599:

  Prepare v2017.09-rc1 (2017-07-31 20:37:25 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-mmc.git master

for you to fetch changes up to 5c970013a661c630ab28ddc3dd6766fe6bf83ece:

  regulator: palmas: disable bypass when the LDO is enabled (2017-08-01 
11:58:01 +0900)


Jean-Jacques Hiblot (1):
  regulator: palmas: disable bypass when the LDO is enabled

Kishon Vijay Abraham I (1):
  regulator: palmas: Add support for LDO1 regulator to provide 1.8V

Simon Glass (14):
  ahci: Support non-PCI controllers
  dm: mmc: Allow disabling driver model in SPL
  fdt: Correct fdt_get_base_address()
  dm: scsi: Drop duplicate SCSI and DM_SCSI options
  dm: ahci: Correct uclass private data
  dm: mmc: sunxi: Rename struct sunxi_mmc_host to sunxi_mmc_priv
  dm: mmc: sunxi: Rename mmchost to priv
  dm: mmc: sunxi: Pass private data around explicitly
  dm: mmc: sunxi: Drop mmc_clk_io_on()
  dm: mmc: sunxi: Add support for driver model
  dm: sunxi: Linksprite_pcDuino3: Correct polarity of MMC card detect
  dm: sunxi: sata: Don't build sata support into SPL
  dm: sata: sunxi: Add support for driver model
  dm: sunxi: Move Linksprite_pcDuino3 to use DM for MMC, SATA

 arch/arm/dts/sun7i-a20-pcduino3.dts|   2 +-
 arch/x86/cpu/ivybridge/sata.c  |   2 +-
 board/sunxi/Makefile   |   2 +
 board/sunxi/ahci.c |  61 -
 common/fdt_support.c   |   7 +-
 common/spl/spl_mmc.c   |   4 +-
 configs/Linksprite_pcDuino3_defconfig  |   7 +-
 drivers/ata/Kconfig|  18 --
 drivers/ata/ahci-uclass.c  |   2 +
 drivers/ata/ahci.c |  28 ++-
 drivers/block/Kconfig  |  12 +
 drivers/block/Makefile |   4 +-
 drivers/mmc/Kconfig|  21 ++
 drivers/mmc/Makefile   |   4 +-
 drivers/mmc/mmc-uclass.c   |   6 +-
 drivers/mmc/mmc.c  |  28 +--
 drivers/mmc/mmc_legacy.c   |   2 +-
 drivers/mmc/mmc_private.h  |   6 +-
 drivers/mmc/omap_hsmmc.c   |  20 +-
 drivers/mmc/sunxi_mmc.c| 359 -
 drivers/power/palmas.c |   5 +-
 drivers/power/regulator/palmas_regulator.c |  36 +++
 drivers/scsi/scsi.c|   2 +-
 include/ahci.h |  14 +-
 include/blk.h  |   4 +-
 include/mmc.h  |  12 +-
 include/power/palmas.h |   1 +
 27 files changed, 470 insertions(+), 199 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 07/40] dm: usb: Adjust the 'usb' command to use blk_common_cmd()

2017-07-31 Thread Bin Meng
On Sun, Jul 30, 2017 at 1:34 AM, Simon Glass  wrote:
> Instead of having separate code in the 'usb' command, adjust it to use
> the common function.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2: None
>
>  cmd/usb.c | 111 
> ++
>  1 file changed, 3 insertions(+), 108 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 06/40] dm: ide: Adjust the 'ide' command to use blk_common_cmd()

2017-07-31 Thread Bin Meng
On Sun, Jul 30, 2017 at 1:34 AM, Simon Glass  wrote:
> Instead of having separate code in the 'ide' command, adjust it to use
> the common function.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2: None
>
>  cmd/ide.c | 107 
> ++
>  1 file changed, 3 insertions(+), 104 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 05/40] dm: scsi: Adjust the 'scsi' command to use blk_common_cmd()

2017-07-31 Thread Bin Meng
On Sun, Jul 30, 2017 at 1:34 AM, Simon Glass  wrote:
> Instead of having separate code in the 'scsi' command, adjust it to use
> the common function.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2: None
>
>  cmd/scsi.c | 79 
> +++---
>  1 file changed, 3 insertions(+), 76 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 04/40] dm: sata: Adjust the 'sata' command to use blk_common_cmd()

2017-07-31 Thread Bin Meng
On Sun, Jul 30, 2017 at 1:34 AM, Simon Glass  wrote:
> Instead of having separate code in the 'sata' command, adjust it to use
> the common function.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2: None
>
>  cmd/sata.c | 83 
> +-
>  1 file changed, 1 insertion(+), 82 deletions(-)
>

Reviewed-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 03/40] dm: blk: Add a generic function for block device commands

2017-07-31 Thread Bin Meng
Hi Simon,

On Sun, Jul 30, 2017 at 1:34 AM, Simon Glass  wrote:
> Most block devices provide a command (e.g. 'sata', 'scsi', 'ide') and
> these commands generally do the same thing. This makes it harder to
> maintain this code and keep it consistent.
>
> We now have a block device interface which is either implemented by driver
> model (when CONFIG_BLK is enabled) or with a legacy interface. Therefore
> it is possible to handle most of what these commands do with generic code.
>
> Add a new generic function to process block-device commands using the
> interface type and the current device number for that type.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2: None
>
>  cmd/Makefile |   1 +
>  cmd/blk_common.c | 104 
> +++
>  include/blk.h|  12 +++
>  3 files changed, 117 insertions(+)
>  create mode 100644 cmd/blk_common.c
>
> diff --git a/cmd/Makefile b/cmd/Makefile
> index bd231f24d8..e2b3a9cc71 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -15,6 +15,7 @@ obj-y += version.o
>  # command
>  obj-$(CONFIG_CMD_AES) += aes.o
>  obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
> +obj-y += blk_common.o
>  obj-$(CONFIG_SOURCE) += source.o
>  obj-$(CONFIG_CMD_SOURCE) += source.o
>  obj-$(CONFIG_CMD_BDI) += bdinfo.o
> diff --git a/cmd/blk_common.c b/cmd/blk_common.c
> new file mode 100644
> index 00..86c75e78d8
> --- /dev/null
> +++ b/cmd/blk_common.c
> @@ -0,0 +1,104 @@
> +/*
> + * Handling of common block commands
> + *
> + * Copyright (c) 2017 Google, Inc
> + *
> + * (C) Copyright 2000-2011
> + * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +
> +#ifdef HAVE_BLOCK_DEVICE
> +int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
> +  int *cur_devnump)
> +{
> +   const char *if_name = blk_get_if_type_name(if_type);
> +
> +   switch (argc) {
> +   case 0:
> +   case 1:
> +   return CMD_RET_USAGE;
> +   case 2:
> +   if (strncmp(argv[1], "inf", 3) == 0) {
> +   blk_list_devices(if_type);
> +   return 0;
> +   } else if (strncmp(argv[1], "dev", 3) == 0) {
> +   if (blk_print_device_num(if_type, *cur_devnump)) {
> +   printf("\nno %s devices available\n", 
> if_name);
> +   return CMD_RET_FAILURE;
> +   }
> +   return 0;
> +   } else if (strncmp(argv[1], "part", 4) == 0) {
> +   if (blk_list_part(if_type))
> +   printf("\nno %s devices available\n", 
> if_name);
> +   return 0;
> +   }
> +   return CMD_RET_USAGE;
> +   case 3:
> +   if (strncmp(argv[1], "dev", 3) == 0) {
> +   int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> +   if (!blk_show_device(if_type, dev)) {
> +   *cur_devnump = dev;
> +   printf("... is now current device\n");
> +   } else {
> +   return CMD_RET_FAILURE;
> +   }
> +   return 0;
> +   } else if (strncmp(argv[1], "part", 4) == 0) {
> +   int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> +   if (blk_print_part_devnum(if_type, dev)) {
> +   printf("\n%s device %d not available\n",
> +  if_name, dev);
> +   return CMD_RET_FAILURE;
> +   }
> +   return 0;
> +   }
> +   return CMD_RET_USAGE;
> +
> +   default: /* at least 4 args */
> +   if (strcmp(argv[1], "read") == 0) {
> +   ulong addr = simple_strtoul(argv[2], NULL, 16);
> +   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
> +   ulong cnt = simple_strtoul(argv[4], NULL, 16);
> +   ulong n;
> +
> +   printf("\n%s read: device %d block # %lld, count %ld 
> ... ",
> +  if_name, *cur_devnump, (unsigned long long)blk,
> +  cnt);

Please use LBAFU for parameter blk, to handle both 32-bit and 64-bit LBA.

> +
> +   n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
> +   (ulong *)addr);
> +
> +   printf("%ld blocks read: %s\n", n,
> +  n == cnt ? "OK" : "ERROR");
> +   return n == cnt ? 0 : 1;
> +   } else if (strcmp(argv[1], "write") == 0) {
> +   

Re: [U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-07-31 Thread Jaehoon Chung
Dear JJ,

On 07/19/2017 10:52 PM, Jean-Jacques Hiblot wrote:
> In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
> IO cells. Without this bias voltage these I/O cells can not function
> properly. The PBIAS cell is controlled by software.
> 
> Signed-off-by: Jean-Jacques Hiblot 
> Reviewed-by: Tom Rini 
> Reviewed-by: Simon Glass 
> ---
> 
> changes since v1:
>  - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
>MMC_OMAP_HS are set
>  - use the dev_read_*() API to access the DT
> 
>  drivers/mmc/Kconfig   |   1 +
>  drivers/power/regulator/Kconfig   |  10 +
>  drivers/power/regulator/Makefile  |   1 +
>  drivers/power/regulator/pbias_regulator.c | 302 
> ++
>  4 files changed, 314 insertions(+)
>  create mode 100644 drivers/power/regulator/pbias_regulator.c
> 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index 588e118..63e1122 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -158,6 +158,7 @@ config MMC_PCI
>  config MMC_OMAP_HS
>   bool "TI OMAP High Speed Multimedia Card Interface support"
>   select DM_MMC_OPS if DM_MMC
> + select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
>   help
> This selects the TI OMAP High Speed Multimedia card Interface.
> If you have an omap2plus board with a Multimedia Card slot,
> diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
> index f213487..f4ed3cc 100644
> --- a/drivers/power/regulator/Kconfig
> +++ b/drivers/power/regulator/Kconfig
> @@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
>   features for REGULATOR PALMAS and the family of PALMAS PMICs.
>   The driver implements get/set api for: value and enable.
>  
> +config DM_REGULATOR_PBIAS
> + bool "Enable driver for PBIAS regulator"

pbias_regulator is using the regmap and syscon..
I think that i needs to select REGMAP and SYSCON at here.

So i dropped the your patch from my repository.
Could you resend the patch? otherwise i will resend your patch after fixing.
let me know what you want.

Best Regards,
Jaehoon Chung

> + ---help---
> + This enables implementation of driver-model regulator uclass
> + features for pseudo-regulator PBIAS found in the OMAP SOCs.
> + This pseudo-regulator is used to provide a BIAS voltage to MMC1
> + signal pads and must be configured properly during a voltage switch.
> + Voltage switching is required by some operating modes of SDcards and
> + eMMC.
> +
>  config DM_REGULATOR_LP873X
>   bool "Enable driver for LP873X PMIC regulators"
>  depends on PMIC_LP873X
> diff --git a/drivers/power/regulator/Makefile 
> b/drivers/power/regulator/Makefile
> index ce14d08..75d611a 100644
> --- a/drivers/power/regulator/Makefile
> +++ b/drivers/power/regulator/Makefile
> @@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
>  obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
>  obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
> +obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
> diff --git a/drivers/power/regulator/pbias_regulator.c 
> b/drivers/power/regulator/pbias_regulator.c
> new file mode 100644
> index 000..303eca9
> --- /dev/null
> +++ b/drivers/power/regulator/pbias_regulator.c
> @@ -0,0 +1,302 @@
> +/*
> + * (C) Copyright 2016 Texas Instruments Incorporated, 
> + * Jean-Jacques Hiblot 
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct pbias_reg_info {
> + u32 enable;
> + u32 enable_mask;
> + u32 disable_val;
> + u32 vmode;
> + unsigned int enable_time;
> + char *name;
> +};
> +
> +struct pbias_priv {
> + struct regmap *regmap;
> + int offset;
> +};
> +
> +static const struct pmic_child_info pmic_children_info[] = {
> + { .prefix = "pbias", .driver = "pbias_regulator"},
> + { },
> +};
> +
> +static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
> +   int len)
> +{
> + struct pbias_priv *priv = dev_get_priv(dev);
> + uint32_t val = *(uint32_t *)buff;
> +
> + if (len != 4)
> + return -EINVAL;
> +
> + return regmap_write(priv->regmap, priv->offset, val);
> +}
> +
> +static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
> +{
> + struct pbias_priv *priv = dev_get_priv(dev);
> +
> + if (len != 4)
> + return -EINVAL;
> +
> + return regmap_read(priv->regmap, priv->offset, (uint32_t *)buff);
> +}
> +
> +static int 

[U-Boot] [PATCH] mtd/spi: Add MT35XU512ABA1G12 NOR flash support

2017-07-31 Thread Yogesh Gaur
Add MT35XU512ABA1G12 parameters to NOR flash parameters array. Since the
manufactory ID is changed to 0x2C, add it for micron and using it for
relevant settings.

The MT35XU512ABA1G12 only supports 1 bit mode and 8 bits. It can't support
dual and quad. Supports subsector erase with 4KB granularity, have support
of FSR(flag status register) and flash size is 64MB.
---
 drivers/mtd/spi/sf_internal.h   | 1 +
 drivers/mtd/spi/spi_flash.c | 2 ++
 drivers/mtd/spi/spi_flash_ids.c | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 839cdbe..f46cb3a 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -33,6 +33,7 @@ enum spi_nor_option_flags {
 /* CFI Manufacture ID's */
 #define SPI_FLASH_CFI_MFR_SPANSION 0x01
 #define SPI_FLASH_CFI_MFR_STMICRO  0x20
+#define SPI_FLASH_CFI_MFR_MICRON   0x2C
 #define SPI_FLASH_CFI_MFR_MACRONIX 0xc2
 #define SPI_FLASH_CFI_MFR_SST  0xbf
 #define SPI_FLASH_CFI_MFR_WINBOND  0xef
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 0034a28..23b8adf 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -903,6 +903,7 @@ static int set_quad_mode(struct spi_flash *flash,
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO
case SPI_FLASH_CFI_MFR_STMICRO:
+   case SPI_FLASH_CFI_MFR_MICRON:
debug("SF: QEB is volatile for %02x flash\n", JEDEC_MFR(info));
return 0;
 #endif
@@ -976,6 +977,7 @@ int spi_flash_scan(struct spi_flash *flash)
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
/* NOR protection support for STmicro/Micron chips and similar */
if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_STMICRO ||
+   JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_MICRON ||
JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) {
flash->flash_lock = stm_lock;
flash->flash_unlock = stm_unlock;
diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
index edca94e..f144cc3 100644
--- a/drivers/mtd/spi/spi_flash_ids.c
+++ b/drivers/mtd/spi/spi_flash_ids.c
@@ -133,6 +133,7 @@ const struct spi_flash_info spi_flash_ids[] = {
{"n25q1024a",  INFO(0x20bb21, 0x0,  64 * 1024,  2048, RD_FULL | 
WR_QPP | E_FSR | SECT_4K) },
{"mt25qu02g",  INFO(0x20bb22, 0x0,  64 * 1024,  4096, RD_FULL | 
WR_QPP | E_FSR | SECT_4K) },
{"mt25ql02g",  INFO(0x20ba22, 0x0,  64 * 1024,  4096, RD_FULL | 
WR_QPP | E_FSR | SECT_4K) },
+   {"mt35xu512g", INFO6(0x2c5b1a, 0x104100,  128 * 1024,  512, E_FSR | 
SECT_4K) },
 #endif
 #ifdef CONFIG_SPI_FLASH_SST/* SST */
{"sst25vf040b",INFO(0xbf258d, 0x0,  64 * 1024, 8, SECT_4K | 
SST_WR) },
-- 
1.9.1


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [GIT PULL] Please pull u-boot-mmc master

2017-07-31 Thread Jaehoon Chung
Dear Tom,

On 07/31/2017 08:27 PM, Tom Rini wrote:
> On Mon, Jul 31, 2017 at 11:59:07AM +0900, Jaehoon Chung wrote:
> 
>> Dear Tom,
>>
>> Could you pull these patches into u-boot/master?
>>
>> The following changes since commit 55f228b07e2d84938a88737445441e736de41340:
>>
>>   x86: minnowmax: Remove CONFIG_SMSC_LPC47M (2017-07-30 10:30:25 +0800)
>>
>> are available in the git repository at:
>>
>>   git://git.denx.de/u-boot-mmc.git master
>>
>> for you to fetch changes up to 9b32160db8264d32f5b0640412c9cb1b882c1d6e:
>>
>>   dm: syscon: scan sub-nodes of the syscon node (2017-07-31 11:49:18 +0900)
>>
> 
> This fails with at least:
>arm:  +   am57xx_hs_evm
> +(am57xx_hs_evm) drivers/power/regulator/built-in.o: In function 
> `pbias_write':
> +(am57xx_hs_evm) build/../drivers/power/regulator/pbias_regulator.c:49: 
> undefined reference to `regmap_write'
> +(am57xx_hs_evm) drivers/power/regulator/built-in.o: In function `pbias_read':
> +(am57xx_hs_evm) build/../drivers/power/regulator/pbias_regulator.c:59: 
> undefined reference to `regmap_read'
> +(am57xx_hs_evm) drivers/power/regulator/built-in.o: In function 
> `pbias_ofdata_to_platdata':
> +(am57xx_hs_evm) build/../drivers/power/regulator/pbias_regulator.c:78: 
> undefined reference to `syscon_get_regmap'
> +(am57xx_hs_evm) arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Debian) 
> 2.28 assertion fail ../../bfd/elf32-arm.c:9514
> +(am57xx_hs_evm) make[1]: *** [u-boot] Error 1
> +(am57xx_hs_evm) make: *** [sub-make] Error 2

after fixing it, resend the PR. Sorry for bothering you.

> 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] rockchip: rk3399-firefly: update gmac parameter

2017-07-31 Thread Kever Yang
Update the tx_deday and rx_delay to match the timing for
rk3399-firefly board to improve the stability of gmac data
transfer.

Signed-off-by: Kever Yang 
---

 arch/arm/dts/rk3399-firefly.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/rk3399-firefly.dts b/arch/arm/dts/rk3399-firefly.dts
index 3d3f507..31e3ba8 100644
--- a/arch/arm/dts/rk3399-firefly.dts
+++ b/arch/arm/dts/rk3399-firefly.dts
@@ -211,8 +211,8 @@
snps,reset-gpio = < RK_PB7 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
snps,reset-delays-us = <0 1 5>;
-   tx_delay = <0x28>;
-   rx_delay = <0x11>;
+   tx_delay = <0x33>;
+   rx_delay = <0x45>;
status = "okay";
 };
 
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2, 07/14] Convert CONFIG_CMD_REGINFO to Kconfig

2017-07-31 Thread Tom Rini
On Mon, Jul 31, 2017 at 06:13:03PM +0200, Christophe LEROY wrote:
> 
> 
> Le 25/07/2017 à 02:44, Tom Rini a écrit :
> >On Thu, Jul 13, 2017 at 03:09:56PM +0200, Christophe Leroy wrote:
> >
> >>This patch converts CONFIG_CMD_REGINFO to Kconfig
> >>
> >>Signed-off-by: Christophe Leroy 
> >
> >Applied to u-boot/master, thanks!
> >
> 
> Hi Tom,
> 
> It looks like this patch hasn't been applied to u-boot/master yes, has it ?

Good spotting, sorry about that.  I think it got lost a bit somewhere in
that when I was doing the conversion I found a handful of non-PowerPC
platforms enabled it.  I'll things up on top of what's in now via
Simon's conversion.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 50/66] rockchip: rk3368: add DRAM controller driver with DRAM initialisation

2017-07-31 Thread Andy Yan

add Tony from our dram team, maybe he has  some ideas for this patch.


On 2017年07月29日 03:22, Philipp Tomsich wrote:

This adds a DRAM controller driver for the RK3368 and places it in
drivers/ram/rockchip (where the other DM-enabled DRAM controller
drivers for rockchip devices should also be moved eventually).

At this stage, only the following feature-set is supported:
  - DDR3
  - 32-bit configuration (i.e. fully populated)
  - dual-rank (i.e. no auto-detection of ranks)
  - DDR3-1600K speed-bin

This driver expects to run from a TPL stage that will later return to
the RK3368 BROM.  It communicates with later stages through the
os_reg2 in the pmugrf (i.e. using the same mechanism as Rockchip's DDR
init code).

Unlike other DMC drivers for RK32xx and RK33xx parts, the required
timings are calculated within the driver based on a target frequency
and a DDR3 speed-bin (only the DDR3-1600K speed-bin is support at this
time).

The RK3368 also has the DDRC0_CON0 (DDR ch. 0, control-register 0)
register for controlling the operation of its (single-channel) DRAM
controller in the GRF block.  This provides for selecting DDR3, mobile
DDR modes, and control low-power operation.
As part of this change, DDRC0_CON0 is also added to the GRF structure
definition (at offset 0x600).

Signed-off-by: Philipp Tomsich 

Reviewed-by: Simon Glass 
---

Changes in v3:
- correctly states the location of the driver in the commit message

Changes in v2: None

  arch/arm/include/asm/arch-rockchip/ddr_rk3368.h| 187 
  arch/arm/include/asm/arch-rockchip/grf_rk3368.h|   3 +
  arch/arm/mach-rockchip/rk3368/Makefile |   1 -
  arch/arm/mach-rockchip/rk3368/sdram_rk3368.c   |  60 --
  .../clock/rockchip,rk3368-dmc.txt  |  67 ++
  drivers/ram/Makefile   |   2 +
  drivers/ram/rockchip/Makefile  |   7 +
  drivers/ram/rockchip/dmc-rk3368.c  | 990 +
  include/dt-bindings/memory/rk3368-dmc.h|  30 +
  9 files changed, 1286 insertions(+), 61 deletions(-)
  create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
  delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
  create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
  create mode 100644 drivers/ram/rockchip/Makefile
  create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
  create mode 100644 include/dt-bindings/memory/rk3368-dmc.h

diff --git a/arch/arm/include/asm/arch-rockchip/ddr_rk3368.h 
b/arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
new file mode 100644
index 000..4e2b233
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
@@ -0,0 +1,187 @@
+/*
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+
+#ifndef __ASM_ARCH_DDR_RK3368_H__
+#define __ASM_ARCH_DDR_RK3368_H__
+
+/*
+ * The RK3368 DDR PCTL differs from the incarnation in the RK3288 only
+ * in a few details. Most notably, it has an additional field to track
+ * tREFI in controller cycles (i.e. trefi_mem_ddr3).
+ */
+struct rk3368_ddr_pctl {
+   u32 scfg;
+   u32 sctl;
+   u32 stat;
+   u32 intrstat;
+   u32 reserved0[12];
+   u32 mcmd;
+   u32 powctl;
+   u32 powstat;
+   u32 cmdtstat;
+   u32 cmdtstaten;
+   u32 reserved1[3];
+   u32 mrrcfg0;
+   u32 mrrstat0;
+   u32 mrrstat1;
+   u32 reserved2[4];
+   u32 mcfg1;
+   u32 mcfg;
+   u32 ppcfg;
+   u32 mstat;
+   u32 lpddr2zqcfg;
+   u32 reserved3;
+   u32 dtupdes;
+   u32 dtuna;
+   u32 dtune;
+   u32 dtuprd0;
+   u32 dtuprd1;
+   u32 dtuprd2;
+   u32 dtuprd3;
+   u32 dtuawdt;
+   u32 reserved4[3];
+   u32 togcnt1u;
+   u32 tinit;
+   u32 trsth;
+   u32 togcnt100n;
+   u32 trefi;
+   u32 tmrd;
+   u32 trfc;
+   u32 trp;
+   u32 trtw;
+   u32 tal;
+   u32 tcl;
+   u32 tcwl;
+   u32 tras;
+   u32 trc;
+   u32 trcd;
+   u32 trrd;
+   u32 trtp;
+   u32 twr;
+   u32 twtr;
+   u32 texsr;
+   u32 txp;
+   u32 txpdll;
+   u32 tzqcs;
+   u32 tzqcsi;
+   u32 tdqs;
+   u32 tcksre;
+   u32 tcksrx;
+   u32 tcke;
+   u32 tmod;
+   u32 trstl;
+   u32 tzqcl;
+   u32 tmrr;
+   u32 tckesr;
+   u32 tdpd;
+   u32 trefi_mem_ddr3;
+   u32 reserved5[45];
+   u32 dtuwactl;
+   u32 dturactl;
+   u32 dtucfg;
+   u32 dtuectl;
+   u32 dtuwd0;
+   u32 dtuwd1;
+   u32 dtuwd2;
+   u32 dtuwd3;
+   u32 dtuwdm;
+   u32 dturd0;
+   u32 dturd1;
+   u32 dturd2;
+   u32 dturd3;
+   u32 dtulfsrwd;
+   u32 dtulfsrrd;
+   u32 dtueaf;
+   u32 dfitctrldelay;
+   u32 dfiodtcfg;
+   u32 dfiodtcfg1;
+   u32 dfiodtrankmap;
+   u32 dfitphywrdata;
+   u32 

Re: [U-Boot] [U-Boot, 2/3] console: Unify the check for a serial console

2017-07-31 Thread Tom Rini
On Thu, Jul 27, 2017 at 09:31:03AM -0600, Simon Glass wrote:

> Put the check for whether a console is a serial device in a function so
> that we can share the code in the two places that use it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] env: Migrate CONFIG_ENV_IS_IN_FAT options to Kconfig

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 09:48:00PM -0400, Tom Rini wrote:

> We rename the various FAT_ENV_xxx options to CONFIG_ENV_FAT_xxx so that
> they can be modified via Kconfig.  Migrate all existing users to the new
> values.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 3/3] dm: console: Check for serial devices properly

2017-07-31 Thread Tom Rini
On Thu, Jul 27, 2017 at 09:31:04AM -0600, Simon Glass wrote:

> With driver model the serial device is often not called "serial". Mark
> driver-model stdio devices so that they can be detected and we can look up
> the uclass. This is a more reliable way of finding out whether the console
> is connected to a serial device or not.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [ANN] U-Boot v2017.09-rc1 released

2017-07-31 Thread Tom Rini
Hey all,

So it's release day and I've put up v2017.09-rc1.  The merge window is
now closed and I've updated git and the tarballs are also up now.

I think my patch queue is in reasonable shape currently, but I need to
pick up some of the environment stuff Simon has been doing after it's
reviewed a little more, and I'm sure I'm forgetting about a few other
things.  The MMC PR (which contains a lot of things we do want in), I
expect to be re-issued shortly and I'll be taking that in as well.

Thanks all!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,PATCHv2] configs: Migrate CMD_NAND*

2017-07-31 Thread Tom Rini
On Fri, Jul 28, 2017 at 09:31:42PM -0400, Tom Rini wrote:

> Migrate all remaining instances of CMD_NAND, CMD_NAND_TRIMFFS
> CMD_NAND_LOCK_UNLOCK and CMD_NAND_TORTURE from the headers into the
> defconfig files.
> 
> Tested-by: Adam Ford 
> Signed-off-by: Tom Rini 
> Reviewed-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] arm: mach-omap2: Align image address before cache operations

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 02:53:19PM -0500, Andrew F. Davis wrote:

> The image address passed to secure_boot_verify_image() may not be
> cacheline aligned, round the address down to the nearest cacheline.
> 
> Signed-off-by: Andrew F. Davis 
> Reviewed-by: Lokesh Vutla 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/3] am335x_hs_evm: Disable CONFIG_SPL_ENV_SUPPORT

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 01:11:36PM -0400, Tom Rini wrote:

> The main uses of CONFIG_SPL_ENV_SUPPORT are for network support and for
> disabling "Falcon Mode" support at run-time.  As this build enables
> neither, remove this feature.
> 
> Cc: Andrew F. Davis 
> Signed-off-by: Tom Rini 
> Reviewed-by: Lokesh Vutla 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 3/3] ti: Default to ENV_IS_IN_FAT if MMC_OMAP_HS

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 01:11:37PM -0400, Tom Rini wrote:

> When we have MMC available we assume that we want to put the env as a
> file on FAT.
> 
> Cc: Lokesh Vutla 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Remove unused CONFIG_TWL4030_PWM

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 10:04:40AM -0500, Adam Ford wrote:

> CONFIG_TWL4030_PWM is not being used by any source, so let's remove the 
> #define
> and the whitelist entry
> 
> Signed-off-by: Adam Ford 
> Reviewed-by: Tom Rini 
> 
> diff --git a/include/configs/omap3_logic.h b/include/configs/omap3_logic.h
> index 60d1f88..51187c6 100644

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/1] serial: stm32x7: Convert CONFIG_STM32X7_SERIAL to Kconfig

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 03:48:39PM +0200, Patrice Chotard wrote:

> From: Patrice Chotard 
> 
> Add CONFIG_STM32X7_SERIAL as a Kconfig option.
> 
> Signed-off-by: Patrice Chotard 
> Reviewed-by: Vikas Manocha 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] dm: Kconfig: fix typo in help for SPL_PINCTRL

2017-07-31 Thread Tom Rini
On Wed, Jul 26, 2017 at 12:27:42PM +0200, Philipp Tomsich wrote:

> Changes 'controlloers' to 'controllers' in the help-text for
> SPL_PINCTRL.
> 
> Signed-off-by: Philipp Tomsich 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mkimage: check environment for dtc binary location

2017-07-31 Thread Hauke Mehrtens
On 07/31/2017 04:45 PM, Simon Glass wrote:
> Hi,
> 
> On 19 July 2017 at 14:30, Hauke Mehrtens  wrote:
>> Currently mkimage assumes the dtc binary is in the path and fails
>> otherwise. This patch makes it check the DTC environment variable first
>> for the dtc binary and then fall back to the default path. This makes
>> it possible to call the u-boot build with make DTC=... and build a fit
>> image with the dtc binary not being the the default path.
>>
>> Signed-off-by: Hauke Mehrtens 
>> Cc: Simon Glass 
>> ---
>>  tools/fit_image.c | 7 ++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/fit_image.c b/tools/fit_image.c
>> index 4dc8bd8862..d7a7b07faf 100644
>> --- a/tools/fit_image.c
>> +++ b/tools/fit_image.c
>> @@ -647,9 +647,14 @@ static int fit_handle_file(struct image_tool_params 
>> *params)
>> }
>> *cmd = '\0';
>> } else if (params->datafile) {
>> +   const char* dtc = getenv("DTC");
>> +
>> +   if (!dtc)
>> +   dtc = MKIMAGE_DTC;
>> +
>> /* dtc -I dts -O dtb -p 500 datafile > tmpfile */
>> snprintf(cmd, sizeof(cmd), "%s %s %s > %s",
>> -MKIMAGE_DTC, params->dtc, params->datafile, 
>> tmpfile);
>> +dtc, params->dtc, params->datafile, tmpfile);
>> debug("Trying to execute \"%s\"\n", cmd);
>> } else {
>> snprintf(cmd, sizeof(cmd), "cp %s %s",
>> --
>> 2.11.0
>>
> 
> Reviewed-by: Simon Glass 
> 
> But please can you add mention of this to the help (mkimage.1)
> 
> Regards,
> Simon

Hi Simon,

where should I add the description?

Somewhere in the OPTIONS list or under DESCRIPTION -> FIT?

Hauke
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] armv7m: mpu_config add missing break

2017-07-31 Thread Vikas Manocha
Hi,

On 07/30/2017 11:34 AM, Heinrich Schuchardt wrote:
> For DEVICE_NON_SHARED the newly assigned value of attr
> is overwritten due to a missing break.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt 

reviewed-by : Vikas Manocha 

Cheers,
Vikas

> ---
>  arch/arm/cpu/armv7m/mpu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/cpu/armv7m/mpu.c b/arch/arm/cpu/armv7m/mpu.c
> index 31a243b49a..4622aa4826 100644
> --- a/arch/arm/cpu/armv7m/mpu.c
> +++ b/arch/arm/cpu/armv7m/mpu.c
> @@ -68,6 +68,7 @@ void mpu_config(struct mpu_region_config *reg_config)
>   break;
>   case DEVICE_NON_SHARED:
>   attr = (2 << TEX_SHIFT) | BUFFERABLE;
> + break;
>   default:
>   attr = 0; /* strongly ordered */
>   break;
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] compilation failure on Powerpc with SPL

2017-07-31 Thread York Sun
On 07/26/2017 12:45 AM, Ashish Kumar wrote:
> Hello York,
> 
> Thanks for the help. Issue is not observed with toolchain gcc-4.9,
> 
> Could you please help understand why this is compiler dependent?
> 

Ashish,

To understand your issue, please post the complete log for the error. We 
need to see what has failed. You may be using an old toolchain from 
internal SDK, which requires you to set the lib path otherwise you 
wouldn't be able to link gcc libraries.

York
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 2/2] MIPS: Stop building position independent code

2017-07-31 Thread Paul Burton
On Monday, 31 July 2017 03:52:57 PDT Daniel Schwierzeck wrote:
> 2017-07-30 18:04 GMT+02:00 Álvaro Fernández Rojas :
> > El 30/07/2017 a las 16:05, Daniel Schwierzeck escribió:
> >> Am 30.07.2017 um 14:27 schrieb Álvaro Fernández Rojas:
> >>> I've been a bit busy lately and I couldn't test this until now, but I
> >>> have to say that this commit breaks u-boot bmips support :(
> >>> 
> >>> BTW, I tried this on several bmips boards (one of them is a Netgear
> >>> CG3100D, which uses u-boot.bin instead of u-boot.elf)
> >>> 
> >>> Do you have any idea on what could be hapenning?
> >> 
> >> maybe you need to specify "--emit-relocs" too when linking u-boot.elf
> >> from u-boot-elf.o. But u-boot-elf.o should already contain the correct
> >> .reloc section with the updated relocation entries so you don't need to
> >> rerun the reloc-tool on u-boot.elf.
> > 
> > I tried that and it doesn't work.
> > However, I've just found out that if I remove the relocs call it boots
> > again... https://gist.github.com/Noltari/ce3a6a9dda69e74caf7ba33c9c8ade9a
> 
> I wonder how this can work. Even the u-boot.elf now contains
> position-dependent code so that an update of the relocation entries is
> required there too. Without the updated entries, U-Boot can't execute
> after jumping from relocate_code() to board_init_r(). Did you use a
> clean build if U-Boot?

Indeed - without the .rel section being generated by the mips-relocs tool I'd 
expect relocate_code() to either apply some bogus relocations or none at all 
(depending what's in the memory starting from __rel_start) and then, if it 
gets there at all, for the "relocated" U-Boot to fall over pretty quickly.

Fernandez - I don't suppose you're aware of an emulated version of any of the 
supported bmips systems? That would be an easy way for me to take a look. FYI 
the systems I use most (Boston & Malta) also use u-boot.bin or derivatives 
thereof & I'm sure the .rel section is copied across to it, so I doubt it has 
anything to do with binary formats.

Thanks,
Paul

signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] board/freescale: Share qbman init between archs

2017-07-31 Thread York Sun
On 05/12/2017 01:30 PM, Roy Pledge wrote:
> From: Ahmed Mansour 
> 
> This patch adds changes necessary to move functionality present in
> PowerPC folders with ARM architectures that have DPAA1 QBMan hardware
> 
> - Created new board/freescale/common/portals.c to house shared device
>tree fixups for DPAA1 devices with ARM and PowerPC cores
> - Added new header file to top includes directory to allow files in
>both architectures to grab the function prototypes
> - Port inhibit_portals() from PowerPC to ARM. This function is used in
>setup to disable interrupts on all QMan and BMan portals. It is
>needed because the interrupts are enabled by default for all portals
>including unused/uninitialised portals. When the kernel attempts to
>go to deep sleep the unused portals prevent it from doing so
> 
> Signed-off-by: Ahmed Mansour 
> Signed-off-by: Roy Pledge 
> ---
>   arch/arm/cpu/armv8/fsl-layerscape/cpu.c|   7 +
>   arch/arm/cpu/armv8/fsl-layerscape/fdt.c|  15 +
>   .../arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c |   3 +
>   .../include/asm/arch-fsl-layerscape/immap_lsch2.h  |  29 ++
>   arch/powerpc/cpu/mpc85xx/cpu_init.c|   3 +-
>   arch/powerpc/cpu/mpc85xx/fdt.c |   1 +
>   arch/powerpc/cpu/mpc85xx/portals.c | 281 ---
>   arch/powerpc/include/asm/fsl_liodn.h   |   5 +-
>   arch/powerpc/include/asm/fsl_portals.h |   4 -
>   arch/powerpc/include/asm/immap_85xx.h  |  60 
>   board/freescale/common/Makefile|   2 +
>   board/freescale/common/portals.c   | 312 
> +
>   include/configs/ls1043a_common.h   |   2 +
>   include/fsl_qbman.h|  75 +
>   14 files changed, 451 insertions(+), 348 deletions(-)
>   create mode 100644 board/freescale/common/portals.c
>   create mode 100644 include/fsl_qbman.h
> 

Roy,

Compiling all 85xx found two issues. One is setup_portals(), called by 
P1023RDB and Cyrus boards directly. The other issue is the 
board/freescale/common is not compiled for other than Freescale boards 
for obvious reason. However, several boards have 85xx SoCs with QBMan 
portal. They are kmlion1,Cyrus_P5040,Cyrus_P5020,kmcoge4. Please check 
how to make them happy.

York
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2, 07/14] Convert CONFIG_CMD_REGINFO to Kconfig

2017-07-31 Thread Christophe LEROY



Le 25/07/2017 à 02:44, Tom Rini a écrit :

On Thu, Jul 13, 2017 at 03:09:56PM +0200, Christophe Leroy wrote:


This patch converts CONFIG_CMD_REGINFO to Kconfig

Signed-off-by: Christophe Leroy 


Applied to u-boot/master, thanks!



Hi Tom,

It looks like this patch hasn't been applied to u-boot/master yes, has it ?

Christophe
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/3] ARM: k2g: Add FIT image handler for PMMC firmware

2017-07-31 Thread Andrew F. Davis
The PMMC firmware should be bundled into a FIT image on HS
devices to allow authentication/decryption, add a handler to
process this PMMC firmware.

Signed-off-by: Andrew F. Davis 
---
 board/ti/ks2_evm/board_k2g.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 21605762ef..d4d582cb85 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "mux-k2g.h"
 #include "../common/board_detect.h"
 
@@ -353,3 +354,23 @@ int get_num_eth_ports(void)
return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
 }
 #endif
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+void board_pmmc_image_process(ulong pmmc_image, size_t pmmc_size)
+{
+   int id = getenv_ulong("dev_pmmc", 10, 0);
+   int ret;
+
+   if (!rproc_is_initialized())
+   rproc_init();
+
+   ret = rproc_load(id, pmmc_image, pmmc_size);
+   printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
+  id, pmmc_image, pmmc_size, ret ? " Failed!" : " Success!");
+
+   if (!ret)
+   rproc_start(id);
+}
+
+U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_PMMC, board_pmmc_image_process);
+#endif
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/3] configs: k2g_evm: Remove PMMC loading environment commands

2017-07-31 Thread Andrew F. Davis
The PMMC firmware should be bundled with the FIT image for HS devices,
remove the steps that load and install this firmware outside of FIT.

Signed-off-by: Andrew F. Davis 
---
 include/configs/k2g_evm.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h
index 1117e5e5dd..9117cda24c 100644
--- a/include/configs/k2g_evm.h
+++ b/include/configs/k2g_evm.h
@@ -69,7 +69,6 @@
"run envboot; " \
"run run_mon_hs; "  \
"run init_${boot}; "\
-   "run set_name_pmmc get_pmmc_${boot} run_pmmc; " \
"run get_fit_${boot}; " \
"bootm ${fit_loadaddr}#${name_fdt}"
 #endif
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/3] image: Add TI PMMC image type

2017-07-31 Thread Andrew F. Davis
Add a new image type representing TI Power Management
Micro-Controller (PMMC) Firmware image type.

Signed-off-by: Andrew F. Davis 
---
 common/image.c  | 1 +
 include/image.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/common/image.c b/common/image.c
index 0f88984f2d..1f6885cb85 100644
--- a/common/image.c
+++ b/common/image.c
@@ -167,6 +167,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_FPGA,   "fpga",   "FPGA Image" },
{   IH_TYPE_TEE,"tee","Trusted Execution 
Environment Image",},
{   IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" 
},
+   {   IH_TYPE_PMMC,"pmmc","TI Power Management 
Micro-Controller Firmware",},
{   -1, "",   "",   },
 };
 
diff --git a/include/image.h b/include/image.h
index c6f1513220..a251faf8e3 100644
--- a/include/image.h
+++ b/include/image.h
@@ -269,6 +269,7 @@ enum {
IH_TYPE_VYBRIDIMAGE,/* VYBRID .vyb Image */
IH_TYPE_TEE,/* Trusted Execution Environment OS Image */
IH_TYPE_FIRMWARE_IVT,   /* Firmware Image with HABv4 IVT */
+   IH_TYPE_PMMC,/* TI Power Management Micro-Controller 
Firmware */
 
IH_TYPE_COUNT,  /* Number of image types */
 };
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] test/py: Handle the banner being printed after relocation

2017-07-31 Thread Stephen Warren

On 07/28/2017 09:57 PM, Simon Glass wrote:

Hi Stephen,

On 27 July 2017 at 15:27, Stephen Warren  wrote:

On 07/27/2017 09:31 AM, Simon Glass wrote:


If CONFIG_DISPLAY_BOARDINFO_LATE is enabled, U-Boot displays the banner
again after relocation so that it is visible on the video display. Detect
this and allow it.

Note: This patch is only an interim fix. If it is applied we should
consider reverting it later since it is not needed if U-Boot is working
correctly.



It'd be useful if that paragraph could be expanded a bit; what exactly is
the bug and how will it be fixed? The situation described in the first
paragraph doesn't seem like a bug. Perhaps the fix be to delay the sign-on
message until video output is available and only print it once, or not print
the sign-on to serial when printing it a second time so that it's seen on
video?


The bug is described /fixed in patches 2 & 3 of this series. I sent
this patch in case there was urgency in fixing it.




diff --git a/test/py/u_boot_console_base.py
b/test/py/u_boot_console_base.py




@@ -355,12 +355,31 @@ class ConsoleBase(object):
   self.u_boot_version_string = self.p.after
   while True:
   m = self.p.expect([self.prompt_compiled,
-pattern_stop_autoboot_prompt] + self.bad_patterns)
+pattern_stop_autoboot_prompt,
pattern_u_boot_main_signon] +
+self.bad_patterns)



This doesn't seem quite right. At a very high level, the current code does
this:

1) If SPL will print a sign-on:
  Wait for SPL to print sign-on
2) Wait for main U-Boot to print a sign-on
3) Wait for auto-boot prompt and interrupt it.

This change modifies (3) to alternatively wait for another sign-on prompt,


Well actually the existing code already does this if you look closely.
If it sees second sign-on it detects this and fails the test
(presumably because it indicates there was an unexpected reboot).
Otherwise I would not have bothered with this patch.


But it's doing it in a much more "after-the-fact" and brittle way.


which means it's doing 2 unrelated things. Better would be to just add a new
standalone step to wait for the extra sign-on message:

1) If SPL will print a sign-on:
  Wait for SPL to print sign-on
2) Wait for main U-Boot to print a sign-on
3) If a duplicate sign-on message will be printed:
  Wait for duplicate sign-on from main U-Boot
4) Wait for auto-boot prompt and interrupt it.

Judging by the code quoted below, new step (3) above can use the value of
bcfg.get('config_display_boardinfo_late', 'n') == 'y' to make the decision.

That has the advantage of not requiring the following heuristic to
differentiate between expected sign-on messages and unexpected sign-on
messages due to U-Boot crashing and restarting:


Yes I think that would work. I did consider making it explicit on that
option, which is indeed what causes the problem.

But if there are no objections I think it is best to skip this interim
patch and apply the real fix (patches 2, 3) once they get some review.


Yes, if patches 2/3 fix the root-cause, then I'd agree let's just apply 
those instead.

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] efi patch queue 2017-07-29

2017-07-31 Thread Tom Rini
On Sat, Jul 29, 2017 at 12:31:02AM +0200, Alexander Graf wrote:

> Hi Tom,
> 
> This is my current patch queue for efi.  Please pull.
> 
> Alex
> 
> 
> The following changes since commit 8d3a25685e4aac7070365a2b3c53c2c81b27930f:
> 
>   Merge git://git.denx.de/u-boot-dm (2017-07-11 20:28:46 -0400)
> 
> are available in the git repository at:
> 
>   git://github.com/agraf/u-boot.git tags/signed-efi-next
> 
> for you to fetch changes up to af65db85b82b161f037e0889ae58bf461217b3f1:
> 
>   efi_loader: indent entry/exit prints to show nesting level (2017-07-29 
> 00:18:46 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] efi_loader: Fix warning in efi_gop

2017-07-31 Thread Tom Rini
On Mon, Jul 31, 2017 at 09:15:57AM +0200, Alexander Graf wrote:

> Commit ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without
> CONFIG_LCD") dropped the explicit (void*) cast for fb_base in efi gop support
> for CONFIG_LCD without DM. This patch adds it back, eliminating the now 
> occuring
> warning again
> 
> Fixes: ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without 
> CONFIG_LCD")
> Reported-by: Tom Rini 
> Signed-off-by: Alexander Graf 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC 1/1] m68k: mfc5227x: do not rely on uninitialized stack values

2017-07-31 Thread Angelo Dureghello

Hi Heinrich,

thanks for the patch

On 30/07/2017 20:59, Heinrich Schuchardt wrote:

The behavior get_clocks depends on the unitialized
value of bootmode.

By setting it to zero we get a defined behavior and
can get rid of superfluos coding.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt 
---
I have no hardware to test this.
Please, check thorougly before merging.
---
---
  arch/m68k/cpu/mcf5227x/speed.c | 10 ++
  1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/m68k/cpu/mcf5227x/speed.c b/arch/m68k/cpu/mcf5227x/speed.c
index 44de4a6701..978cc7adc6 100644
--- a/arch/m68k/cpu/mcf5227x/speed.c
+++ b/arch/m68k/cpu/mcf5227x/speed.c
@@ -73,14 +73,8 @@ int get_clocks(void)
  
  	ccm_t *ccm = (ccm_t *)MMAP_CCM;

pll_t *pll = (pll_t *)MMAP_PLL;
-   int vco, temp, pcrvalue, pfdr;
-   u8 bootmode;
-
-   pcrvalue = in_be32(>pcr) & 0xFF0F0FFF;
-   pfdr = pcrvalue >> 24;
-
-   if (pfdr == 0x1E)
-   bootmode = 0;   /* Normal Mode */
+   int vco, temp, pcrvalue;
+   u8 bootmode = 0;/* Normal Mode */;
  
  #ifdef CONFIG_CF_SBF

bootmode = 3;   /* Serial Mode */



sure uninitialized vars are an issue.This change works and make things simpler.

But looking the code i have a doubt now:
this code seems attempting to detect "runtime" the boot mode, getting clocks 
from
pll registers already set i.e. form SBF header.
So there can be a case where jumpers (or pull up/down resistors) are set to SBF 
(11)
and "bootmode" variable will be set to 3 only if CONFIG_CF_SBF is set, otherwise
it will be 0 and not 3.

Of course, if we try to boot by SBF and CONFIG_CF_SBF is not set, u-boot will 
not
boot in anyway, since spi init will be totally missing.

But in case a different "fully runtime" proposal could be:

diff --git a/arch/m68k/cpu/mcf5227x/speed.c b/arch/m68k/cpu/mcf5227x/speed.c
index 44de4a6701..e21c1d574b 100644
--- a/arch/m68k/cpu/mcf5227x/speed.c
+++ b/arch/m68k/cpu/mcf5227x/speed.c
@@ -74,7 +74,7 @@ int get_clocks(void)
ccm_t *ccm = (ccm_t *)MMAP_CCM;
pll_t *pll = (pll_t *)MMAP_PLL;
int vco, temp, pcrvalue, pfdr;
-   u8 bootmode;
+   u8 bootmode = 3;

pcrvalue = in_be32(>pcr) & 0xFF0F0FFF;
pfdr = pcrvalue >> 24;
@@ -82,10 +82,6 @@ int get_clocks(void)
if (pfdr == 0x1E)
bootmode = 0;   /* Normal Mode */

-#ifdef CONFIG_CF_SBF
-   bootmode = 3;   /* Serial Mode */
-#endif
-
if (bootmode == 0) {
/* Normal mode */
vco = ((in_be32(>pcr) & 0xFF00) >> 24) * 
CONFIG_SYS_INPUT_CLKSRC;

What do you think ?

Regards,
Angelo Dureghello
 



 
___

U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC PATCH 1/1] dm: core: add clocks node scan

2017-07-31 Thread patrice.chotard
From: Patrice Chotard 

Currently, all fixed-clock declared in "clocks" node in device tree
can be binded by clk_fixed_rate.c driver only if the "simple-bus"
compatible string is set inside "clocks" node.
This constraint has been invoked here [1].

This patch offers a solution to avoid adding "simple-bus" compatible
string to "clocks" node.

[1] https://patchwork.ozlabs.org/patch/558837/

Signed-off-by: Patrice Chotard 
---
 drivers/core/root.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index d691d6f..f285df8 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -312,6 +312,12 @@ int dm_scan_fdt(const void *blob, bool pre_reloc_only)
 #endif
return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
 }
+#else
+static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
+   int offset, bool pre_reloc_only)
+{
+   return 0;
+}
 #endif
 
 __weak int dm_scan_other(bool pre_reloc_only)
@@ -322,6 +328,7 @@ __weak int dm_scan_other(bool pre_reloc_only)
 int dm_init_and_scan(bool pre_reloc_only)
 {
int ret;
+   int node;
 
ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE));
if (ret) {
@@ -340,6 +347,12 @@ int dm_init_and_scan(bool pre_reloc_only)
debug("dm_scan_fdt() failed: %d\n", ret);
return ret;
}
+
+   /* bind fixed-clock */
+   node = fdt_path_offset(gd->fdt_blob, "/clocks");
+   if (node >= 0)
+   dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, node,
+pre_reloc_only);
}
 
ret = dm_scan_other(pre_reloc_only);
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 23/29] env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()

2017-07-31 Thread Simon Glass
Rename this function for consistency with env_set().

Signed-off-by: Simon Glass 
---

Changes in v4:
- Add new patch to rename eth_setenv_enetaddr()

Changes in v3: None
Changes in v2: None

 arch/arm/mach-davinci/misc.c  |  2 +-
 arch/arm/mach-omap2/utils.c   |  2 +-
 board/BuR/common/common.c |  2 +-
 board/CZ.NIC/turris_omnia/turris_omnia.c  |  6 +++---
 board/LaCie/net2big_v2/net2big_v2.c   |  2 +-
 board/LaCie/netspace_v2/netspace_v2.c |  2 +-
 board/amlogic/odroid-c2/odroid-c2.c   |  2 +-
 board/atmel/sama5d2_xplained/sama5d2_xplained.c   |  2 +-
 board/birdland/bav335x/board.c|  2 +-
 board/bosch/shc/board.c   |  6 +++---
 board/compulab/cl-som-am57x/eth.c |  2 +-
 board/compulab/cm_fx6/cm_fx6.c|  2 +-
 board/compulab/cm_t335/cm_t335.c  |  2 +-
 board/compulab/cm_t35/cm_t35.c|  2 +-
 board/compulab/cm_t3517/cm_t3517.c|  2 +-
 board/compulab/cm_t54/cm_t54.c|  2 +-
 board/davinci/da8xxevm/da850evm.c |  2 +-
 board/gateworks/gw_ventana/gw_ventana.c   |  4 ++--
 board/grinn/chiliboard/board.c|  4 ++--
 board/gumstix/pepper/board.c  |  2 +-
 board/isee/igep003x/board.c   |  2 +-
 board/kosagi/novena/novena.c  |  2 +-
 board/logicpd/zoom1/zoom1.c   |  2 +-
 board/phytec/pcm051/board.c   |  2 +-
 board/raspberrypi/rpi/rpi.c   |  2 +-
 board/renesas/blanche/blanche.c   |  2 +-
 board/rockchip/tinker_rk3288/tinker-rk3288.c  |  2 +-
 board/samtec/vining_2000/vining_2000.c|  2 +-
 board/samtec/vining_fpga/socfpga.c|  2 +-
 board/siemens/common/factoryset.c |  2 +-
 board/siemens/pxm2/board.c|  2 +-
 board/silica/pengwyn/board.c  |  2 +-
 board/spear/common/spr_misc.c |  2 +-
 board/sunxi/board.c   |  2 +-
 board/tcl/sl50/board.c|  6 +++---
 board/technologic/ts4800/ts4800.c |  2 +-
 board/theobroma-systems/puma_rk3399/puma-rk3399.c |  2 +-
 board/ti/am335x/board.c   |  6 +++---
 board/ti/am43xx/board.c   |  4 ++--
 board/ti/am57xx/board.c   | 10 +-
 board/ti/common/board_detect.c|  4 ++--
 board/ti/dra7xx/evm.c |  4 ++--
 board/ti/evm/evm.c|  2 +-
 board/ti/ti814x/evm.c |  2 +-
 board/ti/ti816x/evm.c |  2 +-
 board/timll/devkit8000/devkit8000.c   |  2 +-
 board/toradex/common/tdx-common.c |  4 ++--
 board/vscom/baltos/board.c|  2 +-
 doc/README.enetaddr   |  4 ++--
 drivers/net/fec_mxc.c |  2 +-
 drivers/net/lan91c96.c|  2 +-
 drivers/net/ne2000_base.c |  2 +-
 drivers/usb/gadget/ether.c|  2 +-
 include/net.h |  6 +++---
 net/eth-uclass.c  |  2 +-
 net/eth_common.c  |  6 +++---
 net/eth_internal.h|  4 ++--
 net/eth_legacy.c  |  4 ++--
 58 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/arch/arm/mach-davinci/misc.c b/arch/arm/mach-davinci/misc.c
index ec331ba6bb..4441242cc7 100644
--- a/arch/arm/mach-davinci/misc.c
+++ b/arch/arm/mach-davinci/misc.c
@@ -99,7 +99,7 @@ void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
debug("### Setting environment from EEPROM MAC address = "
"\"%pM\"\n",
env_enetaddr);
-   ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr);
+   ret = !eth_env_set_enetaddr("ethaddr", rom_enetaddr);
}
if (!ret)
printf("Failed to set mac address from EEPROM: %d\n", ret);
diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index b7074638bd..c03e93878d 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -214,7 +214,7 @@ void omap_die_id_usbethaddr(void)
mac[4] = die_id[0] & 0xff;
mac[5] = (die_id[0] >> 8) & 0xff;
 
-   eth_setenv_enetaddr("usbethaddr", mac);
+   eth_env_set_enetaddr("usbethaddr", mac);
}
 }
 
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 6bea9a4383..eb34de931e 100644
--- a/board/BuR/common/common.c
+++ 

[U-Boot] [PATCH v4 20/29] env: Drop saveenv() in favour of env_save()

2017-07-31 Thread Simon Glass
Use the env_save() function directly now that there is only one
implementation of saveenv().

Signed-off-by: Simon Glass 
Reviewed-by: Wolfgang Denk 
Reviewed-by: Tom Rini 
---

Changes in v4:
- Add changes for edison also

Changes in v3: None
Changes in v2: None

 arch/arm/mach-omap2/boot-common.c   | 3 ++-
 board/intel/edison/edison.c | 5 +++--
 board/siemens/taurus/taurus.c   | 5 +++--
 board/toradex/apalis_imx6/apalis_imx6.c | 3 ++-
 cmd/nvedit.c| 2 +-
 drivers/bootcount/bootcount_env.c   | 3 ++-
 env/env.c   | 6 --
 include/common.h| 1 -
 include/environment.h   | 7 +++
 9 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index 700e6c2f79..2bcc8e9f97 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -241,7 +242,7 @@ int fb_set_reboot_flag(void)
 {
printf("Setting reboot to fastboot flag ...\n");
setenv("dofastboot", "1");
-   saveenv();
+   env_save();
return 0;
 }
 #endif
diff --git a/board/intel/edison/edison.c b/board/intel/edison/edison.c
index a1a7d4d7c8..80f9b544b0 100644
--- a/board/intel/edison/edison.c
+++ b/board/intel/edison/edison.c
@@ -5,6 +5,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -70,7 +71,7 @@ static void assign_serial(void)
setenv("serial#", serial);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-   saveenv();
+   env_save();
 #endif
 }
 
@@ -88,7 +89,7 @@ static void assign_hardware_id(void)
setenv("hardware_id", hardware_id);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-   saveenv();
+   env_save();
 #endif
 }
 
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
index 4aa8d64869..3b742ebc22 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -405,7 +406,7 @@ static int upgrade_failure_fallback(void)
setenv("bootargs", '\0');
setenv("upgrade_available", '\0');
setenv("boot_retries", '\0');
-   saveenv();
+   env_save();
 
return 0;
 }
@@ -424,7 +425,7 @@ static int do_upgrade_available(cmd_tbl_t *cmdtp, int flag, 
int argc,
boot_retry++;
sprintf(boot_buf, "%lx", boot_retry);
setenv("boot_retries", boot_buf);
-   saveenv();
+   env_save();
 
/*
 * Here the boot_retries count is checked, and if the
diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 8e5613cb12..e41547bbee 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -818,7 +819,7 @@ int board_late_init(void)
setenv("fdt_file", FDT_FILE_V1_0);
printf("patching fdt_file to " FDT_FILE_V1_0 "\n");
 #ifndef CONFIG_ENV_IS_NOWHERE
-   saveenv();
+   env_save();
 #endif
}
}
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 75df997592..4431ef66d8 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -710,7 +710,7 @@ static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 
printf("Saving Environment to %s...\n", env->name);
 
-   return saveenv() ? 1 : 0;
+   return env_save() ? 1 : 0;
 }
 
 U_BOOT_CMD(
diff --git a/drivers/bootcount/bootcount_env.c 
b/drivers/bootcount/bootcount_env.c
index 2d6e8db126..7f22dd0748 100644
--- a/drivers/bootcount/bootcount_env.c
+++ b/drivers/bootcount/bootcount_env.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 
 void bootcount_store(ulong a)
 {
@@ -13,7 +14,7 @@ void bootcount_store(ulong a)
 
if (upgrade_available) {
setenv_ulong("bootcount", a);
-   saveenv();
+   env_save();
}
 }
 
diff --git a/env/env.c b/env/env.c
index 85d95e5747..2b8b9611cf 100644
--- a/env/env.c
+++ b/env/env.c
@@ -149,9 +149,3 @@ int env_init(void)
 
return 0;
 }
-
-int saveenv(void)
-{
-   return env_save();
-}
-
diff --git a/include/common.h b/include/common.h
index 751665f8a4..f0fc02cd3b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -335,7 +335,6 @@ ulong getenv_hex(const char *varname, ulong default_val);
  * Return -1 if variable does not exist (default to true)
  */
 int getenv_yesno(const char *var);
-intsaveenv  (void);
 intsetenv   (const char *, const char *);
 int setenv_ulong(const char *varname, 

[U-Boot] [PATCH v4 13/29] env: Switch over to use environment location drivers

2017-07-31 Thread Simon Glass
Move over to use a the master implementation of the location drivers, with
each method calling out to the appropriate driver.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4:
- Adjust implementation of env_get_char_spec() to avoid recursion

Changes in v3: None
Changes in v2: None

 env/dataflash.c | 16 
 env/eeprom.c| 16 
 env/env.c   | 20 
 env/ext4.c  | 13 ++---
 env/fat.c   | 13 ++---
 env/flash.c | 34 ++
 env/mmc.c   | 19 +--
 env/nand.c  | 14 +++---
 env/nowhere.c   |  8 
 env/nvram.c | 16 
 env/onenand.c   | 13 ++---
 env/remote.c| 13 ++---
 env/sata.c  | 13 ++---
 env/sf.c| 17 -
 env/ubi.c   | 17 -
 15 files changed, 128 insertions(+), 114 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index 9c59d8e63a..6d95d6409b 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -18,7 +18,7 @@ env_t *env_ptr;
 
 char *env_name_spec = "dataflash";
 
-uchar env_get_char_spec(int index)
+static unsigned char env_dataflash_get_char(int index)
 {
uchar c;
 
@@ -27,7 +27,7 @@ uchar env_get_char_spec(int index)
return c;
 }
 
-void env_relocate_spec(void)
+static void env_dataflash_load(void)
 {
ulong crc, new = 0;
unsigned off;
@@ -54,7 +54,7 @@ void env_relocate_spec(void)
 #error No support for redundant environment on dataflash yet!
 #endif
 
-int saveenv(void)
+static int env_dataflash_save(void)
 {
env_t env_new;
int ret;
@@ -74,7 +74,7 @@ int saveenv(void)
  * We are still running from ROM, so data use is limited.
  * Use a (moderately small) buffer on the stack
  */
-int env_init(void)
+int env_dataflash_init(void)
 {
/* use default */
gd->env_addr = (ulong)_environment[0];
@@ -85,8 +85,8 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(dataflash) = {
.location   = ENVL_DATAFLASH,
-   .get_char   = env_get_char_spec,
-   .load   = env_relocate_spec,
-   .save   = env_save_ptr(saveenv),
-   .init   = env_init,
+   .get_char   = env_dataflash_get_char,
+   .load   = env_dataflash_load,
+   .save   = env_save_ptr(env_dataflash_save),
+   .init   = env_dataflash_init,
 };
diff --git a/env/eeprom.c b/env/eeprom.c
index 78569b286b..eb69f75f7b 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -65,7 +65,7 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned 
offset,
return rcode;
 }
 
-uchar env_get_char_spec(int index)
+static uchar env_eeprom_get_char(int index)
 {
uchar c;
unsigned int off = CONFIG_ENV_OFFSET;
@@ -80,7 +80,7 @@ uchar env_get_char_spec(int index)
return c;
 }
 
-void env_relocate_spec(void)
+static void env_eeprom_load(void)
 {
char buf_env[CONFIG_ENV_SIZE];
unsigned int off = CONFIG_ENV_OFFSET;
@@ -188,7 +188,7 @@ void env_relocate_spec(void)
env_import(buf_env, 1);
 }
 
-int saveenv(void)
+static int env_eeprom_save(void)
 {
env_t   env_new;
int rc;
@@ -237,7 +237,7 @@ int saveenv(void)
  * We are still running from ROM, so data use is limited.
  * Use a (moderately small) buffer on the stack
  */
-int env_init(void)
+static int env_eeprom_init(void)
 {
gd->env_addr = (ulong)_environment[0];
gd->env_valid = ENV_VALID;
@@ -246,8 +246,8 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(eeprom) = {
.location   = ENVL_EEPROM,
-   .get_char   = env_get_char_spec,
-   .load   = env_relocate_spec,
-   .save   = env_save_ptr(saveenv),
-   .init   = env_init,
+   .get_char   = env_eeprom_get_char,
+   .load   = env_eeprom_load,
+   .save   = env_save_ptr(env_eeprom_save),
+   .init   = env_eeprom_init,
 };
diff --git a/env/env.c b/env/env.c
index 9f0a04c33c..d327f9cdff 100644
--- a/env/env.c
+++ b/env/env.c
@@ -143,3 +143,23 @@ int env_init_new(void)
 
return 0;
 }
+
+unsigned char env_get_char_spec(int index)
+{
+   return *(uchar *)(gd->env_addr + index);
+}
+
+void env_relocate_spec(void)
+{
+   env_load();
+}
+
+int saveenv(void)
+{
+   return env_save();
+}
+
+int env_init(void)
+{
+   return env_init_new();
+}
diff --git a/env/ext4.c b/env/ext4.c
index c6a84925d9..aa69219021 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -37,7 +37,7 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
+static int env_ext4_init(void)
 {
/* use default */
gd->env_addr = (ulong)_environment[0];
@@ -47,7 +47,7 @@ int env_init(void)
 }
 
 #ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_ext4_save(void)
 {
env_t   env_new;
struct blk_desc *dev_desc = NULL;
@@ -88,7 +88,7 

[U-Boot] [PATCH v4 09/29] env: Add an enum for environment state

2017-07-31 Thread Simon Glass
At present we have three states for the environment, numbered 0, 1 and 2.
Add an enum to record this to avoid open-coded values.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/Arcturus/ucp1020/spl.c   |  3 ++-
 board/freescale/b4860qds/spl.c |  3 ++-
 board/freescale/c29xpcie/spl.c |  3 ++-
 board/freescale/p1010rdb/spl.c |  3 ++-
 board/freescale/p1022ds/spl.c  |  3 ++-
 board/freescale/p1_p2_rdb_pc/spl.c |  3 ++-
 board/freescale/t102xqds/spl.c |  3 ++-
 board/freescale/t102xrdb/spl.c |  3 ++-
 board/freescale/t104xrdb/spl.c |  3 ++-
 board/freescale/t208xqds/spl.c |  3 ++-
 board/freescale/t208xrdb/spl.c |  3 ++-
 board/freescale/t4qds/spl.c|  3 ++-
 board/freescale/t4rdb/spl.c|  3 ++-
 env/dataflash.c|  2 +-
 env/eeprom.c   | 30 +++---
 env/ext4.c |  2 +-
 env/fat.c  |  2 +-
 env/flash.c| 22 +++---
 env/mmc.c  | 10 +-
 env/nand.c | 29 +++--
 env/nvram.c|  2 +-
 env/onenand.c  |  4 ++--
 env/remote.c   |  2 +-
 env/sata.c |  2 +-
 env/sf.c   | 26 +-
 env/ubi.c  |  6 +++---
 include/asm-generic/global_data.h  |  2 +-
 include/environment.h  |  7 +++
 28 files changed, 104 insertions(+), 83 deletions(-)

diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c
index cd484fc44b..b5e7a5db06 100644
--- a/board/Arcturus/ucp1020/spl.c
+++ b/board/Arcturus/ucp1020/spl.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,7 +100,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
(uchar *)CONFIG_ENV_ADDR);
gd->env_addr = (ulong)(CONFIG_ENV_ADDR);
-   gd->env_valid = 1;
+   gd->env_valid = ENV_VALID;
 #else
env_relocate();
 #endif
diff --git a/board/freescale/b4860qds/spl.c b/board/freescale/b4860qds/spl.c
index 60d7f0d48a..b1824b07a2 100644
--- a/board/freescale/b4860qds/spl.c
+++ b/board/freescale/b4860qds/spl.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -101,7 +102,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
(uchar *)CONFIG_ENV_ADDR);
gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-   gd->env_valid = 1;
+   gd->env_valid = ENV_VALID;
 #endif
 
i2c_init_all();
diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c
index 94093f11a8..28541a72cb 100644
--- a/board/freescale/c29xpcie/spl.c
+++ b/board/freescale/c29xpcie/spl.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -63,7 +64,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
(uchar *)CONFIG_ENV_ADDR);
gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-   gd->env_valid = 1;
+   gd->env_valid = ENV_VALID;
 
i2c_init_all();
 
diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c
index 2cebc2c002..001308874e 100644
--- a/board/freescale/p1010rdb/spl.c
+++ b/board/freescale/p1010rdb/spl.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -87,7 +88,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
(uchar *)CONFIG_ENV_ADDR);
gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-   gd->env_valid = 1;
+   gd->env_valid = ENV_VALID;
 #else
env_relocate();
 #endif
diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c
index a117dc3a2c..94b357d446 100644
--- a/board/freescale/p1022ds/spl.c
+++ b/board/freescale/p1022ds/spl.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -100,7 +101,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
(uchar *)CONFIG_ENV_ADDR);
 
gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-   gd->env_valid = 1;
+   gd->env_valid = ENV_VALID;
 #else
env_relocate();
 #endif
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c 
b/board/freescale/p1_p2_rdb_pc/spl.c
index ca7ba5754e..c1d4c36b06 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -92,7 +93,7 @@ void board_init_r(gd_t *gd, 

[U-Boot] [PATCH v4 07/29] env: common: Drop env_get_char_init()

2017-07-31 Thread Simon Glass
This function does nothing but call env_get_char_spec(). Drop it and
adjust its only caller.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/env/common.c b/env/common.c
index bfa8cfb143..f0ffe4ed73 100644
--- a/env/common.c
+++ b/env/common.c
@@ -32,11 +32,6 @@ __weak uchar env_get_char_spec(int index)
return *((uchar *)(gd->env_addr + index));
 }
 
-static uchar env_get_char_init(int index)
-{
-   return env_get_char_spec(index);
-}
-
 static uchar env_get_char_memory(int index)
 {
return *(uchar *)(gd->env_addr + index);
@@ -50,7 +45,7 @@ uchar env_get_char(int index)
else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
return env_get_char_memory(index);
else
-   return env_get_char_init(index);
+   return env_get_char_spec(index);
 }
 
 /*
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 11/29] env: Create a location driver for each location

2017-07-31 Thread Simon Glass
Set up a location driver for each supported environment location. At
present this just points to the global functions and is not used. A
later patch will switch this over to use private functions in each driver.

There are several special cases here in various drivers to handle
peculiarities of certain boards:

1. Some boards define CONFIG_ENV_IS_IN_FAT and CONFIG_SPL_ENV_SUPPORT but
do not actually load the environment in SPL. The env load code was
optimised out before but with the driver, it is not. Therefore a special
case is added to env/fat.c. The correct fix (depending on board testing
might be to disable CONFIG_SPL_ENV_SUPPORT.

2. A similar situations happens with CONFIG_ENV_IS_IN_FLASH. Some boards
do not actually load the environment in SPL, so to reduce code size we
need to drop that code. A similar fix may be possible with these boards,
or it may be possible to adjust the environment CONFIG settings.

Added to the above is that the CONFIG_SPL_ENV_SUPPORT option does not
apply when the environment is in flash.

Obviously the above has been discovered through painful and time-consuming
trial and error. Hopefully board maintainers can take a look and figure
out what is actually needed.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Update the commit message to comment on special cases

Changes in v3: None
Changes in v2:
- Add conditions for the am335x_hs_evm board with SPL

 env/dataflash.c   |  8 ++
 env/eeprom.c  |  8 ++
 env/ext4.c|  8 ++
 env/fat.c | 30 --
 env/flash.c   | 39 +---
 env/mmc.c | 10 
 env/nand.c| 12 -
 env/nowhere.c |  6 +
 env/nvram.c   | 10 
 env/onenand.c |  8 ++
 env/remote.c  |  8 ++
 env/sata.c|  8 ++
 env/sf.c  | 20 +++
 env/ubi.c |  8 ++
 include/environment.h | 70 +++
 15 files changed, 246 insertions(+), 7 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index c140b74c98..9c59d8e63a 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -82,3 +82,11 @@ int env_init(void)
 
return 0;
 }
+
+U_BOOT_ENV_LOCATION(dataflash) = {
+   .location   = ENVL_DATAFLASH,
+   .get_char   = env_get_char_spec,
+   .load   = env_relocate_spec,
+   .save   = env_save_ptr(saveenv),
+   .init   = env_init,
+};
diff --git a/env/eeprom.c b/env/eeprom.c
index ac6b30fa8f..78569b286b 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -243,3 +243,11 @@ int env_init(void)
gd->env_valid = ENV_VALID;
return 0;
 }
+
+U_BOOT_ENV_LOCATION(eeprom) = {
+   .location   = ENVL_EEPROM,
+   .get_char   = env_get_char_spec,
+   .load   = env_relocate_spec,
+   .save   = env_save_ptr(saveenv),
+   .init   = env_init,
+};
diff --git a/env/ext4.c b/env/ext4.c
index 7bb4ce7cff..c6a84925d9 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -127,3 +127,11 @@ void env_relocate_spec(void)
 err_env_relocate:
set_default_env(NULL);
 }
+
+U_BOOT_ENV_LOCATION(ext4) = {
+   .location   = ENVL_EXT4,
+   .get_char   = env_get_char_spec,
+   .load   = env_relocate_spec,
+   .save   = env_save_ptr(saveenv),
+   .init   = env_init,
+};
diff --git a/env/fat.c b/env/fat.c
index 5a2131a5a9..8f5fff81ad 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -19,6 +19,18 @@
 #include 
 #include 
 
+#ifdef CONFIG_SPL_BUILD
+/* TODO(s...@chromium.org): Figure out why this is needed */
+# if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT)
+#  define LOADENV
+# endif
+#else
+# define LOADENV
+# if defined(CONFIG_CMD_SAVEENV)
+#  define CMD_SAVEENV
+# endif
+#endif
+
 char *env_name_spec = "FAT";
 
 env_t *env_ptr;
@@ -34,7 +46,7 @@ int env_init(void)
return 0;
 }
 
-#ifdef CONFIG_CMD_SAVEENV
+#ifdef CMD_SAVEENV
 int saveenv(void)
 {
env_t   env_new;
@@ -72,8 +84,9 @@ int saveenv(void)
puts("done\n");
return 0;
 }
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CMD_SAVEENV */
 
+#ifdef LOADENV
 void env_relocate_spec(void)
 {
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -108,3 +121,16 @@ void env_relocate_spec(void)
 err_env_relocate:
set_default_env(NULL);
 }
+#endif /* LOADENV */
+
+U_BOOT_ENV_LOCATION(fat) = {
+   .location   = ENVL_FAT,
+   .get_char   = env_get_char_spec,
+#ifdef LOADENV
+   .load   = env_relocate_spec,
+#endif
+#ifdef CMD_SAVEENV
+   .save   = env_save_ptr(saveenv),
+#endif
+   .init   = env_init,
+};
diff --git a/env/flash.c b/env/flash.c
index dcf3cd2c62..cf068d11ee 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -20,10 +20,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_SAVEENV) && 

[U-Boot] [PATCH v4 16/29] env: Drop unused env_ptr variables

2017-07-31 Thread Simon Glass
This variable is declared as a global in most environment location
drivers. But it is not used outside the drivers and most of the
declarations are unnecessary.

Also some drivers call free() on env_ptr which seems wrong since it is
not in the heap.

Drop the variable where possible, and all calls to free().

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/dataflash.c | 2 --
 env/eeprom.c| 4 
 env/ext4.c  | 2 --
 env/fat.c   | 2 --
 env/mmc.c   | 6 --
 env/nowhere.c   | 2 --
 env/nvram.c | 1 -
 env/ubi.c   | 2 --
 8 files changed, 21 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index 9421a6a5b2..28dcf6fa1c 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -14,8 +14,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 static unsigned char env_dataflash_get_char(int index)
 {
uchar c;
diff --git a/env/eeprom.c b/env/eeprom.c
index 2c795b9236..39adccabbe 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -21,8 +21,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
   uchar *buffer, unsigned cnt)
 {
@@ -196,8 +194,6 @@ static int env_eeprom_save(void)
char flag_obsolete  = OBSOLETE_FLAG;
 #endif
 
-   BUG_ON(env_ptr != NULL);
-
rc = env_export(_new);
if (rc)
return rc;
diff --git a/env/ext4.c b/env/ext4.c
index 5acdf0eda0..ee073a8b7c 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -31,8 +31,6 @@
 #include 
 #include 
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_CMD_SAVEENV
diff --git a/env/fat.c b/env/fat.c
index ad0c4321c7..69319f8834 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -31,8 +31,6 @@
 # endif
 #endif
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CMD_SAVEENV
diff --git a/env/mmc.c b/env/mmc.c
index 18da6dc58c..88ffc91f0b 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -23,12 +23,6 @@
 #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
 #endif
 
-#ifdef ENV_IS_EMBEDDED
-env_t *env_ptr = 
-#else /* ! ENV_IS_EMBEDDED */
-env_t *env_ptr;
-#endif /* ENV_IS_EMBEDDED */
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #if !defined(CONFIG_ENV_OFFSET)
diff --git a/env/nowhere.c b/env/nowhere.c
index 1a17d6978b..d60de494e6 100644
--- a/env/nowhere.c
+++ b/env/nowhere.c
@@ -15,8 +15,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 U_BOOT_ENV_LOCATION(nowhere) = {
.location   = ENVL_NOWHERE,
ENV_NAME("nowhere")
diff --git a/env/nvram.c b/env/nvram.c
index 0f4b491fd3..ac389ace62 100644
--- a/env/nvram.c
+++ b/env/nvram.c
@@ -36,7 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
 extern void *nvram_read(void *dest, const long src, size_t count);
 extern void nvram_write(long dest, const void *src, size_t count);
-env_t *env_ptr;
 #else
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
diff --git a/env/ubi.c b/env/ubi.c
index 4d5ae1343d..9399f943dc 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -16,8 +16,6 @@
 #include 
 #undef crc32
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_CMD_SAVEENV
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 18/29] env: Drop env_get_char_spec()

2017-07-31 Thread Simon Glass
We only have a single implementation of this function now and it is called
env_get_char(). Drop the old function and the weak version.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c  | 14 --
 env/env.c |  9 +++--
 include/environment.h | 14 ++
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/env/common.c b/env/common.c
index 842c0f7fd1..9b3a26859f 100644
--- a/env/common.c
+++ b/env/common.c
@@ -27,20 +27,6 @@ struct hsearch_data env_htab = {
.change_ok = env_flags_validate,
 };
 
-__weak uchar env_get_char_spec(int index)
-{
-   return *(uchar *)(gd->env_addr + index);
-}
-
-uchar env_get_char(int index)
-{
-   /* if env is not set up, or crc was bad, use the default environment */
-   if (!gd->env_valid)
-   return default_environment[index];
-   else
-   return env_get_char_spec(index);
-}
-
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
diff --git a/env/env.c b/env/env.c
index ac6a583a02..a239d93156 100644
--- a/env/env.c
+++ b/env/env.c
@@ -69,11 +69,13 @@ struct env_driver *env_driver_lookup_default(void)
return drv;
 }
 
-int env_get_char_new(int index)
+int env_get_char(int index)
 {
struct env_driver *drv = env_driver_lookup_default();
int ret;
 
+   if (!gd->env_valid)
+   return default_environment[index];
if (!drv)
return -ENODEV;
if (!drv->get_char)
@@ -148,11 +150,6 @@ int env_init(void)
return 0;
 }
 
-unsigned char env_get_char_spec(int index)
-{
-   return *(uchar *)(gd->env_addr + index);
-}
-
 void env_relocate_spec(void)
 {
env_load();
diff --git a/include/environment.h b/include/environment.h
index 584fd7216d..1df243462e 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -171,7 +171,6 @@ extern const unsigned char default_environment[];
 extern env_t *env_ptr;
 
 extern void env_relocate_spec(void);
-extern unsigned char env_get_char_spec(int);
 
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 extern void env_reloc(void);
@@ -281,9 +280,6 @@ struct env_driver {
 
 extern struct hsearch_data env_htab;
 
-/* Function that returns a character from the environment */
-unsigned char env_get_char(int);
-
 /* Function that updates CRC of the enironment */
 void env_crc_update(void);
 
@@ -314,6 +310,16 @@ int env_import_redund(const char *buf1, const char *buf2);
  */
 struct env_driver *env_driver_lookup_default(void);
 
+/**
+ * env_get_char() - Get a character from the early environment
+ *
+ * This reads from the pre-relocation environemnt
+ *
+ * @index: Index of character to read (0 = first)
+ * @return character read, or -ve on error
+ */
+int env_get_char(int index);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 04/29] env: common: Make env_get_addr/get_char_memory() static

2017-07-31 Thread Simon Glass
These functions are not used outside this file. Make them static and order
them to avoid forward declarations.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c  | 18 +-
 include/environment.h |  4 
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/env/common.c b/env/common.c
index d9c0c4e3f3..5a17e52615 100644
--- a/env/common.c
+++ b/env/common.c
@@ -41,7 +41,15 @@ static uchar env_get_char_init(int index)
return default_environment[index];
 }
 
-uchar env_get_char_memory(int index)
+static const uchar *env_get_addr(int index)
+{
+   if (gd->env_valid)
+   return (uchar *)(gd->env_addr + index);
+   else
+   return _environment[index];
+}
+
+static uchar env_get_char_memory(int index)
 {
return *env_get_addr(index);
 }
@@ -55,14 +63,6 @@ uchar env_get_char(int index)
return env_get_char_init(index);
 }
 
-const uchar *env_get_addr(int index)
-{
-   if (gd->env_valid)
-   return (uchar *)(gd->env_addr + index);
-   else
-   return _environment[index];
-}
-
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
diff --git a/include/environment.h b/include/environment.h
index d86230a2e9..5f2064bf23 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -202,10 +202,6 @@ extern struct hsearch_data env_htab;
 /* Function that returns a character from the environment */
 unsigned char env_get_char(int);
 
-/* Function that returns a pointer to a value from the environment */
-const unsigned char *env_get_addr(int);
-unsigned char env_get_char_memory(int index);
-
 /* Function that updates CRC of the enironment */
 void env_crc_update(void);
 
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 27/29] env: Rename some other getenv()-related functions

2017-07-31 Thread Simon Glass
We are now using an env_ prefix for environment functions. Rename these
other functions as well, for consistency:

   getenv_vlan()
   getenv_bootm_size()
   getenv_bootm_low()
   getenv_bootm_mapsize()
   env_get_default()

Suggested-by: Wolfgang Denk 
Signed-off-by: Simon Glass 
---

Changes in v4:
- Add new patch to rename some other genenv()-related functions

Changes in v3: None
Changes in v2:
- Add new patch to rename getenv() and friends to env_get()

 arch/powerpc/lib/bootm.c|  8 
 board/Arcturus/ucp1020/ucp1020.c|  4 ++--
 board/freescale/b4860qds/b4860qds.c |  4 ++--
 board/freescale/bsc9131rdb/bsc9131rdb.c |  4 ++--
 board/freescale/bsc9132qds/bsc9132qds.c |  4 ++--
 board/freescale/c29xpcie/c29xpcie.c |  4 ++--
 board/freescale/corenet_ds/corenet_ds.c |  4 ++--
 board/freescale/mpc8572ds/mpc8572ds.c   |  4 ++--
 board/freescale/p1010rdb/p1010rdb.c |  4 ++--
 board/freescale/p1022ds/p1022ds.c   |  4 ++--
 board/freescale/p1023rdb/p1023rdb.c |  4 ++--
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c |  4 ++--
 board/freescale/p1_twr/p1_twr.c |  4 ++--
 board/freescale/p2041rdb/p2041rdb.c |  4 ++--
 board/freescale/t102xqds/t102xqds.c |  4 ++--
 board/freescale/t102xrdb/t102xrdb.c |  4 ++--
 board/freescale/t1040qds/t1040qds.c |  4 ++--
 board/freescale/t104xrdb/t104xrdb.c |  4 ++--
 board/freescale/t208xqds/t208xqds.c |  4 ++--
 board/freescale/t208xrdb/t208xrdb.c |  4 ++--
 board/freescale/t4qds/t4240emu.c|  4 ++--
 board/freescale/t4qds/t4240qds.c|  4 ++--
 board/freescale/t4rdb/t4240rdb.c|  4 ++--
 board/gdsys/p1022/controlcenterd.c  |  4 ++--
 board/keymile/kmp204x/kmp204x.c |  4 ++--
 board/varisys/cyrus/cyrus.c |  4 ++--
 cmd/elf.c   |  2 +-
 cmd/mtdparts.c  |  6 +++---
 cmd/net.c   |  2 +-
 common/bootm.c  |  4 ++--
 common/image-fdt.c  |  4 ++--
 common/image.c  | 18 +-
 drivers/net/netconsole.c|  6 +++---
 env/common.c|  2 +-
 env/flags.c |  2 +-
 include/common.h|  2 +-
 include/environment.h   |  2 +-
 include/image.h |  6 +++---
 include/net.h   |  2 +-
 net/link_local.c|  2 +-
 net/net.c   |  2 +-
 41 files changed, 85 insertions(+), 85 deletions(-)

diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 932c38ab4c..b9ae24dc98 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -86,7 +86,7 @@ static void boot_jump_linux(bootm_headers_t *images)
debug ("   Booting using OF flat tree...\n");
WATCHDOG_RESET ();
(*kernel) ((bd_t *)of_flat_tree, 0, 0, EPAPR_MAGIC,
-  getenv_bootm_mapsize(), 0, 0);
+  env_get_bootm_mapsize(), 0, 0);
/* does not return */
} else
 #endif
@@ -121,8 +121,8 @@ void arch_lmb_reserve(struct lmb *lmb)
phys_size_t bootm_size;
ulong size, sp, bootmap_base;
 
-   bootmap_base = getenv_bootm_low();
-   bootm_size = getenv_bootm_size();
+   bootmap_base = env_get_bootm_low();
+   bootm_size = env_get_bootm_size();
 
 #ifdef DEBUG
if (((u64)bootmap_base + bootm_size) >
@@ -340,6 +340,6 @@ void boot_jump_vxworks(bootm_headers_t *images)
 
((void (*)(void *, ulong, ulong, ulong,
ulong, ulong, ulong))images->ep)(images->ft_addr,
-   0, 0, EPAPR_MAGIC, getenv_bootm_mapsize(), 0, 0);
+   0, 0, EPAPR_MAGIC, env_get_bootm_mapsize(), 0, 0);
 }
 #endif
diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c
index dfdaf0441c..3f786a2014 100644
--- a/board/Arcturus/ucp1020/ucp1020.c
+++ b/board/Arcturus/ucp1020/ucp1020.c
@@ -307,8 +307,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
ft_cpu_setup(blob, bd);
 
-   base = getenv_bootm_low();
-   size = getenv_bootm_size();
+   base = env_get_bootm_low();
+   size = env_get_bootm_size();
 
fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/b4860qds/b4860qds.c 
b/board/freescale/b4860qds/b4860qds.c
index 1fea91b3b5..5d872fdfd9 100644
--- a/board/freescale/b4860qds/b4860qds.c
+++ b/board/freescale/b4860qds/b4860qds.c
@@ -1197,8 +1197,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
ft_cpu_setup(blob, bd);
 
-   base = getenv_bootm_low();
-   size = getenv_bootm_size();
+   base = env_get_bootm_low();
+   

[U-Boot] [PATCH v4 10/29] env: Rename nand env_location to nand_env_location

2017-07-31 Thread Simon Glass
We want to use this name for all environment drivers. Update the nand
driver to use a more specific name.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/nand.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/env/nand.c b/env/nand.c
index 90f274bf8a..d1b8b26999 100644
--- a/env/nand.c
+++ b/env/nand.c
@@ -158,12 +158,12 @@ static int writeenv(size_t offset, u_char *buf)
return 0;
 }
 
-struct env_location {
+struct nand_env_location {
const char *name;
const nand_erase_options_t erase_opts;
 };
 
-static int erase_and_write_env(const struct env_location *location,
+static int erase_and_write_env(const struct nand_env_location *location,
u_char *env_new)
 {
struct mtd_info *mtd;
@@ -189,7 +189,7 @@ int saveenv(void)
int ret = 0;
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
int env_idx = 0;
-   static const struct env_location location[] = {
+   static const struct nand_env_location location[] = {
{
.name = "NAND",
.erase_opts = {
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 06/29] env: common: Factor out the common env_valid check

2017-07-31 Thread Simon Glass
The check for gd->env_valid is used in both the 'if' and 'else' part of
env_get_char(). Move it into that function instead for simplicity. Drop
that code from the two leaf functions.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/env/common.c b/env/common.c
index 2e94dd71e2..bfa8cfb143 100644
--- a/env/common.c
+++ b/env/common.c
@@ -34,25 +34,20 @@ __weak uchar env_get_char_spec(int index)
 
 static uchar env_get_char_init(int index)
 {
-   /* if crc was bad, use the default environment */
-   if (gd->env_valid)
-   return env_get_char_spec(index);
-   else
-   return default_environment[index];
+   return env_get_char_spec(index);
 }
 
 static uchar env_get_char_memory(int index)
 {
-   if (gd->env_valid)
-   return *(uchar *)(gd->env_addr + index);
-   else
-   return default_environment[index];
+   return *(uchar *)(gd->env_addr + index);
 }
 
 uchar env_get_char(int index)
 {
-   /* if relocated to RAM */
-   if (gd->flags & GD_FLG_RELOC)
+   /* if env is not set up, or crc was bad, use the default environment */
+   if (!gd->env_valid)
+   return default_environment[index];
+   else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
return env_get_char_memory(index);
else
return env_get_char_init(index);
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 01/29] Makefile: Rename 'env' target to 'environ'

2017-07-31 Thread Simon Glass
This target stops us using 'env' as a subdirectory. It is not mentioned in
the help so seems to be an internal target. Rename it.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 78a5f73687..5b16965585 100644
--- a/Makefile
+++ b/Makefile
@@ -1463,14 +1463,14 @@ checkarmreloc: u-boot
false; \
fi
 
-env: scripts_basic
+environ: scripts_basic
$(Q)$(MAKE) $(build)=tools/$@
 
 tools-only: scripts_basic $(version_h) $(timestamp_h)
$(Q)$(MAKE) $(build)=tools
 
 tools-all: export HOST_TOOLS_ALL=y
-tools-all: env tools ;
+tools-all: environ tools ;
 
 cross_tools: export CROSS_BUILD_TOOLS=y
 cross_tools: tools ;
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 26/29] env: Rename eth_getenv_enetaddr() to eth_env_get_enetaddr()

2017-07-31 Thread Simon Glass
Rename this function for consistency with env_get().

Signed-off-by: Simon Glass 
---

Changes in v4:
- Add new patch to rename eth_getenv_enetaddr()

Changes in v3: None
Changes in v2: None

 arch/arm/mach-davinci/misc.c|  2 +-
 arch/powerpc/cpu/mpc85xx/fdt.c  |  2 +-
 board/amlogic/odroid-c2/odroid-c2.c |  2 +-
 board/buffalo/lsxl/lsxl.c   |  2 +-
 board/compulab/cl-som-am57x/eth.c   |  2 +-
 board/compulab/cm_fx6/cm_fx6.c  |  6 +++---
 board/compulab/cm_t335/cm_t335.c|  2 +-
 board/compulab/cm_t35/cm_t35.c  |  2 +-
 board/compulab/cm_t3517/cm_t3517.c  |  2 +-
 board/compulab/cm_t54/cm_t54.c  |  4 ++--
 board/davinci/da8xxevm/da850evm.c   |  2 +-
 board/gumstix/pepper/board.c|  2 +-
 board/isee/igep003x/board.c |  2 +-
 board/logicpd/zoom1/zoom1.c |  2 +-
 board/phytec/pcm051/board.c |  2 +-
 board/renesas/alt/alt.c |  2 +-
 board/renesas/blanche/blanche.c |  2 +-
 board/renesas/gose/gose.c   |  2 +-
 board/renesas/koelsch/koelsch.c |  2 +-
 board/renesas/lager/lager.c |  2 +-
 board/renesas/porter/porter.c   |  2 +-
 board/renesas/silk/silk.c   |  2 +-
 board/renesas/stout/stout.c |  2 +-
 board/silica/pengwyn/board.c|  2 +-
 board/spear/common/spr_misc.c   |  2 +-
 board/ti/evm/evm.c  |  2 +-
 board/ti/ti814x/evm.c   |  2 +-
 board/ti/ti816x/evm.c   |  2 +-
 board/timll/devkit8000/devkit8000.c |  2 +-
 board/toradex/common/tdx-common.c   |  4 ++--
 cmd/elf.c   |  4 ++--
 cmd/pxe.c   |  3 +--
 common/board_r.c| 12 ++--
 doc/README.enetaddr |  4 ++--
 drivers/net/dc2114x.c   |  2 +-
 drivers/net/fsl-mc/mc.c |  4 ++--
 drivers/net/fsl_mcdmafec.c  |  4 ++--
 drivers/net/ftgmac100.c |  2 +-
 drivers/net/ftmac100.c  |  2 +-
 drivers/net/lan91c96.c  |  2 +-
 drivers/net/mcffec.c|  8 
 drivers/net/ne2000_base.c   |  4 ++--
 drivers/net/sh_eth.c|  2 +-
 include/net.h   |  4 ++--
 net/eth-uclass.c|  2 +-
 net/eth_common.c|  8 
 net/eth_legacy.c|  2 +-
 net/net_rand.h  |  2 +-
 48 files changed, 69 insertions(+), 70 deletions(-)

diff --git a/arch/arm/mach-davinci/misc.c b/arch/arm/mach-davinci/misc.c
index 4441242cc7..461ff778c2 100644
--- a/arch/arm/mach-davinci/misc.c
+++ b/arch/arm/mach-davinci/misc.c
@@ -90,7 +90,7 @@ void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
uint8_t env_enetaddr[6];
int ret;
 
-   ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
+   ret = eth_env_get_enetaddr_by_index("eth", 0, env_enetaddr);
if (!ret) {
/*
 * There is no MAC address in the environment, so we
diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index 27d3b3ffe9..599839d0ff 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -580,7 +580,7 @@ static void fdt_fixup_l2_switch(void *blob)
return;
 
/* Get MAC address for the l2switch from "l2switchaddr"*/
-   if (!eth_getenv_enetaddr("l2switchaddr", l2swaddr)) {
+   if (!eth_env_get_enetaddr("l2switchaddr", l2swaddr)) {
printf("Warning: MAC address for l2switch not found\n");
memset(l2swaddr, 0, sizeof(l2swaddr));
}
diff --git a/board/amlogic/odroid-c2/odroid-c2.c 
b/board/amlogic/odroid-c2/odroid-c2.c
index 611155d3e5..eac04d8178 100644
--- a/board/amlogic/odroid-c2/odroid-c2.c
+++ b/board/amlogic/odroid-c2/odroid-c2.c
@@ -44,7 +44,7 @@ int misc_init_r(void)
mdelay(10);
setbits_le32(GXBB_GPIO_OUT(3), BIT(14));
 
-   if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+   if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
  mac_addr, EFUSE_MAC_SIZE);
if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 5b31e056ba..2d01ac25d8 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -203,7 +203,7 @@ void check_enetaddr(void)
 {
uchar enetaddr[6];
 
-   if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+   if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
/* signal unset/invalid ethaddr to user */
set_led(LED_INFO_BLINKING);
}
diff --git a/board/compulab/cl-som-am57x/eth.c 
b/board/compulab/cl-som-am57x/eth.c
index 0ad10056fe..b615fb9e7e 100644
--- a/board/compulab/cl-som-am57x/eth.c
+++ b/board/compulab/cl-som-am57x/eth.c
@@ -95,7 +95,7 @@ static int cl_som_am57x_handle_mac_address(char 

[U-Boot] [PATCH v4 19/29] env: Drop env_relocate_spec() in favour of env_load()

2017-07-31 Thread Simon Glass
This is a strange name for a function that loads the environment. There is
now only one implementation of this function, so use the new env_load()
function directly instead.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/birdland/bav335x/board.c  | 2 +-
 board/gateworks/gw_ventana/gw_ventana_spl.c | 2 +-
 board/tcl/sl50/board.c  | 2 +-
 board/ti/am335x/board.c | 2 +-
 board/ti/am57xx/board.c | 2 +-
 board/ti/dra7xx/evm.c   | 2 +-
 env/common.c| 2 +-
 env/env.c   | 5 -
 include/environment.h   | 9 +++--
 9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/board/birdland/bav335x/board.c b/board/birdland/bav335x/board.c
index 67aca3cc43..b49365e157 100644
--- a/board/birdland/bav335x/board.c
+++ b/board/birdland/bav335x/board.c
@@ -162,7 +162,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
if (getenv_yesno("boot_os") != 1)
return 1;
 #endif
diff --git a/board/gateworks/gw_ventana/gw_ventana_spl.c 
b/board/gateworks/gw_ventana/gw_ventana_spl.c
index 69a638d71d..baa8480b6c 100644
--- a/board/gateworks/gw_ventana/gw_ventana_spl.c
+++ b/board/gateworks/gw_ventana/gw_ventana_spl.c
@@ -690,7 +690,7 @@ int spl_start_uboot(void)
debug("%s\n", __func__);
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
debug("boot_os=%s\n", getenv("boot_os"));
if (getenv_yesno("boot_os") == 1)
ret = 0;
diff --git a/board/tcl/sl50/board.c b/board/tcl/sl50/board.c
index e89ee35d30..d3c953e993 100644
--- a/board/tcl/sl50/board.c
+++ b/board/tcl/sl50/board.c
@@ -76,7 +76,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
if (getenv_yesno("boot_os") != 1)
return 1;
 #endif
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 0a16529b5f..ac0592b725 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -249,7 +249,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
if (getenv_yesno("boot_os") != 1)
return 1;
 #endif
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 00a31a97fd..126c9ef694 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -742,7 +742,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
if (getenv_yesno("boot_os") != 1)
return 1;
 #endif
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 7d36f03fa1..23be2c70e4 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -825,7 +825,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
env_init();
-   env_relocate_spec();
+   env_load();
if (getenv_yesno("boot_os") != 1)
return 1;
 #endif
diff --git a/env/common.c b/env/common.c
index 9b3a26859f..0cc8829d0d 100644
--- a/env/common.c
+++ b/env/common.c
@@ -280,7 +280,7 @@ void env_relocate(void)
set_default_env("!bad CRC");
 #endif
} else {
-   env_relocate_spec();
+   env_load();
}
 }
 
diff --git a/env/env.c b/env/env.c
index a239d93156..85d95e5747 100644
--- a/env/env.c
+++ b/env/env.c
@@ -150,11 +150,6 @@ int env_init(void)
return 0;
 }
 
-void env_relocate_spec(void)
-{
-   env_load();
-}
-
 int saveenv(void)
 {
return env_save();
diff --git a/include/environment.h b/include/environment.h
index 1df243462e..b4f93663da 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -170,8 +170,6 @@ extern env_t environment;
 extern const unsigned char default_environment[];
 extern env_t *env_ptr;
 
-extern void env_relocate_spec(void);
-
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 extern void env_reloc(void);
 #endif
@@ -320,6 +318,13 @@ struct env_driver *env_driver_lookup_default(void);
  */
 int env_get_char(int index);
 
+/**
+ * env_load() - Load the environment from storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_load(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 29/29] env: Adjust the load() method to return an error

2017-07-31 Thread Simon Glass
The load() methods have inconsistent behaviour on error. Some of them load
an empty default environment. Some load an environment containing an error
message. Others do nothing.

As a step in the right direction, have the method return an error code.
Then the caller could handle this itself in a consistent way.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3:
- Rebase to master
- Rebase to master, dropping patches already applied

Changes in v2:
- Rebase to master

 env/dataflash.c   |  4 +++-
 env/eeprom.c  |  4 +++-
 env/ext4.c|  6 --
 env/fat.c |  6 --
 env/flash.c   |  4 +++-
 env/mmc.c | 19 +++
 env/nand.c| 17 -
 env/nvram.c   |  4 +++-
 env/onenand.c |  4 +++-
 env/remote.c  |  4 +++-
 env/sata.c| 15 +--
 env/sf.c  | 20 +---
 env/ubi.c | 14 +-
 include/environment.h |  4 +++-
 14 files changed, 83 insertions(+), 42 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index afa08f8fd5..77bc595e0d 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -23,7 +23,7 @@ static int env_dataflash_get_char(int index)
return c;
 }
 
-static void env_dataflash_load(void)
+static int env_dataflash_load(void)
 {
ulong crc, new = 0;
unsigned off;
@@ -44,6 +44,8 @@ static void env_dataflash_load(void)
env_import(buf, 1);
else
set_default_env("!bad CRC");
+
+   return 0;
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
diff --git a/env/eeprom.c b/env/eeprom.c
index fbe4fd4efc..08ef6307fc 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -76,7 +76,7 @@ static int env_eeprom_get_char(int index)
return c;
 }
 
-static void env_eeprom_load(void)
+static int env_eeprom_load(void)
 {
char buf_env[CONFIG_ENV_SIZE];
unsigned int off = CONFIG_ENV_OFFSET;
@@ -182,6 +182,8 @@ static void env_eeprom_load(void)
off, (uchar *)buf_env, CONFIG_ENV_SIZE);
 
env_import(buf_env, 1);
+
+   return 0;
 }
 
 static int env_eeprom_save(void)
diff --git a/env/ext4.c b/env/ext4.c
index ee073a8b7c..65202213d3 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -75,7 +75,7 @@ static int env_ext4_save(void)
 }
 #endif /* CONFIG_CMD_SAVEENV */
 
-static void env_ext4_load(void)
+static int env_ext4_load(void)
 {
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct blk_desc *dev_desc = NULL;
@@ -109,10 +109,12 @@ static void env_ext4_load(void)
}
 
env_import(buf, 1);
-   return;
+   return 0;
 
 err_env_relocate:
set_default_env(NULL);
+
+   return -EIO;
 }
 
 U_BOOT_ENV_LOCATION(ext4) = {
diff --git a/env/fat.c b/env/fat.c
index 69319f8834..83d4ba1340 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -74,7 +74,7 @@ static int env_fat_save(void)
 #endif /* CMD_SAVEENV */
 
 #ifdef LOADENV
-static void env_fat_load(void)
+static int env_fat_load(void)
 {
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct blk_desc *dev_desc = NULL;
@@ -103,10 +103,12 @@ static void env_fat_load(void)
}
 
env_import(buf, 1);
-   return;
+   return 0;
 
 err_env_relocate:
set_default_env(NULL);
+
+   return -EIO;
 }
 #endif /* LOADENV */
 
diff --git a/env/flash.c b/env/flash.c
index 2d72c51622..b60be57a8d 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -308,7 +308,7 @@ done:
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
 #ifdef LOADENV
-static void env_flash_load(void)
+static int env_flash_load(void)
 {
 #ifdef CONFIG_ENV_ADDR_REDUND
if (gd->env_addr != (ulong)&(flash_addr->data)) {
@@ -352,6 +352,8 @@ static void env_flash_load(void)
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
env_import((char *)flash_addr, 1);
+
+   return 0;
 }
 #endif /* LOADENV */
 
diff --git a/env/mmc.c b/env/mmc.c
index 88ffc91f0b..3f3092d975 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -207,7 +207,7 @@ static inline int read_env(struct mmc *mmc, unsigned long 
size,
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-static void env_mmc_load(void)
+static int env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
struct mmc *mmc;
@@ -224,13 +224,13 @@ static void env_mmc_load(void)
 
errmsg = init_mmc_for_env(mmc);
if (errmsg) {
-   ret = 1;
+   ret = -EIO;
goto err;
}
 
if (mmc_get_env_addr(mmc, 0, ) ||
mmc_get_env_addr(mmc, 1, )) {
-   ret = 1;
+   ret = -EIO;
goto fini;
}
 
@@ -245,7 +245,7 @@ static void env_mmc_load(void)
 
if (read1_fail && read2_fail) {
errmsg = "!bad CRC";
-   ret = 1;
+   ret = -EIO;
goto fini;
} else if (!read1_fail && read2_fail) {
gd->env_valid = ENV_VALID;
@@ -264,10 +264,12 @@ fini:
 

[U-Boot] [PATCH v4 25/29] env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()

2017-07-31 Thread Simon Glass
We are now using an env_ prefix for environment functions. Rename these
for consistency. Also add function comments in common.h.

Suggested-by: Wolfgang Denk 
Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Add new patch to rename getenv_hex(), getenv_yesno(), getenv_ulong()

 arch/powerpc/cpu/mpc85xx/mp.c   |  2 +-
 board/BuR/brxre1/board.c|  6 ++---
 board/BuR/common/common.c   | 40 ++---
 board/birdland/bav335x/board.c  |  2 +-
 board/gateworks/gw_ventana/gw_ventana_spl.c |  2 +-
 board/gdsys/p1022/controlcenterd-id.c   |  4 +--
 board/tcl/sl50/board.c  |  2 +-
 board/ti/am335x/board.c |  2 +-
 board/ti/am57xx/board.c |  2 +-
 board/ti/dra7xx/evm.c   |  2 +-
 cmd/fdt.c   |  2 +-
 cmd/nvedit.c|  4 +--
 cmd/source.c|  2 +-
 cmd/trace.c |  6 ++---
 cmd/ximg.c  |  2 +-
 common/autoboot.c   |  2 +-
 common/board_f.c|  4 +--
 common/board_r.c|  6 ++---
 common/bootm.c  |  4 +--
 drivers/bootcount/bootcount_env.c   |  6 ++---
 env/common.c|  2 +-
 include/common.h| 19 +++---
 lib/fdtdec.c|  2 +-
 net/bootp.c |  2 +-
 net/net.c   |  2 +-
 25 files changed, 70 insertions(+), 59 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c
index 0addf8493c..2ea9f5c7be 100644
--- a/arch/powerpc/cpu/mpc85xx/mp.c
+++ b/arch/powerpc/cpu/mpc85xx/mp.c
@@ -31,7 +31,7 @@ u32 get_my_id()
 int hold_cores_in_reset(int verbose)
 {
/* Default to no, overridden by 'y', 'yes', 'Y', 'Yes', or '1' */
-   if (getenv_yesno("mp_holdoff") == 1) {
+   if (env_get_yesno("mp_holdoff") == 1) {
if (verbose) {
puts("Secondary cores are being held in reset.\n");
puts("See 'mp_holdoff' environment variable\n");
diff --git a/board/BuR/brxre1/board.c b/board/BuR/brxre1/board.c
index cdbc93a8ec..ca08f3cd90 100644
--- a/board/BuR/brxre1/board.c
+++ b/board/BuR/brxre1/board.c
@@ -282,9 +282,9 @@ int board_late_init(void)
snprintf(othbootargs, sizeof(othbootargs),
 "u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
 (unsigned int) gd->fb_base-0x20,
-(u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
-(u32)getenv_ulong("vx_romfsbase", 16, 0),
-(u32)getenv_ulong("vx_romfssize", 16, 0));
+(u32)env_get_ulong("vx_memtop", 16, gd->fb_base-0x20),
+(u32)env_get_ulong("vx_romfsbase", 16, 0),
+(u32)env_get_ulong("vx_romfssize", 16, 0));
env_set("othbootargs", othbootargs);
/*
 * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 39a600b5c1..c1cd010023 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -58,9 +58,9 @@ void lcdbacklight(int on)
unsigned int bright = FDTPROP(PATHINF, "brightdef");
unsigned int pwmfrq = FDTPROP(PATHINF, "brightfdim");
 #else
-   unsigned int driver = getenv_ulong("ds1_bright_drv", 16, 0UL);
-   unsigned int bright = getenv_ulong("ds1_bright_def", 10, 50);
-   unsigned int pwmfrq = getenv_ulong("ds1_pwmfreq", 10, ~0UL);
+   unsigned int driver = env_get_ulong("ds1_bright_drv", 16, 0UL);
+   unsigned int bright = env_get_ulong("ds1_bright_def", 10, 50);
+   unsigned int pwmfrq = env_get_ulong("ds1_pwmfreq", 10, ~0UL);
 #endif
unsigned int tmp;
struct gptimer *timerhw;
@@ -186,20 +186,20 @@ int load_lcdtiming(struct am335x_lcdpanel *panel)
snprintf(buf, sizeof(buf), "fbcon=rotate:%d", panel_info.vl_rot);
env_set("optargs_rot", buf);
 #else
-   pnltmp.hactive = getenv_ulong("ds1_hactive", 10, ~0UL);
-   pnltmp.vactive = getenv_ulong("ds1_vactive", 10, ~0UL);
-   pnltmp.bpp = getenv_ulong("ds1_bpp", 10, ~0UL);
-   pnltmp.hfp = getenv_ulong("ds1_hfp", 10, ~0UL);
-   pnltmp.hbp = getenv_ulong("ds1_hbp", 10, ~0UL);
-   pnltmp.hsw = getenv_ulong("ds1_hsw", 10, ~0UL);
-   pnltmp.vfp = getenv_ulong("ds1_vfp", 10, ~0UL);
-   pnltmp.vbp = getenv_ulong("ds1_vbp", 10, ~0UL);
-   pnltmp.vsw = getenv_ulong("ds1_vsw", 10, ~0UL);
-   pnltmp.pxl_clk_div = getenv_ulong("ds1_pxlclkdiv", 10, ~0UL);
-   pnltmp.pol = getenv_ulong("ds1_pol", 16, ~0UL);
-   pnltmp.pup_delay = 

[U-Boot] [PATCH v4 15/29] env: Drop the env_name_spec global

2017-07-31 Thread Simon Glass
Add a name to the driver and use that instead of the global variable
declared by each driver.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/nvedit.c  |  4 +++-
 env/dataflash.c   |  3 +--
 env/eeprom.c  |  3 +--
 env/env.c |  2 +-
 env/ext4.c|  3 +--
 env/fat.c |  3 +--
 env/flash.c   |  3 +--
 env/mmc.c |  3 +--
 env/nand.c|  3 +--
 env/nowhere.c |  1 +
 env/nvram.c   |  3 +--
 env/onenand.c |  3 +--
 env/remote.c  |  3 +--
 env/sata.c|  3 +--
 env/sf.c  |  3 +--
 env/ubi.c |  2 --
 include/environment.h | 19 +++
 17 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index cd17db6409..75df997592 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -706,7 +706,9 @@ ulong getenv_ulong(const char *name, int base, ulong 
default_val)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
   char * const argv[])
 {
-   printf("Saving Environment to %s...\n", env_name_spec);
+   struct env_driver *env = env_driver_lookup_default();
+
+   printf("Saving Environment to %s...\n", env->name);
 
return saveenv() ? 1 : 0;
 }
diff --git a/env/dataflash.c b/env/dataflash.c
index 8ab482b3b4..9421a6a5b2 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -16,8 +16,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-char *env_name_spec = "dataflash";
-
 static unsigned char env_dataflash_get_char(int index)
 {
uchar c;
@@ -70,6 +68,7 @@ static int env_dataflash_save(void)
 
 U_BOOT_ENV_LOCATION(dataflash) = {
.location   = ENVL_DATAFLASH,
+   ENV_NAME("dataflash")
.get_char   = env_dataflash_get_char,
.load   = env_dataflash_load,
.save   = env_save_ptr(env_dataflash_save),
diff --git a/env/eeprom.c b/env/eeprom.c
index 3cc412620a..2c795b9236 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -23,8 +23,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-char *env_name_spec = "EEPROM";
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
   uchar *buffer, unsigned cnt)
 {
@@ -233,6 +231,7 @@ static int env_eeprom_save(void)
 
 U_BOOT_ENV_LOCATION(eeprom) = {
.location   = ENVL_EEPROM,
+   ENV_NAME("EEPROM")
.get_char   = env_eeprom_get_char,
.load   = env_eeprom_load,
.save   = env_save_ptr(env_eeprom_save),
diff --git a/env/env.c b/env/env.c
index 12cd4750df..53a085c431 100644
--- a/env/env.c
+++ b/env/env.c
@@ -54,7 +54,7 @@ static enum env_location env_get_default_location(void)
return ENVL_UNKNOWN;
 }
 
-static struct env_driver *env_driver_lookup_default(void)
+struct env_driver *env_driver_lookup_default(void)
 {
enum env_location loc = env_get_default_location();
struct env_driver *drv;
diff --git a/env/ext4.c b/env/ext4.c
index 25a5cbecdd..5acdf0eda0 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -31,8 +31,6 @@
 #include 
 #include 
 
-char *env_name_spec = "EXT4";
-
 env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -121,6 +119,7 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(ext4) = {
.location   = ENVL_EXT4,
+   ENV_NAME("EXT4")
.load   = env_ext4_load,
.save   = env_save_ptr(env_ext4_save),
 };
diff --git a/env/fat.c b/env/fat.c
index bd31b2904d..ad0c4321c7 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -31,8 +31,6 @@
 # endif
 #endif
 
-char *env_name_spec = "FAT";
-
 env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -116,6 +114,7 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(fat) = {
.location   = ENVL_FAT,
+   ENV_NAME("FAT")
 #ifdef LOADENV
.load   = env_fat_load,
 #endif
diff --git a/env/flash.c b/env/flash.c
index 6ec9b61883..2d72c51622 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -45,8 +45,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define INITENV
 #endif
 
-char *env_name_spec = "Flash";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = 
 
@@ -359,6 +357,7 @@ static void env_flash_load(void)
 
 U_BOOT_ENV_LOCATION(flash) = {
.location   = ENVL_FLASH,
+   ENV_NAME("Flash")
 #ifdef LOADENV
.load   = env_flash_load,
 #endif
diff --git a/env/mmc.c b/env/mmc.c
index 966f620653..18da6dc58c 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -23,8 +23,6 @@
 #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "MMC";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = 
 #else /* ! ENV_IS_EMBEDDED */
@@ -318,6 +316,7 @@ err:
 
 U_BOOT_ENV_LOCATION(mmc) = {
.location   = ENVL_MMC,
+   ENV_NAME("MMC")
.load   = env_mmc_load,
 #ifndef CONFIG_SPL_BUILD
.save   = env_save_ptr(env_mmc_save),
diff --git 

[U-Boot] [PATCH v4 03/29] env: Move help from README to Kconfig

2017-07-31 Thread Simon Glass
The CONFIG_ENV_IS_IN_... options which have already been converted to
Kconfig only have a small amount of help. Move the rest of it over from
the README.

(The v1 patch of this was nak'ed[1]. Please ignore this patch if not
wanted)

[1] http://patchwork.ozlabs.org/patch/794040/

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/Kconfig | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index 6e885f85a6..402ace3327 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -80,35 +80,35 @@ config ENV_IS_IN_FAT
bool "Environment is in a FAT filesystem"
depends on !CHAIN_OF_TRUST
help
- Define this if you want to use the FAT file system for the 
environment.
+ Define this if you want to use the FAT file system for the 
environment.
 
- - FAT_ENV_INTERFACE:
+ - FAT_ENV_INTERFACE:
 
- Define this to a string that is the name of the block device.
+ Define this to a string that is the name of the block device.
 
- - FAT_ENV_DEVICE_AND_PART:
+ - FAT_ENV_DEVICE_AND_PART:
 
- Define this to a string to specify the partition of the device. It can
- be as following:
+ Define this to a string to specify the partition of the device. It can
+ be as following:
 
-   "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
-   - "D:P": device D partition P. Error occurs if device D has no
-partition table.
-   - "D:0": device D.
-   - "D" or "D:": device D partition 1 if device D has partition
-  table, or the whole device D if has no partition
-  table.
-   - "D:auto": first partition in device D with bootable flag set.
-   If none, first valid partition in device D. If no
-   partition table then means device D.
+ "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
+ - "D:P": device D partition P. Error occurs if device D has no
+   partition table.
+ - "D:0": device D.
+ - "D" or "D:": device D partition 1 if device D has partition
+   table, or the whole device D if has no partition
+   table.
+ - "D:auto": first partition in device D with bootable flag set.
+   If none, first valid partition in device D. If no
+   partition table then means device D.
 
- - FAT_ENV_FILE:
+ - FAT_ENV_FILE:
 
- It's a string of the FAT file name. This file use to store the
- environment.
+ It's a string of the FAT file name. This file use to store the
+ environment.
 
- - CONFIG_FAT_WRITE:
- This must be enabled. Otherwise it cannot save the environment file.
+ - CONFIG_FAT_WRITE:
+ This must be enabled. Otherwise it cannot save the environment file.
 
 config ENV_IS_IN_FLASH
bool "Environment in flash memory"
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 08/29] env: common: Drop env_get_char_memory()

2017-07-31 Thread Simon Glass
This function is the same as env_get_char_spec() apart from dropping the
brackets. Drop the brackets from env_get_char_spec() and use that instead
of env_get_char_memory().

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/env/common.c b/env/common.c
index f0ffe4ed73..842c0f7fd1 100644
--- a/env/common.c
+++ b/env/common.c
@@ -28,11 +28,6 @@ struct hsearch_data env_htab = {
 };
 
 __weak uchar env_get_char_spec(int index)
-{
-   return *((uchar *)(gd->env_addr + index));
-}
-
-static uchar env_get_char_memory(int index)
 {
return *(uchar *)(gd->env_addr + index);
 }
@@ -42,8 +37,6 @@ uchar env_get_char(int index)
/* if env is not set up, or crc was bad, use the default environment */
if (!gd->env_valid)
return default_environment[index];
-   else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
-   return env_get_char_memory(index);
else
return env_get_char_spec(index);
 }
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 17/29] env: Drop env_init_new()

2017-07-31 Thread Simon Glass
Now that env_init() is only defined once we can drop the env_init_new()
name and just use env_init().

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/env.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/env/env.c b/env/env.c
index 53a085c431..ac6a583a02 100644
--- a/env/env.c
+++ b/env/env.c
@@ -125,7 +125,7 @@ int env_save(void)
return 0;
 }
 
-int env_init_new(void)
+int env_init(void)
 {
struct env_driver *drv = env_driver_lookup_default();
int ret = -ENOENT;
@@ -163,7 +163,3 @@ int saveenv(void)
return env_save();
 }
 
-int env_init(void)
-{
-   return env_init_new();
-}
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 14/29] env: Drop common init() functions

2017-07-31 Thread Simon Glass
Most of the init() implementations just use the default environment.
Adjust env_init_new() to do this automatically, and drop the redundant
code.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4:
- Fix incorrect setting of env_valid in env_init_new()

Changes in v3: None
Changes in v2: None

 env/dataflash.c   | 16 
 env/eeprom.c  | 14 --
 env/env.c | 14 +-
 env/ext4.c| 10 --
 env/fat.c | 10 --
 env/mmc.c | 10 --
 env/nowhere.c | 19 ---
 env/onenand.c | 10 --
 env/remote.c  |  4 +---
 env/sata.c| 10 --
 env/sf.c  | 10 --
 env/ubi.c | 10 --
 include/environment.h |  3 ++-
 13 files changed, 12 insertions(+), 128 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index 6d95d6409b..8ab482b3b4 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -68,25 +68,9 @@ static int env_dataflash_save(void)
CONFIG_ENV_SIZE);
 }
 
-/*
- * Initialize environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-int env_dataflash_init(void)
-{
-   /* use default */
-   gd->env_addr = (ulong)_environment[0];
-   gd->env_valid = ENV_VALID;
-
-   return 0;
-}
-
 U_BOOT_ENV_LOCATION(dataflash) = {
.location   = ENVL_DATAFLASH,
.get_char   = env_dataflash_get_char,
.load   = env_dataflash_load,
.save   = env_save_ptr(env_dataflash_save),
-   .init   = env_dataflash_init,
 };
diff --git a/env/eeprom.c b/env/eeprom.c
index eb69f75f7b..3cc412620a 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -231,23 +231,9 @@ static int env_eeprom_save(void)
return rc;
 }
 
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-static int env_eeprom_init(void)
-{
-   gd->env_addr = (ulong)_environment[0];
-   gd->env_valid = ENV_VALID;
-   return 0;
-}
-
 U_BOOT_ENV_LOCATION(eeprom) = {
.location   = ENVL_EEPROM,
.get_char   = env_eeprom_get_char,
.load   = env_eeprom_load,
.save   = env_save_ptr(env_eeprom_save),
-   .init   = env_eeprom_init,
 };
diff --git a/env/env.c b/env/env.c
index d327f9cdff..12cd4750df 100644
--- a/env/env.c
+++ b/env/env.c
@@ -128,14 +128,18 @@ int env_save(void)
 int env_init_new(void)
 {
struct env_driver *drv = env_driver_lookup_default();
-   int ret;
+   int ret = -ENOENT;
 
if (!drv)
return -ENODEV;
-   if (!drv->init)
-   return -ENOSYS;
-   ret = drv->init();
-   if (ret) {
+   if (drv->init)
+   ret = drv->init();
+   if (ret == -ENOENT) {
+   gd->env_addr = (ulong)_environment[0];
+   gd->env_valid = 0;
+
+   return 0;
+   } else if (ret) {
debug("%s: Environment failed to init (err=%d)\n", __func__,
  ret);
return ret;
diff --git a/env/ext4.c b/env/ext4.c
index aa69219021..25a5cbecdd 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -37,15 +37,6 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int env_ext4_init(void)
-{
-   /* use default */
-   gd->env_addr = (ulong)_environment[0];
-   gd->env_valid = ENV_VALID;
-
-   return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 static int env_ext4_save(void)
 {
@@ -132,5 +123,4 @@ U_BOOT_ENV_LOCATION(ext4) = {
.location   = ENVL_EXT4,
.load   = env_ext4_load,
.save   = env_save_ptr(env_ext4_save),
-   .init   = env_ext4_init,
 };
diff --git a/env/fat.c b/env/fat.c
index f7abfdb952..bd31b2904d 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -37,15 +37,6 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int env_fat_init(void)
-{
-   /* use default */
-   gd->env_addr = (ulong)_environment[0];
-   gd->env_valid = ENV_VALID;
-
-   return 0;
-}
-
 #ifdef CMD_SAVEENV
 static int env_fat_save(void)
 {
@@ -131,5 +122,4 @@ U_BOOT_ENV_LOCATION(fat) = {
 #ifdef CMD_SAVEENV
.save   = env_save_ptr(env_fat_save),
 #endif
-   .init   = env_fat_init,
 };
diff --git a/env/mmc.c b/env/mmc.c
index d63feea2b8..966f620653 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -82,15 +82,6 @@ __weak int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-static int env_mmc_init(void)
-{
-   /* use default */
-   gd->env_addr= (ulong)_environment[0];
-   gd->env_valid   = ENV_VALID;
-
-   return 0;
-}
-
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -331,5 +322,4 @@ 

[U-Boot] [PATCH v4 00/29] env: Move environment code to use location drivers

2017-07-31 Thread Simon Glass
The environment code is ripe for improvement in various ways. It has lots
of duplication and inconsistencies between how things work with different
environment locations. It does not properly use Kconfig. Error checking
and handling is patchy.

This series makes a start at improving things:

- moves the rest of the CONFIG_ENV_IS_IN_... options to Kconfig
- introduces the concept of a location driver for the environment
- drops some of the duplicated code
- improves error handling a little (more to be done here)
- moves code into a new env/ directory

There is still much more to do:
- complete Kconfig conversion (e.g. CONFIG_ENV_SIZE)
- unify environment settings so that all locations support the same options
- try to rationalise the redundancy code (can we create a common
implementation used by all drivers?)
- allow environment in multiple locations (e.g. as a fallback)
- figure out why CONFIG_ENV_IS_IN_FLASH enables the environment in flash
even in SPL, which other locations do not
- move environment functions from common.h to environment.h

Changes in v4:
- Update the commit message to comment on special cases
- Adjust implementation of env_get_char_spec() to avoid recursion
- Fix incorrect setting of env_valid in env_init_new()
- Add changes for edison also
- Reduce patch to only change setenv(), not any related function
- Split out changes to setenv_ulong(), etc. into a new patch
- Add new patch to rename eth_setenv_enetaddr()
- Reduce patch to only change getenv() and getenv_f()
- Update comment message to mention use of getenv() in condition context
- Add new patch to rename eth_getenv_enetaddr()
- Add new patch to rename some other genenv()-related functions

Changes in v3:
- Rebase to master
- Rebase to master, dropping patches already applied

Changes in v2:
- Add conditions for the am335x_hs_evm board with SPL
- Add new patch to rename setenv() and friends to env_set()
- Add new patch to rename setenv() and friends to env_set()
- Add new patch to rename getenv() and friends to env_get()
- Add new patch to rename getenv_hex(), getenv_yesno(), getenv_ulong()
- Add new patch to rename getenv() and friends to env_get()
- Rebase to master

Simon Glass (29):
  Makefile: Rename 'env' target to 'environ'
  Move environment files from common/ to env/
  env: Move help from README to Kconfig
  env: common: Make env_get_addr/get_char_memory() static
  env: common: Drop env_get_addr()
  env: common: Factor out the common env_valid check
  env: common: Drop env_get_char_init()
  env: common: Drop env_get_char_memory()
  env: Add an enum for environment state
  env: Rename nand env_location to nand_env_location
  env: Create a location driver for each location
  env: Add a new implementation of environment access
  env: Switch over to use environment location drivers
  env: Drop common init() functions
  env: Drop the env_name_spec global
  env: Drop unused env_ptr variables
  env: Drop env_init_new()
  env: Drop env_get_char_spec()
  env: Drop env_relocate_spec() in favour of env_load()
  env: Drop saveenv() in favour of env_save()
  env: Rename setenv() to env_set()
  env: Rename common functions related to setenv()
  env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()
  env: Rename getenv/_f() to env_get()
  env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()
  env: Rename eth_getenv_enetaddr() to eth_env_get_enetaddr()
  env: Rename some other getenv()-related functions
  env: Adjust the get_char() method to return an int
  env: Adjust the load() method to return an error

 Kconfig|   2 +
 Makefile   |   5 +-
 README |   2 +-
 api/api.c  |   6 +-
 arch/arc/lib/bootm.c   |   2 +-
 arch/arm/cpu/armv7/vf610/generic.c |   2 +-
 arch/arm/cpu/armv8/fsl-layerscape/soc.c|   2 +-
 arch/arm/lib/bootm.c   |   6 +-
 arch/arm/lib/semihosting.c |   2 +-
 arch/arm/mach-davinci/misc.c   |   4 +-
 arch/arm/mach-imx/mx6/opos6ul.c|   2 +-
 arch/arm/mach-imx/mx7/soc.c|   4 +-
 arch/arm/mach-imx/video.c  |   2 +-
 arch/arm/mach-keystone/ddr3.c  |   2 +-
 arch/arm/mach-keystone/keystone.c  |   2 +-
 arch/arm/mach-kirkwood/cpu.c   |   4 +-
 arch/arm/mach-omap2/boot-common.c  |   5 +-
 arch/arm/mach-omap2/utils.c|  20 +-
 arch/arm/mach-rockchip/rk3036-board.c  |   4 +-
 arch/arm/mach-rockchip/rk322x-board.c  |   4 +-
 arch/arm/mach-rockchip/rk3288-board.c  |   4 +-
 arch/arm/mach-socfpga/misc_gen5.c  |   4 +-
 arch/arm/mach-tegra/board2.c   |   4 +-
 

[U-Boot] [PATCH v4 05/29] env: common: Drop env_get_addr()

2017-07-31 Thread Simon Glass
This function is not used anywhere other than env_get_char(). Move the
code into that function.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/env/common.c b/env/common.c
index 5a17e52615..2e94dd71e2 100644
--- a/env/common.c
+++ b/env/common.c
@@ -41,17 +41,12 @@ static uchar env_get_char_init(int index)
return default_environment[index];
 }
 
-static const uchar *env_get_addr(int index)
+static uchar env_get_char_memory(int index)
 {
if (gd->env_valid)
-   return (uchar *)(gd->env_addr + index);
+   return *(uchar *)(gd->env_addr + index);
else
-   return _environment[index];
-}
-
-static uchar env_get_char_memory(int index)
-{
-   return *env_get_addr(index);
+   return default_environment[index];
 }
 
 uchar env_get_char(int index)
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 28/29] env: Adjust the get_char() method to return an int

2017-07-31 Thread Simon Glass
In principle this can fail, e.g. if the index is out of range. Adjust the
driver signature to allow returning an error code.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/dataflash.c   | 2 +-
 env/eeprom.c  | 2 +-
 env/nvram.c   | 2 +-
 include/environment.h | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index 28dcf6fa1c..afa08f8fd5 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -14,7 +14,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static unsigned char env_dataflash_get_char(int index)
+static int env_dataflash_get_char(int index)
 {
uchar c;
 
diff --git a/env/eeprom.c b/env/eeprom.c
index 39adccabbe..fbe4fd4efc 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -61,7 +61,7 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned 
offset,
return rcode;
 }
 
-static uchar env_eeprom_get_char(int index)
+static int env_eeprom_get_char(int index)
 {
uchar c;
unsigned int off = CONFIG_ENV_OFFSET;
diff --git a/env/nvram.c b/env/nvram.c
index ac389ace62..85af37d4a0 100644
--- a/env/nvram.c
+++ b/env/nvram.c
@@ -41,7 +41,7 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
 
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-static uchar env_nvram_get_char(int index)
+static int env_nvram_get_char(int index)
 {
uchar c;
 
diff --git a/include/environment.h b/include/environment.h
index 9a44215235..ba8af28414 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -227,9 +227,9 @@ struct env_driver {
 * will read from gd->env_addr.
 *
 * @index: Index of character to read (0=first)
-* @return character read
+* @return character read, or -ve on error
 */
-   unsigned char (*get_char)(int index);
+   int (*get_char)(int index);
 
/**
 * load() - Load the environment from storage
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 22/29] env: Rename common functions related to setenv()

2017-07-31 Thread Simon Glass
We are now using an env_ prefix for environment functions. Rename these
commonly used functions, for consistency. Also add function comments in
common.h.

Suggested-by: Wolfgang Denk 
Signed-off-by: Simon Glass 
---

Changes in v4:
- Split out changes to setenv_ulong(), etc. into a new patch

Changes in v3: None
Changes in v2:
- Add new patch to rename setenv() and friends to env_set()

 api/api.c|  2 +-
 arch/arm/mach-tegra/tegra186/nvtboot_board.c |  2 +-
 arch/arm/mach-uniphier/mmc-first-dev.c   |  2 +-
 board/boundary/nitrogen6x/nitrogen6x.c   |  2 +-
 board/engicam/common/board.c |  2 +-
 board/freescale/qemu-ppce500/qemu-ppce500.c  |  4 ++--
 board/grinn/liteboard/board.c|  2 +-
 board/raspberrypi/rpi/rpi.c  |  2 +-
 board/sunxi/board.c  |  2 +-
 cmd/cbfs.c   |  2 +-
 cmd/cramfs.c |  2 +-
 cmd/fdt.c|  4 ++--
 cmd/jffs2.c  |  2 +-
 cmd/load.c   |  6 +++---
 cmd/lzmadec.c|  2 +-
 cmd/mtdparts.c   |  2 +-
 cmd/nand.c   |  6 +++---
 cmd/nvedit.c |  6 +++---
 cmd/reiser.c |  2 +-
 cmd/setexpr.c|  4 ++--
 cmd/tpm.c|  4 ++--
 cmd/trace.c  | 12 ++--
 cmd/unzip.c  |  2 +-
 cmd/ximg.c   |  4 ++--
 cmd/zfs.c|  2 +-
 cmd/zip.c|  2 +-
 common/autoboot.c|  6 +++---
 common/board_r.c |  2 +-
 common/bootm.c   |  4 ++--
 common/bootm_os.c|  2 +-
 drivers/bootcount/bootcount_env.c|  2 +-
 drivers/net/fm/fm.c  |  2 +-
 drivers/scsi/scsi.c  |  2 +-
 fs/fs.c  |  6 +++---
 fs/ubifs/ubifs.c |  2 +-
 include/common.h | 26 +-
 net/net.c|  4 ++--
 37 files changed, 79 insertions(+), 63 deletions(-)

diff --git a/api/api.c b/api/api.c
index 423fb6b0c1..2e620e2a0f 100644
--- a/api/api.c
+++ b/api/api.c
@@ -663,7 +663,7 @@ void api_init(void)
return;
}
 
-   setenv_hex("api_address", (unsigned long)sig);
+   env_set_hex("api_address", (unsigned long)sig);
debugf("API sig @ 0x%lX\n", (unsigned long)sig);
memcpy(sig->magic, API_SIG_MAGIC, 8);
sig->version = API_SIG_VERSION;
diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c 
b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
index 56650efd4f..9cd3fe2f30 100644
--- a/arch/arm/mach-tegra/tegra186/nvtboot_board.c
+++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
@@ -15,7 +15,7 @@ static int set_fdt_addr(void)
 {
int ret;
 
-   ret = setenv_hex("fdt_addr", nvtboot_boot_x0);
+   ret = env_set_hex("fdt_addr", nvtboot_boot_x0);
if (ret) {
printf("Failed to set fdt_addr to point at DTB: %d\n", ret);
return ret;
diff --git a/arch/arm/mach-uniphier/mmc-first-dev.c 
b/arch/arm/mach-uniphier/mmc-first-dev.c
index 8c45229a89..acc859a6c3 100644
--- a/arch/arm/mach-uniphier/mmc-first-dev.c
+++ b/arch/arm/mach-uniphier/mmc-first-dev.c
@@ -35,7 +35,7 @@ static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
if (dev < 0)
return CMD_RET_FAILURE;
 
-   setenv_ulong("mmc_first_dev", dev);
+   env_set_ulong("mmc_first_dev", dev);
return CMD_RET_SUCCESS;
 }
 
diff --git a/board/boundary/nitrogen6x/nitrogen6x.c 
b/board/boundary/nitrogen6x/nitrogen6x.c
index c04926c0bb..0e2c4fc0ef 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -1021,6 +1021,6 @@ int misc_init_r(void)
 #ifdef CONFIG_CMD_BMODE
add_board_boot_modes(board_boot_modes);
 #endif
-   setenv_hex("reset_cause", get_imx_reset_cause());
+   env_set_hex("reset_cause", get_imx_reset_cause());
return 0;
 }
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 56112d3459..c7ec55ff82 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -21,7 +21,7 @@ static void mmc_late_init(void)
char mmcblk[32];
u32 dev_no = mmc_get_env_dev();
 
-   setenv_ulong("mmcdev", dev_no);
+   env_set_ulong("mmcdev", dev_no);
 
/* Set mmcblk env */
sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
diff 

[U-Boot] [PATCH v4 12/29] env: Add a new implementation of environment access

2017-07-31 Thread Simon Glass
We plan to move to a environment access via drivers for each location
where the environment can be stored. Add an implementation for this. So
far it is not used, but will be pressed into service in a future patch.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/Makefile |   2 +-
 env/env.c| 145 +++
 2 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 env/env.c

diff --git a/env/Makefile b/env/Makefile
index 4c1bdcfdf4..8df5b9d4c9 100644
--- a/env/Makefile
+++ b/env/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-y += common.o
+obj-y += common.o env.o
 
 ifndef CONFIG_SPL_BUILD
 obj-y += attr.o
diff --git a/env/env.c b/env/env.c
new file mode 100644
index 00..9f0a04c33c
--- /dev/null
+++ b/env/env.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2017 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct env_driver *env_driver_lookup(enum env_location loc)
+{
+   struct env_driver *drv;
+   const int n_ents = ll_entry_count(struct env_driver, env_driver);
+   struct env_driver *entry;
+
+   drv = ll_entry_start(struct env_driver, env_driver);
+   for (entry = drv; entry != drv + n_ents; entry++) {
+   if (loc == entry->location)
+   return entry;
+   }
+
+   /* Not found */
+   return NULL;
+}
+
+static enum env_location env_get_default_location(void)
+{
+   if IS_ENABLED(CONFIG_ENV_IS_IN_DATAFLASH)
+   return ENVL_DATAFLASH;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
+   return ENVL_EEPROM;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
+   return ENVL_FAT;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH)
+   return ENVL_FLASH;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC)
+   return ENVL_MMC;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND)
+   return ENVL_NAND;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM)
+   return ENVL_NVRAM;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE)
+   return ENVL_REMOTE;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)
+   return ENVL_SPI_FLASH;
+   else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI)
+   return ENVL_UBI;
+   else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+   return ENVL_NOWHERE;
+   else
+   return ENVL_UNKNOWN;
+}
+
+static struct env_driver *env_driver_lookup_default(void)
+{
+   enum env_location loc = env_get_default_location();
+   struct env_driver *drv;
+
+   drv = env_driver_lookup(loc);
+   if (!drv) {
+   debug("%s: No environment driver for location %d\n", __func__,
+ loc);
+   return NULL;
+   }
+
+   return drv;
+}
+
+int env_get_char_new(int index)
+{
+   struct env_driver *drv = env_driver_lookup_default();
+   int ret;
+
+   if (!drv)
+   return -ENODEV;
+   if (!drv->get_char)
+   return *(uchar *)(gd->env_addr + index);
+   ret = drv->get_char(index);
+   if (ret < 0) {
+   debug("%s: Environment failed to load (err=%d)\n",
+ __func__, ret);
+   }
+
+   return ret;
+}
+
+int env_load(void)
+{
+   struct env_driver *drv = env_driver_lookup_default();
+   int ret = 0;
+
+   if (!drv)
+   return -ENODEV;
+   if (!drv->load)
+   return 0;
+   drv->load();  /* TODO(s...@chromium.org): Make this return an error */
+   if (ret) {
+   debug("%s: Environment failed to load (err=%d)\n", __func__,
+ ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+int env_save(void)
+{
+   struct env_driver *drv = env_driver_lookup_default();
+   int ret;
+
+   if (!drv)
+   return -ENODEV;
+   if (!drv->save)
+   return -ENOSYS;
+   ret = drv->save();
+   if (ret) {
+   debug("%s: Environment failed to save (err=%d)\n", __func__,
+ ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+int env_init_new(void)
+{
+   struct env_driver *drv = env_driver_lookup_default();
+   int ret;
+
+   if (!drv)
+   return -ENODEV;
+   if (!drv->init)
+   return -ENOSYS;
+   ret = drv->init();
+   if (ret) {
+   debug("%s: Environment failed to init (err=%d)\n", __func__,
+ ret);
+   return ret;
+   }
+
+   return 0;
+}
-- 
2.14.0.rc0.400.g1c36432dff-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] clk: zynqmp: Remove unused macros/variables

2017-07-31 Thread Simon Glass
On 20 July 2017 at 03:03, Michal Simek  wrote:
> These macros and one variable is not used anywhere that's why
> it should be removed.

they

>
> Signed-off-by: Michal Simek 
> ---
>
>  drivers/clk/clk_zynqmp.c | 4 
>  1 file changed, 4 deletions(-)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 02/29] Move environment files from common/ to env/

2017-07-31 Thread Simon Glass
About a quarter of the files in common/ relate to the environment. It
seems better to put these into their own subdirectory and remove the
prefix.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Kconfig   |   2 +
 Makefile  |   1 +
 arch/sh/cpu/u-boot.lds|   4 +-
 board/freescale/mx31ads/u-boot.lds|   2 +-
 common/Kconfig| 429 --
 common/Makefile   |  49 +---
 env/Kconfig   | 428 +
 env/Makefile  |  57 
 common/env_attr.c => env/attr.c   |   0
 common/env_callback.c => env/callback.c   |   0
 common/env_common.c => env/common.c   |   0
 common/env_dataflash.c => env/dataflash.c |   0
 common/env_eeprom.c => env/eeprom.c   |   0
 common/env_embedded.c => env/embedded.c   |   0
 common/env_ext4.c => env/ext4.c   |   0
 common/env_fat.c => env/fat.c |   0
 common/env_flags.c => env/flags.c |   0
 common/env_flash.c => env/flash.c |   0
 common/env_mmc.c => env/mmc.c |   0
 common/env_nand.c => env/nand.c   |   0
 common/env_nowhere.c => env/nowhere.c |   0
 common/env_nvram.c => env/nvram.c |   0
 common/env_onenand.c => env/onenand.c |   0
 common/env_remote.c => env/remote.c   |   0
 common/env_sata.c => env/sata.c   |   0
 common/env_sf.c => env/sf.c   |   0
 common/env_ubi.c => env/ubi.c |   0
 include/configs/M5208EVBE.h   |   4 +-
 include/configs/M5235EVB.h|   2 +-
 include/configs/M5249EVB.h|   4 +-
 include/configs/M5253DEMO.h   |   4 +-
 include/configs/M5253EVBE.h   |   2 +-
 include/configs/M5272C3.h |   4 +-
 include/configs/M5275EVB.h|   4 +-
 include/configs/M5282EVB.h|   2 +-
 include/configs/M53017EVB.h   |   2 +-
 include/configs/M5329EVB.h|   4 +-
 include/configs/M5373EVB.h|   4 +-
 include/configs/amcore.h  |   4 +-
 include/configs/astro_mcf5373l.h  |   2 +-
 include/configs/cobra5272.h   |   4 +-
 scripts/Makefile.spl  |   4 +-
 tools/Makefile|   4 +-
 43 files changed, 519 insertions(+), 507 deletions(-)
 create mode 100644 env/Kconfig
 create mode 100644 env/Makefile
 rename common/env_attr.c => env/attr.c (100%)
 rename common/env_callback.c => env/callback.c (100%)
 rename common/env_common.c => env/common.c (100%)
 rename common/env_dataflash.c => env/dataflash.c (100%)
 rename common/env_eeprom.c => env/eeprom.c (100%)
 rename common/env_embedded.c => env/embedded.c (100%)
 rename common/env_ext4.c => env/ext4.c (100%)
 rename common/env_fat.c => env/fat.c (100%)
 rename common/env_flags.c => env/flags.c (100%)
 rename common/env_flash.c => env/flash.c (100%)
 rename common/env_mmc.c => env/mmc.c (100%)
 rename common/env_nand.c => env/nand.c (100%)
 rename common/env_nowhere.c => env/nowhere.c (100%)
 rename common/env_nvram.c => env/nvram.c (100%)
 rename common/env_onenand.c => env/onenand.c (100%)
 rename common/env_remote.c => env/remote.c (100%)
 rename common/env_sata.c => env/sata.c (100%)
 rename common/env_sf.c => env/sf.c (100%)
 rename common/env_ubi.c => env/ubi.c (100%)

diff --git a/Kconfig b/Kconfig
index c1451bceda..5ca3854b23 100644
--- a/Kconfig
+++ b/Kconfig
@@ -368,6 +368,8 @@ source "disk/Kconfig"
 
 source "dts/Kconfig"
 
+source "env/Kconfig"
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
diff --git a/Makefile b/Makefile
index 5b16965585..e95b658570 100644
--- a/Makefile
+++ b/Makefile
@@ -690,6 +690,7 @@ libs-y += drivers/usb/phy/
 libs-y += drivers/usb/ulpi/
 libs-y += cmd/
 libs-y += common/
+libs-y += env/
 libs-$(CONFIG_API) += api/
 libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
diff --git a/arch/sh/cpu/u-boot.lds b/arch/sh/cpu/u-boot.lds
index bbf9ff485f..7fc91bc4aa 100644
--- a/arch/sh/cpu/u-boot.lds
+++ b/arch/sh/cpu/u-boot.lds
@@ -33,9 +33,9 @@ SECTIONS
KEEP(CONFIG_BOARDDIR/lowlevel_init.o(.text .spiboot1.text))
KEEP(*(.spiboot2.text))
. = ALIGN(8192);
-   common/env_embedded.o   (.ppcenv)
+   env/embedded.o  (.ppcenv)
. = ALIGN(8192);
-   common/env_embedded.o   (.ppcenvr)
+   env/embedded.o  (.ppcenvr)
. = ALIGN(8192);
*(.text)
. = ALIGN(4);
diff --git a/board/freescale/mx31ads/u-boot.lds 
b/board/freescale/mx31ads/u-boot.lds
index 8a4a8a2f07..71a63f188e 100644
--- a/board/freescale/mx31ads/u-boot.lds
+++ b/board/freescale/mx31ads/u-boot.lds
@@ -30,7 

Re: [U-Boot] [PATCH 2/3] clk: zynqmp: Dont panic incase of mmio write/read failures

2017-07-31 Thread Simon Glass
On 20 July 2017 at 03:03, Michal Simek  wrote:
> From: Siva Durga Prasad Paladugu 
>
> Dont panic incase of mmio write/read failures instead return
> error and let the peripheral driver take care of clock get
> and set failures.
>
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
>
>  drivers/clk/clk_zynqmp.c | 63 
> +---
>  1 file changed, 44 insertions(+), 19 deletions(-)

Reviewed-by: Simon Glass 

But I suggest using debug() instead of printf() on error. This is a
driver, after all.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 10/14] dm: mmc: sunxi: Add support for driver model

2017-07-31 Thread Simon Glass
Hi Suneel,

On 28 July 2017 at 15:34, Suneel Garapati  wrote:
> Hi Simon,
>
>
> On Fri, Jul 28, 2017 at 11:44 AM, Simon Glass  wrote:
>> Hi Suneel,
>>
>> On 27 July 2017 at 23:03, Suneel Garapati  wrote:
>>> Hi Simon,
>>>
>>> I have similar requirement of Cavium boards using two card slots on
>>> one host and currently trying to figure out to support it using
>>> DM_MMC.
>>> Would like to know if you have quick thoughts or seen similar use case
>>> with some other boards too?
>>
>> It should work correctly - what sort of problem do you have?
>
> Each mmc_bind call creates child blk_device and initialize the mmc
> structure with defaults and further mmc_init or driver_probe would set
> the rest of the members.
> For the case, one host and two card slots, assuming card slots put up
> as child nodes to mmc node in devicetree
>  - driver probe called for once on host, initiates only one
> mmc_bind call -> only one child blk device(udevice) created
>  - also 'struct mmc' includes card specific data cid csd scr rca
> which should scale for multiple slots simultaneously
>  - assuming boot up detects two cards on two slots, mmc dev 0 will
> chose host but not slot
>  - mmc_uclass_priv holds mmc reference but depending on slot it
> should get updated.
>  - maybe need to split mmc into mmc_host and mmc_card structures like 
> Linux.
>
> Also, mmc dev 0/1 from cmd prompt would choose host and not the card slot.

I thought this thread was about switching between different MMC controllers...

OK, I see. I did not know that an MMC controller could support two
devices. How do you switch between slots? Does U-Boot have any support
for this at present?

It should be possible to add a second child device for MMC easily
enough. But there will need to be some changes, e.g.
mmc_get_blk_desc() will need an extra parameter with the slot number.

Regards,
Simon

>
> Please correct me.
>
> Regards,
> Suneel
>
>>
>>>
>>> Please correct me if I miss something obvious.
>>>
>>
>> Regards,
>> Simon
>>
>>> Regards,
>>> Suneel
>>>
>>>
>>> On Thu, Jul 27, 2017 at 9:19 PM, Simon Glass  wrote:
 Hi Maxime,

 On 17 July 2017 at 03:26, Maxime Ripard
  wrote:
> Hi Simon,
>
> On Fri, Jul 14, 2017 at 07:47:45AM -0600, Simon Glass wrote:
>> On 5 July 2017 at 14:14, Maxime Ripard 
>>  wrote:
>> > On Wed, Jul 05, 2017 at 04:57:40PM +0200, Maxime Ripard wrote:
>> >> On Tue, Jul 04, 2017 at 01:33:25PM -0600, Simon Glass wrote:
>> >> > Hi Maxime,
>> >> >
>> >> > On 21 June 2017 at 01:31, Maxime Ripard
>> >> >  wrote:
>> >> > > Hi Simon,
>> >> > >
>> >> > > On Mon, Jun 19, 2017 at 11:11:27AM -0600, Simon Glass wrote:
>> >> > >> Add a driver-model version of this driver which mostly uses the 
>> >> > >> existing
>> >> > >> code. The old code can be removed once all boards are switched 
>> >> > >> over.
>> >> > >>
>> >> > >> Signed-off-by: Simon Glass 
>> >> > >
>> >> > > I'm not sure if you tested that, but we have some code that 
>> >> > > switches
>> >> > > the MMC indices when using both an eMMC and an external MMC.
>> >> > >
>> >> > > http://git.denx.de/?p=u-boot.git;a=blob;f=board/sunxi/board.c#l494
>> >> > >
>> >> > > This predates my time, but it seems that it was done to have a
>> >> > > consistent boot MMC device ID.
>> >> > >
>> >> > > I'm not really sure we can get rid of it (even if it creates some
>> >> > > issues of it's own), but what would be the impact of a switch to 
>> >> > > the
>> >> > > device model on that logic?
>> >> >
>> >> > That is a pretty terrible hack.
>> >>
>> >> Yes, I know. This is especially bad when used together with other
>> >> tools that rely on one MMC index for example (such as fastboot).
>> >>
>> >> I wanted to kill it for quite some time, but I'm a bit reluctant due
>> >> to the possible side effects.
>> >>
>> >> > I'm not sure whether it will continue to work with DM. It does still
>> >> > use the device number in the block device, so maybe...  Do you have
>> >> > a board would use this?
>> >>
>> >> I guess I do. I'll give it a try or tonight and let you know.
>> >
>> > I just tested. Even with an eMMC (which was the first use case for
>> > that hack), it works, even things that are not mainline yet (fastboot,
>> > etc).
>> >
>> > It obviously break the old scripts relying on the mmc index, but I
>> > guess that's ok.
>> >
>> > There's one regression though. Our eMMC will always be the second one,
>> > which means that the distro bootargs will always boot on the external
>> > SD first (which is always going to be mmc0).
>> >
>> > 

Re: [U-Boot] [PATCH] arm64: zynqmp: Move dts zcu102 to zcu102-revA

2017-07-31 Thread Simon Glass
On 20 July 2017 at 04:42, Michal Simek  wrote:
> Not using board revision is causing confusion about which board is
> supported and tested. Mark dts files exactly with board revision which
> was tested. When new board revision arives it can be symlink if SW view
> is the same. Also add -revX suffix to compatible string because user space
> tools are parsing this string and can change behavior depends of board
> revision.
>
> Signed-off-by: Michal Simek 
> ---
>
>  arch/arm/dts/Makefile   | 2 
> +-
>  arch/arm/dts/{zynqmp-zcu102.dts => zynqmp-zcu102-revA.dts}  | 2 
> +-
>  arch/arm/dts/zynqmp-zcu102-revB.dts | 2 
> +-
>  ...linx_zynqmp_zcu102_defconfig => xilinx_zynqmp_zcu102_revA_defconfig} | 2 
> +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>  rename arch/arm/dts/{zynqmp-zcu102.dts => zynqmp-zcu102-revA.dts} (99%)
>  rename configs/{xilinx_zynqmp_zcu102_defconfig => 
> xilinx_zynqmp_zcu102_revA_defconfig} (97%)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] clk: zynqmp: Add support for CCF driver

2017-07-31 Thread Simon Glass
Hi Michal,

On 20 July 2017 at 03:03, Michal Simek  wrote:
> From: Siva Durga Prasad Paladugu 
>
> Add support for CCF, this CCF reads the ref clocks
> from dt and checks all the required clock control
> registers for its source , divisors and calculates
> the clock from them. This supports clock and set
> functions.
>
> Panic when read/write fails.
>
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
>
>  drivers/clk/clk_zynqmp.c | 673 
> ---
>  1 file changed, 526 insertions(+), 147 deletions(-)
>

Reviewed-by: Simon Glass 

Where is soc_clk_dump() called from?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mkimage: check environment for dtc binary location

2017-07-31 Thread Simon Glass
Hi,

On 19 July 2017 at 14:30, Hauke Mehrtens  wrote:
> Currently mkimage assumes the dtc binary is in the path and fails
> otherwise. This patch makes it check the DTC environment variable first
> for the dtc binary and then fall back to the default path. This makes
> it possible to call the u-boot build with make DTC=... and build a fit
> image with the dtc binary not being the the default path.
>
> Signed-off-by: Hauke Mehrtens 
> Cc: Simon Glass 
> ---
>  tools/fit_image.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/fit_image.c b/tools/fit_image.c
> index 4dc8bd8862..d7a7b07faf 100644
> --- a/tools/fit_image.c
> +++ b/tools/fit_image.c
> @@ -647,9 +647,14 @@ static int fit_handle_file(struct image_tool_params 
> *params)
> }
> *cmd = '\0';
> } else if (params->datafile) {
> +   const char* dtc = getenv("DTC");
> +
> +   if (!dtc)
> +   dtc = MKIMAGE_DTC;
> +
> /* dtc -I dts -O dtb -p 500 datafile > tmpfile */
> snprintf(cmd, sizeof(cmd), "%s %s %s > %s",
> -MKIMAGE_DTC, params->dtc, params->datafile, tmpfile);
> +dtc, params->dtc, params->datafile, tmpfile);
> debug("Trying to execute \"%s\"\n", cmd);
> } else {
> snprintf(cmd, sizeof(cmd), "cp %s %s",
> --
> 2.11.0
>

Reviewed-by: Simon Glass 

But please can you add mention of this to the help (mkimage.1)

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] am335x_hs_evm: Disable CONFIG_SPL_ENV_SUPPORT

2017-07-31 Thread Simon Glass
On 26 July 2017 at 20:46, Lokesh Vutla  wrote:
>
>
> On 7/26/2017 10:41 PM, Tom Rini wrote:
>> The main uses of CONFIG_SPL_ENV_SUPPORT are for network support and for
>> disabling "Falcon Mode" support at run-time.  As this build enables
>> neither, remove this feature.
>>
>> Cc: Andrew F. Davis 
>> Signed-off-by: Tom Rini 
>
> Reviewed-by: Lokesh Vutla 
>
> Thanks and regards,
> Lokesh
>
>> ---
>>  configs/am335x_hs_evm_defconfig | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/configs/am335x_hs_evm_defconfig 
>> b/configs/am335x_hs_evm_defconfig
>> index 2b1acb70d18f..ffdbe7585573 100644
>> --- a/configs/am335x_hs_evm_defconfig
>> +++ b/configs/am335x_hs_evm_defconfig
>> @@ -18,6 +18,7 @@ CONFIG_VERSION_VARIABLE=y
>>  CONFIG_ARCH_MISC_INIT=y
>>  CONFIG_SPL=y
>>  CONFIG_SPL_STACK_R=y
>> +# CONFIG_SPL_ENV_SUPPORT is not set
>>  # CONFIG_SPL_EXT_SUPPORT is not set
>>  CONFIG_SPL_MTD_SUPPORT=y
>>  # CONFIG_SPL_YMODEM_SUPPORT is not set

Reviewed-by: Simon Glass 

>>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 4/5] arm: socfpga: Add intermediate driver between flash and FPGA manager

2017-07-31 Thread Marek Vasut
On 07/31/2017 12:50 PM, tien.fong.c...@intel.com wrote:
> From: Tien Fong Chee 
> 
> Configuration flip-flop driver is mainly used for handling the FPGA program
> operation where the FPGA image loading from the flash into FPGA manager.
> 
> Signed-off-by: Tien Fong Chee 
> ---
>  arch/arm/mach-socfpga/cff.c  |  581 
> ++
>  arch/arm/mach-socfpga/include/mach/cff.h |   40 ++
>  include/configs/socfpga_arria10_socdk.h  |6 +
>  3 files changed, 627 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-socfpga/cff.c
>  create mode 100644 arch/arm/mach-socfpga/include/mach/cff.h
> 

Same comment as to previous patch, there is already support for loading
FPGA from storage used by Xilinx, improve on that.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/5] configs: socfpga: Add config for RBF loading from FAT fs

2017-07-31 Thread Marek Vasut
On 07/31/2017 12:50 PM, tien.fong.c...@intel.com wrote:
> From: Tien Fong Chee 
> 
> This config enable the mechanism for loading RBF file from FAT fs into
> FPGA manager.
> 
> Signed-off-by: Tien Fong Chee 
> ---
>  arch/arm/mach-socfpga/Kconfig |7 +++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
> index 45e5379..3fbac20 100644
> --- a/arch/arm/mach-socfpga/Kconfig
> +++ b/arch/arm/mach-socfpga/Kconfig
> @@ -33,6 +33,13 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
>  config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE
>   default 0xa2
>  
> +config RBF_SDMMC_FAT_SUPPORT

NAK, Xilinx already has some support for loading FPGA from FS, so
improve on that.

> + bool "Support FPGA program with FAT RBF"
> + default y if SPL_FAT_SUPPORT
> + help
> + Enable support for programming FPGA with RAW binary file
> + (periph rbf + core rbf) loading from FAT partition.
> +
>  config TARGET_SOCFPGA_ARRIA5
>   bool
>   select TARGET_SOCFPGA_GEN5
> 


-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] arm: socfpga: Add checking function on searching boot device

2017-07-31 Thread Marek Vasut
On 07/31/2017 12:50 PM, tien.fong.c...@intel.com wrote:
> From: Tien Fong Chee 
> 
> Function for checking boot device type, which is required for locating
> flash where U-boot image, FPGA design are stored.
> 
> Signed-off-by: Tien Fong Chee 
> ---
>  arch/arm/mach-socfpga/include/mach/misc.h |   19 +++
>  arch/arm/mach-socfpga/misc_arria10.c  |   22 ++
>  2 files changed, 41 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/include/mach/misc.h 
> b/arch/arm/mach-socfpga/include/mach/misc.h
> index 0b65783..b219aac 100644
> --- a/arch/arm/mach-socfpga/include/mach/misc.h
> +++ b/arch/arm/mach-socfpga/include/mach/misc.h
> @@ -14,6 +14,24 @@ struct bsel {
>   const char  *name;
>  };
>  
> +enum {
> + BOOT_DEVICE_RAM,
> + BOOT_DEVICE_MMC1,
> + BOOT_DEVICE_MMC2,
> + BOOT_DEVICE_MMC2_2,
> + BOOT_DEVICE_NAND,
> + BOOT_DEVICE_ONENAND,
> + BOOT_DEVICE_NOR,
> + BOOT_DEVICE_UART,
> + BOOT_DEVICE_SPI,
> + BOOT_DEVICE_USB,
> + BOOT_DEVICE_SATA,
> + BOOT_DEVICE_I2C,
> + BOOT_DEVICE_BOARD,
> + BOOT_DEVICE_DFU,
> + BOOT_DEVICE_NONE

Why do you have so many bootdevices here if half of them aren't
supported/used ?

> +};
> +
>  extern struct bsel bsel_str[];
>  
>  #ifdef CONFIG_FPGA
> @@ -26,6 +44,7 @@ static inline void socfpga_fpga_add(void) {}
>  unsigned int dedicated_uart_com_port(const void *blob);
>  unsigned int shared_uart_com_port(const void *blob);
>  unsigned int uart_com_port(const void *blob);
> +u32 boot_device(void);
>  #endif
>  
>  #endif /* _MISC_H_ */
> diff --git a/arch/arm/mach-socfpga/misc_arria10.c 
> b/arch/arm/mach-socfpga/misc_arria10.c
> index 9d751f6..069a0a6 100644
> --- a/arch/arm/mach-socfpga/misc_arria10.c
> +++ b/arch/arm/mach-socfpga/misc_arria10.c
> @@ -235,6 +235,28 @@ unsigned int uart_com_port(const void *blob)
>   return shared_uart_com_port(blob);
>  }
>  
> +u32 boot_device(void)
> +{
> + const u32 bsel = readl(_regs->bootinfo);
> +
> + switch (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {

This looks very similar to what is on Gen5 ?

> + case 0x1:   /* FPGA (HPS2FPGA Bridge) */
> + return BOOT_DEVICE_RAM;
> + case 0x2:   /* NAND Flash (1.8V) */
> + case 0x3:   /* NAND Flash (3.0V) */
> + return BOOT_DEVICE_NAND;
> + case 0x4:   /* SD/MMC External Transceiver (1.8V) */
> + case 0x5:   /* SD/MMC Internal Transceiver (3.0V) */
> + return BOOT_DEVICE_MMC1;
> + case 0x6:   /* QSPI Flash (1.8V) */
> + case 0x7:   /* QSPI Flash (3.0V) */
> + return BOOT_DEVICE_SPI;
> + default:
> + printf("Invalid boot device (bsel=%08x)!\n", bsel);
> + hang();
> + }
> +}
> +
>  /*
>   * Print CPU information
>   */
> 


-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/2] misc: i2c_eeprom: Add compatibles

2017-07-31 Thread Tom Rini
On Mon, Jul 31, 2017 at 11:25:29AM +0800, Wenyou Yang wrote:

> Add the compatibles to support the I2C EEPROM 24AA02E48 and AT24MAC402
> respectively.
>  - microchip,24aa02e48
>  - atmel,24mac402
> 
> 
> Wenyou Yang (2):
>   misc: i2c_eeprom: Add compatible for 24AA02E48
>   misc: i2c_eeprom: Add compatible for AT24MAC402
> 
>  drivers/misc/i2c_eeprom.c | 2 ++
>  1 file changed, 2 insertions(+)

How does this work in the kernel?  Grepping around on what we list
currently even, I see that
Documentation/devicetree/bindings/eeprom/eeprom.txt lists some of the
ones we have in drivers/misc/i2c_eeprom.c as an example but nothing
catching on the compatible string.  Does the kernel have some smart
logic to match these compatibles?  If so, could we mirror that?  Thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] vsprintf.c: add wide string (%ls) support

2017-07-31 Thread Rob Clark
This is convenient for efi_loader which deals a lot with utf16.

Signed-off-by: Rob Clark 
---
 lib/vsprintf.c | 39 +--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 874a2951f7..84e157ecb1 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -270,6 +270,35 @@ static char *string(char *buf, char *end, char *s, int 
field_width,
return buf;
 }
 
+static size_t strnlen16(const u16* s, size_t count)
+{
+   const u16 *sc;
+
+   for (sc = s; count-- && *sc; ++sc)
+   /* nothing */;
+   return sc - s;
+}
+
+static char *string16(char *buf, char *end, u16 *s, int field_width,
+   int precision, int flags)
+{
+   int len, i;
+
+   if (s == NULL)
+   s = L"";
+
+   len = strnlen16(s, precision);
+
+   if (!(flags & LEFT))
+   while (len < field_width--)
+   ADDCH(buf, ' ');
+   for (i = 0; i < len; ++i)
+   ADDCH(buf, *s++);
+   while (len < field_width--)
+   ADDCH(buf, ' ');
+   return buf;
+}
+
 #ifdef CONFIG_CMD_NET
 static const char hex_asc[] = "0123456789abcdef";
 #define hex_asc_lo(x)  hex_asc[((x) & 0x0f)]
@@ -528,8 +557,14 @@ repeat:
continue;
 
case 's':
-   str = string(str, end, va_arg(args, char *),
-field_width, precision, flags);
+   if (qualifier == 'l') {
+   str = string16(str, end, va_arg(args, u16 *),
+  field_width, precision, flags);
+
+   } else {
+   str = string(str, end, va_arg(args, char *),
+field_width, precision, flags);
+   }
continue;
 
case 'p':
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] sf: Add Macronix MX25U6435F device parameters

2017-07-31 Thread Bin Meng
Hi Jagan,

On Mon, Jul 31, 2017 at 5:33 PM, Jagan Teki  wrote:
> On Sun, Jul 23, 2017 at 8:14 PM, Bin Meng  wrote:
>> This adds support for Macronix flash MX25U6435F (device ID 0xc22537).
>>
>> Signed-off-by: Bin Meng 
>> ---
>>
>>  drivers/mtd/spi/spi_flash_ids.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/mtd/spi/spi_flash_ids.c 
>> b/drivers/mtd/spi/spi_flash_ids.c
>> index edca94e..c4ccf48 100644
>> --- a/drivers/mtd/spi/spi_flash_ids.c
>> +++ b/drivers/mtd/spi/spi_flash_ids.c
>> @@ -81,6 +81,7 @@ const struct spi_flash_info spi_flash_ids[] = {
>> {"mx25l12805", INFO(0xc22018, 0x0, 64 * 1024,   256, RD_FULL | 
>> WR_QPP) },
>> {"mx25l25635f",INFO(0xc22019, 0x0, 64 * 1024,   512, RD_FULL | 
>> WR_QPP) },
>> {"mx25l51235f",INFO(0xc2201a, 0x0, 64 * 1024,  1024, RD_FULL | 
>> WR_QPP) },
>> +   {"mx25u6435f", INFO(0xc22537, 0x0, 64 * 1024,   128, RD_FULL | 
>> WR_QPP) },
>
> Applied to u-boot-spi/master

What about the 2nd patch [1] in this series?

And I don't see this patch showing in
http://git.denx.de/?p=u-boot/u-boot-spi.git;a=summary. Am I missing
anything?

[1] http://patchwork.ozlabs.org/patch/792565/

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 2/2] MIPS: Stop building position independent code

2017-07-31 Thread Daniel Schwierzeck
2017-07-30 18:04 GMT+02:00 Álvaro Fernández Rojas :
>
>
> El 30/07/2017 a las 16:05, Daniel Schwierzeck escribió:
>>
>>
>> Am 30.07.2017 um 14:27 schrieb Álvaro Fernández Rojas:
>>> I've been a bit busy lately and I couldn't test this until now, but I have 
>>> to say that this commit breaks u-boot bmips support :(
>>>
>>> BTW, I tried this on several bmips boards (one of them is a Netgear 
>>> CG3100D, which uses u-boot.bin instead of u-boot.elf)
>>>
>>> Do you have any idea on what could be hapenning?
>>>
>>
>> maybe you need to specify "--emit-relocs" too when linking u-boot.elf
>> from u-boot-elf.o. But u-boot-elf.o should already contain the correct
>> .reloc section with the updated relocation entries so you don't need to
>> rerun the reloc-tool on u-boot.elf.
>>
>
> I tried that and it doesn't work.
> However, I've just found out that if I remove the relocs call it boots 
> again...
> https://gist.github.com/Noltari/ce3a6a9dda69e74caf7ba33c9c8ade9a

I wonder how this can work. Even the u-boot.elf now contains
position-dependent code so that an update of the relocation entries is
required there too. Without the updated entries, U-Boot can't execute
after jumping from relocate_code() to board_init_r(). Did you use a
clean build if U-Boot?

-- 
- Daniel
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/5] arm: socfpga: Add checking function on searching boot device

2017-07-31 Thread tien . fong . chee
From: Tien Fong Chee 

Function for checking boot device type, which is required for locating
flash where U-boot image, FPGA design are stored.

Signed-off-by: Tien Fong Chee 
---
 arch/arm/mach-socfpga/include/mach/misc.h |   19 +++
 arch/arm/mach-socfpga/misc_arria10.c  |   22 ++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/misc.h 
b/arch/arm/mach-socfpga/include/mach/misc.h
index 0b65783..b219aac 100644
--- a/arch/arm/mach-socfpga/include/mach/misc.h
+++ b/arch/arm/mach-socfpga/include/mach/misc.h
@@ -14,6 +14,24 @@ struct bsel {
const char  *name;
 };
 
+enum {
+   BOOT_DEVICE_RAM,
+   BOOT_DEVICE_MMC1,
+   BOOT_DEVICE_MMC2,
+   BOOT_DEVICE_MMC2_2,
+   BOOT_DEVICE_NAND,
+   BOOT_DEVICE_ONENAND,
+   BOOT_DEVICE_NOR,
+   BOOT_DEVICE_UART,
+   BOOT_DEVICE_SPI,
+   BOOT_DEVICE_USB,
+   BOOT_DEVICE_SATA,
+   BOOT_DEVICE_I2C,
+   BOOT_DEVICE_BOARD,
+   BOOT_DEVICE_DFU,
+   BOOT_DEVICE_NONE
+};
+
 extern struct bsel bsel_str[];
 
 #ifdef CONFIG_FPGA
@@ -26,6 +44,7 @@ static inline void socfpga_fpga_add(void) {}
 unsigned int dedicated_uart_com_port(const void *blob);
 unsigned int shared_uart_com_port(const void *blob);
 unsigned int uart_com_port(const void *blob);
+u32 boot_device(void);
 #endif
 
 #endif /* _MISC_H_ */
diff --git a/arch/arm/mach-socfpga/misc_arria10.c 
b/arch/arm/mach-socfpga/misc_arria10.c
index 9d751f6..069a0a6 100644
--- a/arch/arm/mach-socfpga/misc_arria10.c
+++ b/arch/arm/mach-socfpga/misc_arria10.c
@@ -235,6 +235,28 @@ unsigned int uart_com_port(const void *blob)
return shared_uart_com_port(blob);
 }
 
+u32 boot_device(void)
+{
+   const u32 bsel = readl(_regs->bootinfo);
+
+   switch (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
+   case 0x1:   /* FPGA (HPS2FPGA Bridge) */
+   return BOOT_DEVICE_RAM;
+   case 0x2:   /* NAND Flash (1.8V) */
+   case 0x3:   /* NAND Flash (3.0V) */
+   return BOOT_DEVICE_NAND;
+   case 0x4:   /* SD/MMC External Transceiver (1.8V) */
+   case 0x5:   /* SD/MMC Internal Transceiver (3.0V) */
+   return BOOT_DEVICE_MMC1;
+   case 0x6:   /* QSPI Flash (1.8V) */
+   case 0x7:   /* QSPI Flash (3.0V) */
+   return BOOT_DEVICE_SPI;
+   default:
+   printf("Invalid boot device (bsel=%08x)!\n", bsel);
+   hang();
+   }
+}
+
 /*
  * Print CPU information
  */
-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/5] Add intermediate driver(cff driver) between flash & FPGA

2017-07-31 Thread tien . fong . chee
From: Tien Fong Chee 

This patchset adding intermediate driver called cff driver to support all the
FPGA program operations between FPGA manager and flash.

Tien Fong Chee (5):
  arm: socfpga: Add checking function on searching boot device
  arm: socfpga: Add checking function on FPGA setting in FDT
  configs: socfpga: Add config for RBF loading from FAT fs
  arm: socfpga: Add intermediate driver between flash and FPGA manager
  arm: socfpga: Enable cff driver build

 arch/arm/mach-socfpga/Kconfig |7 +
 arch/arm/mach-socfpga/Makefile|1 +
 arch/arm/mach-socfpga/cff.c   |  581 +
 arch/arm/mach-socfpga/include/mach/cff.h  |   40 ++
 arch/arm/mach-socfpga/include/mach/misc.h |   20 +
 arch/arm/mach-socfpga/misc_arria10.c  |   42 ++
 include/configs/socfpga_arria10_socdk.h   |6 +
 7 files changed, 697 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/cff.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/cff.h

-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] arm: socfpga: Remove unused FPGA feature from gen5 SPL

2017-07-31 Thread Chee, Tien Fong
On Jum, 2017-07-28 at 13:40 +0200, Marek Vasut wrote:
> On 07/28/2017 01:35 PM, Chee, Tien Fong wrote:
> > 
> > On Jum, 2017-07-28 at 09:52 +0200, Marek Vasut wrote:
> > > 
> > > On 07/28/2017 07:16 AM, Chee, Tien Fong wrote:
> > > > 
> > > > 
> > > > On Kha, 2017-07-27 at 11:37 +0200, Marek Vasut wrote:
> > > > > 
> > > > > 
> > > > > On 07/27/2017 11:21 AM, Chee, Tien Fong wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On Kha, 2017-07-27 at 10:21 +0200, Marek Vasut wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > On 07/27/2017 06:36 AM, tien.fong.c...@intel.com wrote:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > From: Tien Fong Chee 
> > > > > > > > 
> > > > > > > > Remove unused FPGA feature for saving some space in
> > > > > > > > gen5
> > > > > > > > SPL.
> > > > > > > I really dislike the ifdefery. Why is this patch even
> > > > > > > needed?
> > > > > > > I thought we had no space problems in the Gen5 SPL?
> > > > > > > 
> > > > > > I can remove those codes within ifdefery because they are
> > > > > > no
> > > > > > longer
> > > > > > required.
> > > > > Why ?
> > > > > 
> > > > because those functions are testing on FPGA when the bridge is
> > > > enabled
> > > > in SPL.
> > > That's what those functions do, it doesn't answer my question why
> > > they're no longer needed.
> > > 
> > It is because fpga is disabled in SPL, hence those fpga checking
> > routine can be removed. For example init sdram mmr running before
> > calling command "enable fpga", then we can safely
> > remove pgamgr_test_fpga_ready(). But, drivers are shared between
> > SPL
> > and U-boot, we still need minimal ifdefery in
> > socfpga_bridges_reset.
> What if the FPGA starts before the HPS and is loaded from ie. EPCQ ?
> 
On an FPGA Boot the BootROM checks to see that the INIT_DONE bit from
the FPGA is set. It reads the bit twice and the bit must be set for
both reads. Once the INIT_DONE bit has been checked the BootROM maps
the FPGA into the HPS address space. The BootROM code will then take
the H2F AXI Bridge out of reset. So, the impact of changes i made are
no pinmux of fpga interface update from handoff and also no functions
checking on FPGA interface in SPL pahse. Because no functions checking
on FPGA interface in SPL, which are located in arch/arm/mach-
socpfga/fpga_manager.c, so i can merge fpga_manager.c into
drivers/fpga/socfpga_gen5.
> > 
> > > 
> > > > 
> > > > 
> > > > But, i will keep minimal ifdefery on socfpga_bridges_reset to
> > > > indicate the fpga bridges should not be released in SPL.
> > > > > 
> > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > I keep them here just for one day we can use if we need to.
> > > > > > Do you remember we have consent to clean up those useless
> > > > > > codes
> > > > > > for
> > > > > > SPL, all fpga related drivers will be moved into one driver
> > > > > > location.
> > > > > No, sorry.
> > > > > 
> > > > Are you disagree on keeping the ifdefery codes, or disagree on
> > > > moving
> > > > all FPGA related functions into drivers/fpga/... ?
> > > I dislike the ifdeffery.
> > > 
> > DO you have any better idea on this common function shared between
> > SPL
> > and U-boot?
> [...]
> 
> I'm not really sure you can remove them from the SPL, see above.
> 
I found out OCRAM is already remap and FPGA intefaces is set visible on
L3 memory map by function socfpga_nic301_slave_ns in very early of
spl.c . So, it is safe for above changes.
> > 
> > > 
> > > > 
> > > > Yeah, you are rightthis is what i missing, the OCRAM should
> > > > be
> > > > remap to lowest memory region 1 MiB. So i propose just to remap
> > > > OCRAM,
> > > > and FPGA related bridges can be remaped in U-boot by calling
> > > > the
> > > > "enable bridge" command.
> > > So basically the user would need to run this random command to
> > > fix
> > > his
> > > obscure memory issues with the first 1 MiB ? Unacceptable, U-Boot
> > > does
> > > this and this behavior will be retained. There's no way such a
> > > change
> > > of
> > > behavior can be let in.
> > > 
> > The only remap first 1 MiB required to L3 is OCRAM. Hence, i
> > propose we
> > only keep OCRAM remap at here. Any FPGA related bridges visibility
> > to
> > L3 master can be set visible on L3 memory map when we require
> > accessing
> > to FPGA or calling "enable bridge".
> > 
> > Chin Liang, Could you help to advice on these?
> > > 
> > > [...]
> 
I propose to keep this patchset as open discussion, with more people
included especially input from chin liang(gen5 owener). The purpose of
this patch set is to keep SPL on HW critial intialization and sdram
init setting only, remove useless feature(no FPGA pinmux update and
function checking on FPGA in SPL), cleaning up FPGA driver
code(fpga_manager.c) for gen5 by moving them into one location
/drivers/fpga. All FPGA driver should be enabled by one control
CONFIG_SPL_FPGA_SUPPORT.

What do you guys think?

Re: [U-Boot] [PATCH 1/2] sf: Add Macronix MX25U6435F device parameters

2017-07-31 Thread Jagan Teki
On Sun, Jul 23, 2017 at 8:14 PM, Bin Meng  wrote:
> This adds support for Macronix flash MX25U6435F (device ID 0xc22537).
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/mtd/spi/spi_flash_ids.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
> index edca94e..c4ccf48 100644
> --- a/drivers/mtd/spi/spi_flash_ids.c
> +++ b/drivers/mtd/spi/spi_flash_ids.c
> @@ -81,6 +81,7 @@ const struct spi_flash_info spi_flash_ids[] = {
> {"mx25l12805", INFO(0xc22018, 0x0, 64 * 1024,   256, RD_FULL | 
> WR_QPP) },
> {"mx25l25635f",INFO(0xc22019, 0x0, 64 * 1024,   512, RD_FULL | 
> WR_QPP) },
> {"mx25l51235f",INFO(0xc2201a, 0x0, 64 * 1024,  1024, RD_FULL | 
> WR_QPP) },
> +   {"mx25u6435f", INFO(0xc22537, 0x0, 64 * 1024,   128, RD_FULL | 
> WR_QPP) },

Applied to u-boot-spi/master

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] usb: dwc2: Align size of invalidating dcache before starting DMA

2017-07-31 Thread Łukasz Majewski

Hi Seung-Woo,


During using dwc2 usb gadget, if usb message size is too small,
following cache misaligned warning is shown:

   CACHE: Misaligned operation at range [bfdbcb00, bfdbcb04]

Align size of invalidating dcache before starting DMA to remove the
warning.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 0d6d2fb..b6164af 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -111,7 +111,8 @@ static int setdma_rx(struct dwc2_ep *ep, struct 
dwc2_request *req)
ctrl =  readl(>out_endp[ep_num].doepctl);

invalidate_dcache_range((unsigned long) ep->dma_buf,
-   (unsigned long) ep->dma_buf + ep->len);
+   (unsigned long) ep->dma_buf +
+   ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));

writel((unsigned int) ep->dma_buf, >out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),



Reviewed-by: Łukasz Majewski 

--
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ARM64: zynqmp: avoid out of buffer access

2017-07-31 Thread Michal Simek
On 30.7.2017 22:18, Heinrich Schuchardt wrote:
> strncat(a, b, c) appends a maximum of c characters plus the 0 byte
> to a.
> 
> In board_init we first write 4 characters plus 0 byte to version.
> So only ZYNQMP_VERSION_SIZE - 5 additional characters fit into
> version.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  board/xilinx/zynqmp/zynqmp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 51a3d9f276..bbcab9869e 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -133,10 +133,10 @@ int board_init(void)
>   if (current_el() != 3) {
>   static char version[ZYNQMP_VERSION_SIZE];
>  
> - strncat(version, "xczu", ZYNQMP_VERSION_SIZE);
> + strncat(version, "xczu", 4);
>   zynqmppl.name = strncat(version,
>   zynqmp_get_silicon_idcode_name(),
> - ZYNQMP_VERSION_SIZE);
> + ZYNQMP_VERSION_SIZE - 5);
>   printf("Chip ID:\t%s\n", zynqmppl.name);
>   fpga_init();
>   fpga_add(fpga_xilinx, );
> 

Applied.

Thanks,
Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ARM64: zynqmp: avoid out of buffer access

2017-07-31 Thread Michal Simek
On 30.7.2017 22:18, Heinrich Schuchardt wrote:
> strncat(a, b, c) appends a maximum of c characters plus the 0 byte
> to a.
> 
> In board_init we first write 4 characters plus 0 byte to version.
> So only ZYNQMP_VERSION_SIZE - 5 additional characters fit into
> version.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  board/xilinx/zynqmp/zynqmp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 51a3d9f276..bbcab9869e 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -133,10 +133,10 @@ int board_init(void)
>   if (current_el() != 3) {
>   static char version[ZYNQMP_VERSION_SIZE];
>  
> - strncat(version, "xczu", ZYNQMP_VERSION_SIZE);
> + strncat(version, "xczu", 4);
>   zynqmppl.name = strncat(version,
>   zynqmp_get_silicon_idcode_name(),
> - ZYNQMP_VERSION_SIZE);
> + ZYNQMP_VERSION_SIZE - 5);
>   printf("Chip ID:\t%s\n", zynqmppl.name);
>   fpga_init();
>   fpga_add(fpga_xilinx, );
> 

Applied.

Thanks,
Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] usb: dwc2: Align size of invalidating dcache before starting DMA

2017-07-31 Thread Seung-Woo Kim
During using dwc2 usb gadget, if usb message size is too small,
following cache misaligned warning is shown:

   CACHE: Misaligned operation at range [bfdbcb00, bfdbcb04]

Align size of invalidating dcache before starting DMA to remove the
warning.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 0d6d2fb..b6164af 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -111,7 +111,8 @@ static int setdma_rx(struct dwc2_ep *ep, struct 
dwc2_request *req)
ctrl =  readl(>out_endp[ep_num].doepctl);
 
invalidate_dcache_range((unsigned long) ep->dma_buf,
-   (unsigned long) ep->dma_buf + ep->len);
+   (unsigned long) ep->dma_buf +
+   ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));
 
writel((unsigned int) ep->dma_buf, >out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ARM64: zynqmp: avoid out of buffer access

2017-07-31 Thread Michal Simek
On 30.7.2017 22:18, Heinrich Schuchardt wrote:
> strncat(a, b, c) appends a maximum of c characters plus the 0 byte
> to a.
> 
> In board_init we first write 4 characters plus 0 byte to version.
> So only ZYNQMP_VERSION_SIZE - 5 additional characters fit into
> version.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  board/xilinx/zynqmp/zynqmp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 51a3d9f276..bbcab9869e 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -133,10 +133,10 @@ int board_init(void)
>   if (current_el() != 3) {
>   static char version[ZYNQMP_VERSION_SIZE];
>  
> - strncat(version, "xczu", ZYNQMP_VERSION_SIZE);
> + strncat(version, "xczu", 4);
>   zynqmppl.name = strncat(version,
>   zynqmp_get_silicon_idcode_name(),
> - ZYNQMP_VERSION_SIZE);
> + ZYNQMP_VERSION_SIZE - 5);
>   printf("Chip ID:\t%s\n", zynqmppl.name);
>   fpga_init();
>   fpga_add(fpga_xilinx, );
> 

Applied.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs




signature.asc
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] sf: Add Macronix MX25U6435F device parameters

2017-07-31 Thread Bin Meng
Hi Jagan,

On Sun, Jul 23, 2017 at 10:44 PM, Bin Meng  wrote:
> This adds support for Macronix flash MX25U6435F (device ID 0xc22537).
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/mtd/spi/spi_flash_ids.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
> index edca94e..c4ccf48 100644
> --- a/drivers/mtd/spi/spi_flash_ids.c
> +++ b/drivers/mtd/spi/spi_flash_ids.c
> @@ -81,6 +81,7 @@ const struct spi_flash_info spi_flash_ids[] = {
> {"mx25l12805", INFO(0xc22018, 0x0, 64 * 1024,   256, RD_FULL | 
> WR_QPP) },
> {"mx25l25635f",INFO(0xc22019, 0x0, 64 * 1024,   512, RD_FULL | 
> WR_QPP) },
> {"mx25l51235f",INFO(0xc2201a, 0x0, 64 * 1024,  1024, RD_FULL | 
> WR_QPP) },
> +   {"mx25u6435f", INFO(0xc22537, 0x0, 64 * 1024,   128, RD_FULL | 
> WR_QPP) },
> {"mx25l12855e",INFO(0xc22618, 0x0, 64 * 1024,   256, RD_FULL | 
> WR_QPP) },
> {"mx66u51235f",INFO(0xc2253a, 0x0, 64 * 1024,  1024, RD_FULL | 
> WR_QPP) },
> {"mx66l1g45g", INFO(0xc2201b, 0x0, 64 * 1024,  2048, RD_FULL | 
> WR_QPP) },
> --

Ping.

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 0/8] sf: improve support of (Q)SPI flash memories

2017-07-31 Thread Yang, Wenyou

Hi,

Do you have comments?


Best Regards,
Wenyou Yang

On 2017/7/25 15:00, Wenyou Yang wrote:

This series of patches are based and have been tested on the 'master'
branch of the u-boot.git tree.

Tests were passed with a sama5d2 xplained board which embeds both SPI and
QSPI controllers.

The following tests have been passed:

- QSPI0 + Macronix MX25L25673G:
   + probe: OK
   + Fast Read 1-1-4 at offset 0x1 (u-boot env): OK
   + Page Program 1-1-4 at offset 0x1: OK
 The Macronix datasheet tells that only Page Program 1-4-4 is
 supported, not Page Program 1-1-4, however it worked, I don't know
 why...

- QSPI0 + Microchip SST26
   + probe: OK
   + Fast Read 1-1-4 at offset 0x1 (u-boot env): OK
   + Page Program 1-1-1 at offset 0x1: OK
 SST26 memories support Page Program 1-4-4 but with the op code of
 Page Program 1-1-4, which is not standard so I don't use it.

- QSPI0 + Adesto AT25DF321A
   + probe: OK
   + Fast Read 1-1-1 at offset 0x1 (u-boot env): OK
   + Page Program 1-1-1 at offset 0x1: OK

- SPI0 + Adesto AT25DF321A
   + probe: OK
   + Fast Read 1-1-1 at offset 0x6000 (u-boot env): OK
   + Page Program 1-1-1 at offest 0x6000: OK

- SPI1 + Atmel AT45
   + probe: OK
   + Read at offset 0 and other than 0: OK
   + Write at offset 0 and other than 0: OK

During my tests, I used:
   - setenv/saveenv, reboot, printenv
   or
   - sf probe, sf read, sf write, sf erase and sf update.

Changes in v3:
  - Add the include  to fix build error for corvus_defconfig.

Changes in v2:
  - Rebase on the latest u-boot/master(2710d54f5).

Cyrille Pitchen (8):
   spi: add support of SPI flash commands
   sf: describe all SPI flash commands with 'struct spi_flash_command'
   sf: select the relevant SPI flash protocol for read and write commands
   sf: differentiate Page Program 1-1-4 and 1-4-4
   sf: add 'addr_len' member to 'struct spi_flash'
   sf: add new option to support SPI flash above 16MiB
   sf: add support to Microchip SST26 QSPI memories
   sf: add driver for Atmel QSPI controller

  drivers/mtd/spi/Kconfig |  16 +-
  drivers/mtd/spi/sf.c|  78 ++--
  drivers/mtd/spi/sf_dataflash.c  | 119 ++--
  drivers/mtd/spi/sf_internal.h   |  48 +++--
  drivers/mtd/spi/spi_flash.c | 341 +++--
  drivers/mtd/spi/spi_flash_ids.c |   5 +
  drivers/spi/Kconfig |   7 +
  drivers/spi/Makefile|   1 +
  drivers/spi/atmel_qspi.c| 404 
  drivers/spi/atmel_qspi.h| 169 +
  drivers/spi/spi-uclass.c|  40 
  drivers/spi/spi.c   |  13 ++
  include/spi.h   | 168 +
  include/spi_flash.h |   7 +
  14 files changed, 1226 insertions(+), 190 deletions(-)
  create mode 100644 drivers/spi/atmel_qspi.c
  create mode 100644 drivers/spi/atmel_qspi.h



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] clk: Kconfig: Add dependences of SPL_CLK

2017-07-31 Thread Wenyou Yang
The SPL_CLK config should depend on SPL && SPL_DM.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v2:
 - Add the Reviewed-by tag.

 drivers/clk/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 44da716b26..628f76bc48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -12,7 +12,7 @@ config CLK
 
 config SPL_CLK
bool "Enable clock support in SPL"
-   depends on CLK
+   depends on CLK && SPL && SPL_DM
help
  The clock subsystem adds a small amount of overhead to the image.
  If this is acceptable and you have a need to use clock drivers in
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] efi_loader: Fix warning in efi_gop

2017-07-31 Thread Alexander Graf
Commit ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without
CONFIG_LCD") dropped the explicit (void*) cast for fb_base in efi gop support
for CONFIG_LCD without DM. This patch adds it back, eliminating the now occuring
warning again

Fixes: ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without 
CONFIG_LCD")
Reported-by: Tom Rini 
Signed-off-by: Alexander Graf 
---
 lib/efi_loader/efi_gop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 806cfaeea1..e063e0c79b 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -155,7 +155,7 @@ int efi_gop_register(void)
row = panel_info.vl_row;
fb_base = gd->fb_base;
fb_size = lcd_get_size(_len);
-   fb = gd->fb_base;
+   fb = (void*)gd->fb_base;
 #endif
 
switch (bpix) {
-- 
2.12.3

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 5/6] ARM: at91: Get the Chip ID of SAMA5D2 SiP

2017-07-31 Thread Wenyou Yang
From: Wenyou Yang 

The SAMA5D2 SiP(System in Package) has different Chip IDs in the
CHIPID and CHIP_EXID registers.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-at91/armv7/sama5d2_devices.c | 26 --
 arch/arm/mach-at91/include/mach/sama5d2.h  |  7 ++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-at91/armv7/sama5d2_devices.c 
b/arch/arm/mach-at91/armv7/sama5d2_devices.c
index 978eac29bd..de1d9b5bfb 100644
--- a/arch/arm/mach-at91/armv7/sama5d2_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d2_devices.c
@@ -10,11 +10,20 @@
 #include 
 #include 
 
-char *get_cpu_name()
+int cpu_is_sama5d2(void)
 {
+   unsigned int chip_id = get_chip_id();
+
+   return ((chip_id == ARCH_ID_SAMA5D2) ||
+   (chip_id == ARCH_ID_SAMA5D2_SIP)) ? 1 : 0;
+}
+
+char *get_cpu_name(void)
+{
+   unsigned int chip_id = get_chip_id();
unsigned int extension_id = get_extension_chip_id();
 
-   if (cpu_is_sama5d2()) {
+   if (chip_id == ARCH_ID_SAMA5D2) {
switch (extension_id) {
case ARCH_EXID_SAMA5D21CU:
return "SAMA5D21";
@@ -41,6 +50,19 @@ char *get_cpu_name()
}
}
 
+   if ((chip_id == ARCH_ID_SAMA5D2) || (chip_id == ARCH_ID_SAMA5D2_SIP)) {
+   switch (extension_id) {
+   case ARCH_EXID_SAMA5D225C_D1M:
+   return "SAMA5D225 128M bits DDR2 SDRAM";
+   case ARCH_EXID_SAMA5D27C_D5M:
+   return "SAMA5D27 512M bits DDR2 SDRAM";
+   case ARCH_EXID_SAMA5D27C_D1G:
+   return "SAMA5D27 1G bits DDR2 SDRAM";
+   case ARCH_EXID_SAMA5D28C_D1G:
+   return "SAMA5D28 1G bits DDR2 SDRAM";
+   }
+   }
+
return "Unknown CPU type";
 }
 
diff --git a/arch/arm/mach-at91/include/mach/sama5d2.h 
b/arch/arm/mach-at91/include/mach/sama5d2.h
index 25c85411e5..49283ed86b 100644
--- a/arch/arm/mach-at91/include/mach/sama5d2.h
+++ b/arch/arm/mach-at91/include/mach/sama5d2.h
@@ -222,7 +222,11 @@
 #define ARCH_EXID_SAMA5D28CU   0x0010
 #define ARCH_EXID_SAMA5D28CN   0x0020
 
-#define cpu_is_sama5d2()   (get_chip_id() == ARCH_ID_SAMA5D2)
+#define ARCH_ID_SAMA5D2_SIP0x8a5c08c2
+#define ARCH_EXID_SAMA5D225C_D1M   0x0053
+#define ARCH_EXID_SAMA5D27C_D5M0x0032
+#define ARCH_EXID_SAMA5D27C_D1G0x0033
+#define ARCH_EXID_SAMA5D28C_D1G0x0013
 
 /* PIT Timer(PIT_PIIR) */
 #define CONFIG_SYS_TIMER_COUNTER   0xf804803c
@@ -233,6 +237,7 @@
 #ifndef __ASSEMBLY__
 unsigned int get_chip_id(void);
 unsigned int get_extension_chip_id(void);
+int cpu_is_sama5d2(void);
 unsigned int has_lcdc(void);
 char *get_cpu_name(void);
 #endif
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 6/6] board: atmel: Add SAMA5D27 SOM1 EK board

2017-07-31 Thread Wenyou Yang
From: Wenyou Yang 

The SAMA5D27-SiP (System in Package) integrates the SAMA5D2
with 1Gbit DDR2-SDRAM in a single package.

The SAMA5D27 SOM1 embeds a 64Mbit QSPI flash, KSZ8081 Phy and
Mac-address EEPROM.

Signed-off-by: Wenyou Yang 
---

Changes in v2:
 - Add the reviewed-by tag.
 - Add the help in Kconfig to describe the board and peripherals.
 - Add the code to display the company's logo and board information.
 - Replace the code to set the ethernet mac address with the common
   code from the board/atmel/common folder.

 arch/arm/dts/Makefile   |   3 +
 arch/arm/dts/at91-sama5d27_som1_ek.dts  | 215 
 arch/arm/dts/sama5d2.dtsi   |  20 +++
 arch/arm/dts/sama5d27_som1.dtsi | 159 ++
 arch/arm/mach-at91/Kconfig  |  14 ++
 board/atmel/sama5d27_som1_ek/Kconfig|  15 ++
 board/atmel/sama5d27_som1_ek/MAINTAINERS|   6 +
 board/atmel/sama5d27_som1_ek/Makefile   |   8 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 189 +
 configs/sama5d27_som1_ek_mmc_defconfig  |  86 ++
 configs/sama5d27_som1_ek_spiflash_defconfig |  86 ++
 include/configs/sama5d27_som1_ek.h  |  95 +++
 12 files changed, 896 insertions(+)
 create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts
 create mode 100644 arch/arm/dts/sama5d27_som1.dtsi
 create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig
 create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS
 create mode 100644 board/atmel/sama5d27_som1_ek/Makefile
 create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
 create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig
 create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig
 create mode 100644 include/configs/sama5d27_som1_ek.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 132fa69fe5..0a68663e9f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -404,6 +404,9 @@ dtb-$(CONFIG_TARGET_OMAP3_LOGIC) += \
 dtb-$(CONFIG_TARGET_SAMA5D2_XPLAINED) += \
at91-sama5d2_xplained.dtb
 
+dtb-$(CONFIG_TARGET_SAMA5D27_SOM1_EK) += \
+   at91-sama5d27_som1_ek.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D3XEK) += \
sama5d31ek.dtb \
sama5d33ek.dtb \
diff --git a/arch/arm/dts/at91-sama5d27_som1_ek.dts 
b/arch/arm/dts/at91-sama5d27_som1_ek.dts
new file mode 100644
index 00..5e62d4af71
--- /dev/null
+++ b/arch/arm/dts/at91-sama5d27_som1_ek.dts
@@ -0,0 +1,215 @@
+/*
+ * at91-sama5d27_som1_ek.dts - Device Tree file for SAMA5D27 SOM1 EK board
+ *
+ *  Copyright (C) 2017 Microchip Corporation
+ * Wenyou Yang 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+/dts-v1/;
+#include "sama5d27_som1.dtsi"
+
+/ {
+   model = "Atmel SAMA5D27 SOM1 EK";
+   compatible = "atmel,sama5d27-som1-ek", "atmel,sama5d2", "atmel,sama5";
+
+   chosen {
+   u-boot,dm-pre-reloc;

[U-Boot] [PATCH v2 4/6] ARM: at91: mach: Add missing defines of MPDDRC

2017-07-31 Thread Wenyou Yang
Add missing defines of Multiport DDR-SDRAM Controller (MPDDRC).

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-at91/include/mach/atmel_mpddrc.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-at91/include/mach/atmel_mpddrc.h 
b/arch/arm/mach-at91/include/mach/atmel_mpddrc.h
index 803501f5cf..40e1cf0a0a 100644
--- a/arch/arm/mach-at91/include/mach/atmel_mpddrc.h
+++ b/arch/arm/mach-at91/include/mach/atmel_mpddrc.h
@@ -96,6 +96,10 @@ int ddr3_init(const unsigned int base,
 #define ATMEL_MPDDRC_CR_DLL_RESET_ENABLED  (0x1 << 7)
 #define ATMEL_MPDDRC_CR_DIC_DS (0x1 << 8)
 #define ATMEL_MPDDRC_CR_DIS_DLL(0x1 << 9)
+#define ATMEL_MPDDRC_CR_ZQ_INIT(0x0 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_LONG(0x1 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_SHORT   (0x2 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_RESET   (0x3 << 10)
 #define ATMEL_MPDDRC_CR_OCD_DEFAULT(0x7 << 12)
 #define ATMEL_MPDDRC_CR_DQMS_SHARED(0x1 << 16)
 #define ATMEL_MPDDRC_CR_ENRDM_ON   (0x1 << 17)
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/6] ARM: at91: spl: Add mck function to lower rate while switching

2017-07-31 Thread Wenyou Yang
Refer to the commit 70f8c8316ad(PMC: add new mck function to lower
rate while switching) from AT91Bootstrap.

While switching to a lower clock source, we must switch the clock
source first instead of last. Otherwise, we could end up with
too high frequency on internal bus and peripherals.
This happen on SAMA5D2 as we exit from ROM code @396MHz.

Add a function pmc_mck_init_down() to allow this sequence.

Signed-off-by: Wenyou Yang 
---

Changes in v2: None

 arch/arm/mach-at91/armv7/clock.c  | 36 +++
 arch/arm/mach-at91/include/mach/at91_common.h |  1 +
 2 files changed, 37 insertions(+)

diff --git a/arch/arm/mach-at91/armv7/clock.c b/arch/arm/mach-at91/armv7/clock.c
index 2e55953799..8ae01f4020 100644
--- a/arch/arm/mach-at91/armv7/clock.c
+++ b/arch/arm/mach-at91/armv7/clock.c
@@ -150,6 +150,42 @@ void at91_mck_init(u32 mckr)
;
 }
 
+void at91_mck_init_down(u32 mckr)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   u32 tmp;
+
+   tmp = readl(>mckr);
+   tmp &= (~AT91_PMC_MCKR_CSS_MASK);
+   tmp |= (mckr & AT91_PMC_MCKR_CSS_MASK);
+   writel(tmp, >mckr);
+
+   while (!(readl(>sr) & AT91_PMC_MCKRDY))
+   ;
+
+#ifdef CPU_HAS_H32MXDIV
+   tmp = readl(>mckr);
+   tmp &= (~AT91_PMC_MCKR_H32MXDIV);
+   tmp |= (mckr & AT91_PMC_MCKR_H32MXDIV);
+   writel(tmp, >mckr);
+#endif
+
+   tmp = readl(>mckr);
+   tmp &= (~AT91_PMC_MCKR_PLLADIV_MASK);
+   tmp |= (mckr & AT91_PMC_MCKR_PLLADIV_MASK);
+   writel(tmp, >mckr);
+
+   tmp = readl(>mckr);
+   tmp &= (~AT91_PMC_MCKR_MDIV_MASK);
+   tmp |= (mckr & AT91_PMC_MCKR_MDIV_MASK);
+   writel(tmp, >mckr);
+
+   tmp = readl(>mckr);
+   tmp &= (~AT91_PMC_MCKR_PRES_MASK);
+   tmp |= (mckr & AT91_PMC_MCKR_PRES_MASK);
+   writel(tmp, >mckr);
+}
+
 int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
diff --git a/arch/arm/mach-at91/include/mach/at91_common.h 
b/arch/arm/mach-at91/include/mach/at91_common.h
index 5416eb455d..0b09ce7b2e 100644
--- a/arch/arm/mach-at91/include/mach/at91_common.h
+++ b/arch/arm/mach-at91/include/mach/at91_common.h
@@ -25,6 +25,7 @@ void at91_lcd_hw_init(void);
 void at91_plla_init(u32 pllar);
 void at91_pllb_init(u32 pllar);
 void at91_mck_init(u32 mckr);
+void at91_mck_init_down(u32 mckr);
 void at91_pmc_init(void);
 void mem_init(void);
 void at91_phy_reset(void);
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/6] ARM: at91: spl: Adjust switching to oscillator for SAMA5D2

2017-07-31 Thread Wenyou Yang
As said in 29.5.7 section of SAMA5D2 datasheet, before switching to
the crystal oscillator, a check must be carried out to ensure that
the oscillator is present and that its freqency is valid.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-at91/include/mach/at91_pmc.h |  2 ++
 arch/arm/mach-at91/spl_atmel.c | 18 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 2875ff20b1..08ad1bf2d0 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -87,6 +87,8 @@ typedef struct at91_pmc {
 
 #define AT91_PMC_MCFR_MAINRDY  0x0001
 #define AT91_PMC_MCFR_MAINF_MASK   0x
+#define AT91_PMC_MCFR_RCMEAS   0x0010
+#define AT91_PMC_MCFR_CCSS_XTAL_OSC0x0100
 
 #define AT91_PMC_MCKR_CSS_SLOW 0x
 #define AT91_PMC_MCKR_CSS_MAIN 0x0001
diff --git a/arch/arm/mach-at91/spl_atmel.c b/arch/arm/mach-at91/spl_atmel.c
index b75c2ccefd..ce16ef3bdb 100644
--- a/arch/arm/mach-at91/spl_atmel.c
+++ b/arch/arm/mach-at91/spl_atmel.c
@@ -32,6 +32,20 @@ static void switch_to_main_crystal_osc(void)
while (!(readl(>sr) & AT91_PMC_IXR_MOSCS))
;
 
+#if defined(CONFIG_SAMA5D2)
+   /* Enable a measurement of the external oscillator */
+   tmp = readl(>mcfr);
+   tmp |= AT91_PMC_MCFR_CCSS_XTAL_OSC;
+   tmp |= AT91_PMC_MCFR_RCMEAS;
+   writel(tmp, >mcfr);
+
+   while (!(readl(>mcfr) & AT91_PMC_MCFR_MAINRDY))
+   ;
+
+   if (!(readl(>mcfr) & AT91_PMC_MCFR_MAINF_MASK))
+   hang();
+#endif
+
tmp = readl(>mor);
tmp &= ~AT91_PMC_MOR_OSCBYPASS;
tmp &= ~AT91_PMC_MOR_KEY(0xff);
@@ -47,11 +61,13 @@ static void switch_to_main_crystal_osc(void)
while (!(readl(>sr) & AT91_PMC_IXR_MOSCSELS))
;
 
+#if !defined(CONFIG_SAMA5D2)
/* Wait until MAINRDY field is set to make sure main clock is stable */
while (!(readl(>mcfr) & AT91_PMC_MAINRDY))
;
+#endif
 
-#ifndef CONFIG_SAMA5D4
+#if !defined(CONFIG_SAMA5D4) && !defined(CONFIG_SAMA5D2)
tmp = readl(>mor);
tmp &= ~AT91_PMC_MOR_MOSCRCEN;
tmp &= ~AT91_PMC_MOR_KEY(0xff);
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 3/6] ARM: at91: spl: Add boot device for boot from QSPI

2017-07-31 Thread Wenyou Yang
Add the boot device for booting from the QSPI flash.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-at91/spl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-at91/spl.c b/arch/arm/mach-at91/spl.c
index e113336b7b..98337aebbe 100644
--- a/arch/arm/mach-at91/spl.c
+++ b/arch/arm/mach-at91/spl.c
@@ -56,6 +56,8 @@ u32 spl_boot_device(void)
if (dev == ATMEL_SAMA5_BOOT_FROM_SPI)
return BOOT_DEVICE_SPI;
 #endif
+   if (dev == ATMEL_SAMA5_BOOT_FROM_QSPI)
+   return BOOT_DEVICE_SPI;
 
if (dev == ATMEL_SAMA5_BOOT_FROM_SMC)
return BOOT_DEVICE_NAND;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 0/6] board: atmel: Add new board SAMA5D27-SOM1-EK board.

2017-07-31 Thread Wenyou Yang
The SAMA5D27-SOM1-EK board embeds a SAMA5D27 SOM1 module, which includes
a SAMA5D27-SiP chip and QSPI flash, Phy and MAC EEPROM. The SAMA5D27 SiP
integrates the SAMA5D2 with 1Gbit DDR2-SDRAM in a single package.
It is based on
1./ [PATCH v2 0/8] sf: improve support of (Q)SPI flash memories
https://lists.denx.de/pipermail/u-boot/2017-July/298806.html
2./ [PATCH v2 0/3] board: atmel: Set the ethernet mac address from 
eeprom
https://lists.denx.de/pipermail/u-boot/2017-July/300527.html
3./ [PATCH 0/7] board: atmel: Convert to support DM_VIDEO
https://lists.denx.de/pipermail/u-boot/2017-July/300533.html

Changes in v2:
 - Add the reviewed-by tag.
 - Add the help in Kconfig to describe the board and peripherals.
 - Add the code to display the company's logo and board information.
 - Replace the code to set the ethernet mac address with the common
   code from the board/atmel/common folder.

Wenyou Yang (6):
  ARM: at91: spl: Adjust switching to oscillator for SAMA5D2
  ARM: at91: spl: Add mck function to lower rate while switching
  ARM: at91: spl: Add boot device for boot from QSPI
  ARM: at91: mach: Add missing defines of MPDDRC
  ARM: at91: Get the Chip ID of SAMA5D2 SiP
  board: atmel: Add SAMA5D27 SOM1 EK board

 arch/arm/dts/Makefile   |   3 +
 arch/arm/dts/at91-sama5d27_som1_ek.dts  | 215 
 arch/arm/dts/sama5d2.dtsi   |  20 +++
 arch/arm/dts/sama5d27_som1.dtsi | 159 ++
 arch/arm/mach-at91/Kconfig  |  14 ++
 arch/arm/mach-at91/armv7/clock.c|  36 
 arch/arm/mach-at91/armv7/sama5d2_devices.c  |  26 ++-
 arch/arm/mach-at91/include/mach/at91_common.h   |   1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h  |   2 +
 arch/arm/mach-at91/include/mach/atmel_mpddrc.h  |   4 +
 arch/arm/mach-at91/include/mach/sama5d2.h   |   7 +-
 arch/arm/mach-at91/spl.c|   2 +
 arch/arm/mach-at91/spl_atmel.c  |  18 +-
 board/atmel/sama5d27_som1_ek/Kconfig|  15 ++
 board/atmel/sama5d27_som1_ek/MAINTAINERS|   6 +
 board/atmel/sama5d27_som1_ek/Makefile   |   8 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 189 +
 configs/sama5d27_som1_ek_mmc_defconfig  |  86 ++
 configs/sama5d27_som1_ek_spiflash_defconfig |  86 ++
 include/configs/sama5d27_som1_ek.h  |  95 +++
 20 files changed, 988 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts
 create mode 100644 arch/arm/dts/sama5d27_som1.dtsi
 create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig
 create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS
 create mode 100644 board/atmel/sama5d27_som1_ek/Makefile
 create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
 create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig
 create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig
 create mode 100644 include/configs/sama5d27_som1_ek.h

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/7] board: sama5d3xek: Convert to support DM_VIDEO

2017-07-31 Thread Wenyou Yang
From: Wenyou Yang 

Convert the board to enable the driver model support for LCD/video.

Signed-off-by: Wenyou Yang 
---

 arch/arm/dts/sama5d36ek_cmp.dts|  1 +
 arch/arm/dts/sama5d3_lcd.dtsi  | 21 +--
 arch/arm/dts/sama5d3xdm.dtsi   | 26 +
 board/atmel/sama5d3xek/sama5d3xek.c| 93 +-
 configs/sama5d36ek_cmp_mmc_defconfig   |  3 +-
 configs/sama5d36ek_cmp_nandflash_defconfig |  3 +-
 configs/sama5d36ek_cmp_spiflash_defconfig  |  3 +-
 configs/sama5d3xek_mmc_defconfig   |  3 +-
 configs/sama5d3xek_nandflash_defconfig |  3 +-
 configs/sama5d3xek_spiflash_defconfig  |  3 +-
 include/configs/sama5d3xek.h   | 12 
 11 files changed, 42 insertions(+), 129 deletions(-)

diff --git a/arch/arm/dts/sama5d36ek_cmp.dts b/arch/arm/dts/sama5d36ek_cmp.dts
index be41490f63..c17bc9f0dc 100644
--- a/arch/arm/dts/sama5d36ek_cmp.dts
+++ b/arch/arm/dts/sama5d36ek_cmp.dts
@@ -8,6 +8,7 @@
 /dts-v1/;
 #include "sama5d36.dtsi"
 #include "sama5d3xmb_cmp.dtsi"
+#include "sama5d3xdm.dtsi"
 
 / {
model = "Atmel SAMA5D36-EK";
diff --git a/arch/arm/dts/sama5d3_lcd.dtsi b/arch/arm/dts/sama5d3_lcd.dtsi
index 14d7c2bc75..10fb3a97ea 100644
--- a/arch/arm/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/dts/sama5d3_lcd.dtsi
@@ -14,31 +14,12 @@
ahb {
apb {
hlcdc: hlcdc@f003 {
-   compatible = "atmel,sama5d3-hlcdc";
+   compatible = "atmel,at91sam9x5-hlcdc";
reg = <0xf003 0x2000>;
interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
clocks = <_clk>, <>, <>;
clock-names = "periph_clk","sys_clk", 
"slow_clk";
status = "disabled";
-
-   hlcdc-display-controller {
-   compatible = 
"atmel,hlcdc-display-controller";
-   #address-cells = <1>;
-   #size-cells = <0>;
-
-   port@0 {
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0>;
-   };
-   };
-
-   hlcdc_pwm: hlcdc-pwm {
-   compatible = "atmel,hlcdc-pwm";
-   pinctrl-names = "default";
-   pinctrl-0 = <_lcd_pwm>;
-   #pwm-cells = <3>;
-   };
};
 
pinctrl@f200 {
diff --git a/arch/arm/dts/sama5d3xdm.dtsi b/arch/arm/dts/sama5d3xdm.dtsi
index 035ab72b39..b3df9af2b4 100644
--- a/arch/arm/dts/sama5d3xdm.dtsi
+++ b/arch/arm/dts/sama5d3xdm.dtsi
@@ -10,6 +10,32 @@
 / {
ahb {
apb {
+   hlcdc: hlcdc@f003 {
+   atmel,vl-bpix = <4>;
+   atmel,output-mode = <24>;
+   atmel,guard-time = <1>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_pwm 
_lcd_rgb888_alt>;
+   status = "okay";
+   u-boot,dm-pre-reloc;
+
+   display-timings {
+   u-boot,dm-pre-reloc;
+   800x480 {
+   clock-frequency = <2400>;
+   hactive = <800>;
+   vactive = <480>;
+   hsync-len = <5>;
+   hfront-porch = <64>;
+   hback-porch = <64>;
+   vfront-porch = <22>;
+   vback-porch = <21>;
+   vsync-len = <5>;
+   u-boot,dm-pre-reloc;
+   };
+   };
+   };
+
i2c1: i2c@f0018000 {
qt1070: keyboard@1b {
compatible = "qt1070";
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c 
b/board/atmel/sama5d3xek/sama5d3xek.c
index c1f2769f1c..2b7a6d4ecb 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -13,9 +13,7 @@
 

  1   2   >