Re: [U-Boot] [PATCH 1/2] mtd: nand: tegra: convert to driver model and live tree

2018-02-23 Thread Stefan Agner
On 21.02.2018 16:16, Marcel Ziswiler wrote:
> From: Marcel Ziswiler 
> 
> The Tegra NAND driver recently got broken by ongoing driver model resp.
> live tree migration work:
> 
> NAND:  Could not decode nand-flash in device tree
> Tegra NAND init failed
> 0 MiB
> 
> A patch for NAND uclass support was proposed about a year ago:
> https://patchwork.ozlabs.org/patch/722282/
> 
> It was not merged and I do not see on-going work for this.
> 
> This commit just provides a driver model probe hook to retrieve further
> configuration from the live device tree. As there is no NAND ulass as of
> yet (ab)using UCLASS_MISC. Once UCLASS_NAND is supported, it would be
> possible to migrate to it.
> 
> Signed-off-by: Marcel Ziswiler 
> 
> ---
> 
>  drivers/mtd/nand/tegra_nand.c | 98 
> ---
>  1 file changed, 55 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c
> index c03c9cb178..405018018c 100644
> --- a/drivers/mtd/nand/tegra_nand.c
> +++ b/drivers/mtd/nand/tegra_nand.c
> @@ -18,6 +18,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "tegra_nand.h"
>  
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -29,6 +30,13 @@ DECLARE_GLOBAL_DATA_PTR;
>  /* ECC bytes to be generated for tag data */
>  #define TAG_ECC_BYTES4
>  
> +static const struct udevice_id tegra_nand_dt_ids[] = {
> + {
> + .compatible = "nvidia,tegra20-nand",
> + },
> + { /* sentinel */ }
> +};
> +
>  /* 64 byte oob block info for large page (== 2KB) device
>   *
>   * OOB flash layout for Tegra with Reed-Solomon 4 symbol correct ECC:
> @@ -91,9 +99,11 @@ struct nand_drv {
>   struct fdt_nand config;
>  };
>  
> -static struct nand_drv nand_ctrl;
> -static struct mtd_info *our_mtd;
> -static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
> +struct tegra_nand_info {
> + struct udevice *dev;
> + struct nand_drv nand_ctrl;
> + struct nand_chip nand_chip;
> +};
>  
>  /**
>   * Wait for command completion
> @@ -453,8 +463,8 @@ static void stop_command(struct nand_ctlr *reg)
>   * @param *reg_val   address of reg_val
>   * @return 0 if ok, -1 on error
>   */
> -static int set_bus_width_page_size(struct fdt_nand *config,
> - u32 *reg_val)
> +static int set_bus_width_page_size(struct mtd_info *our_mtd,
> +struct fdt_nand *config, u32 *reg_val)
>  {
>   if (config->width == 8)
>   *reg_val = CFG_BUS_WIDTH_8BIT;
> @@ -514,7 +524,7 @@ static int nand_rw_page(struct mtd_info *mtd,
> struct nand_chip *chip,
>  
>   info = (struct nand_drv *)nand_get_controller_data(chip);
>   config = >config;
> - if (set_bus_width_page_size(config, _val))
> + if (set_bus_width_page_size(mtd, config, _val))
>   return -EINVAL;
>  
>   /* Need to be 4-byte aligned */
> @@ -722,7 +732,7 @@ static int nand_rw_oob(struct mtd_info *mtd,
> struct nand_chip *chip,
>   if (((int)chip->oob_poi) & 0x03)
>   return -EINVAL;
>   info = (struct nand_drv *)nand_get_controller_data(chip);
> - if (set_bus_width_page_size(>config, _val))
> + if (set_bus_width_page_size(mtd, >config, _val))
>   return -EINVAL;
>  
>   stop_command(info->reg);
> @@ -883,51 +893,39 @@ static void setup_timing(unsigned
> timing[FDT_NAND_TIMING_COUNT],
>  /**
>   * Decode NAND parameters from the device tree
>   *
> - * @param blob   Device tree blob
> - * @param node   Node containing "nand-flash" compatible node
> + * @param devDriver model device
> + * @param config Device tree NAND configuration
>   * @return 0 if ok, -ve on error (FDT_ERR_...)
>   */
> -static int fdt_decode_nand(const void *blob, int node, struct fdt_nand 
> *config)
> +static int fdt_decode_nand(struct udevice *dev, struct fdt_nand *config)
>  {
>   int err;
>  
> - config->reg = (struct nand_ctlr *)fdtdec_get_addr(blob, node, "reg");
> - config->enabled = fdtdec_get_is_enabled(blob, node);
> - config->width = fdtdec_get_int(blob, node, "nvidia,nand-width", 8);
> - err = gpio_request_by_name_nodev(offset_to_ofnode(node),
> - "nvidia,wp-gpios", 0, >wp_gpio, GPIOD_IS_OUT);
> + config->reg = (struct nand_ctlr *)dev_read_addr(dev);
> + config->enabled = dev_read_enabled(dev);
> + config->width = dev_read_u32_default(dev, "nvidia,nand-width", 8);
> + err = gpio_request_by_name(dev, "nvidia,wp-gpios", 0, >wp_gpio,
> +GPIOD_IS_OUT);
>   if (err)
>   return err;
> - err = fdtdec_get_int_array(blob, node, "nvidia,timing",
> - config->timing, FDT_NAND_TIMING_COUNT);
> + err = dev_read_u32_array(dev, "nvidia,timing", config->timing,
> +  FDT_NAND_TIMING_COUNT);
>   if (err < 0)
>   return err;
>  
> - 

Re: [U-Boot] [PATCH 1/2] usb: gadget: sdp: add missing line breaks

2018-02-15 Thread Stefan Agner


On 15.02.2018 09:59, Lukasz Majewski wrote:
> On Thu, 15 Feb 2018 07:08:55 +0100
> Andre Heider <a.hei...@gmail.com> wrote:
>
>> Cosmetic change.

Hm, this got introduced by
commit 9b643e312d52 ("treewide: replace with error() with pr_err()")

error() did print the newline...

Acked-by: Stefan Agner <stefan.ag...@toradex.com>

Best regards,
Stefan


>>
>> Signed-off-by: Andre Heider <a.hei...@gmail.com>
>> ---
>>  cmd/usb_gadget_sdp.c   |  4 ++--
>>  common/spl/spl_sdp.c   |  4 ++--
>>  drivers/usb/gadget/f_sdp.c | 14 +++---
>>  3 files changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
>> index ae4d73c125..97d00ec545 100644
>> --- a/cmd/usb_gadget_sdp.c
>> +++ b/cmd/usb_gadget_sdp.c
>> @@ -28,13 +28,13 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int
>> argc, char * const argv[]) 
>>  ret = sdp_init(controller_index);
>>  if (ret) {
>> -pr_err("SDP init failed: %d", ret);
>> +pr_err("SDP init failed: %d\n", ret);
>>  goto exit;
>>  }
>>  
>>  /* This command typically does not return but jumps to an
>> image */ sdp_handle(controller_index);
>> -pr_err("SDP ended");
>> +pr_err("SDP ended\n");
>>  
>>  exit:
>>  g_dnl_unregister();
>> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
>> index 333d518f4d..0c4603a3db 100644
>> --- a/common/spl/spl_sdp.c
>> +++ b/common/spl/spl_sdp.c
>> @@ -24,13 +24,13 @@ static int spl_sdp_load_image(struct
>> spl_image_info *spl_image, 
>>  ret = sdp_init(controller_index);
>>  if (ret) {
>> -pr_err("SDP init failed: %d", ret);
>> +pr_err("SDP init failed: %d\n", ret);
>>  return -ENODEV;
>>  }
>>  
>>  /* This command typically does not return but jumps to an
>> image */ sdp_handle(controller_index);
>> -pr_err("SDP ended");
>> +pr_err("SDP ended\n");
>>  
>>  return -EINVAL;
>>  }
>> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
>> index dd7b9cddb1..6da0530095 100644
>> --- a/drivers/usb/gadget/f_sdp.c
>> +++ b/drivers/usb/gadget/f_sdp.c
>> @@ -238,12 +238,12 @@ static void sdp_rx_command_complete(struct
>> usb_ep *ep, struct usb_request *req) u8 report = data[0];
>>  
>>  if (status != 0) {
>> -pr_err("Status: %d", status);
>> +pr_err("Status: %d\n", status);
>>  return;
>>  }
>>  
>>  if (report != 1) {
>> -pr_err("Unexpected report %d", report);
>> +pr_err("Unexpected report %d\n", report);
>>  return;
>>  }
>>  
>> @@ -323,12 +323,12 @@ static void sdp_rx_data_complete(struct usb_ep
>> *ep, struct usb_request *req) int datalen = req->length - 1;
>>  
>>  if (status != 0) {
>> -pr_err("Status: %d", status);
>> +pr_err("Status: %d\n", status);
>>  return;
>>  }
>>  
>>  if (report != 2) {
>> -pr_err("Unexpected report %d", report);
>> +pr_err("Unexpected report %d\n", report);
>>  return;
>>  }
>>  
>> @@ -361,7 +361,7 @@ static void sdp_rx_data_complete(struct usb_ep
>> *ep, struct usb_request *req) sdp->state = SDP_STATE_TX_SEC_CONF;
>>  break;
>>  default:
>> -pr_err("Invalid state: %d", sdp->state);
>> +pr_err("Invalid state: %d\n", sdp->state);
>>  }
>>  }
>>  
>> @@ -371,7 +371,7 @@ static void sdp_tx_complete(struct usb_ep *ep,
>> struct usb_request *req) int status = req->status;
>>  
>>  if (status != 0) {
>> -pr_err("Status: %d", status);
>> +pr_err("Status: %d\n", status);
>>  return;
>>  }
>>  
>> @@ -394,7 +394,7 @@ static void sdp_tx_complete(struct usb_ep *ep,
>> struct usb_request *req) sdp->state = SDP_STATE_IDLE;
>>  break;
>>  default:
>> -pr_err("Wrong State: %d", sdp->state);
>> +pr_err("Wrong State: %d\n", sdp->state);
>>  sdp->state = SDP_STATE_IDLE;
>>  break;
>>  }
>
> Reviewed-by: Lukasz Majewski <lu...@denx.de>
>
> 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] Fix --noheader on fw_printenv

2018-02-08 Thread Stefan Agner
On 08.02.2018 17:17, Alex Kiernan wrote:
> On Thu, Feb 8, 2018 at 3:37 PM,   wrote:
>> On 08.02.2018 10:35, Alex Kiernan wrote:
>>> Using fw_printenv with --noheader fails:
>>>
>>>   root@nrr-922:~# fw_printenv --noheader arch
>>>   ## Error: `-n' option requires exactly one argument
>>
>> I think it would work with --noheader=arch
>>
> 
> It doesn't:
> 
> root@nrr-922:~# fw_printenv --noheader=arch
> ## Error: `-n' option requires exactly one argument
> 
> Probably I should fix the error too as it's misleading.
> 

This comes from getopt_long, so I don't think you can fix it. The getopt
string in parse_printenv_args actually says argument "n" has no argument
(no colon), so it actually is surprising that it prints that...

Maybe this is from the getopt_long call in parse_common_args?

>>>
>>> Whereas -n works:
>>>
>>>   root@nrr-922:~# fw_printenv -n arch
>>>   arm
>>>
>>> The single argument it's expecting isn't taken from getopt parsing,
>>> but instead from the remaining argv arguments.
>>
>> That makes sense. But the commit log text above is kind of unrelated/not
>> relevant, I would just use this two lines as git message.
>>
> 
> Happy to chop it down to the last two lines though as it does include
> the relevant details.

IMHO the error is that struct option long_options ask for an argument
whereas the optstring passed to getopt_long doesn't. The rather erratic
is not really relevant and should not be mentioned.

--
Stefan



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


[U-Boot] [PATCH v2 3/4] spl: use ARCH_MX23/28 to specify SPL_LDSCRIPT

2018-02-06 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Simplify SPL_LDSCRIPT config by using the new arch Kconfig
configurations ARCH_MX23 and ARCH_MX28.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8a0cbc7faa..a3d3a6274e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1326,7 +1326,7 @@ source "arch/arm/Kconfig.debug"
 endmenu
 
 config SPL_LDSCRIPT
-default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if 
TARGET_APX4DEVKIT || TARGET_BG0900 || TARGET_M28EVK || TARGET_MX23_OLINUXINO || 
TARGET_MX23EVK || TARGET_MX28EVK || TARGET_SANSA_FUZE_PLUS || TARGET_SC_SPS_1 
|| TARGET_TS4600 || TARGET_XFI3
+default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if ARCH_MX23 || 
ARCH_MX28
 default "arch/arm/cpu/arm1136/u-boot-spl.lds" if CPU_ARM1136
default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
 
-- 
2.16.1

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


[U-Boot] [PATCH v2 4/4] Convert CONFIG_NAND_MXS to Kconfig

2018-02-06 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This converts CONFIG_NAND_MXS to Kconfig.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 configs/apx4devkit_defconfig|  3 ++-
 configs/aristainetos2_defconfig |  3 ++-
 configs/aristainetos2b_defconfig|  3 ++-
 configs/aristainetos_defconfig  |  3 ++-
 configs/bg0900_defconfig|  3 ++-
 configs/cm_fx6_defconfig| 11 ++-
 configs/colibri_imx7_defconfig  |  3 ++-
 configs/gwventana_nand_defconfig|  3 ++-
 configs/m28evk_defconfig|  3 ++-
 configs/mx28evk_auart_console_defconfig |  3 ++-
 configs/mx28evk_defconfig   |  3 ++-
 configs/mx28evk_nand_defconfig  |  3 ++-
 configs/mx28evk_spi_defconfig   |  3 ++-
 configs/mx6sabreauto_defconfig  |  3 ++-
 configs/mx6sxsabreauto_defconfig|  3 ++-
 configs/pcm058_defconfig|  3 ++-
 configs/pfla02_defconfig|  3 +++
 configs/platinum_picon_defconfig|  3 ++-
 configs/platinum_titanium_defconfig |  3 ++-
 configs/titanium_defconfig  |  3 ++-
 drivers/mtd/nand/Kconfig|  2 +-
 include/configs/aristainetos-common.h   |  1 -
 include/configs/cm_fx6.h|  1 -
 include/configs/colibri_imx7.h  |  2 --
 include/configs/gw_ventana.h|  1 -
 include/configs/mx6sabreauto.h  |  1 -
 include/configs/mx6sxsabreauto.h|  1 -
 include/configs/mxs.h   |  1 -
 include/configs/pcm058.h|  1 -
 include/configs/pfla02.h|  1 -
 include/configs/platinum.h  |  1 -
 include/configs/titanium.h  |  1 -
 32 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/configs/apx4devkit_defconfig b/configs/apx4devkit_defconfig
index 6d57bb2dbc..260ddb2194 100644
--- a/configs/apx4devkit_defconfig
+++ b/configs/apx4devkit_defconfig
@@ -14,7 +14,6 @@ CONFIG_SPL=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -28,6 +27,8 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:128k(bootstrap),1024k(boot),768k(env
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_MMC_MXS=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/aristainetos2_defconfig b/configs/aristainetos2_defconfig
index 288dab0d3c..c0daed6b22 100644
--- a/configs/aristainetos2_defconfig
+++ b/configs/aristainetos2_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos2b_defconfig b/configs/aristainetos2b_defconfig
index 115ae07ad6..fbb2c1c38d 100644
--- a/configs/aristainetos2b_defconfig
+++ b/configs/aristainetos2b_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos_defconfig b/configs/aristainetos_defconfig
index cad8b4af8a..13f4d6eb52 100644
--- a/configs/aristainetos_defconfig
+++ b/configs/aristainetos_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/bg0900_defconfig b/configs/bg0900_defconfig
index ed0448d55d..602eb60808 100644
--- a/configs/bg0900_defconfig
+++ b/configs/bg0900_defconfig
@@ -17,7 +17,6 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -27,6 +26,8 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_DOS_PARTITION=y
 # CONFIG_MMC is not set
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index 6b1c0a823c..995baabd5d 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -20,9 +20,7 @@ CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcm

[U-Boot] [PATCH v2 1/4] arm: imx: mx23: Move MX23 selection to Kconfig

2018-02-06 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The motivation for moving MX23 selection to Kconfig is to be able
to better handle NAND MXS selection through Kconfig.

This selection method also aligns with the way other i.MX SoCs are
selected in U-Boot.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2:
- Move to arch/arm/mach-imx/mxs/Kconfig
- Fix SoC name

 arch/arm/Kconfig  | 38 --
 arch/arm/mach-imx/mxs/Kconfig | 35 +++
 configs/mx23_olinuxino_defconfig  |  3 ++-
 configs/mx23evk_defconfig |  3 ++-
 configs/sansa_fuze_plus_defconfig |  1 +
 configs/xfi3_defconfig|  3 ++-
 include/configs/mx23_olinuxino.h  |  1 -
 include/configs/mx23evk.h |  1 -
 include/configs/sansa_fuze_plus.h |  3 ---
 include/configs/xfi3.h|  3 ---
 scripts/config_whitelist.txt  |  1 -
 11 files changed, 50 insertions(+), 42 deletions(-)
 create mode 100644 arch/arm/mach-imx/mxs/Kconfig

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 880a56ba90..59b0588027 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -402,25 +402,12 @@ config TARGET_APX4DEVKIT
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_XFI3
-   bool "Support xfi3"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config TARGET_M28EVK
bool "Support m28evk"
select CPU_ARM926EJS
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_MX23EVK
-   bool "Support mx23evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
 config TARGET_MX28EVK
bool "Support mx28evk"
select CPU_ARM926EJS
@@ -428,25 +415,12 @@ config TARGET_MX28EVK
select BOARD_EARLY_INIT_F
select PL011_SERIAL
 
-config TARGET_MX23_OLINUXINO
-   bool "Support mx23_olinuxino"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
 config TARGET_BG0900
bool "Support bg0900"
select CPU_ARM926EJS
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_SANSA_FUZE_PLUS
-   bool "Support sansa_fuze_plus"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config TARGET_SC_SPS_1
bool "Support sc_sps_1"
select CPU_ARM926EJS
@@ -666,6 +640,12 @@ config ARCH_MX8M
select DM
select SUPPORT_SPL
 
+config ARCH_MX23
+   bool "NXP i.MX23 family"
+   select CPU_ARM926EJS
+   select PL011_SERIAL
+   select SUPPORT_SPL
+
 config ARCH_MX25
bool "NXP MX25"
select CPU_ARM926EJS
@@ -1270,6 +1250,8 @@ source "arch/arm/mach-imx/mx7ulp/Kconfig"
 
 source "arch/arm/mach-imx/mx8m/Kconfig"
 
+source "arch/arm/mach-imx/mxs/Kconfig"
+
 source "arch/arm/mach-omap2/Kconfig"
 
 source "arch/arm/cpu/armv8/fsl-layerscape/Kconfig"
@@ -1328,7 +1310,6 @@ source "board/broadcom/bcmnsp/Kconfig"
 source "board/broadcom/bcmns2/Kconfig"
 source "board/cavium/thunderx/Kconfig"
 source "board/cirrus/edb93xx/Kconfig"
-source "board/creative/xfi3/Kconfig"
 source "board/eets/pdu001/Kconfig"
 source "board/freescale/ls2080a/Kconfig"
 source "board/freescale/ls2080aqds/Kconfig"
@@ -1344,7 +1325,6 @@ source "board/freescale/ls1046ardb/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
-source "board/freescale/mx23evk/Kconfig"
 source "board/freescale/mx28evk/Kconfig"
 source "board/freescale/mx31ads/Kconfig"
 source "board/freescale/mx31pdk/Kconfig"
@@ -1358,10 +1338,8 @@ source "board/hisilicon/hikey/Kconfig"
 source "board/hisilicon/poplar/Kconfig"
 source "board/imx31_phycore/Kconfig"
 source "board/isee/igep003x/Kconfig"
-source "board/olimex/mx23_olinuxino/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
-source "board/sandisk/sansa_fuze_plus/Kconfig"
 source "board/schulercontrol/sc_sps_1/Kconfig"
 source "board/silica/pengwyn/Kconfig"
 source "board/spear/spear300/Kconfig"
diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig
new file mode 100644
index 00..f984545887
--- /dev/null
+++ b/arch/arm/mach-imx/mxs/Kconfig
@@ -0,0 +1,35 @@
+if ARCH_MX23
+
+config MX23
+   bool
+   default y
+
+choice
+   prompt "MX23 board select"
+   optional
+
+config TARGET_MX23_OLINUXINO
+  

[U-Boot] [PATCH v2 2/4] arm: imx: mx28: Move MX28 selection to Kconfig

2018-02-06 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The motivation for moving MX28 selection to Kconfig is to be able
to better handle NAND MXS selection through Kconfig.

This selection method also aligns with the way other i.MX SoCs are
selected in U-Boot.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2:
- Move to arch/arm/mach-imx/mxs/Kconfig

 arch/arm/Kconfig| 49 -
 arch/arm/mach-imx/mxs/Kconfig   | 43 +
 configs/apx4devkit_defconfig|  3 +-
 configs/bg0900_defconfig|  3 +-
 configs/m28evk_defconfig|  3 +-
 configs/mx28evk_auart_console_defconfig |  3 +-
 configs/mx28evk_defconfig   |  3 +-
 configs/mx28evk_nand_defconfig  |  3 +-
 configs/mx28evk_spi_defconfig   |  3 +-
 configs/sc_sps_1_defconfig  |  3 +-
 configs/ts4600_defconfig|  3 +-
 include/configs/apx4devkit.h|  1 -
 include/configs/bg0900.h|  3 --
 include/configs/m28evk.h|  1 -
 include/configs/mx28evk.h   |  1 -
 include/configs/sc_sps_1.h  |  1 -
 include/configs/ts4600.h|  3 --
 scripts/config_whitelist.txt|  1 -
 18 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 59b0588027..8a0cbc7faa 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -396,37 +396,6 @@ config TARGET_APF27
select CPU_ARM926EJS
select SUPPORT_SPL
 
-config TARGET_APX4DEVKIT
-   bool "Support apx4devkit"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_M28EVK
-   bool "Support m28evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_MX28EVK
-   bool "Support mx28evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
-config TARGET_BG0900
-   bool "Support bg0900"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_SC_SPS_1
-   bool "Support sc_sps_1"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config ORION5X
bool "Marvell Orion"
select CPU_ARM926EJS
@@ -650,6 +619,12 @@ config ARCH_MX25
bool "NXP MX25"
select CPU_ARM926EJS
 
+config ARCH_MX28
+   bool "NXP i.MX28 family"
+   select CPU_ARM926EJS
+   select PL011_SERIAL
+   select SUPPORT_SPL
+
 config ARCH_MX7ULP
 bool "NXP MX7ULP"
 select CPU_V7
@@ -767,12 +742,6 @@ config ARCH_SUNXI
imply SPL_SERIAL_SUPPORT
imply USB_GADGET
 
-config TARGET_TS4600
-   bool "Support TS4600"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config ARCH_VF610
bool "Freescale Vybrid"
select CPU_V7
@@ -1294,7 +1263,6 @@ source "arch/arm/cpu/armv8/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
-source "board/aries/m28evk/Kconfig"
 source "board/bosch/shc/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
 source "board/Marvell/aspenite/Kconfig"
@@ -1302,7 +1270,6 @@ source "board/Marvell/gplugd/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
-source "board/bluegiga/apx4devkit/Kconfig"
 source "board/broadcom/bcm23550_w1d/Kconfig"
 source "board/broadcom/bcm28155_ap/Kconfig"
 source "board/broadcom/bcmcygnus/Kconfig"
@@ -1325,7 +1292,6 @@ source "board/freescale/ls1046ardb/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
-source "board/freescale/mx28evk/Kconfig"
 source "board/freescale/mx31ads/Kconfig"
 source "board/freescale/mx31pdk/Kconfig"
 source "board/freescale/mx35pdk/Kconfig"
@@ -1339,8 +1305,6 @@ source "board/hisilicon/poplar/Kconfig"
 source "board/imx31_phycore/Kconfig"
 source "board/isee/igep003x/Kconfig"
 source "board/phytec/pcm051/Kconfig"
-source "board/ppcag/bg0900/Kconfig"
-source "board/schulercontrol/sc_sps_1/Kconfig"
 source "board/silica/pengwyn/Kconfig"
 source "board/spear/spear300/Kconfig"
 source "board/spear/spear310/Kconfig"
@@ -1352,7 +1316,6 @@ source "board/tcl/sl50/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/timll/devkit3250/Kconfig"
 source "board/torad

[U-Boot] [PATCH v2 0/4] arm: imx: convert MX23/28 and MXS NAND to Kconfig

2018-02-06 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This converts i.MX23/28 to Kconfig. This helps to properly
add dependencies for GPMI NAND (NAND_MXS) configs.
Patch 4 is from a previous patchset "mtd: nand: mxs_nand:
improve ECC support".

--
Stefan

Changes in v2:
- Move to arch/arm/mach-imx/mxs/Kconfig
- Fix SoC name
- Move to arch/arm/mach-imx/mxs/Kconfig

Stefan Agner (4):
  arm: imx: mx23: Move MX23 selection to Kconfig
  arm: imx: mx28: Move MX28 selection to Kconfig
  spl: use ARCH_MX23/28 to specify SPL_LDSCRIPT
  Convert CONFIG_NAND_MXS to Kconfig

 arch/arm/Kconfig| 89 ++---
 arch/arm/mach-imx/mxs/Kconfig   | 78 +
 configs/apx4devkit_defconfig|  6 ++-
 configs/aristainetos2_defconfig |  3 +-
 configs/aristainetos2b_defconfig|  3 +-
 configs/aristainetos_defconfig  |  3 +-
 configs/bg0900_defconfig|  6 ++-
 configs/cm_fx6_defconfig| 11 +---
 configs/colibri_imx7_defconfig  |  3 +-
 configs/gwventana_nand_defconfig|  3 +-
 configs/m28evk_defconfig|  6 ++-
 configs/mx23_olinuxino_defconfig|  3 +-
 configs/mx23evk_defconfig   |  3 +-
 configs/mx28evk_auart_console_defconfig |  6 ++-
 configs/mx28evk_defconfig   |  6 ++-
 configs/mx28evk_nand_defconfig  |  6 ++-
 configs/mx28evk_spi_defconfig   |  6 ++-
 configs/mx6sabreauto_defconfig  |  3 +-
 configs/mx6sxsabreauto_defconfig|  3 +-
 configs/pcm058_defconfig|  3 +-
 configs/pfla02_defconfig|  3 ++
 configs/platinum_picon_defconfig|  3 +-
 configs/platinum_titanium_defconfig |  3 +-
 configs/sansa_fuze_plus_defconfig   |  1 +
 configs/sc_sps_1_defconfig  |  3 +-
 configs/titanium_defconfig  |  3 +-
 configs/ts4600_defconfig|  3 +-
 configs/xfi3_defconfig  |  3 +-
 drivers/mtd/nand/Kconfig|  2 +-
 include/configs/apx4devkit.h|  1 -
 include/configs/aristainetos-common.h   |  1 -
 include/configs/bg0900.h|  3 --
 include/configs/cm_fx6.h|  1 -
 include/configs/colibri_imx7.h  |  2 -
 include/configs/gw_ventana.h|  1 -
 include/configs/m28evk.h|  1 -
 include/configs/mx23_olinuxino.h|  1 -
 include/configs/mx23evk.h   |  1 -
 include/configs/mx28evk.h   |  1 -
 include/configs/mx6sabreauto.h  |  1 -
 include/configs/mx6sxsabreauto.h|  1 -
 include/configs/mxs.h   |  1 -
 include/configs/pcm058.h|  1 -
 include/configs/pfla02.h|  1 -
 include/configs/platinum.h  |  1 -
 include/configs/sansa_fuze_plus.h   |  3 --
 include/configs/sc_sps_1.h  |  1 -
 include/configs/titanium.h  |  1 -
 include/configs/ts4600.h|  3 --
 include/configs/xfi3.h  |  3 --
 scripts/config_whitelist.txt|  2 -
 51 files changed, 160 insertions(+), 146 deletions(-)
 create mode 100644 arch/arm/mach-imx/mxs/Kconfig

-- 
2.16.1

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


[U-Boot] [PATCH 4/4] Convert CONFIG_NAND_MXS to Kconfig

2018-02-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This converts CONFIG_NAND_MXS to Kconfig.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 configs/apx4devkit_defconfig|  3 ++-
 configs/aristainetos2_defconfig |  3 ++-
 configs/aristainetos2b_defconfig|  3 ++-
 configs/aristainetos_defconfig  |  3 ++-
 configs/bg0900_defconfig|  3 ++-
 configs/cm_fx6_defconfig| 11 ++-
 configs/colibri_imx7_defconfig  |  3 ++-
 configs/gwventana_nand_defconfig|  3 ++-
 configs/m28evk_defconfig|  3 ++-
 configs/mx28evk_auart_console_defconfig |  3 ++-
 configs/mx28evk_defconfig   |  3 ++-
 configs/mx28evk_nand_defconfig  |  3 ++-
 configs/mx28evk_spi_defconfig   |  3 ++-
 configs/mx6sabreauto_defconfig  |  3 ++-
 configs/mx6sxsabreauto_defconfig|  3 ++-
 configs/pcm058_defconfig|  3 ++-
 configs/pfla02_defconfig|  3 +++
 configs/platinum_picon_defconfig|  3 ++-
 configs/platinum_titanium_defconfig |  3 ++-
 configs/titanium_defconfig  |  3 ++-
 drivers/mtd/nand/Kconfig|  2 +-
 include/configs/aristainetos-common.h   |  1 -
 include/configs/cm_fx6.h|  1 -
 include/configs/colibri_imx7.h  |  2 --
 include/configs/gw_ventana.h|  1 -
 include/configs/mx6sabreauto.h  |  1 -
 include/configs/mx6sxsabreauto.h|  1 -
 include/configs/mxs.h   |  1 -
 include/configs/pcm058.h|  1 -
 include/configs/pfla02.h|  1 -
 include/configs/platinum.h  |  1 -
 include/configs/titanium.h  |  1 -
 32 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/configs/apx4devkit_defconfig b/configs/apx4devkit_defconfig
index 6d57bb2dbc..260ddb2194 100644
--- a/configs/apx4devkit_defconfig
+++ b/configs/apx4devkit_defconfig
@@ -14,7 +14,6 @@ CONFIG_SPL=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -28,6 +27,8 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:128k(bootstrap),1024k(boot),768k(env
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_MMC_MXS=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/aristainetos2_defconfig b/configs/aristainetos2_defconfig
index 288dab0d3c..c0daed6b22 100644
--- a/configs/aristainetos2_defconfig
+++ b/configs/aristainetos2_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos2b_defconfig b/configs/aristainetos2b_defconfig
index 115ae07ad6..fbb2c1c38d 100644
--- a/configs/aristainetos2b_defconfig
+++ b/configs/aristainetos2b_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos_defconfig b/configs/aristainetos_defconfig
index cad8b4af8a..13f4d6eb52 100644
--- a/configs/aristainetos_defconfig
+++ b/configs/aristainetos_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/bg0900_defconfig b/configs/bg0900_defconfig
index ed0448d55d..602eb60808 100644
--- a/configs/bg0900_defconfig
+++ b/configs/bg0900_defconfig
@@ -17,7 +17,6 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -27,6 +26,8 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_DOS_PARTITION=y
 # CONFIG_MMC is not set
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index 6b1c0a823c..995baabd5d 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -20,9 +20,7 @@ CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd; run 
legacy_

[U-Boot] [PATCH 3/4] spl: use ARCH_MX23/28 to specify SPL_LDSCRIPT

2018-02-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Simplify SPL_LDSCRIPT config by using the new arch Kconfig
configurations ARCH_MX23 and ARCH_MX28.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f4301f18ce..2330c83d74 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1324,7 +1324,7 @@ source "arch/arm/Kconfig.debug"
 endmenu
 
 config SPL_LDSCRIPT
-default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if 
TARGET_APX4DEVKIT || TARGET_BG0900 || TARGET_M28EVK || TARGET_MX23_OLINUXINO || 
TARGET_MX23EVK || TARGET_MX28EVK || TARGET_SANSA_FUZE_PLUS || TARGET_SC_SPS_1 
|| TARGET_TS4600 || TARGET_XFI3
+default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if ARCH_MX23 || 
ARCH_MX28
 default "arch/arm/cpu/arm1136/u-boot-spl.lds" if CPU_ARM1136
default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
 
-- 
2.16.1

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


[U-Boot] [PATCH 2/4] arm: imx: mx28: Move MX28 selection to Kconfig

2018-02-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The motivation for moving MX28 selection to Kconfig is to be able
to better handle NAND MXS selection through Kconfig.

This selection method also aligns with the way other i.MX SoCs are
selected in U-Boot.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 arch/arm/Kconfig| 49 -
 arch/arm/mach-imx/mx2/Kconfig   | 43 +
 configs/apx4devkit_defconfig|  3 +-
 configs/bg0900_defconfig|  3 +-
 configs/m28evk_defconfig|  3 +-
 configs/mx28evk_auart_console_defconfig |  3 +-
 configs/mx28evk_defconfig   |  3 +-
 configs/mx28evk_nand_defconfig  |  3 +-
 configs/mx28evk_spi_defconfig   |  3 +-
 configs/sc_sps_1_defconfig  |  3 +-
 configs/ts4600_defconfig|  3 +-
 include/configs/apx4devkit.h|  1 -
 include/configs/bg0900.h|  3 --
 include/configs/m28evk.h|  1 -
 include/configs/mx28evk.h   |  1 -
 include/configs/sc_sps_1.h  |  1 -
 include/configs/ts4600.h|  3 --
 scripts/config_whitelist.txt|  1 -
 18 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b963a5102e..f4301f18ce 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -396,37 +396,6 @@ config TARGET_APF27
select CPU_ARM926EJS
select SUPPORT_SPL
 
-config TARGET_APX4DEVKIT
-   bool "Support apx4devkit"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_M28EVK
-   bool "Support m28evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_MX28EVK
-   bool "Support mx28evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
-config TARGET_BG0900
-   bool "Support bg0900"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
-config TARGET_SC_SPS_1
-   bool "Support sc_sps_1"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config ORION5X
bool "Marvell Orion"
select CPU_ARM926EJS
@@ -650,6 +619,12 @@ config ARCH_MX25
bool "NXP MX25"
select CPU_ARM926EJS
 
+config ARCH_MX28
+   bool "NXP i.MX28 family"
+   select CPU_ARM926EJS
+   select PL011_SERIAL
+   select SUPPORT_SPL
+
 config ARCH_MX7ULP
 bool "NXP MX7ULP"
 select CPU_V7
@@ -767,12 +742,6 @@ config ARCH_SUNXI
imply SPL_SERIAL_SUPPORT
imply USB_GADGET
 
-config TARGET_TS4600
-   bool "Support TS4600"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config ARCH_VF610
bool "Freescale Vybrid"
select CPU_V7
@@ -1292,7 +1261,6 @@ source "arch/arm/cpu/armv8/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
-source "board/aries/m28evk/Kconfig"
 source "board/bosch/shc/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
 source "board/Marvell/aspenite/Kconfig"
@@ -1300,7 +1268,6 @@ source "board/Marvell/gplugd/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
-source "board/bluegiga/apx4devkit/Kconfig"
 source "board/broadcom/bcm23550_w1d/Kconfig"
 source "board/broadcom/bcm28155_ap/Kconfig"
 source "board/broadcom/bcmcygnus/Kconfig"
@@ -1323,7 +1290,6 @@ source "board/freescale/ls1046ardb/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
-source "board/freescale/mx28evk/Kconfig"
 source "board/freescale/mx31ads/Kconfig"
 source "board/freescale/mx31pdk/Kconfig"
 source "board/freescale/mx35pdk/Kconfig"
@@ -1337,8 +1303,6 @@ source "board/hisilicon/poplar/Kconfig"
 source "board/imx31_phycore/Kconfig"
 source "board/isee/igep003x/Kconfig"
 source "board/phytec/pcm051/Kconfig"
-source "board/ppcag/bg0900/Kconfig"
-source "board/schulercontrol/sc_sps_1/Kconfig"
 source "board/silica/pengwyn/Kconfig"
 source "board/spear/spear300/Kconfig"
 source "board/spear/spear310/Kconfig"
@@ -1350,7 +1314,6 @@ source "board/tcl/sl50/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/timll/devkit3250/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
-source "board/tec

[U-Boot] [PATCH 1/4] arm: imx: mx23: Move MX23 selection to Kconfig

2018-02-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The motivation for moving MX23 selection to Kconfig is to be able
to better handle NAND MXS selection through Kconfig.

This selection method also aligns with the way other i.MX SoCs are
selected in U-Boot.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 arch/arm/Kconfig  | 36 ++--
 arch/arm/mach-imx/mx2/Kconfig | 36 
 configs/mx23_olinuxino_defconfig  |  3 ++-
 configs/mx23evk_defconfig |  3 ++-
 configs/sansa_fuze_plus_defconfig |  1 +
 configs/xfi3_defconfig|  3 ++-
 include/configs/mx23_olinuxino.h  |  1 -
 include/configs/mx23evk.h |  1 -
 include/configs/sansa_fuze_plus.h |  3 ---
 include/configs/xfi3.h|  3 ---
 scripts/config_whitelist.txt  |  1 -
 11 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 880a56ba90..b963a5102e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -402,25 +402,12 @@ config TARGET_APX4DEVKIT
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_XFI3
-   bool "Support xfi3"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config TARGET_M28EVK
bool "Support m28evk"
select CPU_ARM926EJS
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_MX23EVK
-   bool "Support mx23evk"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
 config TARGET_MX28EVK
bool "Support mx28evk"
select CPU_ARM926EJS
@@ -428,25 +415,12 @@ config TARGET_MX28EVK
select BOARD_EARLY_INIT_F
select PL011_SERIAL
 
-config TARGET_MX23_OLINUXINO
-   bool "Support mx23_olinuxino"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select BOARD_EARLY_INIT_F
-   select PL011_SERIAL
-
 config TARGET_BG0900
bool "Support bg0900"
select CPU_ARM926EJS
select SUPPORT_SPL
select PL011_SERIAL
 
-config TARGET_SANSA_FUZE_PLUS
-   bool "Support sansa_fuze_plus"
-   select CPU_ARM926EJS
-   select SUPPORT_SPL
-   select PL011_SERIAL
-
 config TARGET_SC_SPS_1
bool "Support sc_sps_1"
select CPU_ARM926EJS
@@ -666,6 +640,12 @@ config ARCH_MX8M
select DM
select SUPPORT_SPL
 
+config ARCH_MX23
+   bool "NXP i.MX23 family"
+   select CPU_ARM926EJS
+   select PL011_SERIAL
+   select SUPPORT_SPL
+
 config ARCH_MX25
bool "NXP MX25"
select CPU_ARM926EJS
@@ -1328,7 +1308,6 @@ source "board/broadcom/bcmnsp/Kconfig"
 source "board/broadcom/bcmns2/Kconfig"
 source "board/cavium/thunderx/Kconfig"
 source "board/cirrus/edb93xx/Kconfig"
-source "board/creative/xfi3/Kconfig"
 source "board/eets/pdu001/Kconfig"
 source "board/freescale/ls2080a/Kconfig"
 source "board/freescale/ls2080aqds/Kconfig"
@@ -1344,7 +1323,6 @@ source "board/freescale/ls1046ardb/Kconfig"
 source "board/freescale/ls1012aqds/Kconfig"
 source "board/freescale/ls1012ardb/Kconfig"
 source "board/freescale/ls1012afrdm/Kconfig"
-source "board/freescale/mx23evk/Kconfig"
 source "board/freescale/mx28evk/Kconfig"
 source "board/freescale/mx31ads/Kconfig"
 source "board/freescale/mx31pdk/Kconfig"
@@ -1358,10 +1336,8 @@ source "board/hisilicon/hikey/Kconfig"
 source "board/hisilicon/poplar/Kconfig"
 source "board/imx31_phycore/Kconfig"
 source "board/isee/igep003x/Kconfig"
-source "board/olimex/mx23_olinuxino/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
-source "board/sandisk/sansa_fuze_plus/Kconfig"
 source "board/schulercontrol/sc_sps_1/Kconfig"
 source "board/silica/pengwyn/Kconfig"
 source "board/spear/spear300/Kconfig"
diff --git a/arch/arm/mach-imx/mx2/Kconfig b/arch/arm/mach-imx/mx2/Kconfig
index ea308fccab..7d70ee2971 100644
--- a/arch/arm/mach-imx/mx2/Kconfig
+++ b/arch/arm/mach-imx/mx2/Kconfig
@@ -1,3 +1,39 @@
+if ARCH_MX23
+
+config MX23
+   bool
+   default y
+
+choice
+   prompt "MX25 board select"
+   optional
+
+config TARGET_MX23_OLINUXINO
+   bool "Support mx23_olinuxino"
+   select BOARD_EARLY_INIT_F
+
+config TARGET_MX23EVK
+   bool "Support mx23evk"
+   select BOARD_EARLY_INIT_F
+
+config TARGET_SANSA_FUZE_PLUS
+   bool "Support sansa_fuze_plus"
+
+config TARGET_XFI3
+   bool "Support xfi3"
+
+endchoice
+
+config SYS_SOC
+   default "mxs"
+
+source "board/olimex/m

[U-Boot] [PATCH 0/4] arm: imx: convert MX23/28 and MXS NAND to Kconfig

2018-02-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This converts i.MX23/28 to Kconfig. This helps to properly
add dependencies for GPMI NAND (NAND_MXS) configs.
Patch 4 is from a previous patchset "mtd: nand: mxs_nand:
improve ECC support".

--
Stefan


Stefan Agner (4):
  arm: imx: mx23: Move MX23 selection to Kconfig
  arm: imx: mx28: Move MX28 selection to Kconfig
  spl: use ARCH_MX23/28 to specify SPL_LDSCRIPT
  Convert CONFIG_NAND_MXS to Kconfig

 arch/arm/Kconfig| 87 +
 arch/arm/mach-imx/mx2/Kconfig   | 79 ++
 configs/apx4devkit_defconfig|  6 ++-
 configs/aristainetos2_defconfig |  3 +-
 configs/aristainetos2b_defconfig|  3 +-
 configs/aristainetos_defconfig  |  3 +-
 configs/bg0900_defconfig|  6 ++-
 configs/cm_fx6_defconfig| 11 +
 configs/colibri_imx7_defconfig  |  3 +-
 configs/gwventana_nand_defconfig|  3 +-
 configs/m28evk_defconfig|  6 ++-
 configs/mx23_olinuxino_defconfig|  3 +-
 configs/mx23evk_defconfig   |  3 +-
 configs/mx28evk_auart_console_defconfig |  6 ++-
 configs/mx28evk_defconfig   |  6 ++-
 configs/mx28evk_nand_defconfig  |  6 ++-
 configs/mx28evk_spi_defconfig   |  6 ++-
 configs/mx6sabreauto_defconfig  |  3 +-
 configs/mx6sxsabreauto_defconfig|  3 +-
 configs/pcm058_defconfig|  3 +-
 configs/pfla02_defconfig|  3 ++
 configs/platinum_picon_defconfig|  3 +-
 configs/platinum_titanium_defconfig |  3 +-
 configs/sansa_fuze_plus_defconfig   |  1 +
 configs/sc_sps_1_defconfig  |  3 +-
 configs/titanium_defconfig  |  3 +-
 configs/ts4600_defconfig|  3 +-
 configs/xfi3_defconfig  |  3 +-
 drivers/mtd/nand/Kconfig|  2 +-
 include/configs/apx4devkit.h|  1 -
 include/configs/aristainetos-common.h   |  1 -
 include/configs/bg0900.h|  3 --
 include/configs/cm_fx6.h|  1 -
 include/configs/colibri_imx7.h  |  2 -
 include/configs/gw_ventana.h|  1 -
 include/configs/m28evk.h|  1 -
 include/configs/mx23_olinuxino.h|  1 -
 include/configs/mx23evk.h   |  1 -
 include/configs/mx28evk.h   |  1 -
 include/configs/mx6sabreauto.h  |  1 -
 include/configs/mx6sxsabreauto.h|  1 -
 include/configs/mxs.h   |  1 -
 include/configs/pcm058.h|  1 -
 include/configs/pfla02.h|  1 -
 include/configs/platinum.h  |  1 -
 include/configs/sansa_fuze_plus.h   |  3 --
 include/configs/sc_sps_1.h  |  1 -
 include/configs/titanium.h  |  1 -
 include/configs/ts4600.h|  3 --
 include/configs/xfi3.h  |  3 --
 scripts/config_whitelist.txt|  2 -
 51 files changed, 159 insertions(+), 146 deletions(-)

-- 
2.16.1

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


[U-Boot] [PATCH v2 3/6] mtd: nand: mxs_nand: allow to enable BBT support

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add config option which allows to enable on flash bad block table
support. This has the same effect as when using the device tree
property "nand-on-flash-bbt" in Linux.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 drivers/mtd/nand/mxs_nand.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index cf96584fa8..1fe7a712d2 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1172,6 +1172,10 @@ void board_nand_init(void)
 
memset(_ecc_layout, 0, sizeof(fake_ecc_layout));
 
+#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
+   nand->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
+#endif
+
nand_set_controller_data(nand, nand_info);
nand->options |= NAND_NO_SUBPAGE_WRITE;
 
-- 
2.16.1

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


[U-Boot] [PATCH v2 6/6] mtd: nand: mxs_nand: add minimal ECC support

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add support for minimum ECC strength supported by the NAND chip.
This aligns with the behavior when using the fsl,use-minimum-ecc
device tree property in Linux.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 drivers/mtd/nand/Kconfig|  8 +
 drivers/mtd/nand/mxs_nand.c | 71 -
 2 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 9fea8fbd1f..51577ddc10 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -147,6 +147,14 @@ config NAND_MXS
  This enables NAND driver for the NAND flash controller on the
  MXS processors.
 
+if NAND_MXS
+
+config NAND_MXS_USE_MINIMUM_ECC
+   bool "Use minimum ECC strength supported by the controller"
+   default false
+
+endif
+
 config NAND_ZYNQ
bool "Support for Zynq Nand controller"
select SYS_NAND_SELF_INIT
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 2d84bab717..cdd5a86fe2 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -211,11 +211,52 @@ static inline int mxs_nand_calc_mark_offset(struct 
bch_geometry *geo,
return 0;
 }
 
+static inline unsigned int mxs_nand_max_ecc_strength_supported(void)
+{
+   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
+   if (is_mx6sx() || is_mx7())
+   return 62;
+   else
+   return 40;
+}
+
+static inline int mxs_nand_calc_ecc_layout_by_info(struct bch_geometry *geo,
+  struct mtd_info *mtd)
+{
+   struct nand_chip *chip = mtd_to_nand(mtd);
+
+   if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
+   return -ENOTSUPP;
+
+   switch (chip->ecc_step_ds) {
+   case SZ_512:
+   geo->gf_len = 13;
+   break;
+   case SZ_1K:
+   geo->gf_len = 14;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   geo->ecc_chunk_size = chip->ecc_step_ds;
+   geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
+
+   /* Keep the C >= O */
+   if (geo->ecc_chunk_size < mtd->oobsize)
+   return -EINVAL;
+
+   if (geo->ecc_strength > mxs_nand_max_ecc_strength_supported())
+   return -EINVAL;
+
+   geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
+
+   return 0;
+}
+
 static inline int mxs_nand_calc_ecc_layout(struct bch_geometry *geo,
   struct mtd_info *mtd)
 {
-   unsigned int max_ecc_strength_supported;
-
/* The default for the length of Galois Field. */
geo->gf_len = 13;
 
@@ -235,12 +276,6 @@ static inline int mxs_nand_calc_ecc_layout(struct 
bch_geometry *geo,
 
geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
 
-   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
-   if (is_mx6sx() || is_mx7())
-   max_ecc_strength_supported = 62;
-   else
-   max_ecc_strength_supported = 40;
-
/*
 * Determine the ECC layout with the formula:
 *  ECC bits per chunk = (total page spare data bits) /
@@ -252,10 +287,8 @@ static inline int mxs_nand_calc_ecc_layout(struct 
bch_geometry *geo,
geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8)
/ (geo->gf_len * geo->ecc_chunk_count);
 
-   geo->ecc_strength = min(round_down(geo->ecc_strength, 2), 
max_ecc_strength_supported);
-
-   if (mxs_nand_calc_mark_offset(geo, mtd->writesize) < 0)
-   return -EINVAL;
+   geo->ecc_strength = min(round_down(geo->ecc_strength, 2),
+   mxs_nand_max_ecc_strength_supported());
 
return 0;
 }
@@ -1006,9 +1039,19 @@ static int mxs_nand_setup_ecc(struct mtd_info *mtd)
struct bch_geometry *geo = _info->bch_geometry;
struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
uint32_t tmp;
+   int ret = -ENOTSUPP;
 
-   if (mxs_nand_calc_ecc_layout(geo, mtd))
-   return -EINVAL;
+#ifdef CONFIG_NAND_MXS_USE_MINIMUM_ECC
+   ret = mxs_nand_calc_ecc_layout_by_info(geo, mtd);
+#endif
+
+   if (ret == -ENOTSUPP)
+   ret = mxs_nand_calc_ecc_layout(geo, mtd);
+
+   if (ret)
+   return ret;
+
+   mxs_nand_calc_mark_offset(geo, mtd->writesize);
 
/* Configure BCH and set NFC geometry */
mxs_reset_block(_regs->hw_bch_ctrl_reg);
-- 
2.16.1

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


[U-Boot] [PATCH v2 5/6] mtd: nand: mxs_nand: report correct ECC parameters

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Report correct ECC parameters back to the stack. Do not report
bytes as we have it not immeaditly available and the Linux version
also does not report it. It seems to have no aversive effect.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2:
- Extend the patchset with "report correct ECC parameters" patch

 drivers/mtd/nand/mxs_nand.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 5b9398bd98..2d84bab717 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1212,9 +1212,8 @@ void board_nand_init(void)
 
nand->ecc.layout= _ecc_layout;
nand->ecc.mode  = NAND_ECC_HW;
-   nand->ecc.bytes = 9;
-   nand->ecc.size  = 512;
-   nand->ecc.strength  = 8;
+   nand->ecc.size  = nand_info->bch_geometry.ecc_chunk_size;
+   nand->ecc.strength  = nand_info->bch_geometry.ecc_strength;
 
/* second phase scan */
err = nand_scan_tail(mtd);
-- 
2.16.1

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


[U-Boot] [PATCH v2 4/6] mtd: nand: mxs_nand: use structure for BCH geometry

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Calculate BCH geometry at start and store the information in
a structure. This avoids recalculation on every page access
and allows to calculate ECC relevant information in one place.
This patch does not change ECC layout or driver behavior in
any way.

The patch aligns the driver somewhat with the Linux GPMI NAND
driver which drives the same IP.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 drivers/mtd/nand/mxs_nand.c | 182 +++-
 1 file changed, 95 insertions(+), 87 deletions(-)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 1fe7a712d2..5b9398bd98 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -30,7 +30,6 @@
 
 #defineMXS_NAND_DMA_DESCRIPTOR_COUNT   4
 
-#defineMXS_NAND_CHUNK_DATA_CHUNK_SIZE  512
 #if (defined(CONFIG_MX6) || defined(CONFIG_MX7))
 #defineMXS_NAND_CHUNK_DATA_CHUNK_SIZE_SHIFT2
 #else
@@ -47,12 +46,35 @@
 
 #defineMXS_NAND_BCH_TIMEOUT1
 
+/**
+ * @gf_len:   The length of Galois Field. (e.g., 13 or 14)
+ * @ecc_strength: A number that describes the strength of the ECC
+ *algorithm.
+ * @ecc_chunk_size:   The size, in bytes, of a single ECC chunk. Note
+ *the first chunk in the page includes both data 
and
+ *metadata, so it's a bit larger than this value.
+ * @ecc_chunk_count:  The number of ECC chunks in the page,
+ * @block_mark_byte_offset:   The byte offset in the ECC-based page view at
+ *which the underlying physical block mark appears.
+ * @block_mark_bit_offset:The bit offset into the ECC-based page view at
+ *which the underlying physical block mark appears.
+ */
+struct bch_geometry {
+   unsigned int  gf_len;
+   unsigned int  ecc_strength;
+   unsigned int  ecc_chunk_size;
+   unsigned int  ecc_chunk_count;
+   unsigned int  block_mark_byte_offset;
+   unsigned int  block_mark_bit_offset;
+};
+
 struct mxs_nand_info {
struct nand_chip chip;
int cur_chip;
 
uint32_tcmd_queue_len;
uint32_tdata_buf_size;
+   struct bch_geometry bch_geometry;
 
uint8_t *cmd_buf;
uint8_t *data_buf;
@@ -75,8 +97,6 @@ struct mxs_nand_info {
 };
 
 struct nand_ecclayout fake_ecc_layout;
-static int chunk_data_size = MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
-static int galois_field = 13;
 
 /*
  * Cache management functions
@@ -137,61 +157,21 @@ static void mxs_nand_return_dma_descs(struct 
mxs_nand_info *info)
info->desc_index = 0;
 }
 
-static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
-{
-   return page_data_size / chunk_data_size;
-}
-
-static uint32_t mxs_nand_ecc_size_in_bits(uint32_t ecc_strength)
-{
-   return ecc_strength * galois_field;
-}
-
 static uint32_t mxs_nand_aux_status_offset(void)
 {
return (MXS_NAND_METADATA_SIZE + 0x3) & ~0x3;
 }
 
-static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size,
-   uint32_t page_oob_size)
+static inline int mxs_nand_calc_mark_offset(struct bch_geometry *geo,
+   uint32_t page_data_size)
 {
-   int ecc_strength;
-   int max_ecc_strength_supported;
-
-   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
-   if (is_mx6sx() || is_mx7())
-   max_ecc_strength_supported = 62;
-   else
-   max_ecc_strength_supported = 40;
-
-   /*
-* Determine the ECC layout with the formula:
-*  ECC bits per chunk = (total page spare data bits) /
-*  (bits per ECC level) / (chunks per page)
-* where:
-*  total page spare data bits =
-*  (page oob size - meta data size) * (bits per byte)
-*/
-   ecc_strength = ((page_oob_size - MXS_NAND_METADATA_SIZE) * 8)
-   / (galois_field *
-  mxs_nand_ecc_chunk_cnt(page_data_size));
-
-   return min(round_down(ecc_strength, 2), max_ecc_strength_supported);
-}
-
-static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size,
-   uint32_t ecc_strength)
-{
-   uint32_t chunk_data_size_in_bits;
-   uint32_t chunk_ecc_size_in_bits;
+   uint32_t chunk_data_size_in_bits = geo->ecc_chunk_size * 8;
+   uint32_t chunk_ecc_size_in_bits = geo->ecc_strength * geo->gf_len;
uint32_t chunk_total_size_in_bits;
uint32_t block_mark_chunk_number;
uint32_t block_mark_chunk_bit_offset;
uint32_t block_mark_bit_offset;
 
-   chunk_data_size_i

[U-Boot] [PATCH v2 2/6] mtd: nand: mxs_nand: use self init

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Instead of completing initialization via scan_bbt callback use
NAND self init to initialize the GPMI (MXS) NAND controller.

Suggested-by: Scott Wood <o...@buserror.net>
Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2: None

 drivers/mtd/nand/Kconfig|  1 +
 drivers/mtd/nand/mxs_nand.c | 52 +
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 97ec6cf5f9..9fea8fbd1f 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -141,6 +141,7 @@ config NAND_MXC
 config NAND_MXS
bool "MXS NAND support"
depends on MX6 || MX7
+   select SYS_NAND_SELF_INIT
imply CMD_NAND
help
  This enables NAND driver for the NAND flash controller on the
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index bed9b65ef4..cf96584fa8 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,6 +48,7 @@
 #defineMXS_NAND_BCH_TIMEOUT1
 
 struct mxs_nand_info {
+   struct nand_chip chip;
int cur_chip;
 
uint32_tcmd_queue_len;
@@ -972,20 +974,15 @@ static int mxs_nand_block_bad(struct mtd_info *mtd, 
loff_t ofs)
 }
 
 /*
- * Nominally, the purpose of this function is to look for or create the bad
- * block table. In fact, since the we call this function at the very end of
- * the initialization process started by nand_scan(), and we doesn't have a
- * more formal mechanism, we "hook" this function to continue init process.
- *
  * At this point, the physical NAND Flash chips have been identified and
  * counted, so we know the physical geometry. This enables us to make some
  * important configuration decisions.
  *
  * The return value of this function propagates directly back to this driver's
- * call to nand_scan(). Anything other than zero will cause this driver to
+ * board_nand_init(). Anything other than zero will cause this driver to
  * tear everything down and declare failure.
  */
-static int mxs_nand_scan_bbt(struct mtd_info *mtd)
+static int mxs_nand_setup_ecc(struct mtd_info *mtd)
 {
struct nand_chip *nand = mtd_to_nand(mtd);
struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
@@ -1047,8 +1044,7 @@ static int mxs_nand_scan_bbt(struct mtd_info *mtd)
mtd->_block_markbad = mxs_nand_hook_block_markbad;
}
 
-   /* We use the reference implementation for bad block management. */
-   return nand_default_bbt(mtd);
+   return 0;
 }
 
 /*
@@ -1150,27 +1146,22 @@ err1:
return ret;
 }
 
-/*!
- * This function is called during the driver binding process.
- *
- * @param   pdev  the device structure used to store device specific
- *information that is used by the suspend, resume and
- *remove functions
- *
- * @return  The function always returns 0.
- */
-int board_nand_init(struct nand_chip *nand)
+void board_nand_init(void)
 {
+   struct mtd_info *mtd;
struct mxs_nand_info *nand_info;
+   struct nand_chip *nand;
int err;
 
nand_info = malloc(sizeof(struct mxs_nand_info));
if (!nand_info) {
printf("MXS NAND: Failed to allocate private data\n");
-   return -ENOMEM;
+   return;
}
memset(nand_info, 0, sizeof(struct mxs_nand_info));
 
+   nand = _info->chip;
+   mtd = nand_to_mtd(nand);
err = mxs_nand_alloc_buffers(nand_info);
if (err)
goto err1;
@@ -1189,13 +1180,19 @@ int board_nand_init(struct nand_chip *nand)
nand->dev_ready = mxs_nand_device_ready;
nand->select_chip   = mxs_nand_select_chip;
nand->block_bad = mxs_nand_block_bad;
-   nand->scan_bbt  = mxs_nand_scan_bbt;
 
nand->read_byte = mxs_nand_read_byte;
 
nand->read_buf  = mxs_nand_read_buf;
nand->write_buf = mxs_nand_write_buf;
 
+   /* first scan to find the device and get the page size */
+   if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL))
+   goto err2;
+
+   if (mxs_nand_setup_ecc(mtd))
+   goto err2;
+
nand->ecc.read_page = mxs_nand_ecc_read_page;
nand->ecc.write_page= mxs_nand_ecc_write_page;
nand->ecc.read_oob  = mxs_nand_ecc_read_oob;
@@ -1207,12 +1204,21 @@ int board_nand_init(struct nand_chip *nand)
nand->ecc.size  = 512;
nand->ecc.strength  = 8;
 
-   return 0;
+   /* second phase scan */
+   err = nand_scan_tail(mtd);
+   if (err)
+

[U-Boot] [PATCH v2 1/6] Convert CONFIG_NAND_MXS to Kconfig

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This converts CONFIG_NAND_MXS to Kconfig.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2:
- Extend the patchset with "Convert CONFIG_NAND_MXS to Kconfig" patch

 configs/apx4devkit_defconfig|  3 ++-
 configs/aristainetos2_defconfig |  3 ++-
 configs/aristainetos2b_defconfig|  3 ++-
 configs/aristainetos_defconfig  |  3 ++-
 configs/cm_fx6_defconfig| 11 ++-
 configs/colibri_imx7_defconfig  |  3 ++-
 configs/gwventana_nand_defconfig|  3 ++-
 configs/m28evk_defconfig|  3 ++-
 configs/mx28evk_auart_console_defconfig |  3 ++-
 configs/mx28evk_defconfig   |  3 ++-
 configs/mx28evk_nand_defconfig  |  3 ++-
 configs/mx28evk_spi_defconfig   |  3 ++-
 configs/mx6sabreauto_defconfig  |  3 ++-
 configs/mx6sxsabreauto_defconfig|  3 ++-
 configs/pcm058_defconfig|  3 ++-
 configs/pfla02_defconfig|  3 +++
 configs/platinum_picon_defconfig|  3 ++-
 configs/platinum_titanium_defconfig |  3 ++-
 configs/titanium_defconfig  |  3 ++-
 include/configs/aristainetos-common.h   |  1 -
 include/configs/cm_fx6.h|  1 -
 include/configs/colibri_imx7.h  |  2 --
 include/configs/gw_ventana.h|  1 -
 include/configs/mx6sabreauto.h  |  1 -
 include/configs/mx6sxsabreauto.h|  1 -
 include/configs/mxs.h   |  1 -
 include/configs/pcm058.h|  1 -
 include/configs/pfla02.h|  1 -
 include/configs/platinum.h  |  1 -
 include/configs/titanium.h  |  1 -
 30 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/configs/apx4devkit_defconfig b/configs/apx4devkit_defconfig
index 47a4ee9e26..cc6da42066 100644
--- a/configs/apx4devkit_defconfig
+++ b/configs/apx4devkit_defconfig
@@ -13,7 +13,6 @@ CONFIG_SPL=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -27,6 +26,8 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:128k(bootstrap),1024k(boot),768k(env
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_MMC_MXS=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/aristainetos2_defconfig b/configs/aristainetos2_defconfig
index 288dab0d3c..c0daed6b22 100644
--- a/configs/aristainetos2_defconfig
+++ b/configs/aristainetos2_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos2b_defconfig b/configs/aristainetos2b_defconfig
index 115ae07ad6..fbb2c1c38d 100644
--- a/configs/aristainetos2b_defconfig
+++ b/configs/aristainetos2b_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/aristainetos_defconfig b/configs/aristainetos_defconfig
index cad8b4af8a..13f4d6eb52 100644
--- a/configs/aristainetos_defconfig
+++ b/configs/aristainetos_defconfig
@@ -14,7 +14,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_NAND_TRIMFFS=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
@@ -31,6 +30,8 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MTD_UBI_FASTMAP=y
diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index 6b1c0a823c..995baabd5d 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -20,9 +20,7 @@ CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd; run 
legacy_bootcmd"
 CONFIG_SPL=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
 CONFIG_SPL_I2C_SUPPORT=y
-CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="CM-FX6 # "
-CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_XIMG is not set
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_EEPROM=y
@@ -35,20 +33,13 @@ CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
-CONFIG_CMD_NAND=y
 CONFIG_CMD_SATA=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_PING=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT

[U-Boot] [PATCH v2 0/6] mtd: nand: mxs_nand: improve ECC support

2018-02-02 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This patchset reworks the drivers ECC calculation to align more
with the Linux driver gpmi-nand.c. It aims to implements minimal
ECC support as supported by the NAND chip.

The first three patches are of preparational nature, I hope that
especially the first two can go in soonish to avoid conflicts.

--
Stefan

Changes in v2:
- Extend the patchset with "Convert CONFIG_NAND_MXS to Kconfig" patch
- Extend the patchset with "report correct ECC parameters" patch

Stefan Agner (6):
  Convert CONFIG_NAND_MXS to Kconfig
  mtd: nand: mxs_nand: use self init
  mtd: nand: mxs_nand: allow to enable BBT support
  mtd: nand: mxs_nand: use structure for BCH geometry
  mtd: nand: mxs_nand: report correct ECC parameters
  mtd: nand: mxs_nand: add minimal ECC support

 configs/apx4devkit_defconfig|   3 +-
 configs/aristainetos2_defconfig |   3 +-
 configs/aristainetos2b_defconfig|   3 +-
 configs/aristainetos_defconfig  |   3 +-
 configs/cm_fx6_defconfig|  11 +-
 configs/colibri_imx7_defconfig  |   3 +-
 configs/gwventana_nand_defconfig|   3 +-
 configs/m28evk_defconfig|   3 +-
 configs/mx28evk_auart_console_defconfig |   3 +-
 configs/mx28evk_defconfig   |   3 +-
 configs/mx28evk_nand_defconfig  |   3 +-
 configs/mx28evk_spi_defconfig   |   3 +-
 configs/mx6sabreauto_defconfig  |   3 +-
 configs/mx6sxsabreauto_defconfig|   3 +-
 configs/pcm058_defconfig|   3 +-
 configs/pfla02_defconfig|   3 +
 configs/platinum_picon_defconfig|   3 +-
 configs/platinum_titanium_defconfig |   3 +-
 configs/titanium_defconfig  |   3 +-
 drivers/mtd/nand/Kconfig|   9 +
 drivers/mtd/nand/mxs_nand.c | 282 +++-
 include/configs/aristainetos-common.h   |   1 -
 include/configs/cm_fx6.h|   1 -
 include/configs/colibri_imx7.h  |   2 -
 include/configs/gw_ventana.h|   1 -
 include/configs/mx6sabreauto.h  |   1 -
 include/configs/mx6sxsabreauto.h|   1 -
 include/configs/mxs.h   |   1 -
 include/configs/pcm058.h|   1 -
 include/configs/pfla02.h|   1 -
 include/configs/platinum.h  |   1 -
 include/configs/titanium.h  |   1 -
 32 files changed, 219 insertions(+), 149 deletions(-)

-- 
2.16.1

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


[U-Boot] [PATCH 4/4] mtd: nand: mxs_nand: add minimal ECC support

2018-01-29 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add support for minimum ECC strength supported by the NAND chip.
This aligns with the behavior when using the fsl,use-minimum-ecc
device tree property in Linux.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/mtd/nand/Kconfig|  8 +
 drivers/mtd/nand/mxs_nand.c | 71 -
 2 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 1ca86925dc..982e4e8374 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -146,6 +146,14 @@ config NAND_MXS
  This enables NAND driver for the NAND flash controller on the
  MXS processors.
 
+if NAND_MXS
+
+config NAND_MXS_USE_MINIMUM_ECC
+   bool "Use minimum ECC strength supported by the controller"
+   default false
+
+endif
+
 config NAND_ZYNQ
bool "Support for Zynq Nand controller"
select SYS_NAND_SELF_INIT
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 5b9398bd98..e33b0df7ac 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -211,11 +211,52 @@ static inline int mxs_nand_calc_mark_offset(struct 
bch_geometry *geo,
return 0;
 }
 
+static inline unsigned int mxs_nand_max_ecc_strength_supported(void)
+{
+   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
+   if (is_mx6sx() || is_mx7())
+   return 62;
+   else
+   return 40;
+}
+
+static inline int mxs_nand_calc_ecc_layout_by_info(struct bch_geometry *geo,
+  struct mtd_info *mtd)
+{
+   struct nand_chip *chip = mtd_to_nand(mtd);
+
+   if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
+   return -ENOTSUPP;
+
+   switch (chip->ecc_step_ds) {
+   case SZ_512:
+   geo->gf_len = 13;
+   break;
+   case SZ_1K:
+   geo->gf_len = 14;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   geo->ecc_chunk_size = chip->ecc_step_ds;
+   geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
+
+   /* Keep the C >= O */
+   if (geo->ecc_chunk_size < mtd->oobsize)
+   return -EINVAL;
+
+   if (geo->ecc_strength > mxs_nand_max_ecc_strength_supported())
+   return -EINVAL;
+
+   geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
+
+   return 0;
+}
+
 static inline int mxs_nand_calc_ecc_layout(struct bch_geometry *geo,
   struct mtd_info *mtd)
 {
-   unsigned int max_ecc_strength_supported;
-
/* The default for the length of Galois Field. */
geo->gf_len = 13;
 
@@ -235,12 +276,6 @@ static inline int mxs_nand_calc_ecc_layout(struct 
bch_geometry *geo,
 
geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
 
-   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
-   if (is_mx6sx() || is_mx7())
-   max_ecc_strength_supported = 62;
-   else
-   max_ecc_strength_supported = 40;
-
/*
 * Determine the ECC layout with the formula:
 *  ECC bits per chunk = (total page spare data bits) /
@@ -252,10 +287,8 @@ static inline int mxs_nand_calc_ecc_layout(struct 
bch_geometry *geo,
geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8)
/ (geo->gf_len * geo->ecc_chunk_count);
 
-   geo->ecc_strength = min(round_down(geo->ecc_strength, 2), 
max_ecc_strength_supported);
-
-   if (mxs_nand_calc_mark_offset(geo, mtd->writesize) < 0)
-   return -EINVAL;
+   geo->ecc_strength = min(round_down(geo->ecc_strength, 2),
+   mxs_nand_max_ecc_strength_supported());
 
return 0;
 }
@@ -1006,9 +1039,19 @@ static int mxs_nand_setup_ecc(struct mtd_info *mtd)
struct bch_geometry *geo = _info->bch_geometry;
struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
uint32_t tmp;
+   int ret = -ENOTSUPP;
 
-   if (mxs_nand_calc_ecc_layout(geo, mtd))
-   return -EINVAL;
+#ifdef CONFIG_NAND_MXS_USE_MINIMUM_ECC
+   ret = mxs_nand_calc_ecc_layout_by_info(geo, mtd);
+#endif
+
+   if (ret == -ENOTSUPP)
+   ret = mxs_nand_calc_ecc_layout(geo, mtd);
+
+   if (ret)
+   return ret;
+
+   mxs_nand_calc_mark_offset(geo, mtd->writesize);
 
/* Configure BCH and set NFC geometry */
mxs_reset_block(_regs->hw_bch_ctrl_reg);
-- 
2.16.1

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


[U-Boot] [PATCH 2/4] mtd: nand: mxs_nand: allow to enable BBT support

2018-01-29 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add config option which allows to enable on flash bad block table
support. This has the same effect as when using the device tree
property "nand-on-flash-bbt" in Linux.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/mtd/nand/mxs_nand.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index cf96584fa8..1fe7a712d2 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1172,6 +1172,10 @@ void board_nand_init(void)
 
memset(_ecc_layout, 0, sizeof(fake_ecc_layout));
 
+#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
+   nand->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
+#endif
+
nand_set_controller_data(nand, nand_info);
nand->options |= NAND_NO_SUBPAGE_WRITE;
 
-- 
2.16.1

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


[U-Boot] [PATCH 3/4] mtd: nand: mxs_nand: use structure for BCH geometry

2018-01-29 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Calculate BCH geometry at start and store the information in
a structure. This avoids recalculation on every page access
and allows to calculate ECC relevant information in one place.
This patch does not change ECC layout or driver behavior in
any way.

The patch aligns the driver somewhat with the Linux GPMI NAND
driver which drives the same IP.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/mtd/nand/mxs_nand.c | 182 +++-
 1 file changed, 95 insertions(+), 87 deletions(-)

diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 1fe7a712d2..5b9398bd98 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -30,7 +30,6 @@
 
 #defineMXS_NAND_DMA_DESCRIPTOR_COUNT   4
 
-#defineMXS_NAND_CHUNK_DATA_CHUNK_SIZE  512
 #if (defined(CONFIG_MX6) || defined(CONFIG_MX7))
 #defineMXS_NAND_CHUNK_DATA_CHUNK_SIZE_SHIFT2
 #else
@@ -47,12 +46,35 @@
 
 #defineMXS_NAND_BCH_TIMEOUT1
 
+/**
+ * @gf_len:   The length of Galois Field. (e.g., 13 or 14)
+ * @ecc_strength: A number that describes the strength of the ECC
+ *algorithm.
+ * @ecc_chunk_size:   The size, in bytes, of a single ECC chunk. Note
+ *the first chunk in the page includes both data 
and
+ *metadata, so it's a bit larger than this value.
+ * @ecc_chunk_count:  The number of ECC chunks in the page,
+ * @block_mark_byte_offset:   The byte offset in the ECC-based page view at
+ *which the underlying physical block mark appears.
+ * @block_mark_bit_offset:The bit offset into the ECC-based page view at
+ *which the underlying physical block mark appears.
+ */
+struct bch_geometry {
+   unsigned int  gf_len;
+   unsigned int  ecc_strength;
+   unsigned int  ecc_chunk_size;
+   unsigned int  ecc_chunk_count;
+   unsigned int  block_mark_byte_offset;
+   unsigned int  block_mark_bit_offset;
+};
+
 struct mxs_nand_info {
struct nand_chip chip;
int cur_chip;
 
uint32_tcmd_queue_len;
uint32_tdata_buf_size;
+   struct bch_geometry bch_geometry;
 
uint8_t *cmd_buf;
uint8_t *data_buf;
@@ -75,8 +97,6 @@ struct mxs_nand_info {
 };
 
 struct nand_ecclayout fake_ecc_layout;
-static int chunk_data_size = MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
-static int galois_field = 13;
 
 /*
  * Cache management functions
@@ -137,61 +157,21 @@ static void mxs_nand_return_dma_descs(struct 
mxs_nand_info *info)
info->desc_index = 0;
 }
 
-static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
-{
-   return page_data_size / chunk_data_size;
-}
-
-static uint32_t mxs_nand_ecc_size_in_bits(uint32_t ecc_strength)
-{
-   return ecc_strength * galois_field;
-}
-
 static uint32_t mxs_nand_aux_status_offset(void)
 {
return (MXS_NAND_METADATA_SIZE + 0x3) & ~0x3;
 }
 
-static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size,
-   uint32_t page_oob_size)
+static inline int mxs_nand_calc_mark_offset(struct bch_geometry *geo,
+   uint32_t page_data_size)
 {
-   int ecc_strength;
-   int max_ecc_strength_supported;
-
-   /* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
-   if (is_mx6sx() || is_mx7())
-   max_ecc_strength_supported = 62;
-   else
-   max_ecc_strength_supported = 40;
-
-   /*
-* Determine the ECC layout with the formula:
-*  ECC bits per chunk = (total page spare data bits) /
-*  (bits per ECC level) / (chunks per page)
-* where:
-*  total page spare data bits =
-*  (page oob size - meta data size) * (bits per byte)
-*/
-   ecc_strength = ((page_oob_size - MXS_NAND_METADATA_SIZE) * 8)
-   / (galois_field *
-  mxs_nand_ecc_chunk_cnt(page_data_size));
-
-   return min(round_down(ecc_strength, 2), max_ecc_strength_supported);
-}
-
-static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size,
-   uint32_t ecc_strength)
-{
-   uint32_t chunk_data_size_in_bits;
-   uint32_t chunk_ecc_size_in_bits;
+   uint32_t chunk_data_size_in_bits = geo->ecc_chunk_size * 8;
+   uint32_t chunk_ecc_size_in_bits = geo->ecc_strength * geo->gf_len;
uint32_t chunk_total_size_in_bits;
uint32_t block_mark_chunk_number;
uint32_t block_mark_chunk_bit_offset;
uint32_t block_mark_bit_offset;
 
-   chunk_data_size_i

[U-Boot] [PATCH 1/4] mtd: nand: mxs_nand: use self init

2018-01-29 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Instead of completing initialization via scan_bbt callback use
NAND self init to initialize the GPMI (MXS) NAND controller.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/mtd/nand/Kconfig|  1 +
 drivers/mtd/nand/mxs_nand.c | 52 +
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 78a39abf75..1ca86925dc 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -140,6 +140,7 @@ config NAND_MXC
 config NAND_MXS
bool "MXS NAND support"
depends on MX6 || MX7
+   select SYS_NAND_SELF_INIT
imply CMD_NAND
help
  This enables NAND driver for the NAND flash controller on the
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index bed9b65ef4..cf96584fa8 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,6 +48,7 @@
 #defineMXS_NAND_BCH_TIMEOUT1
 
 struct mxs_nand_info {
+   struct nand_chip chip;
int cur_chip;
 
uint32_tcmd_queue_len;
@@ -972,20 +974,15 @@ static int mxs_nand_block_bad(struct mtd_info *mtd, 
loff_t ofs)
 }
 
 /*
- * Nominally, the purpose of this function is to look for or create the bad
- * block table. In fact, since the we call this function at the very end of
- * the initialization process started by nand_scan(), and we doesn't have a
- * more formal mechanism, we "hook" this function to continue init process.
- *
  * At this point, the physical NAND Flash chips have been identified and
  * counted, so we know the physical geometry. This enables us to make some
  * important configuration decisions.
  *
  * The return value of this function propagates directly back to this driver's
- * call to nand_scan(). Anything other than zero will cause this driver to
+ * board_nand_init(). Anything other than zero will cause this driver to
  * tear everything down and declare failure.
  */
-static int mxs_nand_scan_bbt(struct mtd_info *mtd)
+static int mxs_nand_setup_ecc(struct mtd_info *mtd)
 {
struct nand_chip *nand = mtd_to_nand(mtd);
struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
@@ -1047,8 +1044,7 @@ static int mxs_nand_scan_bbt(struct mtd_info *mtd)
mtd->_block_markbad = mxs_nand_hook_block_markbad;
}
 
-   /* We use the reference implementation for bad block management. */
-   return nand_default_bbt(mtd);
+   return 0;
 }
 
 /*
@@ -1150,27 +1146,22 @@ err1:
return ret;
 }
 
-/*!
- * This function is called during the driver binding process.
- *
- * @param   pdev  the device structure used to store device specific
- *information that is used by the suspend, resume and
- *remove functions
- *
- * @return  The function always returns 0.
- */
-int board_nand_init(struct nand_chip *nand)
+void board_nand_init(void)
 {
+   struct mtd_info *mtd;
struct mxs_nand_info *nand_info;
+   struct nand_chip *nand;
int err;
 
nand_info = malloc(sizeof(struct mxs_nand_info));
if (!nand_info) {
printf("MXS NAND: Failed to allocate private data\n");
-   return -ENOMEM;
+   return;
}
memset(nand_info, 0, sizeof(struct mxs_nand_info));
 
+   nand = _info->chip;
+   mtd = nand_to_mtd(nand);
err = mxs_nand_alloc_buffers(nand_info);
if (err)
goto err1;
@@ -1189,13 +1180,19 @@ int board_nand_init(struct nand_chip *nand)
nand->dev_ready = mxs_nand_device_ready;
nand->select_chip   = mxs_nand_select_chip;
nand->block_bad = mxs_nand_block_bad;
-   nand->scan_bbt  = mxs_nand_scan_bbt;
 
nand->read_byte = mxs_nand_read_byte;
 
nand->read_buf  = mxs_nand_read_buf;
nand->write_buf = mxs_nand_write_buf;
 
+   /* first scan to find the device and get the page size */
+   if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL))
+   goto err2;
+
+   if (mxs_nand_setup_ecc(mtd))
+   goto err2;
+
nand->ecc.read_page = mxs_nand_ecc_read_page;
nand->ecc.write_page= mxs_nand_ecc_write_page;
nand->ecc.read_oob  = mxs_nand_ecc_read_oob;
@@ -1207,12 +1204,21 @@ int board_nand_init(struct nand_chip *nand)
nand->ecc.size  = 512;
nand->ecc.strength  = 8;
 
-   return 0;
+   /* second phase scan */
+   err = nand_scan_tail(mtd);
+   if (err)
+   goto err2;
+
+   err = nand_register(0, mtd);
+   if (err)
+ 

[U-Boot] [PATCH] arm: dts: imx6ull: move input include to base device tree

2018-01-25 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The input keycode KEY_POWER is used in the imx6ull.dtsi file,
hence include the input header where used.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 arch/arm/dts/imx6ull-14x14-evk.dts | 1 -
 arch/arm/dts/imx6ull.dtsi  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/imx6ull-14x14-evk.dts 
b/arch/arm/dts/imx6ull-14x14-evk.dts
index 2a941bff1c..8a1b67d6bb 100644
--- a/arch/arm/dts/imx6ull-14x14-evk.dts
+++ b/arch/arm/dts/imx6ull-14x14-evk.dts
@@ -8,7 +8,6 @@
 
 /dts-v1/;
 
-#include 
 #include "imx6ull.dtsi"
 
 / {
diff --git a/arch/arm/dts/imx6ull.dtsi b/arch/arm/dts/imx6ull.dtsi
index ea882a7f14..28b8422f31 100644
--- a/arch/arm/dts/imx6ull.dtsi
+++ b/arch/arm/dts/imx6ull.dtsi
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include "imx6ull-pinfunc.h"
 #include "imx6ull-pinfunc-snvs.h"
-- 
2.15.1

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


Re: [U-Boot] [PATCH 1/2] serial: mxc: support DTE mode

2018-01-19 Thread Stefan Agner
Hi Ryan,


On 19.01.2018 10:53, Ryan Harkin wrote:
> Add DTE mode support via Kconfig on the MXC uart.

Make use of the driver model, there DTE is supported already today:
https://lists.denx.de/pipermail/u-boot/2016-July/259573.html

--
Stefan

>
> Signed-off-by: Ryan Harkin 
> Reviewed-by: Bryan O'Donoghue 
> ---
>  drivers/serial/Kconfig  |  7 +++
>  drivers/serial/serial_mxc.c | 10 --
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 122b8e7..0df57c0 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -597,4 +597,11 @@ config SYS_SDMR
>   depends on MPC8XX_CONS
>   default 0
>  
> +config SERIAL_MXC_DTE_MODE
> + bool "Use DTE mode for the MXC UART"
> + default n
> + help
> +   This is used to set DTE mode on the serial console controlled by
> +   serial_mxc.c.
> +
>  endmenu
> diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> index cce80a8..e7ea30c 100644
> --- a/drivers/serial/serial_mxc.c
> +++ b/drivers/serial/serial_mxc.c
> @@ -111,6 +111,12 @@
>  #define TXTL 2  /* reset default */
>  #define RXTL 1  /* reset default */
>  
> +#ifdef CONFIG_SERIAL_MXC_DTE_MODE
> +#define MXC_DTE_MODE true
> +#else
> +#define MXC_DTE_MODE false
> +#endif
> +
>  DECLARE_GLOBAL_DATA_PTR;
>  
>  struct mxc_uart {
> @@ -189,7 +195,7 @@ static void mxc_serial_setbrg(void)
>   if (!gd->baudrate)
>   gd->baudrate = CONFIG_BAUDRATE;
>  
> - _mxc_serial_setbrg(mxc_base, clk, gd->baudrate, false);
> + _mxc_serial_setbrg(mxc_base, clk, gd->baudrate, MXC_DTE_MODE);
>  }
>  
>  static int mxc_serial_getc(void)
> @@ -367,7 +373,7 @@ static inline void _debug_uart_init(void)
>  
>   _mxc_serial_init(base);
>   _mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK,
> -CONFIG_BAUDRATE, false);
> +CONFIG_BAUDRATE, MXC_DTE_MODE);
>  }
>  
>  static inline void _debug_uart_putc(int ch)

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


[U-Boot] [PATCH v2 2/3] imx: introduce CONFIG_GPT_TIMER

2018-01-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Introduce a new config symbol to select the i.MX
General Purpose Timer (GPT).

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v2:
- Fix Kconfig for MX5

 arch/arm/mach-imx/Kconfig | 3 +++
 arch/arm/mach-imx/Makefile| 3 ++-
 arch/arm/mach-imx/mx5/Kconfig | 1 +
 arch/arm/mach-imx/mx6/Kconfig | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 653819123c..3aec89d440 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -10,6 +10,9 @@ config ROM_UNIFIED_SECTIONS
 config SYSCOUNTER_TIMER
bool
 
+config GPT_TIMER
+   bool
+
 config IMX_RDC
bool "i.MX Resource domain controller driver"
depends on ARCH_MX6 || ARCH_MX7
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index d77c10e176..9322c1ce83 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -11,7 +11,8 @@ ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 vf610))
 obj-y  = iomux-v3.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
-obj-y  += timer.o cpu.o speed.o
+obj-y  += cpu.o speed.o
+obj-$(CONFIG_GPT_TIMER) += timer.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs))
diff --git a/arch/arm/mach-imx/mx5/Kconfig b/arch/arm/mach-imx/mx5/Kconfig
index 250194b623..3ce6bcfc88 100644
--- a/arch/arm/mach-imx/mx5/Kconfig
+++ b/arch/arm/mach-imx/mx5/Kconfig
@@ -1,6 +1,7 @@
 if ARCH_MX5
 
 config MX5
+   select GPT_TIMER
bool
default y
 
diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 752471fb72..1af60df8d8 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -9,6 +9,7 @@ config MX6_SMP
 
 config MX6
select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
+   select GPT_TIMER
bool
default y
imply CMD_FUSE
-- 
2.15.1

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


[U-Boot] [PATCH v2 3/3] imx: initialize and use generic timer on i.MX 6UL/ULL

2018-01-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The i.MX 6UL/ULL feature a Cortex-A7 CPU which suppor the ARM
generic timer. This change makes use of the ARM generic timer in
U-Boot.

This is crucial to make the ARM generic timers usable in Linux since
timer_init() initalizes the system counter module, which is necessary
to use the generic timers CP15 registers.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v2: None

 arch/arm/include/asm/arch-mx6/imx-regs.h | 1 +
 arch/arm/mach-imx/Makefile   | 2 +-
 arch/arm/mach-imx/mx6/Kconfig| 4 +++-
 include/configs/mx6_common.h | 5 -
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 4be7aab18a..48ce0edd06 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -291,6 +291,7 @@
 #endif
 #define IP2APB_TZASC1_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x5)
 #if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#define SCTR_BASE_ADDR  (AIPS2_OFF_BASE_ADDR + 0x5C000)
 #define QSPI0_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x6)
 #define UART6_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x7C000)
 #elif defined(CONFIG_MX6SX)
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 9322c1ce83..d7966cfd4a 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -22,7 +22,6 @@ endif
 ifeq ($(SOC),$(filter $(SOC),mx7))
 obj-y  += cpu.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
-obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx6 mx7))
 obj-y  += cache.o init.o
@@ -31,6 +30,7 @@ obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
 obj-$(CONFIG_IMX_RDC) += rdc-sema.o
 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 obj-$(CONFIG_SECURE_BOOT)+= hab.o
+obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
 obj-y  += cache.o
diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 1af60df8d8..86b80ca576 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -9,7 +9,7 @@ config MX6_SMP
 
 config MX6
select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
-   select GPT_TIMER
+   select GPT_TIMER if !MX6UL && !MX6ULL
bool
default y
imply CMD_FUSE
@@ -54,6 +54,7 @@ config MX6UL
select HAS_CAAM
select SYS_L2CACHE_OFF
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
bool
 
 config MX6UL_LITESOM
@@ -76,6 +77,7 @@ config MX6UL_OPOS6UL
 config MX6ULL
select SYS_L2CACHE_OFF
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
bool
 
 config MX6_DDRCAL
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 59e6daea62..ddc645c136 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -7,7 +7,10 @@
 #ifndef __MX6_COMMON_H
 #define __MX6_COMMON_H
 
-#if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#define CONFIG_SC_TIMER_CLK 800 /* 8Mhz */
+#define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
+#else
 #ifndef CONFIG_SYS_L2CACHE_OFF
 #define CONFIG_SYS_L2_PL310
 #define CONFIG_SYS_PL310_BASE  L2_PL310_BASE
-- 
2.15.1

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


[U-Boot] [PATCH v2 1/3] imx: move CONFIG_SYSCOUNTER_TIMER to Kconfig

2018-01-05 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v2: None

 arch/arm/mach-imx/Kconfig | 3 +++
 arch/arm/mach-imx/mx7/Kconfig | 1 +
 include/configs/mx7_common.h  | 1 -
 scripts/config_whitelist.txt  | 1 -
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index e687048b31..653819123c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -7,6 +7,9 @@ config IMX_CONFIG
 config ROM_UNIFIED_SECTIONS
bool
 
+config SYSCOUNTER_TIMER
+   bool
+
 config IMX_RDC
bool "i.MX Resource domain controller driver"
depends on ARCH_MX6 || ARCH_MX7
diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
index 4f8b4e138e..2a3db860bb 100644
--- a/arch/arm/mach-imx/mx7/Kconfig
+++ b/arch/arm/mach-imx/mx7/Kconfig
@@ -3,6 +3,7 @@ if ARCH_MX7
 config MX7
bool
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
select CPU_V7_HAS_VIRT
select CPU_V7_HAS_NONSEC
select ARCH_SUPPORT_PSCI
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 16e4d95ff4..17850400c1 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -19,7 +19,6 @@
 
 /* Timer settings */
 #define CONFIG_MXC_GPT_HCLK
-#define CONFIG_SYSCOUNTER_TIMER
 #define CONFIG_SC_TIMER_CLK 800 /* 8Mhz */
 #define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
 #define CONFIG_SYS_FSL_CLK
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 43a4ff0892..5d8d907cc4 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -2219,7 +2219,6 @@ CONFIG_SUPPORT_RAW_INITRD
 CONFIG_SUPPORT_VFAT
 CONFIG_SUVD3
 CONFIG_SXNI855T
-CONFIG_SYSCOUNTER_TIMER
 CONFIG_SYSFLAGS_ADDR
 CONFIG_SYSFS
 CONFIG_SYSMGR_ISWGRP_HANDOFF
-- 
2.15.1

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


Re: [U-Boot] [PATCH 3/3] imx: initialize and use generic timer on i.MX 6UL/ULL

2018-01-05 Thread Stefan Agner
On 2018-01-05 13:40, Fabio Estevam wrote:
> On Mon, Jan 1, 2018 at 10:43 PM, Stefan Agner <ste...@agner.ch> wrote:
> 
>> --- a/arch/arm/mach-imx/mx6/Kconfig
>> +++ b/arch/arm/mach-imx/mx6/Kconfig
>> @@ -9,7 +9,7 @@ config MX6_SMP
>>
>>  config MX6
>> select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
>> -   select GPT_TIMER
>> +   select GPT_TIMER if !MX6UL && !MX6ULL
>> bool
>> default y
>> imply CMD_FUSE
>> @@ -54,6 +54,7 @@ config MX6UL
>> select HAS_CAAM
>> select SYS_L2CACHE_OFF
>> select ROM_UNIFIED_SECTIONS
>> +   select SYSCOUNTER_TIMER
>> bool
>>
>>  config MX6UL_LITESOM
>> @@ -76,6 +77,7 @@ config MX6UL_OPOS6UL
>>  config MX6ULL
>> select SYS_L2CACHE_OFF
>> select ROM_UNIFIED_SECTIONS
>> +   select SYSCOUNTER_TIMER
> 
> This is not needed as MX6UL_LITESOM already selects MX6UL.

This does not add it to MX6UL_LITESOM, it adds it to "config MX6ULL".
diff is somewhat confusing here.

--
Stefan

> 
> Other than that:
> 
> Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] imx: introduce CONFIG_GPT_TIMER

2018-01-05 Thread Stefan Agner
On 2018-01-02 01:43, Stefan Agner wrote:
> Introduce a new config symbol to select the i.MX
> General Purpose Timer (GPT).
> 
> Signed-off-by: Stefan Agner <ste...@agner.ch>
> ---
> 
>  arch/arm/mach-imx/Kconfig | 3 +++
>  arch/arm/mach-imx/Makefile| 3 ++-
>  arch/arm/mach-imx/mx5/Kconfig | 1 +
>  arch/arm/mach-imx/mx6/Kconfig | 1 +
>  4 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index 653819123c..3aec89d440 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -10,6 +10,9 @@ config ROM_UNIFIED_SECTIONS
>  config SYSCOUNTER_TIMER
>   bool
>  
> +config GPT_TIMER
> + bool
> +
>  config IMX_RDC
>   bool "i.MX Resource domain controller driver"
>   depends on ARCH_MX6 || ARCH_MX7
> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index d77c10e176..9322c1ce83 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -11,7 +11,8 @@ ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 vf610))
>  obj-y= iomux-v3.o
>  endif
>  ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
> -obj-y+= timer.o cpu.o speed.o
> +obj-y+= cpu.o speed.o
> +obj-$(CONFIG_GPT_TIMER) += timer.o
>  obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
>  endif
>  ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs))
> diff --git a/arch/arm/mach-imx/mx5/Kconfig b/arch/arm/mach-imx/mx5/Kconfig
> index 250194b623..735cd240f1 100644
> --- a/arch/arm/mach-imx/mx5/Kconfig
> +++ b/arch/arm/mach-imx/mx5/Kconfig
> @@ -1,6 +1,7 @@
>  if ARCH_MX5
>  
>  config MX5
> + GPT_TIMER

Just realized, this does not work, select missing. Will send v2.

--
Stefan

>   bool
>   default y
>  
> diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
> index 752471fb72..1af60df8d8 100644
> --- a/arch/arm/mach-imx/mx6/Kconfig
> +++ b/arch/arm/mach-imx/mx6/Kconfig
> @@ -9,6 +9,7 @@ config MX6_SMP
>  
>  config MX6
>   select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
> + select GPT_TIMER
>   bool
>   default y
>   imply CMD_FUSE
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] imx: move CONFIG_SYSCOUNTER_TIMER to Kconfig

2018-01-05 Thread Stefan Agner
Hi Stefano,

Any chance to get this patchset still into v2018.01? IMHO it is almost a
bug that U-Boot does not initialize the ARM architected timer
properly...

--
Stefan


On 2018-01-02 01:43, Stefan Agner wrote:
> Signed-off-by: Stefan Agner <ste...@agner.ch>
> ---
> 
>  arch/arm/mach-imx/Kconfig | 3 +++
>  arch/arm/mach-imx/mx7/Kconfig | 1 +
>  include/configs/mx7_common.h  | 1 -
>  scripts/config_whitelist.txt  | 1 -
>  4 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index e687048b31..653819123c 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -7,6 +7,9 @@ config IMX_CONFIG
>  config ROM_UNIFIED_SECTIONS
>   bool
>  
> +config SYSCOUNTER_TIMER
> + bool
> +
>  config IMX_RDC
>   bool "i.MX Resource domain controller driver"
>   depends on ARCH_MX6 || ARCH_MX7
> diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
> index 4f8b4e138e..2a3db860bb 100644
> --- a/arch/arm/mach-imx/mx7/Kconfig
> +++ b/arch/arm/mach-imx/mx7/Kconfig
> @@ -3,6 +3,7 @@ if ARCH_MX7
>  config MX7
>   bool
>   select ROM_UNIFIED_SECTIONS
> + select SYSCOUNTER_TIMER
>   select CPU_V7_HAS_VIRT
>   select CPU_V7_HAS_NONSEC
>   select ARCH_SUPPORT_PSCI
> diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
> index 16e4d95ff4..17850400c1 100644
> --- a/include/configs/mx7_common.h
> +++ b/include/configs/mx7_common.h
> @@ -19,7 +19,6 @@
>  
>  /* Timer settings */
>  #define CONFIG_MXC_GPT_HCLK
> -#define CONFIG_SYSCOUNTER_TIMER
>  #define CONFIG_SC_TIMER_CLK 800 /* 8Mhz */
>  #define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
>  #define CONFIG_SYS_FSL_CLK
> diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
> index 43a4ff0892..5d8d907cc4 100644
> --- a/scripts/config_whitelist.txt
> +++ b/scripts/config_whitelist.txt
> @@ -2219,7 +2219,6 @@ CONFIG_SUPPORT_RAW_INITRD
>  CONFIG_SUPPORT_VFAT
>  CONFIG_SUVD3
>  CONFIG_SXNI855T
> -CONFIG_SYSCOUNTER_TIMER
>  CONFIG_SYSFLAGS_ADDR
>  CONFIG_SYSFS
>  CONFIG_SYSMGR_ISWGRP_HANDOFF
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/3] imx: initialize and use generic timer on i.MX 6UL/ULL

2018-01-01 Thread Stefan Agner
The i.MX 6UL/ULL feature a Cortex-A7 CPU which suppor the ARM
generic timer. This change makes use of the ARM generic timer in
U-Boot.

This is crucial to make the ARM generic timers usable in Linux since
timer_init() initalizes the system counter module, which is necessary
to use the generic timers CP15 registers.

Signed-off-by: Stefan Agner <ste...@agner.ch>
---

 arch/arm/include/asm/arch-mx6/imx-regs.h | 1 +
 arch/arm/mach-imx/Makefile   | 2 +-
 arch/arm/mach-imx/mx6/Kconfig| 4 +++-
 include/configs/mx6_common.h | 5 -
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 4be7aab18a..48ce0edd06 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -291,6 +291,7 @@
 #endif
 #define IP2APB_TZASC1_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x5)
 #if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#define SCTR_BASE_ADDR  (AIPS2_OFF_BASE_ADDR + 0x5C000)
 #define QSPI0_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x6)
 #define UART6_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x7C000)
 #elif defined(CONFIG_MX6SX)
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 9322c1ce83..d7966cfd4a 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -22,7 +22,6 @@ endif
 ifeq ($(SOC),$(filter $(SOC),mx7))
 obj-y  += cpu.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
-obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx6 mx7))
 obj-y  += cache.o init.o
@@ -31,6 +30,7 @@ obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
 obj-$(CONFIG_IMX_RDC) += rdc-sema.o
 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 obj-$(CONFIG_SECURE_BOOT)+= hab.o
+obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
 obj-y  += cache.o
diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 1af60df8d8..86b80ca576 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -9,7 +9,7 @@ config MX6_SMP
 
 config MX6
select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
-   select GPT_TIMER
+   select GPT_TIMER if !MX6UL && !MX6ULL
bool
default y
imply CMD_FUSE
@@ -54,6 +54,7 @@ config MX6UL
select HAS_CAAM
select SYS_L2CACHE_OFF
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
bool
 
 config MX6UL_LITESOM
@@ -76,6 +77,7 @@ config MX6UL_OPOS6UL
 config MX6ULL
select SYS_L2CACHE_OFF
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
bool
 
 config MX6_DDRCAL
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 59e6daea62..ddc645c136 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -7,7 +7,10 @@
 #ifndef __MX6_COMMON_H
 #define __MX6_COMMON_H
 
-#if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
+#define CONFIG_SC_TIMER_CLK 800 /* 8Mhz */
+#define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
+#else
 #ifndef CONFIG_SYS_L2CACHE_OFF
 #define CONFIG_SYS_L2_PL310
 #define CONFIG_SYS_PL310_BASE  L2_PL310_BASE
-- 
2.15.1

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


[U-Boot] [PATCH 1/3] imx: move CONFIG_SYSCOUNTER_TIMER to Kconfig

2018-01-01 Thread Stefan Agner
Signed-off-by: Stefan Agner <ste...@agner.ch>
---

 arch/arm/mach-imx/Kconfig | 3 +++
 arch/arm/mach-imx/mx7/Kconfig | 1 +
 include/configs/mx7_common.h  | 1 -
 scripts/config_whitelist.txt  | 1 -
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index e687048b31..653819123c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -7,6 +7,9 @@ config IMX_CONFIG
 config ROM_UNIFIED_SECTIONS
bool
 
+config SYSCOUNTER_TIMER
+   bool
+
 config IMX_RDC
bool "i.MX Resource domain controller driver"
depends on ARCH_MX6 || ARCH_MX7
diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
index 4f8b4e138e..2a3db860bb 100644
--- a/arch/arm/mach-imx/mx7/Kconfig
+++ b/arch/arm/mach-imx/mx7/Kconfig
@@ -3,6 +3,7 @@ if ARCH_MX7
 config MX7
bool
select ROM_UNIFIED_SECTIONS
+   select SYSCOUNTER_TIMER
select CPU_V7_HAS_VIRT
select CPU_V7_HAS_NONSEC
select ARCH_SUPPORT_PSCI
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 16e4d95ff4..17850400c1 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -19,7 +19,6 @@
 
 /* Timer settings */
 #define CONFIG_MXC_GPT_HCLK
-#define CONFIG_SYSCOUNTER_TIMER
 #define CONFIG_SC_TIMER_CLK 800 /* 8Mhz */
 #define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
 #define CONFIG_SYS_FSL_CLK
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 43a4ff0892..5d8d907cc4 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -2219,7 +2219,6 @@ CONFIG_SUPPORT_RAW_INITRD
 CONFIG_SUPPORT_VFAT
 CONFIG_SUVD3
 CONFIG_SXNI855T
-CONFIG_SYSCOUNTER_TIMER
 CONFIG_SYSFLAGS_ADDR
 CONFIG_SYSFS
 CONFIG_SYSMGR_ISWGRP_HANDOFF
-- 
2.15.1

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


[U-Boot] [PATCH 2/3] imx: introduce CONFIG_GPT_TIMER

2018-01-01 Thread Stefan Agner
Introduce a new config symbol to select the i.MX
General Purpose Timer (GPT).

Signed-off-by: Stefan Agner <ste...@agner.ch>
---

 arch/arm/mach-imx/Kconfig | 3 +++
 arch/arm/mach-imx/Makefile| 3 ++-
 arch/arm/mach-imx/mx5/Kconfig | 1 +
 arch/arm/mach-imx/mx6/Kconfig | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 653819123c..3aec89d440 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -10,6 +10,9 @@ config ROM_UNIFIED_SECTIONS
 config SYSCOUNTER_TIMER
bool
 
+config GPT_TIMER
+   bool
+
 config IMX_RDC
bool "i.MX Resource domain controller driver"
depends on ARCH_MX6 || ARCH_MX7
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index d77c10e176..9322c1ce83 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -11,7 +11,8 @@ ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 vf610))
 obj-y  = iomux-v3.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
-obj-y  += timer.o cpu.o speed.o
+obj-y  += cpu.o speed.o
+obj-$(CONFIG_GPT_TIMER) += timer.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs))
diff --git a/arch/arm/mach-imx/mx5/Kconfig b/arch/arm/mach-imx/mx5/Kconfig
index 250194b623..735cd240f1 100644
--- a/arch/arm/mach-imx/mx5/Kconfig
+++ b/arch/arm/mach-imx/mx5/Kconfig
@@ -1,6 +1,7 @@
 if ARCH_MX5
 
 config MX5
+   GPT_TIMER
bool
default y
 
diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 752471fb72..1af60df8d8 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -9,6 +9,7 @@ config MX6_SMP
 
 config MX6
select ARM_ERRATA_743622 if !MX6UL && !MX6ULL
+   select GPT_TIMER
bool
default y
imply CMD_FUSE
-- 
2.15.1

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


Re: [U-Boot] [PATCH] mx6ull: Handle the CONFIG_MX6ULL cases correctly

2018-01-01 Thread Stefan Agner
On 2018-01-01 23:29, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.este...@nxp.com>
> 
> Since commit 051ba9e082f7 ("Kconfig: mx6ull: Deselect MX6UL from
> CONFIG_MX6ULL") CONFIG_MX6ULL does not select CONFIG_MX6UL anymore, so
> take this into consideration in all the checks for CONFIG_MX6UL.

Found one more:

--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -8,7 +8,7 @@ config MX6_SMP
bool
 
 config MX6
-   select ARM_ERRATA_743622 if !MX6UL
+   select ARM_ERRATA_743622 if !MX6UL && ! MX6ULL
bool
default y
imply CMD_FUSE


--
Stefan

> 
> Reported-by: Stefan Agner <ste...@agner.ch>
> Signed-off-by: Fabio Estevam <fabio.este...@nxp.com>
> ---
>  arch/arm/include/asm/arch-mx6/imx-regs.h   | 20 ++--
>  arch/arm/include/asm/arch-mx6/mx6-ddr.h|  2 +-
>  arch/arm/include/asm/arch-mx6/mx6ul-ddr.h  |  2 +-
>  arch/arm/include/asm/mach-imx/iomux-v3.h   |  4 ++--
>  arch/arm/include/asm/mach-imx/regs-lcdif.h |  9 ++---
>  arch/arm/mach-imx/mx6/ddr.c|  2 +-
>  drivers/gpio/mxc_gpio.c|  4 ++--
>  include/configs/mx6_common.h   |  4 ++--
>  8 files changed, 25 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h
> b/arch/arm/include/asm/arch-mx6/imx-regs.h
> index 7736b6a..8c7ff6a 100644
> --- a/arch/arm/include/asm/arch-mx6/imx-regs.h
> +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
> @@ -17,7 +17,7 @@
>  #define GPU_2D_ARB_END_ADDR 0x02203FFF
>  #define OPENVG_ARB_BASE_ADDR0x02204000
>  #define OPENVG_ARB_END_ADDR 0x02207FFF
> -#elif (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
> +#elif (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) ||
> defined(CONFIG_MX6ULL))
>  #define CAAM_ARB_BASE_ADDR  0x0010
>  #define CAAM_ARB_END_ADDR   0x00107FFF
>  #define GPU_ARB_BASE_ADDR   0x0180
> @@ -46,7 +46,7 @@
>  #define MXS_BCH_BASE (APBH_DMA_ARB_BASE_ADDR + 0x04000)
>  
>  /* GPV - PL301 configuration ports */
> -#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || \
> +#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) ||
> defined(CONFIG_MX6ULL) || \
>   defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL))
>  #define GPV2_BASE_ADDR  0x00D0
>  #define GPV3_BASE_ADDR   0x00E0
> @@ -88,7 +88,7 @@
>  #define QSPI0_AMBA_END 0x6FFF
>  #define QSPI1_AMBA_BASE0x7000
>  #define QSPI1_AMBA_END 0x7FFF
> -#elif defined(CONFIG_MX6UL)
> +#elif (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define WEIM_ARB_BASE_ADDR  0x5000
>  #define WEIM_ARB_END_ADDR   0x57FF
>  #define QSPI0_AMBA_BASE 0x6000
> @@ -109,7 +109,7 @@
>  #endif
>  
>  #if (defined(CONFIG_MX6SLL) || defined(CONFIG_MX6SL) || \
> - defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
> + defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || 
> defined(CONFIG_MX6ULL))
>  #define MMDC0_ARB_BASE_ADDR 0x8000
>  #define MMDC0_ARB_END_ADDR  0x
>  #define MMDC1_ARB_BASE_ADDR 0xC000
> @@ -262,7 +262,7 @@
>  #define MMDC_P0_BASE_ADDR   (AIPS2_OFF_BASE_ADDR + 0x3)
>  /* i.MX6SL/SLL */
>  #define RNGB_IPS_BASE_ADDR  (AIPS2_OFF_BASE_ADDR + 0x34000)
> -#ifdef CONFIG_MX6UL
> +#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define ENET2_BASE_ADDR (AIPS1_OFF_BASE_ADDR + 0x34000)
>  #else
>  /* i.MX6SX */
> @@ -288,7 +288,7 @@
>  #define IP2APB_PERFMON3_BASE_ADDR   (AIPS2_OFF_BASE_ADDR + 0x4C000)
>  #endif
>  #define IP2APB_TZASC1_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x5)
> -#ifdef CONFIG_MX6UL
> +#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define QSPI0_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x6)
>  #define UART6_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x7C000)
>  #elif defined(CONFIG_MX6SX)
> @@ -337,7 +337,7 @@
>  #define PWM6_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xA8000)
>  #define PWM7_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xAC000)
>  #define PWM8_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xB)
> -#elif defined(CONFIG_MX6ULL)
> +#elif (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define AIPS3_CONFIG_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0x7C000)
>  #define DCP_BASE_ADDR   (AIPS3_ARB_BASE_ADDR + 0x8)
>  #define RNGB_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0x84000)
> @@ -354,7 +354,7 @@
>  #define MX6SX_LCDIF1_BASE_ADDR  (AIPS3_ARB_BASE_ADDR +

Re: [U-Boot] [PATCH] mx6ull: Handle the CONFIG_MX6ULL cases correctly

2018-01-01 Thread Stefan Agner
Hi Fabio,

On 2018-01-01 23:29, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.este...@nxp.com>
> 
> Since commit 051ba9e082f7 ("Kconfig: mx6ull: Deselect MX6UL from
> CONFIG_MX6ULL") CONFIG_MX6ULL does not select CONFIG_MX6UL anymore, so
> take this into consideration in all the checks for CONFIG_MX6UL.

Those changes seem to cover it.

Reviewed-by: Stefan Agner <ste...@agner.ch>

One minor nit below.


> 
> Reported-by: Stefan Agner <ste...@agner.ch>
> Signed-off-by: Fabio Estevam <fabio.este...@nxp.com>
> ---
>  arch/arm/include/asm/arch-mx6/imx-regs.h   | 20 ++--
>  arch/arm/include/asm/arch-mx6/mx6-ddr.h|  2 +-
>  arch/arm/include/asm/arch-mx6/mx6ul-ddr.h  |  2 +-
>  arch/arm/include/asm/mach-imx/iomux-v3.h   |  4 ++--
>  arch/arm/include/asm/mach-imx/regs-lcdif.h |  9 ++---
>  arch/arm/mach-imx/mx6/ddr.c|  2 +-
>  drivers/gpio/mxc_gpio.c|  4 ++--
>  include/configs/mx6_common.h   |  4 ++--
>  8 files changed, 25 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h
> b/arch/arm/include/asm/arch-mx6/imx-regs.h
> index 7736b6a..8c7ff6a 100644
> --- a/arch/arm/include/asm/arch-mx6/imx-regs.h
> +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
> @@ -17,7 +17,7 @@
>  #define GPU_2D_ARB_END_ADDR 0x02203FFF
>  #define OPENVG_ARB_BASE_ADDR0x02204000
>  #define OPENVG_ARB_END_ADDR 0x02207FFF
> -#elif (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
> +#elif (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) ||
> defined(CONFIG_MX6ULL))
>  #define CAAM_ARB_BASE_ADDR  0x0010
>  #define CAAM_ARB_END_ADDR   0x00107FFF
>  #define GPU_ARB_BASE_ADDR   0x0180
> @@ -46,7 +46,7 @@
>  #define MXS_BCH_BASE (APBH_DMA_ARB_BASE_ADDR + 0x04000)
>  
>  /* GPV - PL301 configuration ports */
> -#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || \
> +#if (defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) ||
> defined(CONFIG_MX6ULL) || \
>   defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL))
>  #define GPV2_BASE_ADDR  0x00D0
>  #define GPV3_BASE_ADDR   0x00E0
> @@ -88,7 +88,7 @@
>  #define QSPI0_AMBA_END 0x6FFF
>  #define QSPI1_AMBA_BASE0x7000
>  #define QSPI1_AMBA_END 0x7FFF
> -#elif defined(CONFIG_MX6UL)
> +#elif (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define WEIM_ARB_BASE_ADDR  0x5000
>  #define WEIM_ARB_END_ADDR   0x57FF
>  #define QSPI0_AMBA_BASE 0x6000
> @@ -109,7 +109,7 @@
>  #endif
>  
>  #if (defined(CONFIG_MX6SLL) || defined(CONFIG_MX6SL) || \
> - defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL))
> + defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || 
> defined(CONFIG_MX6ULL))
>  #define MMDC0_ARB_BASE_ADDR 0x8000
>  #define MMDC0_ARB_END_ADDR  0x
>  #define MMDC1_ARB_BASE_ADDR 0xC000
> @@ -262,7 +262,7 @@
>  #define MMDC_P0_BASE_ADDR   (AIPS2_OFF_BASE_ADDR + 0x3)
>  /* i.MX6SL/SLL */
>  #define RNGB_IPS_BASE_ADDR  (AIPS2_OFF_BASE_ADDR + 0x34000)
> -#ifdef CONFIG_MX6UL
> +#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define ENET2_BASE_ADDR (AIPS1_OFF_BASE_ADDR + 0x34000)
>  #else
>  /* i.MX6SX */
> @@ -288,7 +288,7 @@
>  #define IP2APB_PERFMON3_BASE_ADDR   (AIPS2_OFF_BASE_ADDR + 0x4C000)
>  #endif
>  #define IP2APB_TZASC1_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x5)
> -#ifdef CONFIG_MX6UL
> +#if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define QSPI0_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x6)
>  #define UART6_BASE_ADDR (AIPS2_OFF_BASE_ADDR + 0x7C000)
>  #elif defined(CONFIG_MX6SX)
> @@ -337,7 +337,7 @@
>  #define PWM6_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xA8000)
>  #define PWM7_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xAC000)
>  #define PWM8_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0xB)
> -#elif defined(CONFIG_MX6ULL)
> +#elif (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
>  #define AIPS3_CONFIG_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0x7C000)
>  #define DCP_BASE_ADDR   (AIPS3_ARB_BASE_ADDR + 0x8)
>  #define RNGB_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0x84000)
> @@ -354,7 +354,7 @@
>  #define MX6SX_LCDIF1_BASE_ADDR  (AIPS3_ARB_BASE_ADDR + 0x2)
>  #define MX6SX_WDOG3_BASE_ADDR   (AIPS3_ARB_BASE_ADDR + 0x88000)
>  
> -#if !(defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || \
> +#if !(defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) ||
>

Re: [U-Boot] [PATCH 4/5] Kconfig: mx6ull: Deselect MX6UL from CONFIG_MX6ULL

2018-01-01 Thread Stefan Agner
On 2017-11-28 00:07, Breno Lima wrote:
> From: Breno Lima 
> 
> MX6UL contains features that MX6ULL doesn't support.
> Deselect CONFIG_MX6UL and select SYS_L2CACHE_OFF and ROM_UNIFIED_SECTIONS.
> 
> The motivation for doing this change is that MX6UL supports CAAM and
> MX6ULL does not.

While I agree with the idea of the change in general, it must be done
more carefully! There are several places where we rely that
CONFIG_MX6ULL selects CONFIG_MX6ULL, e.g.
include/configs/mx6_common.h
arch/arm/include/asm/arch-mx6/imx-regs.h
arch/arm/include/asm/mach-imx/regs-lcdif.h

I see that this patch already got merged... So I guess we either fix all
those places before the release, or we revert this patch...

--
Stefan


> 
> Signed-off-by: Breno Lima 
> ---
>  arch/arm/mach-imx/mx6/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
> index 4f8bb8f..279f088 100644
> --- a/arch/arm/mach-imx/mx6/Kconfig
> +++ b/arch/arm/mach-imx/mx6/Kconfig
> @@ -66,8 +66,9 @@ config MX6UL_OPOS6UL
>   select SUPPORT_SPL
>  
>  config MX6ULL
> + select SYS_L2CACHE_OFF
> + select ROM_UNIFIED_SECTIONS
>   bool
> - select MX6UL
>  
>  config MX6_DDRCAL
>   bool "Include dynamic DDR calibration routines"
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [OE-core] [PATCH] u-boot: Upgrade to 2017.11 release

2017-11-15 Thread Stefan Agner
On 2017-11-14 19:32, Otavio Salvador wrote:
> This upgrades the U-Boot from 2017.09 to 2017.11 release.

You might encounter this when building fw_printenv/setenv tools alone:

https://lists.denx.de/pipermail/u-boot/2017-November/311505.html

--
Stefan

> 
> Signed-off-by: Otavio Salvador 
> ---
> 
>  .../u-boot/{u-boot-common_2017.09.inc => u-boot-common_2017.11.inc} | 2 
> +-
>  .../u-boot/{u-boot-fw-utils_2017.09.bb => u-boot-fw-utils_2017.11.bb}   | 0
>  .../u-boot/{u-boot-mkimage_2017.09.bb => u-boot-mkimage_2017.11.bb} | 0
>  meta/recipes-bsp/u-boot/{u-boot_2017.09.bb => u-boot_2017.11.bb}| 0
>  4 files changed, 1 insertion(+), 1 deletion(-)
>  rename meta/recipes-bsp/u-boot/{u-boot-common_2017.09.inc =>
> u-boot-common_2017.11.inc} (89%)
>  rename meta/recipes-bsp/u-boot/{u-boot-fw-utils_2017.09.bb =>
> u-boot-fw-utils_2017.11.bb} (100%)
>  rename meta/recipes-bsp/u-boot/{u-boot-mkimage_2017.09.bb =>
> u-boot-mkimage_2017.11.bb} (100%)
>  rename meta/recipes-bsp/u-boot/{u-boot_2017.09.bb => u-boot_2017.11.bb} 
> (100%)
> 
> diff --git a/meta/recipes-bsp/u-boot/u-boot-common_2017.09.inc
> b/meta/recipes-bsp/u-boot/u-boot-common_2017.11.inc
> similarity index 89%
> rename from meta/recipes-bsp/u-boot/u-boot-common_2017.09.inc
> rename to meta/recipes-bsp/u-boot/u-boot-common_2017.11.inc
> index 02e51242cb..bfdf1a0d8f 100644
> --- a/meta/recipes-bsp/u-boot/u-boot-common_2017.09.inc
> +++ b/meta/recipes-bsp/u-boot/u-boot-common_2017.11.inc
> @@ -7,7 +7,7 @@ PE = "1"
>  
>  # We use the revision in order to avoid having to fetch it from the
>  # repo during parse
> -SRCREV = "c98ac3487e413c71e5d36322ef3324b21c6f60f9"
> +SRCREV = "c253573f3e269fd9a24ee6684d87dd91106018a5"
>  
>  SRC_URI = "git://git.denx.de/u-boot.git \
>  file://MPC8315ERDB-enable-DHCP.patch \
> diff --git a/meta/recipes-bsp/u-boot/u-boot-fw-utils_2017.09.bb
> b/meta/recipes-bsp/u-boot/u-boot-fw-utils_2017.11.bb
> similarity index 100%
> rename from meta/recipes-bsp/u-boot/u-boot-fw-utils_2017.09.bb
> rename to meta/recipes-bsp/u-boot/u-boot-fw-utils_2017.11.bb
> diff --git a/meta/recipes-bsp/u-boot/u-boot-mkimage_2017.09.bb
> b/meta/recipes-bsp/u-boot/u-boot-mkimage_2017.11.bb
> similarity index 100%
> rename from meta/recipes-bsp/u-boot/u-boot-mkimage_2017.09.bb
> rename to meta/recipes-bsp/u-boot/u-boot-mkimage_2017.11.bb
> diff --git a/meta/recipes-bsp/u-boot/u-boot_2017.09.bb
> b/meta/recipes-bsp/u-boot/u-boot_2017.11.bb
> similarity index 100%
> rename from meta/recipes-bsp/u-boot/u-boot_2017.09.bb
> rename to meta/recipes-bsp/u-boot/u-boot_2017.11.bb
> -- 
> 2.15.0
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] envtools: make sure version/timestamp header file are available

2017-11-14 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

With commit 84d46e7e8948 ("tools: env: allow to print U-Boot version")
the fw_env utilities need the version.h header file. Building only
the envtools in a pristine build directory will fail due to missing
header files.

Make sure the header files are a dependency of the envtools target.

Fixes: 84d46e7e8948 ("tools: env: allow to print U-Boot version")
Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 67f01ad7e4..b93c2fb05b 100644
--- a/Makefile
+++ b/Makefile
@@ -1460,7 +1460,7 @@ checkarmreloc: u-boot
false; \
fi
 
-envtools: scripts_basic
+envtools: scripts_basic $(version_h) $(timestamp_h)
$(Q)$(MAKE) $(build)=tools/env
 
 tools-only: scripts_basic $(version_h) $(timestamp_h)
-- 
2.15.0

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


Re: [U-Boot] [PATCH] configs: vf610: increase maximum size and enforce correct limit

2017-10-30 Thread Stefan Agner
Hi Tom, Stefano,

Any chance to get this still into 2017.11? It allows to use 2017.11 on
my board...

--
Stefan

On 2017-10-17 13:59, Stefan Agner wrote:
> From: Stefan Agner <stefan.ag...@toradex.com>
> 
> On Vybrid SoCs U-Boot gets loaded into GFX SRAM which is 512KiB.
> Currently 32KiB is reserved for the IMX header. However, this is
> not reflected in the size limit. In v2017.11-rc2 the actual size
> limit (512KiB-32KiB) has been reached for Colibri VF61, which
> lead to a successful build of U-Boot but not a working binary.
> 
> The IMX header is much smaller than 32KiB, typically around 1KiB.
> Decrease the reserved size to 4KiB and specify the correct U-Boot
> size limit. Apply this new base address and limit for all Vybrid
> based boards.
> 
> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
> ---
> 
>  include/configs/colibri_vf.h | 4 ++--
>  include/configs/pcm052.h | 4 ++--
>  include/configs/vf610twr.h   | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h
> index 8166aa4afb..bf3bbffe24 100644
> --- a/include/configs/colibri_vf.h
> +++ b/include/configs/colibri_vf.h
> @@ -75,8 +75,8 @@
>  #define CONFIG_FDTADDR   0x8400
>  
>  /* We boot from the gfxRAM area of the OCRAM. */
> -#define CONFIG_SYS_TEXT_BASE 0x3f408000
> -#define CONFIG_BOARD_SIZE_LIMIT  524288
> +#define CONFIG_SYS_TEXT_BASE 0x3f401000
> +#define CONFIG_BOARD_SIZE_LIMIT  520192
>  
>  #define SD_BOOTCMD \
>   "sdargs=root=/dev/mmcblk0p2 rw rootwait\0"  \
> diff --git a/include/configs/pcm052.h b/include/configs/pcm052.h
> index 8144a83db2..060928bd30 100644
> --- a/include/configs/pcm052.h
> +++ b/include/configs/pcm052.h
> @@ -89,8 +89,8 @@
>  #define CONFIG_LOADADDR  0x8200
>  
>  /* We boot from the gfxRAM area of the OCRAM. */
> -#define CONFIG_SYS_TEXT_BASE 0x3f408000
> -#define CONFIG_BOARD_SIZE_LIMIT  524288
> +#define CONFIG_SYS_TEXT_BASE 0x3f401000
> +#define CONFIG_BOARD_SIZE_LIMIT  520192
>  
>  /* if no target-specific extra environment settings were defined by the
> target, define an empty one */
> diff --git a/include/configs/vf610twr.h b/include/configs/vf610twr.h
> index 3430f27c40..ddfcd6f618 100644
> --- a/include/configs/vf610twr.h
> +++ b/include/configs/vf610twr.h
> @@ -79,8 +79,8 @@
>  #define CONFIG_SYS_LOAD_ADDR 0x8200
>  
>  /* We boot from the gfxRAM area of the OCRAM. */
> -#define CONFIG_SYS_TEXT_BASE 0x3f408000
> -#define CONFIG_BOARD_SIZE_LIMIT  524288
> +#define CONFIG_SYS_TEXT_BASE 0x3f401000
> +#define CONFIG_BOARD_SIZE_LIMIT  520192
>  
>  /*
>   * We do have 128MB of memory on the Vybrid Tower board. Leave the last
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] tools: env: allow to print U-Boot version

2017-10-26 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The fw_env utility family has a default environment compiled in
which ties it quite strongly to the U-Boot source/config it has
been built with. Allow to display the U-Boot version it has been
built with using the -v/--version argument.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 tools/env/fw_env_main.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 6e278ca80b..0b9063742c 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "fw_env_private.h"
 #include "fw_env.h"
 
@@ -48,6 +49,7 @@ static struct option long_options[] = {
{"script", required_argument, NULL, 's'},
{"noheader", required_argument, NULL, 'n'},
{"lock", required_argument, NULL, 'l'},
+   {"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
 };
 
@@ -67,6 +69,7 @@ void usage_printenv(void)
"Print variables from U-Boot environment\n"
"\n"
" -h, --help   print this help.\n"
+   " -v, --versiondisplay version\n"
 #ifdef CONFIG_ENV_AES
" -a, --aesaes key to access environment\n"
 #endif
@@ -85,6 +88,7 @@ void usage_env_set(void)
"Modify variables in U-Boot environment\n"
"\n"
" -h, --help   print this help.\n"
+   " -v, --versiondisplay version\n"
 #ifdef CONFIG_ENV_AES
" -a, --aesaes key to access environment\n"
 #endif
@@ -123,7 +127,7 @@ static void parse_common_args(int argc, char *argv[])
env_opts.config_file = CONFIG_FILE;
 #endif
 
-   while ((c = getopt_long(argc, argv, ":a:c:l:h", long_options, NULL)) !=
+   while ((c = getopt_long(argc, argv, ":a:c:l:h:v", long_options, NULL)) 
!=
   EOF) {
switch (c) {
case 'a':
@@ -145,6 +149,10 @@ static void parse_common_args(int argc, char *argv[])
do_printenv ? usage_printenv() : usage_env_set();
exit(EXIT_SUCCESS);
break;
+   case 'v':
+   fprintf(stderr, "Compiled with " U_BOOT_VERSION "\n");
+   exit(EXIT_SUCCESS);
+   break;
default:
/* ignore unknown options */
break;
@@ -162,7 +170,7 @@ int parse_printenv_args(int argc, char *argv[])
 
parse_common_args(argc, argv);
 
-   while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL))
+   while ((c = getopt_long(argc, argv, "a:c:ns:l:h:v", long_options, NULL))
!= EOF) {
switch (c) {
case 'n':
@@ -189,7 +197,7 @@ int parse_setenv_args(int argc, char *argv[])
 
parse_common_args(argc, argv);
 
-   while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL))
+   while ((c = getopt_long(argc, argv, "a:c:ns:l:h:v", long_options, NULL))
!= EOF) {
switch (c) {
case 's':
-- 
2.14.2

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


Re: [U-Boot] [U-boot][SDP] Trigger watchdog before calling usb_gadget_handle_interrupts

2017-10-26 Thread Stefan Agner


On 26.10.2017 13:25, Lukasz Majewski wrote:
> Hi Vincent,
>
>> This prevents board resets when calling sdp command on boards which
>> have a watchdog.
>>
>> Signed-off-by: Vincent Prince <vincent.prince...@gmail.com>
>> ---
>>  drivers/usb/gadget/f_sdp.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
>> index 0fae66b..c3eba6d 100644
>> --- a/drivers/usb/gadget/f_sdp.c
>> +++ b/drivers/usb/gadget/f_sdp.c
>> @@ -32,6 +32,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #define HID_REPORT_ID_MASK  0x00ff
>>  
>> @@ -602,6 +603,8 @@ int sdp_init(int controller_index)
>>  puts("\rCTRL+C - Operation aborted.\n");
>>  return 1;
>>  }
>> +
>> +WATCHDOG_RESET();
>>  usb_gadget_handle_interrupts(controller_index);
>>  }
>>  
>> @@ -712,6 +715,7 @@ void sdp_handle(int controller_index)
>>  return;
>>  }
>>  
>> +WATCHDOG_RESET();
>>  usb_gadget_handle_interrupts(controller_index);
>>  
>>  sdp_handle_in_ep();
> Reviewed-by: Lukasz Majewski <lu...@denx.de>

Thanks for the patch! Looks good to me too.
Reviewed-by: Stefan Agner <stefan.ag...@toradex.com>

Best regards,
Stefan

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


[U-Boot] [PATCH] configs: vf610: increase maximum size and enforce correct limit

2017-10-17 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

On Vybrid SoCs U-Boot gets loaded into GFX SRAM which is 512KiB.
Currently 32KiB is reserved for the IMX header. However, this is
not reflected in the size limit. In v2017.11-rc2 the actual size
limit (512KiB-32KiB) has been reached for Colibri VF61, which
lead to a successful build of U-Boot but not a working binary.

The IMX header is much smaller than 32KiB, typically around 1KiB.
Decrease the reserved size to 4KiB and specify the correct U-Boot
size limit. Apply this new base address and limit for all Vybrid
based boards.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 include/configs/colibri_vf.h | 4 ++--
 include/configs/pcm052.h | 4 ++--
 include/configs/vf610twr.h   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h
index 8166aa4afb..bf3bbffe24 100644
--- a/include/configs/colibri_vf.h
+++ b/include/configs/colibri_vf.h
@@ -75,8 +75,8 @@
 #define CONFIG_FDTADDR 0x8400
 
 /* We boot from the gfxRAM area of the OCRAM. */
-#define CONFIG_SYS_TEXT_BASE   0x3f408000
-#define CONFIG_BOARD_SIZE_LIMIT524288
+#define CONFIG_SYS_TEXT_BASE   0x3f401000
+#define CONFIG_BOARD_SIZE_LIMIT520192
 
 #define SD_BOOTCMD \
"sdargs=root=/dev/mmcblk0p2 rw rootwait\0"  \
diff --git a/include/configs/pcm052.h b/include/configs/pcm052.h
index 8144a83db2..060928bd30 100644
--- a/include/configs/pcm052.h
+++ b/include/configs/pcm052.h
@@ -89,8 +89,8 @@
 #define CONFIG_LOADADDR0x8200
 
 /* We boot from the gfxRAM area of the OCRAM. */
-#define CONFIG_SYS_TEXT_BASE   0x3f408000
-#define CONFIG_BOARD_SIZE_LIMIT524288
+#define CONFIG_SYS_TEXT_BASE   0x3f401000
+#define CONFIG_BOARD_SIZE_LIMIT520192
 
 /* if no target-specific extra environment settings were defined by the
target, define an empty one */
diff --git a/include/configs/vf610twr.h b/include/configs/vf610twr.h
index 3430f27c40..ddfcd6f618 100644
--- a/include/configs/vf610twr.h
+++ b/include/configs/vf610twr.h
@@ -79,8 +79,8 @@
 #define CONFIG_SYS_LOAD_ADDR   0x8200
 
 /* We boot from the gfxRAM area of the OCRAM. */
-#define CONFIG_SYS_TEXT_BASE   0x3f408000
-#define CONFIG_BOARD_SIZE_LIMIT524288
+#define CONFIG_SYS_TEXT_BASE   0x3f401000
+#define CONFIG_BOARD_SIZE_LIMIT520192
 
 /*
  * We do have 128MB of memory on the Vybrid Tower board. Leave the last
-- 
2.14.2

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


[U-Boot] [PATCH v1] doc: update imx_usb_loader URL

2017-10-03 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The changes required to use U-Boot's Serial Download Protocol
implementation are now available in upstream imx_usb_loader
repository. Update the URL accordingly.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 doc/README.sdp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/README.sdp b/doc/README.sdp
index 9b438c0746..178ea688a7 100644
--- a/doc/README.sdp
+++ b/doc/README.sdp
@@ -14,7 +14,7 @@ SoC's recovery mechanism is using.
 The SDP protocol over USB is a USB HID class protocol. USB HID class
 protocols allow to access a USB device without OS specific drivers. The
 U-Boot implementation has primarly been tested using the open source
-imx_loader utility (https://github.com/toradex/imx_loader).
+imx_loader utility (https://github.com/boundarydevices/imx_usb_loader).
 
 The host side utilities are typically capable to interpret the i.MX
 specific image header (see doc/README.imximage). There are extensions
-- 
2.14.1

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


Re: [U-Boot] [PATCH] mx6: toradex: Remove custom CONFIG_SPL_PAD_TO definition

2017-09-27 Thread Stefan Agner


On 25.09.2017 20:20, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.este...@nxp.com>
>
> CONFIG_SPL_PAD_TO is already defined inside "imx6_spl.h", so there
> is no need to redefine it in the board config files.

That looks good to me.
Reviewed-by: Stefan Agner <stefan.ag...@toradex.com>

--
Stefan

>
> Signed-off-by: Fabio Estevam <fabio.este...@nxp.com>
> ---
>  include/configs/apalis_imx6.h  | 1 -
>  include/configs/colibri_imx6.h | 1 -
>  2 files changed, 2 deletions(-)
>
> diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
> index a15f19d..51bf61c 100644
> --- a/include/configs/apalis_imx6.h
> +++ b/include/configs/apalis_imx6.h
> @@ -23,7 +23,6 @@
>  
>  #ifdef CONFIG_SPL
>  #include "imx6_spl.h"
> -#define CONFIG_SPL_PAD_TO0x11000 /* 4k IVT/DCD, 64k SPL */
>  #endif
>  
>  #define CONFIG_CMDLINE_TAG
> diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
> index db71369..ac9a23d 100644
> --- a/include/configs/colibri_imx6.h
> +++ b/include/configs/colibri_imx6.h
> @@ -21,7 +21,6 @@
>  
>  #ifdef CONFIG_SPL
>  #include "imx6_spl.h"
> -#define CONFIG_SPL_PAD_TO0x11000 /* 4k IVT/DCD, 64k SPL */
>  #endif
>  
>  #define CONFIG_CMDLINE_TAG

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


Re: [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably

2017-09-18 Thread Stefan Agner


On September 18, 2017 8:05:43 AM PDT, Stefano Babic <sba...@denx.de> wrote:
>Hi Stefan,
>
>On 14/09/2017 07:24, Eric Nelson wrote:
>> Hi Stefan,
>> 
>> Thanks for this patch.
>> 
>> On 09/13/2017 02:29 PM, Stefan Agner wrote:
>>> From: Stefan Agner <stefan.ag...@toradex.com>
>>>
>>> The current mechanism using SCR/GPR registers work well when
>>> the serial downloader boot mode has been selected explicitly
>>> (either via boot mode pins or using bmode command). However,
>>> in case the system entered boot ROM due to unbootable primary
>>> boot devices (e.g. empty eMMC), the SPL fails to detect that
>>> it has been downloaded through serial loader and tries to
>>> continue booting from eMMC:
>>>    Trying to boot from MMC1
>>>    mmc_load_image_raw_sector: mmc block read error
>>>    SPL: failed to boot from all boot devices
>>>    ### ERROR ### Please RESET the board ###
>>>
>>> The only known way to reliably detect USB serial downloader
>>> is by checking the USB PHY receiver block power state...
>>>
>>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>>> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
>>> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
>>> ---
>>>
>>> Changes in v4:
>>> - Rename macro to is_usbotg_phy_active()
>>>
>>> Changes in v3:
>>> - Fix spelling and grammar
>>>
>>> Changes in v2:
>>> - Add comment that we infer boot ROM behavior from USB PHY state
>>>
>>>   arch/arm/mach-imx/spl.c | 12 
>>>   1 file changed, 12 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>>> index 258578ac25..534cc6504d 100644
>>> --- a/arch/arm/mach-imx/spl.c
>>> +++ b/arch/arm/mach-imx/spl.c
>>> @@ -31,6 +31,18 @@ u32 spl_boot_device(void)
>>>   if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>>   return BOOT_DEVICE_BOARD;
>>>   +    /*
>>> + * The above method does not detect that the boot ROM used
>>> + * serial downloader in case the boot ROM decided to use the
>>> + * serial downloader as a fall back (primary boot source
>failed).
>>> + *
>>> + * Infer that the boot ROM used the USB serial downloader by
>>> + * checking whether the USB PHY is currently active... This
>>> + * assumes that SPL did not (yet) initialize the USB PHY...
>>> + */
>>> +    if (is_otgusb_phy_active())
>
>This is "otgusb", but in sys_proto.h is "usbotg".
>
>Can I fix it myself as "usbotg" by merging ?

Good point, wonder why I did not notice, I usually build it again. Sure go 
ahead.

--
Stefan

>
>Best regards,
>Stefano
>
>>> +    return BOOT_DEVICE_BOARD;
>>> +
>>>   /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>>>   switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>>>    /* EIM: See 8.5.1, Table 8-9 */
>>>
>> 
>> Reviewed-by: Eric Nelson <e...@nelint.com>

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active

2017-09-14 Thread Stefan Agner
On 2017-09-13 22:23, Eric Nelson wrote:
> On 09/13/2017 02:29 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> This macro allows to detect whether the USB PHY is active. This
>> is helpful to detect if the boot ROM has previously started the
>> USB serial downloader.
>>
>> The idea is taken from the mfgtool support in the NXP U-Boot:
>> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
>> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
>> ---
>>
>> Changes in v4:
>> - Rename macro to is_usbotg_phy_active()
>>
>> Changes in v3: None
>> Changes in v2:
>> - Move macro to sys_proto.h
>> - Renamed from is_boot_from_usb() to is_usbphy_active()
>> - Use defines for register offset and field
>> - Remove tab after define
>> - Remove comment since the actual "magic" is happening and
>>documented at usage side
>>
>>   arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h 
>> b/arch/arm/include/asm/arch-mx6/sys_proto.h
>> index 14f5d948c9..ba73943260 100644
>> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
>> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
>> @@ -6,3 +6,10 @@
>>*/
>> #include 
> 
> I'd be more worried about these macro names (asking that they also
> include "OTG") if they weren't defined in such close proximity to
> their only use.
> 

The registers for the host and otg phy are the same, one might reuse
them for host...

>> +
>> +#define USBPHY_PWD  0x
>> +
>> +#define USBPHY_PWD_RXPWDRX  (1 << 20) /* receiver block power down */
>> +
>> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + 
>> USBPHY_PWD) & \
>> +   USBPHY_PWD_RXPWDRX))
>>

In contrast, this function define is really OTG phy specific since we
use PHY0.

> 
> Otherwise,
> 
> Reviewed-by: Eric Nelson <e...@nelint.com>

Thx!

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


Re: [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active

2017-09-13 Thread Stefan Agner
Sorry, the subject should have been v4.

--
Stefan

On 2017-09-13 14:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.ag...@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3: None
> Changes in v2:
> - Move macro to sys_proto.h
> - Renamed from is_boot_from_usb() to is_usbphy_active()
> - Use defines for register offset and field
> - Remove tab after define
> - Remove comment since the actual "magic" is happening and
>   documented at usage side
> 
>  arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h
> b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 14f5d948c9..ba73943260 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -6,3 +6,10 @@
>   */
>  
>  #include 
> +
> +#define USBPHY_PWD   0x
> +
> +#define USBPHY_PWD_RXPWDRX   (1 << 20) /* receiver block power down */
> +
> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR +
> USBPHY_PWD) & \
> +USBPHY_PWD_RXPWDRX))


On 2017-09-13 14:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.ag...@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3: None
> Changes in v2:
> - Move macro to sys_proto.h
> - Renamed from is_boot_from_usb() to is_usbphy_active()
> - Use defines for register offset and field
> - Remove tab after define
> - Remove comment since the actual "magic" is happening and
>   documented at usage side
> 
>  arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h
> b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 14f5d948c9..ba73943260 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -6,3 +6,10 @@
>   */
>  
>  #include 
> +
> +#define USBPHY_PWD   0x
> +
> +#define USBPHY_PWD_RXPWDRX   (1 << 20) /* receiver block power down */
> +
> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR +
> USBPHY_PWD) & \
> +USBPHY_PWD_RXPWDRX))
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active

2017-09-13 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This macro allows to detect whether the USB PHY is active. This
is helpful to detect if the boot ROM has previously started the
USB serial downloader.

The idea is taken from the mfgtool support in the NXP U-Boot:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v4:
- Rename macro to is_usbotg_phy_active()

Changes in v3: None
Changes in v2:
- Move macro to sys_proto.h
- Renamed from is_boot_from_usb() to is_usbphy_active()
- Use defines for register offset and field
- Remove tab after define
- Remove comment since the actual "magic" is happening and
  documented at usage side

 arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h 
b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 14f5d948c9..ba73943260 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -6,3 +6,10 @@
  */
 
 #include 
+
+#define USBPHY_PWD 0x
+
+#define USBPHY_PWD_RXPWDRX (1 << 20) /* receiver block power down */
+
+#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & 
\
+  USBPHY_PWD_RXPWDRX))
-- 
2.14.1

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


[U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably

2017-09-13 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v4:
- Rename macro to is_usbotg_phy_active()

Changes in v3:
- Fix spelling and grammar

Changes in v2:
- Add comment that we infer boot ROM behavior from USB PHY state

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..534cc6504d 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,18 @@ u32 spl_boot_device(void)
if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
return BOOT_DEVICE_BOARD;
 
+   /*
+* The above method does not detect that the boot ROM used
+* serial downloader in case the boot ROM decided to use the
+* serial downloader as a fall back (primary boot source failed).
+*
+* Infer that the boot ROM used the USB serial downloader by
+* checking whether the USB PHY is currently active... This
+* assumes that SPL did not (yet) initialize the USB PHY...
+*/
+   if (is_otgusb_phy_active())
+   return BOOT_DEVICE_BOARD;
+
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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


[U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active

2017-09-12 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This macro allows to detect whether the USB PHY is active. This
is helpful to detect if the boot ROM has previously started the
USB serial downloader.

The idea is taken from the mfgtool support in the NXP U-Boot:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v3: None
Changes in v2:
- Move macro to sys_proto.h
- Renamed from is_boot_from_usb() to is_usbphy_active()
- Use defines for register offset and field
- Remove tab after define
- Remove comment since the actual "magic" is happening and
  documented at usage side

 arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h 
b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 14f5d948c9..9d4b1d6768 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -6,3 +6,10 @@
  */
 
 #include 
+
+#define USBPHY_PWD 0x
+
+#define USBPHY_PWD_RXPWDRX (1 << 20) /* receiver block power down */
+
+#define is_usbphy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
+  USBPHY_PWD_RXPWDRX))
-- 
2.14.1

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


[U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably

2017-09-12 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v3:
- Fix spelling and grammar

Changes in v2:
- Add comment that we infer boot ROM behavior from USB PHY state

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..522ab9f260 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,18 @@ u32 spl_boot_device(void)
if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
return BOOT_DEVICE_BOARD;
 
+   /*
+* The above method does not detect that the boot ROM used
+* serial downloader in case the boot ROM decided to use the
+* serial downloader as a fall back (primary boot source failed).
+*
+* Infer that the boot ROM used the USB serial downloader by
+* checking whether the USB PHY is currently active... This
+* assumes that SPL did not (yet) initialize the USB PHY...
+*/
+   if (is_usbphy_active())
+   return BOOT_DEVICE_BOARD;
+
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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


Re: [U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-09-11 Thread Stefan Agner
On 2017-09-11 07:15, Vincent Prince wrote:
> Hi Stefan,
> 
> It was probably a Windows bug as it is almost working now.

Yeah with Windows the multiple re-enumeration is sometimes a bit
strange, it leads to rather long running driver search on first connect.

> I was wondering why sdp command is expecting a jump ?
> Is it necessary to jump after USB transfer, or we should download
> anything we want and jump if asked ?

You don't have to jump, you can also go back to the console using
Ctrl+C. The jump just allows you to remotely continue booting with a
specific script...

--
Stefan

> 
> Regards,
> Vincent
> 
> 
> 2017-09-08 18:37 GMT+02:00 Stefan Agner <ste...@agner.ch>:
>> Hi Vincent,
>>
>> On 2017-09-08 01:27, Vincent Prince wrote:
>>> Hi everyone,
>>>
>>> I managed to get SDP protocol to work with on my custom i.MX6 board,
>>> so big thanks to Stefan for your work!
>>>
>>> I'm now trying to load swupdate ramdisk with u-boot sdp command,
>>> without success.
>>> Is it a possible use case ?
>>
>> Yes it should work, we use the U-Boot sdp command to download a squashfs
>> based ramdisk in our Toradex Easy Installer:
>> http://developer.toradex.com/software/toradex-easy-installer
>>
>>>
>>> Here my steps:
>>>
>>> In u-boot:
>>> => sdp 0
>>>
>>> On Host,
>>> $ imx_usb
>>>
>>> config file <C:\Users\vpr\IMXUSBLOADER2\delivery\\imx_usb.conf>
>>> vid=0x15a2 pid=0x0061 file_name=mx6_usb_rom.conf -> vid=0x0525
>>> pid=0xb4a4 file_name=mx6_usb_sdp_spl.conf
>>> vid=0x0525 pid=0xa4a5 file_name=mx6_usb_uboot.conf
>>> config file <C:\Users\vpr\IMXUSBLOADER2\delivery\\mx6_usb_uboot.conf>
>>> parse C:\Users\vpr\IMXUSBLOADER2\delivery\\mx6_usb_uboot.conf
>>> Trying to open device vid=0x0525 pid=0xa4a5.
>>> Could not open device vid=0x0525 pid=0xa4a5
>>
>> Is VID/PID showing up in Device Manager?
>>
>> We did saw some problems with certain USB host implementation, so it
>> might be a device dependency... I would also try a different
>> machine/maybe Linux machine...
>>
>>>
>>> VID/PID in imx_usb.conf are correctly detected, and correct
>>> configuration file is launched (mx6_usb_uboot.conf),
>>> it contains:
>>>
>>> mx6_usb_sdp_uboot
>>> hid,1024,0x1000,1G,0x00907000,0x31000
>>> test.txt:load 0x1210
>>>
>>> My imx_usb.conf is the following:
>>>
>>> #vid:pid, config_file
>>> 0x15a2:0x0061, mx6_usb_rom.conf, 0x0525:0xb4a4, mx6_usb_sdp_spl.conf
>>> 0x0525:0xa4a5, mx6_usb_uboot.conf
>>
>> Yeah assuming you use the Toradex branch of imx_loader currently this
>> should work.
>>
>> Our script looks like this:
>> mx6_usb_sdp_uboot
>> #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
>> valid ram areas)
>> hid,1024,0x1000,1G,0x00907000,0x31000
>> #Load complete FIT image to $ramdisk_addr_r
>> tezi.itb:load 0x1210
>> #Load script to $loadaddr and jump to it
>> boot-sdp.scr:load 0x1200,jump 0x1200
>>
>> --
>> Stefan
>>
>>
>>>
>>> Am I missing something,
>>> Thanks,
>>> Vincent
>>>
>>> 2017-09-01 22:09 GMT+02:00 Stefan Agner <ste...@agner.ch>:
>>>>
>>>>
>>>> On September 1, 2017 12:25:44 PM PDT, Fabio Estevam <feste...@gmail.com> 
>>>> wrote:
>>>>>On Fri, Sep 1, 2017 at 3:54 PM, Fabio Estevam <feste...@gmail.com>
>>>>>wrote:
>>>>>
>>>>>> I have tested this method and it works, thanks.
>>>>>>
>>>>>> Do you plan to usptream this method?
>>>>>
>>>>>Or I can also put your patch as part of my series that adds SDP
>>>>>support for imx6qsabresd if you prefer.
>>>>
>>>> Let me do a separate, I guess it could be controversial...
>>>>
>>>> --
>>>> Stefan
>>>> --
>>>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>>>> ___
>>>> 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 v2 2/2] imx_common: detect USB serial downloader reliably

2017-09-08 Thread Stefan Agner
On 2017-09-08 17:41, Eric Nelson wrote:
> Hi Stefan,
> 
> On 09/08/2017 05:35 PM, Fabio Estevam wrote:
>> On Fri, Sep 8, 2017 at 8:35 PM, Stefan Agner <ste...@agner.ch> wrote:
>>
>>> +   /*
>>> +* The above method does not detect that the boot ROM used
>>> +* serial downloader in case the boot ROM descided to use the
>>
>> Typo: decided
>>
> 
> You know you're on the right track when the only comments about
> your patch are about naming, spelling and grammar ;)

Hehe, ok cool.

Yeah my parser was searching for a logical issue wrt initialize... :-)

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


Re: [U-Boot] [PATCH v2 2/2] imx_common: detect USB serial downloader reliably

2017-09-08 Thread Stefan Agner
On 2017-09-08 16:41, Eric Nelson wrote:
> Hi Stefan,
> 
> On 09/08/2017 04:35 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> The current mechanism using SCR/GPR registers work well when
>> the serial downloader boot mode has been selected explicitly
>> (either via boot mode pins or using bmode command). However,
>> in case the system entered boot ROM due to unbootable primary
>> boot devices (e.g. empty eMMC), the SPL fails to detect that
>> it has been downloaded through serial loader and tries to
>> continue booting from eMMC:
>>Trying to boot from MMC1
>>mmc_load_image_raw_sector: mmc block read error
>>SPL: failed to boot from all boot devices
>>### ERROR ### Please RESET the board ###
>>
>> The only known way to reliably detect USB serial downloader
>> is by checking the USB PHY receiver block power state...
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
>> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
>> ---
>>
>> Changes in v2:
>> - Add comment that we infer boot ROM behavior from USB PHY state
>>
>>   arch/arm/mach-imx/spl.c | 12 
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>> index 258578ac25..f3fec81de7 100644
>> --- a/arch/arm/mach-imx/spl.c
>> +++ b/arch/arm/mach-imx/spl.c
>> @@ -31,6 +31,18 @@ u32 spl_boot_device(void)
>>  if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>  return BOOT_DEVICE_BOARD;
>>   +  /*
>> + * The above method does not detect that the boot ROM used
>> + * serial downloader in case the boot ROM descided to use the
>> + * serial downloader as a fall back (primary boot source failed).
>> + *
> 
> Nit: should be "did not initialize" instead of "initialized".

Sorry, don't get that. Below I write "did not (yet) initialized"...

--
Stefan

> 
> Otherwise, this is a nice comment that describes the situation.
> 
>> + * Infer that the boot ROM used the USB serial downloader by
>> + * checking whether the USB PHY is currently active... This
>> + * assumes that SPL did not (yet) initialized the USB PHY...
>> + */
>> +if (is_usbphy_active())
>> +return BOOT_DEVICE_BOARD;
>> +
>>  /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>>  switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>>   /* EIM: See 8.5.1, Table 8-9 */
>>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] imx_common: detect USB serial downloader reliably

2017-09-08 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v2:
- Add comment that we infer boot ROM behavior from USB PHY state

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..f3fec81de7 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,18 @@ u32 spl_boot_device(void)
if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
return BOOT_DEVICE_BOARD;
 
+   /*
+* The above method does not detect that the boot ROM used
+* serial downloader in case the boot ROM descided to use the
+* serial downloader as a fall back (primary boot source failed).
+*
+* Infer that the boot ROM used the USB serial downloader by
+* checking whether the USB PHY is currently active... This
+* assumes that SPL did not (yet) initialized the USB PHY...
+*/
+   if (is_usbphy_active())
+   return BOOT_DEVICE_BOARD;
+
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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


[U-Boot] [PATCH v2 1/2] imx: add macro to detect whether USB PHY is active

2017-09-08 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This macro allows to detect whether the USB PHY is active. This
is helpful to detect if the boot ROM has previously started the
USB serial downloader.

The idea is taken from the mfgtool support in the NXP U-Boot:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---

Changes in v2:
- Move macro to sys_proto.h
- Renamed from is_boot_from_usb() to is_usbphy_active()
- Use defines for register offset and field
- Remove tab after define
- Remove comment since the actual "magic" is happening and
  documented at usage side

 arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h 
b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 14f5d948c9..9d4b1d6768 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -6,3 +6,10 @@
  */
 
 #include 
+
+#define USBPHY_PWD 0x
+
+#define USBPHY_PWD_RXPWDRX (1 << 20) /* receiver block power down */
+
+#define is_usbphy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
+  USBPHY_PWD_RXPWDRX))
-- 
2.14.1

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


Re: [U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-09-08 Thread Stefan Agner
Hi Vincent,

On 2017-09-08 01:27, Vincent Prince wrote:
> Hi everyone,
> 
> I managed to get SDP protocol to work with on my custom i.MX6 board,
> so big thanks to Stefan for your work!
> 
> I'm now trying to load swupdate ramdisk with u-boot sdp command,
> without success.
> Is it a possible use case ?

Yes it should work, we use the U-Boot sdp command to download a squashfs
based ramdisk in our Toradex Easy Installer:
http://developer.toradex.com/software/toradex-easy-installer

> 
> Here my steps:
> 
> In u-boot:
> => sdp 0
> 
> On Host,
> $ imx_usb
> 
> config file <C:\Users\vpr\IMXUSBLOADER2\delivery\\imx_usb.conf>
> vid=0x15a2 pid=0x0061 file_name=mx6_usb_rom.conf -> vid=0x0525
> pid=0xb4a4 file_name=mx6_usb_sdp_spl.conf
> vid=0x0525 pid=0xa4a5 file_name=mx6_usb_uboot.conf
> config file <C:\Users\vpr\IMXUSBLOADER2\delivery\\mx6_usb_uboot.conf>
> parse C:\Users\vpr\IMXUSBLOADER2\delivery\\mx6_usb_uboot.conf
> Trying to open device vid=0x0525 pid=0xa4a5.
> Could not open device vid=0x0525 pid=0xa4a5

Is VID/PID showing up in Device Manager?

We did saw some problems with certain USB host implementation, so it
might be a device dependency... I would also try a different
machine/maybe Linux machine...

> 
> VID/PID in imx_usb.conf are correctly detected, and correct
> configuration file is launched (mx6_usb_uboot.conf),
> it contains:
> 
> mx6_usb_sdp_uboot
> hid,1024,0x1000,1G,0x00907000,0x31000
> test.txt:load 0x1210
> 
> My imx_usb.conf is the following:
> 
> #vid:pid, config_file
> 0x15a2:0x0061, mx6_usb_rom.conf, 0x0525:0xb4a4, mx6_usb_sdp_spl.conf
> 0x0525:0xa4a5, mx6_usb_uboot.conf

Yeah assuming you use the Toradex branch of imx_loader currently this
should work.

Our script looks like this:
mx6_usb_sdp_uboot
#hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
valid ram areas)
hid,1024,0x1000,1G,0x00907000,0x31000
#Load complete FIT image to $ramdisk_addr_r
tezi.itb:load 0x1210
#Load script to $loadaddr and jump to it
boot-sdp.scr:load 0x1200,jump 0x1200

--
Stefan


> 
> Am I missing something,
> Thanks,
> Vincent
> 
> 2017-09-01 22:09 GMT+02:00 Stefan Agner <ste...@agner.ch>:
>>
>>
>> On September 1, 2017 12:25:44 PM PDT, Fabio Estevam <feste...@gmail.com> 
>> wrote:
>>>On Fri, Sep 1, 2017 at 3:54 PM, Fabio Estevam <feste...@gmail.com>
>>>wrote:
>>>
>>>> I have tested this method and it works, thanks.
>>>>
>>>> Do you plan to usptream this method?
>>>
>>>Or I can also put your patch as part of my series that adds SDP
>>>support for imx6qsabresd if you prefer.
>>
>> Let me do a separate, I guess it could be controversial...
>>
>> --
>> Stefan
>> --
>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>> ___
>> 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] [RFC] toradex: imx6: Move g_dnl_bind_fixup() into common SPL code

2017-09-05 Thread Stefan Agner


On 03.09.2017 07:56, Fabio Estevam wrote:
> From: Fabio Estevam 
>
> Instead of having every board file to add its own g_dnl_bind_fixup()
> implementation, move it to the common imx6 SPL code.
>
> Signed-off-by: Fabio Estevam 
> ---
> Stefan,
>
> I don't have access to Toradex board to test it, hence marking it
> as RFC.
>
> I have tested it with imx6q-sabresd and it works fine on this board.
>
>  arch/arm/mach-imx/spl.c   | 10 ++
>  board/toradex/apalis_imx6/apalis_imx6.c   | 13 -
>  board/toradex/colibri_imx6/colibri_imx6.c | 13 -
>  board/toradex/common/tdx-common.c | 13 -
>  4 files changed, 10 insertions(+), 39 deletions(-)
>
> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
> index 8e8e2f7..e350bc9 100644
> --- a/arch/arm/mach-imx/spl.c
> +++ b/arch/arm/mach-imx/spl.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -86,6 +87,15 @@ u32 spl_boot_device(void)
>   }
>   return BOOT_DEVICE_NONE;
>  }
> +
> +#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
> +int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
> +{
> + put_unaligned(CONFIG_G_DNL_PRODUCT_NUM + 0xfff, >idProduct);

Note that 0xfff was a rather randomly picked offset, not sure if we want that 
in common code.



> +
> + return 0;
> +}
> +#endif
>  #endif
>  
>  #if defined(CONFIG_SPL_MMC_SUPPORT)
> diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
> b/board/toradex/apalis_imx6/apalis_imx6.c
> index ebc6c12..628a61d 100644
> --- a/board/toradex/apalis_imx6/apalis_imx6.c
> +++ b/board/toradex/apalis_imx6/apalis_imx6.c
> @@ -29,7 +29,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -1224,18 +1223,6 @@ void reset_cpu(ulong addr)
>  {
>  }
>  
> -#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
> -int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
> -{
> - unsigned short usb_pid;
> -
> - usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
> - put_unaligned(usb_pid, >idProduct);
> -
> - return 0;
> -}
> -#endif
> -
>  #endif
>  
>  static struct mxc_serial_platdata mxc_serial_plat = {
> diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
> b/board/toradex/colibri_imx6/colibri_imx6.c
> index 669d912..756e3f3 100644
> --- a/board/toradex/colibri_imx6/colibri_imx6.c
> +++ b/board/toradex/colibri_imx6/colibri_imx6.c
> @@ -28,7 +28,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -1108,18 +1107,6 @@ void reset_cpu(ulong addr)
>  {
>  }
>  
> -#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
> -int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
> -{
> - unsigned short usb_pid;
> -
> - usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
> - put_unaligned(usb_pid, >idProduct);
> -
> - return 0;
> -}
> -#endif
> -
>  #endif
>  
>  static struct mxc_serial_platdata mxc_serial_plat = {
> diff --git a/board/toradex/common/tdx-common.c 
> b/board/toradex/common/tdx-common.c
> index b4e4727..a7efeb8 100644
> --- a/board/toradex/common/tdx-common.c
> +++ b/board/toradex/common/tdx-common.c
> @@ -5,7 +5,6 @@
>   */
>  
>  #include 
> -#include 
>  #include 
>  
>  #include "tdx-cfg-block.h"
> @@ -109,18 +108,6 @@ int show_board_info(void)
>   return 0;
>  }
>  
> -#ifdef CONFIG_USB_GADGET_DOWNLOAD
> -int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
> -{
> - unsigned short usb_pid;
> -
> - usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + tdx_hw_tag.prodid;
> - put_unaligned(usb_pid, >idProduct);
> -
> - return 0;
> -}
> -#endif

Nack to this part, this is U-Boot only (not used in SPL) and reads the product 
ID from eMMC to generate the officially assigned Toradex USB Product ID.

--
Stefan

> -
>  #if defined(CONFIG_OF_LIBFDT)
>  int ft_common_board_setup(void *blob, bd_t *bd)
>  {

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


Re: [U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

2017-09-05 Thread Stefan Agner
On 2017-09-05 09:18, Fabio Estevam wrote:
> On Tue, Sep 5, 2017 at 1:05 PM, Stefan Agner <ste...@agner.ch> wrote:
> 
>> i.MX 7 has a Boot Information structure which is passed from the Boot
>> ROM, so we have a much cleaner method there.
>> http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=arch/arm/mach-imx/mx7/soc.c;h=87bf105f385d4c12bee6d038c0ba50e2e588124c;hb=HEAD#l392
>>
>> As far as I can tell this boot information structure is also accurate
>> when the Boot ROM entered serial downloader as a fallback.
> 
> What I meant is that the is_boot_from_usb() macro is also defined for
> MX7 and MX7ULP:
> 
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1209
> 
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7ulp/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1207
> 

Yes, I understand.

I am just saying, I don't see a point to use that macro over i.MX 7's
Boot Information structure...

> 
>> Do we have boards using SPL on i.MX 7?
> 
> No, we don't have it currently.

Ok.

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


Re: [U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

2017-09-05 Thread Stefan Agner
On 2017-09-05 06:45, Fabio Estevam wrote:
> Hi Stefano,
> 
> On Tue, Sep 5, 2017 at 8:16 AM, Stefano Babic  wrote:
> 
>> Maybe we get some further info from our "insider" (Fabio, Peng). It will
>> be very interesting to know if we can apply this to all spectrum from
>> i.MX6, or if there is some MX6 variant where the Bootrom is doing
>> something different.
> 
> Looking at NXP U-Boot code I see that this same mechanism applies not
> only to mx6, but it extends to mx7 and mx7ulp, so it seems like a good
> approach.

i.MX 7 has a Boot Information structure which is passed from the Boot
ROM, so we have a much cleaner method there.
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=arch/arm/mach-imx/mx7/soc.c;h=87bf105f385d4c12bee6d038c0ba50e2e588124c;hb=HEAD#l392

As far as I can tell this boot information structure is also accurate
when the Boot ROM entered serial downloader as a fallback.

Do we have boards using SPL on i.MX 7?

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


Re: [U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

2017-09-05 Thread Stefan Agner
On 2017-09-05 04:13, Fabio Estevam wrote:
> Hi Stefan,
> 
> On Mon, Sep 4, 2017 at 10:21 PM, Stefan Agner <ste...@agner.ch> wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> This macro allows to detect whether the boot ROM initialized USB
>> already (serial downloader). This is helpful to reliably detect
>> if the system has been recovered via USB serial downloader.
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
> 
> This allows Serial Download Protocol to work on imx6q sabresd:
> 
> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
> 
>> ---
>> Hi Stefano,
>>
>> I noted already in my initial post that detection of serial
>> downloader mode is somewhat brittle:
>> https://lists.denx.de/pipermail/u-boot/2017-August/301952.html
>>
>> This came up quite fast now also for other boards:
>> https://www.mail-archive.com/u-boot@lists.denx.de/msg262234.html
>>
>> We use this patches since quite some time. Also NXP uses this
>> detection method to start their mfgr tools... Altough a hack,
>> maybe we should still add it upstream?
>>
>> --
>> Stefan
>>
>>
>>  arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
>> b/arch/arm/include/asm/arch-mx6/imx-regs.h
>> index 86e267087a..895ef4de83 100644
>> --- a/arch/arm/include/asm/arch-mx6/imx-regs.h
>> +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
>> @@ -985,5 +985,12 @@ struct pwm_regs {
>> u32 pr;
>> u32 cnr;
>>  };
>> +
>> +/*
>> + * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
>> + * If boot from the other mode, USB0_PWD will keep reset value
>> + */
>> +#defineis_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & 
>> (1<<20)))
> 
> Minor nit: imx-regs.h is better suited for storing register layout 
> definitions.
> 
> I think that arch/arm/include/asm/mach-imx/sys_proto.h  would be a
> more appropriate location for this macro.

Makes sense, will move it.


> 
> Also you could remove that tab between 'define' and the macro name.

Agreed.

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


Re: [U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

2017-09-04 Thread Stefan Agner
On 2017-09-04 19:57, Eric Nelson wrote:
> Hi Stefan,
> 
> On 09/04/2017 06:21 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> This macro allows to detect whether the boot ROM initialized USB
>> already (serial downloader). This is helpful to reliably detect
>> if the system has been recovered via USB serial downloader.
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
>> ---
>> Hi Stefano,
>>
>> I noted already in my initial post that detection of serial
>> downloader mode is somewhat brittle:
>> https://lists.denx.de/pipermail/u-boot/2017-August/301952.html
>>
>> This came up quite fast now also for other boards:
>> https://www.mail-archive.com/u-boot@lists.denx.de/msg262234.html
>>
>> We use this patches since quite some time. Also NXP uses this
>> detection method to start their mfgr tools... Altough a hack,
>> maybe we should still add it upstream?
>>
>> --
>> Stefan
>>
>>
>>   arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
>> b/arch/arm/include/asm/arch-mx6/imx-regs.h
>> index 86e267087a..895ef4de83 100644
>> --- a/arch/arm/include/asm/arch-mx6/imx-regs.h
>> +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
>> @@ -985,5 +985,12 @@ struct pwm_regs {
>>  u32 pr;
>>  u32 cnr;
>>   };
> 
> It seems as if you've already named a constant, so you might as well
> #define and use it (USBPH0_PWD or USB0_PWD).

Agreed.

> 
> The reference manual seems to call it RXPWDRX though.

I guess taking the latest naming from the manual make sense. Will update
in v2.

Before I send out v2, I'd like to know from Stefano whether he agrees
with the general direction of the patch.



> 
>> +
>> +/*
>> + * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
>> + * If boot from the other mode, USB0_PWD will keep reset value
>> + */
>> +#define is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
>> +
>>   #endif /* __ASSEMBLER__*/
>>   #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
>>
> If I'm reading your comment correctly, the RXPWDRX bit will be set (the
> PHY will be powered down) unless it was enabled by the Boot ROM.
> 
> Won't this also be clear if you've run 'usb start' under U-Boot?

Yes, this only works before a USB initialization...

This should be fine for the use case I have in mind (see patch 2).

Note this idea is borrowed from NXP downstream and seems to work here:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

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


[U-Boot] [PATCH v1 2/2] imx_common: detect USB serial downloader reliably

2017-09-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
---

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..8e8e2f755b 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,10 @@ u32 spl_boot_device(void)
if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
return BOOT_DEVICE_BOARD;
 
+   /* Check USB state in case we entered serial downloader as fallback */
+   if (is_boot_from_usb())
+   return BOOT_DEVICE_BOARD;
+
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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


[U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

2017-09-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This macro allows to detect whether the boot ROM initialized USB
already (serial downloader). This is helpful to reliably detect
if the system has been recovered via USB serial downloader.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
---
Hi Stefano,

I noted already in my initial post that detection of serial
downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot@lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this
detection method to start their mfgr tools... Altough a hack,
maybe we should still add it upstream?

--
Stefan


 arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 86e267087a..895ef4de83 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -985,5 +985,12 @@ struct pwm_regs {
u32 pr;
u32 cnr;
 };
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#defineis_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
 #endif /* __ASSEMBLER__*/
 #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
-- 
2.14.1

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


Re: [U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-09-01 Thread Stefan Agner


On September 1, 2017 12:25:44 PM PDT, Fabio Estevam  wrote:
>On Fri, Sep 1, 2017 at 3:54 PM, Fabio Estevam 
>wrote:
>
>> I have tested this method and it works, thanks.
>>
>> Do you plan to usptream this method?
>
>Or I can also put your patch as part of my series that adds SDP
>support for imx6qsabresd if you prefer.

Let me do a separate, I guess it could be controversial...

--
Stefan
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-09-01 Thread Stefan Agner
On 2017-09-01 09:48, Fabio Estevam wrote:
> Hi Stefan,
> 
> On Wed, Aug 16, 2017 at 3:00 PM, Stefan Agner <ste...@agner.ch> wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> This series adds NXP's Serial Download Protocol (SDP) support via
>> USB for SPL/U-Boot. It allows to download U-Boot via USB from a
>> (recovered) SPL using the same tools used to download SPL itself
>> (specifically imx_usb, but also sb_loader seems to work).
>>
>> The idea has been brought up when the first targets started to make
>> use of SPL for DDR initialization, see:
>> https://lists.denx.de/pipermail/u-boot/2015-July/220330.html
>>
>> The initial SDP implementation (patch 2) requires the payload to
>> have the imx specific headers (hence the move of the imx header
>> file in patch 1).
>>
>> Patch 3 extends image header support beyond the SDP specification,
>> specifically implements also support for U-Boot headers. This
>> allows to use the same SPL/U-Boot binaries for recovery as used on
>> the regular boot device (SD/eMMC). For that to work also the host
>> side imx_usb tools needed an extension, currently available here:
>>
>> https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored
>>
>> (in case this patchset gets accepted in U-Boot, I plan to push
>> these imx_usb changes upstream as well)
>>
>> The full patchset allows to download SPL and U-Boot over USB to a
>> target in recovery mode using the same usb_imx utility. Refer to
>> the new README.sdp for details how to use usb_imx in combination
>> with this implementation.
> 
> I am trying to use this feature on a imx6qsabresd board.
> 
> Here are the changes I made (against u-boot-imx latest tree):
> 
> diff --git a/board/freescale/mx6sabresd/mx6sabresd.c
> b/board/freescale/mx6sabresd/mx6sabresd.c
> index 5b50bc8..6ca2485 100644
> --- a/board/freescale/mx6sabresd/mx6sabresd.c
> +++ b/board/freescale/mx6sabresd/mx6sabresd.c
> @@ -29,6 +29,7 @@
>  #include 
>  #include "../common/pfuze.h"
>  #include 
> +#include 
> 
>  DECLARE_GLOBAL_DATA_PTR;
> 
> @@ -1033,6 +1034,19 @@ static void spl_dram_init(void)
> ddr_init(mx6dl_dcd_table, ARRAY_SIZE(mx6dl_dcd_table));
>  }
> 
> +#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
> +#define FSL_USB_PRODUCT_NUM_OFFSET0xa4a5
> +int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
> +{
> +   unsigned short usb_pid;
> +
> +   usb_pid = FSL_USB_PRODUCT_NUM_OFFSET + 0xff;
> +   put_unaligned(usb_pid, >idProduct);
> +
> +   return 0;
> +}
> +#endif
> +
>  void board_init_f(ulong dummy)
>  {
> /* DDR initialization */
> diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig
> index 7949c5e..1c08639 100644
> --- a/configs/mx6sabresd_defconfig
> +++ b/configs/mx6sabresd_defconfig
> @@ -19,6 +19,9 @@ CONFIG_SPL=y
>  CONFIG_SPL_EXT_SUPPORT=y
>  CONFIG_SPL_I2C_SUPPORT=y
>  CONFIG_SPL_OS_BOOT=y
> +CONFIG_SPL_USB_HOST_SUPPORT=y
> +CONFIG_SPL_USB_GADGET_SUPPORT=y
> +CONFIG_SPL_USB_SDP_SUPPORT=y
>  CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_BOOTZ=y
>  # CONFIG_CMD_IMLS is not set
> @@ -32,6 +35,7 @@ CONFIG_CMD_PART=y
>  CONFIG_CMD_PCI=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
> +CONFIG_CMD_USB_SDP=y
>  CONFIG_CMD_DHCP=y
>  CONFIG_CMD_MII=y
>  CONFIG_CMD_PING=y
> 
> Then I use the imx_usb tool from
> https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored
> 
> I remove the SD card, so that the board goes to SDP and then run:
> 
> sudo ./imx_usb SPL
> 
> and then I see in the board console:
> 
> U-Boot SPL 2017.09-rc2-36996-g63af4b0-dirty (Sep 01 2017 - 13:42:55)
> Trying to boot from MMC1
> MMC: no card present
> mmc_init: -123, time 1
> spl: mmc init failed with error: -123
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###
> 
> I was expecting to see:
> 
>   Trying to boot from USB SDP
>   SDP: initialize...
>   SDP: handle requests...
> 
> as per the README.sdp
> 
> Any ideas as to what I am missing?


That is the issue I am describing here:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

Either enter recovery mode explicitly (by setting the BMODE pins or
using the bmode command)

Or you can use the USB PHY method which indicates whether the ROM used
serial downloader. We use this in our downstream U-Boot (NXP used that
method to go into "mgfr" mode...)
http://git.toradex.com/cgit/u-boot-toradex.git/commit/?h=2016.11-toradex-next=0d069117614b590848b490e348488362443c5547
http://git.toradex.com/cgit/u-boot-toradex.git/commit/?h=2016.11-toradex-next=80c3bd6c2750c3c2843537f015c0d675b1b74a58

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


[U-Boot] [PATCH v1] imx: remove SATA boot mode for i.MX 6UL and 6ULL

2017-08-29 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

The NXP i.MX 6UL and 6ULL do not support SATA and have no SATA
boot mode, hence remove it from the boot device detecion. This
fixes a build error introduced with 3bd1642d4d50 ("imx: fix USB
boot mode detection for i.MX 6UL and 6ULL")

Fixes: 3bd1642d4d50 ("imx: fix USB boot mode detection for i.MX 6UL and 6ULL")
Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index bcd1033fdb..3853e7739d 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -45,8 +45,10 @@ u32 spl_boot_device(void)
case IMX6_BMODE_RESERVED:
return BOOT_DEVICE_BOARD;
/* SATA: See 8.5.4, Table 8-20 */
+#if !defined(CONFIG_MX6UL) && !defined(CONFIG_MX6ULL)
case IMX6_BMODE_SATA:
return BOOT_DEVICE_SATA;
+#endif
/* Serial ROM: See 8.5.5.1, Table 8-22 */
case IMX6_BMODE_SERIAL_ROM:
/* BOOT_CFG4[2:0] */
-- 
2.14.1

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


Re: [U-Boot] [PATCH v1 2/2] imx: use BOOT_DEVICE_BOARD instead of UART

2017-08-27 Thread Stefan Agner
On 2017-08-27 13:21, Sébastien Szymanski wrote:
> Hello,
> 
>> On 27 Aug 2017, at 21:17, Stefan Agner <ste...@agner.ch> wrote:
>>
>> On 2017-08-27 01:45, Sébastien Szymanski wrote:
>>> Hello,
>>>
>>>> On 25 Aug 2017, at 13:33, Stefano Babic <sba...@denx.de> wrote:
>>>>
>>>> On 16/08/2017 02:49, Stefan Agner wrote:
>>>>> From: Stefan Agner <stefan.ag...@toradex.com>
>>>>>
>>>>> i.MX 6 serial downloader is not necessarily booting via UART but can
>>>>> also boot from USB. In fact only some i.MX chips have serial
>>>>> downloader support via UART (e.g. 6UL/ULL and Vybrid) but all of
>>>>> them have serial downloader support via USB. Use the more appropriate
>>>>> BOOT_DEVICE_BOARD define which is used for ROM provided recovery
>>>>> mechanisms in general.
>>>>>
>>>>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>>>>> ---
>>>>>
>>>>> arch/arm/mach-imx/spl.c | 4 ++--
>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>>>>> index 836b334fa9..bcd1033fdb 100644
>>>>> --- a/arch/arm/mach-imx/spl.c
>>>>> +++ b/arch/arm/mach-imx/spl.c
>>>>> @@ -27,7 +27,7 @@ u32 spl_boot_device(void)
>>>>>* BOOT_MODE - see IMX6DQRM Table 8-1
>>>>>*/
>>>>>   if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>>>> - return BOOT_DEVICE_UART;
>>>
>>> Returning BOOT_DEVICE_UART here makes the SPL to load U-Boot from the
>>> debug UART using a ymodem transfer when enabled with
>>> CONFIG_SPL_YMODEM_SUPPORT like it is on the OPOS6ULDev board. This is
>>> now broken.
>>
>> For reference, the change has been discussed here:
>> https://www.mail-archive.com/u-boot@lists.denx.de/msg259729.html
>>
>> Returning UART is definitely wrong, because the boot ROM can also boot
>> from USB…
>> As I mentioned in the other thread, ideally we should be able to do a
>> runtime detection to discriminate between UART and USB loader. I think
>> Stefano did not like that since it relies on undocumented features.
> 
> I don’t understand.
> This has nothing to do with what the ROM can or can’t boot.

It should reflect what the boot ROM did... And the user presumably wants
SPL to continue booting from the same source.

One could imagine a board specific translation table, e.g. boot from ->
boot continue...

> spl_boot_device returns the device where the SPL will find the U-Boot
> image. Here, it makes the distinction between normal boots and Serial
> Downloader boots (BOOT_MODE[0:1] = 0b01) no matter how the SPL has
> been loaded. So, we actually could return whatever we want here, UART,
> USB, eMMC, etc…, as the function does for normal boots. Of course,
> UART or USB is the only two choices that make sense for Serial
> Downloader boots.

Sure every combination is possible, but most likely is to continue using
what the boot ROM used. So when serial downloader over USB has been
used, you probably want to continue booting through USB. Same for UART.

And that is the problem, from the SRC/GPR regiters we cannot detect
whether the boot ROM loaded SPL through UART or USB... There is a
method, by looking at the USB PHY power flag, which seems to work, but
it is not a really nice way.

I vote for using the USB PHY hack nonetheless


> 
> Maybe we could do something like:
> 
> #if CONFIG_IS_ENABLED(SPL_YMODEM_SUPPORT)
>   return BOOT_DEVICE_UART
> #else
>   return BOOT_DEVICE_BOARD
> #endif
> 
> or let the boards return the device they want by overloading board_boot_order.
> 
> ?

All methods seem a bit hacky to me...

Stefano, any idea/preferences?

--
Stefan

> 
> Regards,
> 
>>
>> So BOOT_DEVICE is really ambiguous. Maybe BOOT_DEVICE_* should be a
>> bitfield? Then we could return BOOT_DEVICE_UART and BOOT_DEVICE_USB, and
>> boards can just compile in the support they need.
>>
>>
>> Changing the Y-Modem support to boot device BOOT_DEVICE_BOARD is not
>> possible since other SoCs use BOOT_DEVICE_UART.
>>
>> I guess we could just add a second SPL_LOAD_IMAGE_METHOD in
>> common/spl/spl_ymodem.c for BOOT_DEVICE_BOARD.
>>
>> --
>> Stefan
>>
>>
>>>
>>> Regards,
>>>
>>>>> + return BOOT_DEVICE_BOARD;
>>>>>
>>>>>   /* BOOT_CFG1[7:4] - see IMX

Re: [U-Boot] [PATCH v1 2/2] imx: use BOOT_DEVICE_BOARD instead of UART

2017-08-27 Thread Stefan Agner
On 2017-08-27 01:45, Sébastien Szymanski wrote:
> Hello,
> 
>> On 25 Aug 2017, at 13:33, Stefano Babic <sba...@denx.de> wrote:
>>
>> On 16/08/2017 02:49, Stefan Agner wrote:
>>> From: Stefan Agner <stefan.ag...@toradex.com>
>>>
>>> i.MX 6 serial downloader is not necessarily booting via UART but can
>>> also boot from USB. In fact only some i.MX chips have serial
>>> downloader support via UART (e.g. 6UL/ULL and Vybrid) but all of
>>> them have serial downloader support via USB. Use the more appropriate
>>> BOOT_DEVICE_BOARD define which is used for ROM provided recovery
>>> mechanisms in general.
>>>
>>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>>> ---
>>>
>>> arch/arm/mach-imx/spl.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>>> index 836b334fa9..bcd1033fdb 100644
>>> --- a/arch/arm/mach-imx/spl.c
>>> +++ b/arch/arm/mach-imx/spl.c
>>> @@ -27,7 +27,7 @@ u32 spl_boot_device(void)
>>>  * BOOT_MODE - see IMX6DQRM Table 8-1
>>>  */
>>> if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>> -   return BOOT_DEVICE_UART;
> 
> Returning BOOT_DEVICE_UART here makes the SPL to load U-Boot from the
> debug UART using a ymodem transfer when enabled with
> CONFIG_SPL_YMODEM_SUPPORT like it is on the OPOS6ULDev board. This is
> now broken.

For reference, the change has been discussed here:
https://www.mail-archive.com/u-boot@lists.denx.de/msg259729.html

Returning UART is definitely wrong, because the boot ROM can also boot
from USB... 

As I mentioned in the other thread, ideally we should be able to do a
runtime detection to discriminate between UART and USB loader. I think
Stefano did not like that since it relies on undocumented features.

So BOOT_DEVICE is really ambiguous. Maybe BOOT_DEVICE_* should be a
bitfield? Then we could return BOOT_DEVICE_UART and BOOT_DEVICE_USB, and
boards can just compile in the support they need.


Changing the Y-Modem support to boot device BOOT_DEVICE_BOARD is not
possible since other SoCs use BOOT_DEVICE_UART.

I guess we could just add a second SPL_LOAD_IMAGE_METHOD in
common/spl/spl_ymodem.c for BOOT_DEVICE_BOARD.

--
Stefan


> 
> Regards,
> 
>>> +   return BOOT_DEVICE_BOARD;
>>>
>>> /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>>> switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>>> @@ -43,7 +43,7 @@ u32 spl_boot_device(void)
>>> }
>>> /* Reserved: Used to force Serial Downloader */
>>> case IMX6_BMODE_RESERVED:
>>> -   return BOOT_DEVICE_UART;
>>> +   return BOOT_DEVICE_BOARD;
>>> /* SATA: See 8.5.4, Table 8-20 */
>>> case IMX6_BMODE_SATA:
>>> return BOOT_DEVICE_SATA;
>>>
>>
>> Applied to u-boot-imx, -master, thanks !
>>
>> Best regards,
>> Stefano Babic
>>
>>
>> --
>> =
>> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
>> =
>> ___
>> 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


[U-Boot] [PATCH] disk: part: align buffer so it can be used with DMA enabled drivers

2017-08-23 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

When using ISO partitions with a DMA enabled block device driver
reading the ISO partition leads to unaligned DMA operations:
  CACHE: Misaligned operation at range [bffb7da8, bffb85a8]

Align the buffer to make sure we pass a buffer which works for
DMA operations.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 disk/part_iso.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/disk/part_iso.c b/disk/part_iso.c
index bb8ed658f2..8aef251f4e 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -24,7 +24,7 @@
 #undef CHECK_FOR_POWERPC_PLATTFORM
 #define CD_SECTSIZE 2048
 
-static unsigned char tmpbuf[CD_SECTSIZE];
+static unsigned char tmpbuf[CD_SECTSIZE] __aligned(ARCH_DMA_MINALIGN);
 
 unsigned long iso_dread(struct blk_desc *block_dev, lbaint_t start,
 lbaint_t blkcnt, void *buffer)
-- 
2.14.1

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


[U-Boot] [PATCH v2 7/8] apalis/colibri_imx6: use independent USB PID for SPL

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Use a completely independent USB Product ID for SPL. This allows
to differentiate a SDP running in SPL and SDP running in a U-Boot
which could not read the config block successfully.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Max Krummenacher <max.krummenac...@toradex.com>
---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c   | 13 +
 board/toradex/colibri_imx6/colibri_imx6.c | 13 +
 2 files changed, 26 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 8e5613cb12..edaca5d346 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1233,6 +1234,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index cbf7aa952a..0cc958a0a8 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1118,6 +1119,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
-- 
2.14.1

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


[U-Boot] [PATCH v2 5/8] spl: add serial download protocol (SDP) support

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add USB serial download protocol support to SPL. If the SoC started
in recovery mode the SPL will immediately switch to SDP and wait for
further downloads/commands from the host side.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Stefano Babic <sba...@denx.de>
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle
- Use BOOT_DEVICE_BOARD

 common/spl/Kconfig  |  6 ++
 common/spl/Makefile |  1 +
 common/spl/spl_sdp.c| 37 +
 drivers/usb/gadget/Makefile |  1 +
 4 files changed, 45 insertions(+)
 create mode 100644 common/spl/spl_sdp.c

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5176857506..b3436b3c28 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -668,6 +668,12 @@ config SPL_DFU_RAM
 
 endchoice
 
+config SPL_USB_SDP_SUPPORT
+   bool "Support SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in SPL. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
 endif
 
 config SPL_WATCHDOG_SUPPORT
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 112b3e6022..6255d4f73c 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -30,4 +30,5 @@ obj-$(CONFIG_$(SPL_TPL_)SATA_SUPPORT) += spl_sata.o
 obj-$(CONFIG_$(SPL_TPL_)DFU_SUPPORT) += spl_dfu.o
 obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
 obj-$(CONFIG_$(SPL_TPL_)RAM_SUPPORT) += spl_ram.o
+obj-$(CONFIG_$(SPL_TPL_)USB_SDP_SUPPORT) += spl_sdp.o
 endif
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
new file mode 100644
index 00..350bcdb056
--- /dev/null
+++ b/common/spl/spl_sdp.c
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2016 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int spl_sdp_load_image(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
+{
+   int ret;
+   const int controller_index = 0;
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init(controller_index);
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   return -ENODEV;
+   }
+
+   /* This command typically does not return but jumps to an image */
+   sdp_handle(controller_index);
+   error("SDP ended");
+
+   return -EINVAL;
+}
+SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6a007d1bcb..7258099c1c 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += g_dnl.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += f_dfu.o
+obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += f_sdp.o
 endif
 
 # new USB gadget layer dependencies
-- 
2.14.1

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


[U-Boot] [PATCH v2 4/8] cmd: add sdp command

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add a new command to start USB Serial Download Protocol (SDP)
state machine.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Łukasz Majewski <lu...@denx.de>
Reviewed-by: Stefano Babic <sba...@denx.de>
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle

 cmd/Kconfig  |  7 +++
 cmd/Makefile |  1 +
 cmd/usb_gadget_sdp.c | 50 ++
 3 files changed, 58 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 42d955c96a..d6d130edfa 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -895,6 +895,13 @@ config CMD_USB
help
  USB support.
 
+config CMD_USB_SDP
+   bool "sdp"
+   select USB_FUNCTION_SDP
+   help
+ Enables the command "sdp" which is used to have U-Boot emulating the
+ Serial Download Protocol (SDP) via USB.
+
 config CMD_USB_MASS_STORAGE
bool "UMS usb mass storage"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 13c86f8fcc..4ec0e175cd 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -131,6 +131,7 @@ obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
 obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
 
 obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o
+obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
 obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
 obj-$(CONFIG_CMD_XIMG) += ximg.o
 obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
new file mode 100644
index 00..b1d8b2858e
--- /dev/null
+++ b/cmd/usb_gadget_sdp.c
@@ -0,0 +1,50 @@
+/*
+ * cmd_sdp.c -- sdp command
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   int ret = CMD_RET_FAILURE;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   char *usb_controller = argv[1];
+   int controller_index = simple_strtoul(usb_controller, NULL, 0);
+   board_usb_init(controller_index, USB_INIT_DEVICE);
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init(controller_index);
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   goto exit;
+   }
+
+   /* This command typically does not return but jumps to an image */
+   sdp_handle(controller_index);
+   error("SDP ended");
+
+exit:
+   g_dnl_unregister();
+   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+
+   return ret;
+}
+
+U_BOOT_CMD(sdp, 2, 1, do_sdp,
+   "Serial Downloader Protocol",
+   "\n"
+   "  - serial downloader protocol via \n"
+);
-- 
2.14.1

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


[U-Boot] [PATCH v2 6/8] doc: add Serial Download Protocol documentation

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Document the U-Boot Serial Download Protocol implementation and
some typical use cases.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---
This ended up to be almost more a imx_usb documentation. But there
is really not much to document from a U-Boot side since actual usage
heavily depends on host side tooling...

This assumes that the necessary changes will get merged upstream:
https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored


Changes in v2: None

 doc/README.sdp | 100 +
 1 file changed, 100 insertions(+)
 create mode 100644 doc/README.sdp

diff --git a/doc/README.sdp b/doc/README.sdp
new file mode 100644
index 00..9b438c0746
--- /dev/null
+++ b/doc/README.sdp
@@ -0,0 +1,100 @@
+-
+SDP in U-Boot
+-
+
+SDP stands for serial download protocol. It is the protocol used in NXP's
+i.MX SoCs ROM Serial Downloader and provides means to download a program
+image to the chip over USB and UART serial connection.
+
+The implementation in U-Boot uses the USB Downloader Gadget (g_dnl) to
+provide a SDP implementation over USB. This allows to download program
+images to the target in SPL/U-Boot using the same protocol/tooling the
+SoC's recovery mechanism is using.
+
+The SDP protocol over USB is a USB HID class protocol. USB HID class
+protocols allow to access a USB device without OS specific drivers. The
+U-Boot implementation has primarly been tested using the open source
+imx_loader utility (https://github.com/toradex/imx_loader).
+
+The host side utilities are typically capable to interpret the i.MX
+specific image header (see doc/README.imximage). There are extensions
+for imx_loader's imx_usb utility which allow to interpret the U-Boot
+specific legacy image format (see mkimage(1)). Also the U-Boot side
+support beside the i.MX specific header the U-Boot legacy header.
+
+Usage
+-
+
+This implementation can be started in U-Boot using the sdp command
+(CONFIG_CMD_USB_SDP) or in SPL if Serial Downloader boot mode has been
+detected (CONFIG_SPL_USB_SDP_SUPPORT).
+
+A typical use case is downloading full U-Boot after SPL has been
+downloaded through the boot ROM's Serial Downloader. Using boot mode
+detection the SPL will run the SDP implementation automatically in
+this case:
+
+  # imx_usb SPL
+
+Targets Serial Console:
+
+  Trying to boot from USB SDP
+  SDP: initialize...
+  SDP: handle requests...
+
+At this point the SPL reenumerated as a new HID device and emulating
+the boot ROM's SDP protocol. The USB VID/PID will depend on standard
+U-Boot configurations CONFIG_G_DNL_(VENDOR|PRODUCT)_NUM. Make sure
+imx_usb is aware of the USB VID/PID for your device by adding a
+configuration entry in imx_usb.conf:
+
+  0x1b67:0x4fff, mx6_usb_sdp_spl.conf
+
+And the device specific configuration file mx6_usb_sdp_spl.conf:
+
+  mx6_spl_sdp
+  hid,uboot_header,1024,0x91,0x1000,1G,0x0090,0x4
+
+This allows to download the regular U-Boot with legacy image headers
+(u-boot.img) using a second invocation of imx_usb:
+
+  # imx_usb u-boot.img
+
+Furthermore, when U-Boot is running the sdp command can be used to
+download and run scripts:
+
+  # imx_usb script.scr
+
+imx_usb configuration files can be also used to download multiple
+files and of arbitrary types, e.g.
+
+  mx6_usb_sdp_uboot
+  hid,1024,0x1000,1G,0x00907000,0x31000
+  full.itb:load 0x1210
+  boot.scr:load 0x1200,jump 0x1200
+
+There is also a batch mode which allows imx_usb to handle multiple
+consecutive reenumerations by adding multiple VID/PID specifications
+in imx_usb.conf:
+
+  0x15a2:0x0061, mx6_usb_rom.conf, 0x1b67:0x4fff, mx6_usb_sdp_spl.conf
+
+In this mode the file to download (imx_usb job) needs to be specified
+in the configuration files.
+
+mx6_usb_rom.conf:
+
+  mx6_qsb
+  hid,1024,0x91,0x1000,1G,0x0090,0x4
+  SPL:jump header2
+
+mx6_usb_sdp_spl.conf:
+
+  mx6_spl_sdp
+  hid,uboot_header,1024,0x1000,1G,0x00907000,0x31000
+  u-boot.img:jump header2
+
+With that SPL and U-Boot can be downloaded with a single invocation
+of imx_usb without arguments:
+
+  # imx_usb
-- 
2.14.1

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


[U-Boot] [PATCH v2 8/8] apalis/colibri_imx6: enable SDP by default

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Enable Serial Download Protocol (SDP) in SPL and U-Boot. This is
useful to make use of imx_usb to download the complete U-Boot
(u-boot.img) after SPL has been downloaded. The U-Boot command
sdp allows to enumerate as SDP capable device again, e.g. to
download a Linux kernel and/or U-Boot script.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Max Krummenacher <max.krummenac...@toradex.com>
---

Changes in v2: None

 configs/apalis_imx6_defconfig  | 4 
 configs/colibri_imx6_defconfig | 4 
 2 files changed, 8 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 468a1fcac7..8f87f1d34c 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Apalis iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -33,6 +36,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index edbd87fe19..beb74b5ae5 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Colibri iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -33,6 +36,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
-- 
2.14.1

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


[U-Boot] [PATCH v2 3/8] usb: gadget: sdp: extend images compatible for jumps

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Support U-Boot images in SPL so that u-boot.img files can be
directly downloaded and executed. Furthermore support U-Boot
scripts download and execution in full U-Boot so that custom
recovery actions can be downloaded from the host in a third
step.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Łukasz Majewski <lu...@denx.de>
Reviewed-by: Stefano Babic <sba...@denx.de>
---

Changes in v2: None

 drivers/usb/gadget/f_sdp.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 9d82abcd69..0fae66beab 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #define HID_REPORT_ID_MASK 0x00ff
@@ -670,8 +672,22 @@ static void sdp_handle_in_ep(void)
sdp_func->state = SDP_STATE_TX_REGISTER_BUSY;
break;
case SDP_STATE_JUMP:
-   printf("Checking imxheader at 0x%08x\n", f_sdp->jmp_address);
-   status = sdp_jump_imxheader((void *)f_sdp->jmp_address);
+   printf("Jumping to header at 0x%08x\n", sdp_func->jmp_address);
+   status = sdp_jump_imxheader((void *)sdp_func->jmp_address);
+
+   /* If imx header fails, try some U-Boot specific headers */
+   if (status) {
+#ifdef CONFIG_SPL_BUILD
+   /* In SPL, allow jumps to U-Boot images */
+   struct spl_image_info spl_image = {};
+   spl_parse_image_header(_image,
+   (struct image_header *)sdp_func->jmp_address);
+   jump_to_image_no_args(_image);
+#else
+   /* In U-Boot, allow jumps to scripts */
+   source(sdp_func->jmp_address, "script@1");
+#endif
+   }
 
sdp_func->next_state = SDP_STATE_IDLE;
sdp_func->error_status = status;
-- 
2.14.1

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


[U-Boot] [PATCH v2 2/8] usb: gadget: add SDP driver

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add SDP (Serial Downloader Protocol) implementation for U-Boot. The
protocol is used in NXP SoC's boot ROM and allows to download program
images. Beside that, it can also be used to read/write registers and
download complete Device Configuration Data (DCD) sets. This basic
implementation supports downloading images with the imx header format
reading and writing registers.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle to allow specifying
  which USB controller should be used.
- Use #defines for security mode
- Improved types used in format strings

 drivers/usb/gadget/Kconfig  |   7 +
 drivers/usb/gadget/Makefile |   1 +
 drivers/usb/gadget/f_sdp.c  | 721 
 include/sdp.h   |  16 +
 4 files changed, 745 insertions(+)
 create mode 100644 drivers/usb/gadget/f_sdp.c
 create mode 100644 include/sdp.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 261ed128ac..225b66bc95 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -103,6 +103,13 @@ config USB_GADGET_DOWNLOAD
 
 if USB_GADGET_DOWNLOAD
 
+config USB_FUNCTION_SDP
+   bool "Enable USB SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in U-Boot. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
+
 config G_DNL_MANUFACTURER
string "Vendor name of USB device"
 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 5e316a7cff..6a007d1bcb 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
 obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o
 obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
 obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
+obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
 endif
 endif
 ifdef CONFIG_USB_ETHER
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
new file mode 100644
index 00..9d82abcd69
--- /dev/null
+++ b/drivers/usb/gadget/f_sdp.c
@@ -0,0 +1,721 @@
+/*
+ * f_sdp.c -- USB HID Serial Download Protocol
+ *
+ * Copyright (C) 2017 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * This file implements the Serial Download Protocol (SDP) as specified in
+ * the i.MX 6 Reference Manual. The SDP is a USB HID based protocol and
+ * allows to download images directly to memory. The implementation
+ * works with the imx_loader (imx_usb) USB client software on host side.
+ *
+ * Not all commands are implemented, e.g. WRITE_REGISTER, DCD_WRITE and
+ * SKIP_DCD_HEADER are only stubs.
+ *
+ * Parts of the implementation are based on f_dfu and f_thor.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define HID_REPORT_ID_MASK 0x00ff
+
+/*
+ * HID class requests
+ */
+#define HID_REQ_GET_REPORT 0x01
+#define HID_REQ_GET_IDLE   0x02
+#define HID_REQ_GET_PROTOCOL   0x03
+#define HID_REQ_SET_REPORT 0x09
+#define HID_REQ_SET_IDLE   0x0A
+#define HID_REQ_SET_PROTOCOL   0x0B
+
+#define HID_USAGE_PAGE_LEN 76
+
+struct hid_report {
+   u8 usage_page[HID_USAGE_PAGE_LEN];
+} __packed;
+
+#define SDP_READ_REGISTER  0x0101
+#define SDP_WRITE_REGISTER 0x0202
+#define SDP_WRITE_FILE 0x0404
+#define SDP_ERROR_STATUS   0x0505
+#define SDP_DCD_WRITE  0x0a0a
+#define SDP_JUMP_ADDRESS   0x0b0b
+#define SDP_SKIP_DCD_HEADER0x0c0c
+
+#define SDP_SECURITY_CLOSED0x12343412
+#define SDP_SECURITY_OPEN  0x56787856
+
+#define SDP_WRITE_FILE_COMPLETE0x
+#define SDP_WRITE_REGISTER_COMPLETE0x128A8A12
+#define SDP_SKIP_DCD_HEADER_COMPLETE   0x900DD009
+#define SDP_ERROR_IMXHEADER0x000a0533
+
+#define SDP_COMMAND_LEN16
+
+struct sdp_command {
+   u16 cmd;
+   u32 addr;
+   u8 format;
+   u32 cnt;
+   u32 data;
+   u8 rsvd;
+} __packed;
+
+enum sdp_state {
+   SDP_STATE_IDLE,
+   SDP_STATE_RX_DCD_DATA,
+   SDP_STATE_RX_FILE_DATA,
+   SDP_STATE_TX_SEC_CONF,
+   SDP_STATE_TX_SEC_CONF_BUSY,
+   SDP_STATE_TX_REGISTER,
+   SDP_STATE_TX_REGISTER_BUSY,
+   SDP_STATE_TX_STATUS,
+   SDP_STATE_TX_STATUS_BUSY,
+   SDP_STATE_JUMP,
+};
+
+struct f_sdp {
+   struct usb_function usb_function;
+
+   struct usb_descriptor_header**function;
+
+   u8  altsetting;
+   enum sdp_state  state;
+   enum sdp_state   

[U-Boot] [PATCH v2 1/8] imx: move imximage header to common location

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Move the imximage.h header file to a common location so we can make
use of it from U-Boot too.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Reviewed-by: Łukasz Majewski <lu...@denx.de>
---

Changes in v2: None

 {tools => include}/imximage.h | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename {tools => include}/imximage.h (100%)

diff --git a/tools/imximage.h b/include/imximage.h
similarity index 100%
rename from tools/imximage.h
rename to include/imximage.h
-- 
2.14.1

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


[U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-08-16 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This series adds NXP's Serial Download Protocol (SDP) support via
USB for SPL/U-Boot. It allows to download U-Boot via USB from a
(recovered) SPL using the same tools used to download SPL itself
(specifically imx_usb, but also sb_loader seems to work).

The idea has been brought up when the first targets started to make
use of SPL for DDR initialization, see:
https://lists.denx.de/pipermail/u-boot/2015-July/220330.html

The initial SDP implementation (patch 2) requires the payload to
have the imx specific headers (hence the move of the imx header
file in patch 1).

Patch 3 extends image header support beyond the SDP specification,
specifically implements also support for U-Boot headers. This
allows to use the same SPL/U-Boot binaries for recovery as used on
the regular boot device (SD/eMMC). For that to work also the host
side imx_usb tools needed an extension, currently available here:

https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored

(in case this patchset gets accepted in U-Boot, I plan to push
these imx_usb changes upstream as well)

The full patchset allows to download SPL and U-Boot over USB to a
target in recovery mode using the same usb_imx utility. Refer to
the new README.sdp for details how to use usb_imx in combination
with this implementation.

Changes in v2:
- Changed function signature of sdp_init/sdp_handle to allow specifying
  which USB controller should be used.
- Use #defines for security mode
- Improved types used in format strings
- Changed function signature of sdp_init/sdp_handle
- Use BOOT_DEVICE_BOARD

Stefan Agner (8):
  imx: move imximage header to common location
  usb: gadget: add SDP driver
  usb: gadget: sdp: extend images compatible for jumps
  cmd: add sdp command
  spl: add serial download protocol (SDP) support
  doc: add Serial Download Protocol documentation
  apalis/colibri_imx6: use independent USB PID for SPL
  apalis/colibri_imx6: enable SDP by default

 board/toradex/apalis_imx6/apalis_imx6.c   |  13 +
 board/toradex/colibri_imx6/colibri_imx6.c |  13 +
 cmd/Kconfig   |   7 +
 cmd/Makefile  |   1 +
 cmd/usb_gadget_sdp.c  |  50 ++
 common/spl/Kconfig|   6 +
 common/spl/Makefile   |   1 +
 common/spl/spl_sdp.c  |  37 ++
 configs/apalis_imx6_defconfig |   4 +
 configs/colibri_imx6_defconfig|   4 +
 doc/README.sdp| 100 
 drivers/usb/gadget/Kconfig|   7 +
 drivers/usb/gadget/Makefile   |   2 +
 drivers/usb/gadget/f_sdp.c| 737 ++
 {tools => include}/imximage.h |   0
 include/sdp.h |  16 +
 16 files changed, 998 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c
 create mode 100644 common/spl/spl_sdp.c
 create mode 100644 doc/README.sdp
 create mode 100644 drivers/usb/gadget/f_sdp.c
 rename {tools => include}/imximage.h (100%)
 create mode 100644 include/sdp.h

-- 
2.14.1

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


[U-Boot] [PATCH v1 2/2] imx: use BOOT_DEVICE_BOARD instead of UART

2017-08-15 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

i.MX 6 serial downloader is not necessarily booting via UART but can
also boot from USB. In fact only some i.MX chips have serial
downloader support via UART (e.g. 6UL/ULL and Vybrid) but all of
them have serial downloader support via USB. Use the more appropriate
BOOT_DEVICE_BOARD define which is used for ROM provided recovery
mechanisms in general.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

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

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 836b334fa9..bcd1033fdb 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -27,7 +27,7 @@ u32 spl_boot_device(void)
 * BOOT_MODE - see IMX6DQRM Table 8-1
 */
if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
-   return BOOT_DEVICE_UART;
+   return BOOT_DEVICE_BOARD;
 
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
@@ -43,7 +43,7 @@ u32 spl_boot_device(void)
}
/* Reserved: Used to force Serial Downloader */
case IMX6_BMODE_RESERVED:
-   return BOOT_DEVICE_UART;
+   return BOOT_DEVICE_BOARD;
/* SATA: See 8.5.4, Table 8-20 */
case IMX6_BMODE_SATA:
return BOOT_DEVICE_SATA;
-- 
2.14.1

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


[U-Boot] [PATCH v1 1/2] imx: fix USB boot mode detection for i.MX 6UL and 6ULL

2017-08-15 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add the reserved boot mode used in the bmode command for i.MX 6UL
and 6ULL as introduced in commit 3fd9579085fa ("imx: mx6ull: fix USB
bmode for i.MX 6UL and 6ULL").

Also replace BMODE_UART with BMODE_RESERVED, which is more appropriate.
Commit 96aac843b68d ("imx: Use IMX6_BMODE_* macros instead of numericals")
added macros for boot modes, in the process the reserved boot mode got
named BMODE_UART. We use the reserved boot mode in the bmode command to
let the boot ROM enter serial downloader recovery mode. But this is only
a side effect, the actual boot mode is reserved...

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---
Afaik there is no board yet using SPL on 6UL/ULL...

 arch/arm/include/asm/mach-imx/sys_proto.h | 7 ++-
 arch/arm/mach-imx/spl.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h 
b/arch/arm/include/asm/mach-imx/sys_proto.h
index 046df6291a..d94c095118 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -69,8 +69,13 @@ enum imx6_bmode_emi {
 
 enum imx6_bmode {
IMX6_BMODE_EMI,
-   IMX6_BMODE_UART,
+#if defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
+   IMX6_BMODE_QSPI,
+   IMX6_BMODE_RESERVED,
+#else
+   IMX6_BMODE_RESERVED,
IMX6_BMODE_SATA,
+#endif
IMX6_BMODE_SERIAL_ROM,
IMX6_BMODE_SD,
IMX6_BMODE_ESD,
diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 75698c48ea..836b334fa9 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -42,7 +42,7 @@ u32 spl_boot_device(void)
break;
}
/* Reserved: Used to force Serial Downloader */
-   case IMX6_BMODE_UART:
+   case IMX6_BMODE_RESERVED:
return BOOT_DEVICE_UART;
/* SATA: See 8.5.4, Table 8-20 */
case IMX6_BMODE_SATA:
-- 
2.14.1

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


Re: [U-Boot] [PATCH v1 2/7] usb: gadget: add SDP driver

2017-08-15 Thread Stefan Agner
On 2017-08-10 01:14, Stefano Babic wrote:
> Hi Stefan,
> 
> On 05/08/2017 01:38, Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> Add SDP (Serial Downloader Protocol) implementation for U-Boot. The
>> protocol is used in NXP SoC's boot ROM and allows to download program
>> images. Beside that, it can also be used to read/write registers and
>> download complete Device Configuration Data (DCD) sets. This basic
>> implementation supports downloading images with the imx header format
>> and reading registers.
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> ---
>>
>>  drivers/usb/gadget/Kconfig  |   7 +
>>  drivers/usb/gadget/Makefile |   1 +
>>  drivers/usb/gadget/f_sdp.c  | 723 
>> 
>>  include/sdp.h   |  16 +
>>  4 files changed, 747 insertions(+)
>>  create mode 100644 drivers/usb/gadget/f_sdp.c
>>  create mode 100644 include/sdp.h
>>
>> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
>> index 261ed128ac..225b66bc95 100644
>> --- a/drivers/usb/gadget/Kconfig
>> +++ b/drivers/usb/gadget/Kconfig
>> @@ -103,6 +103,13 @@ config USB_GADGET_DOWNLOAD
>>
>>  if USB_GADGET_DOWNLOAD
>>
>> +config USB_FUNCTION_SDP
>> +bool "Enable USB SDP (Serial Download Protocol)"
>> +help
>> +  Enable Serial Download Protocol (SDP) device support in U-Boot. This
>> +  allows to download images into memory and execute (jump to) them
>> +  using the same protocol as implemented by the i.MX family's boot ROM.
>> +
>>  config G_DNL_MANUFACTURER
>>  string "Vendor name of USB device"
>>
>> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
>> index 5e316a7cff..6a007d1bcb 100644
>> --- a/drivers/usb/gadget/Makefile
>> +++ b/drivers/usb/gadget/Makefile
>> @@ -28,6 +28,7 @@ obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
>>  obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o
>>  obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
>>  obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
>> +obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
>>  endif
>>  endif
>>  ifdef CONFIG_USB_ETHER
>> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
>> new file mode 100644
>> index 00..eb89695aaf
>> --- /dev/null
>> +++ b/drivers/usb/gadget/f_sdp.c
>> @@ -0,0 +1,723 @@
>> +/*
>> + * f_sdp.c -- USB HID Serial Download Protocol
>> + *
>> + * Copyright (C) 2016 Toradex
>> + * Author: Stefan Agner <stefan.ag...@toradex.com>
>> + *
>> + * This file implements the Serial Download Protocol (SDP) as specified in
>> + * the i.MX 6 Reference Manual. The SDP is a USB HID based protocol and
>> + * allows to download images directly to memory. The implementation
>> + * works with the imx_loader (imx_usb) USB client software on host side.
>> + *
>> + * Not all commands are implemented, e.g. WRITE_REGISTER, DCD_WRITE and
>> + * SKIP_DCD_HEADER are only stubs.
>> + *
>> + * Parts of the implementation are based on f_dfu and f_thor.
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define HID_REPORT_ID_MASK  0x00ff
>> +
>> +/*
>> + * HID class requests
>> + */
>> +#define HID_REQ_GET_REPORT  0x01
>> +#define HID_REQ_GET_IDLE0x02
>> +#define HID_REQ_GET_PROTOCOL0x03
>> +#define HID_REQ_SET_REPORT  0x09
>> +#define HID_REQ_SET_IDLE0x0A
>> +#define HID_REQ_SET_PROTOCOL0x0B
>> +
>> +#define HID_USAGE_PAGE_LEN  76
>> +
>> +struct hid_report {
>> +u8 usage_page[HID_USAGE_PAGE_LEN];
>> +} __packed;
>> +
>> +#define SDP_READ_REGISTER   0x0101
>> +#define SDP_WRITE_REGISTER  0x0202
>> +#define SDP_WRITE_FILE  0x0404
>> +#define SDP_ERROR_STATUS0x0505
>> +#define SDP_DCD_WRITE   0x0a0a
>> +#define SDP_JUMP_ADDRESS0x0b0b
>> +#define SDP_SKIP_DCD_HEADER 0x0c0c
> 
> It looks like that I am again out of sync with documentation. Where is
> defined SDP_SKIP_DCD_HEADER ? It is undefined for MX6Q/D, Solo and DL.
> 

This is only available in newer SoC's e.g. i.MX 7.

It allo

Re: [U-Boot] [PATCH v1 5/7] spl: add serial download protocol (SDP) support

2017-08-08 Thread Stefan Agner
Stefano,

One question below:

On 2017-08-04 16:38, Stefan Agner wrote:
> From: Stefan Agner <stefan.ag...@toradex.com>
> 
> Add USB serial download protocol support to SPL. If the SoC started
> in recovery mode the SPL will immediately switch to SDP and wait for
> further downloads/commands from the host side.
> 
> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
> ---
> 
>  common/spl/Kconfig  |  6 ++
>  common/spl/Makefile |  1 +
>  common/spl/spl_sdp.c| 38 ++
>  drivers/usb/gadget/Makefile |  1 +
>  4 files changed, 46 insertions(+)
>  create mode 100644 common/spl/spl_sdp.c
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index 4de81392b0..95378b98a0 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -646,6 +646,12 @@ config SPL_DFU_RAM
>  
>  endchoice
>  
> +config SPL_USB_SDP_SUPPORT
> + bool "Support SDP (Serial Download Protocol)"
> + help
> +   Enable Serial Download Protocol (SDP) device support in SPL. This
> +   allows to download images into memory and execute (jump to) them
> +   using the same protocol as implemented by the i.MX family's boot ROM.
>  endif
>  
>  config SPL_WATCHDOG_SUPPORT
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 47a64dd7d0..a979560acf 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -29,4 +29,5 @@ obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
>  obj-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o
>  obj-$(CONFIG_SPL_SPI_LOAD) += spl_spi.o
>  obj-$(CONFIG_SPL_RAM_SUPPORT) += spl_ram.o
> +obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += spl_sdp.o
>  endif
> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
> new file mode 100644
> index 00..faa74b8bec
> --- /dev/null
> +++ b/common/spl/spl_sdp.c
> @@ -0,0 +1,38 @@
> +/*
> + * (C) Copyright 2016 Toradex
> + * Author: Stefan Agner <stefan.ag...@toradex.com>
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static int spl_sdp_load_image(struct spl_image_info *spl_image,
> +   struct spl_boot_device *bootdev)
> +{
> + int ret;
> +
> + g_dnl_clear_detach();
> + g_dnl_register("usb_dnl_sdp");
> +
> + ret = sdp_init();
> + if (ret) {
> + error("SDP init failed: %d", ret);
> + return -ENODEV;
> + }
> +
> + ret = sdp_handle();
> + if (ret) {
> + error("SDP failed: %d", ret);
> + return -ENODEV;
> + }
> +
> + return 0;
> +}
> +SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_UART, spl_sdp_load_image);


We currently use BOOT_DEVICE_UART when serial downloader boot mode is
detected. This can be either USB or UART...

In fact, USB is probably much more often used since only 6UL/ULL have
UART serial downloader support afact...

There is BOOT_DEVICE_BOARD which is used by e.g. Sunxi in case the boot
ROM mechanism is used, what do you think, should be change that?

Ideally we should be able to discriminate between USB and UART. But I
don't think its possible... (the USBPH0_PWD method likely does not work
since even in the UART case the boot ROM will initialize the USB PHY
first, at least according to the flow diagram in ULL's Chapter 9...)

The i.MX 7 which has the new Boot Information block actually only
support USB serial downloader...

Thoughts?

--
Stefan


> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> index 6a007d1bcb..7258099c1c 100644
> --- a/drivers/usb/gadget/Makefile
> +++ b/drivers/usb/gadget/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
>  ifdef CONFIG_SPL_BUILD
>  obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += g_dnl.o
>  obj-$(CONFIG_SPL_DFU_SUPPORT) += f_dfu.o
> +obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += f_sdp.o
>  endif
>  
>  # new USB gadget layer dependencies
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 5/7] spl: add serial download protocol (SDP) support

2017-08-08 Thread Stefan Agner
On 2017-08-08 03:43, Lothar Waßmann wrote:
> Hi,
> 
> On Fri,  4 Aug 2017 16:38:11 -0700 Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> Add USB serial download protocol support to SPL. If the SoC started
>> in recovery mode the SPL will immediately switch to SDP and wait for
>> further downloads/commands from the host side.
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> ---
>>
>>  common/spl/Kconfig  |  6 ++
>>  common/spl/Makefile |  1 +
>>  common/spl/spl_sdp.c| 38 ++
>>  drivers/usb/gadget/Makefile |  1 +
>>  4 files changed, 46 insertions(+)
>>  create mode 100644 common/spl/spl_sdp.c
>>
>> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
>> index 4de81392b0..95378b98a0 100644
>> --- a/common/spl/Kconfig
>> +++ b/common/spl/Kconfig
>> @@ -646,6 +646,12 @@ config SPL_DFU_RAM
>>
>>  endchoice
>>
>> +config SPL_USB_SDP_SUPPORT
>> +bool "Support SDP (Serial Download Protocol)"
>> +help
>> +  Enable Serial Download Protocol (SDP) device support in SPL. This
>> +  allows to download images into memory and execute (jump to) them
>> +  using the same protocol as implemented by the i.MX family's boot ROM.
>>  endif
>>
>>  config SPL_WATCHDOG_SUPPORT
>> diff --git a/common/spl/Makefile b/common/spl/Makefile
>> index 47a64dd7d0..a979560acf 100644
>> --- a/common/spl/Makefile
>> +++ b/common/spl/Makefile
>> @@ -29,4 +29,5 @@ obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
>>  obj-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o
>>  obj-$(CONFIG_SPL_SPI_LOAD) += spl_spi.o
>>  obj-$(CONFIG_SPL_RAM_SUPPORT) += spl_ram.o
>> +obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += spl_sdp.o
>>  endif
>> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
>> new file mode 100644
>> index 00..faa74b8bec
>> --- /dev/null
>> +++ b/common/spl/spl_sdp.c
>> @@ -0,0 +1,38 @@
>> +/*
>> + * (C) Copyright 2016 Toradex
>> + * Author: Stefan Agner <stefan.ag...@toradex.com>
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +static int spl_sdp_load_image(struct spl_image_info *spl_image,
>> +  struct spl_boot_device *bootdev)
>> +{
>> +int ret;
>> +
>> +g_dnl_clear_detach();
>> +g_dnl_register("usb_dnl_sdp");
>> +
>> +ret = sdp_init();
>> +if (ret) {
>> +error("SDP init failed: %d", ret);
>> +return -ENODEV;
>> +}
>> +
>> +ret = sdp_handle();
>>
> This function (and sdp_init() above) always return 0. Do you expect to
> be changed in future? Otherwise the return type of those functions
> should be changed to void.
> 

I followed f_thor's approach here which use int in both functions, but
yeah, in the SDP case there is currently no error condition.

Not sure there will be one added in the future, I guess we could just
make it void for now.

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


Re: [U-Boot] [PATCH v1 0/7] imx: add USB Serial Download Protocol (SDP) support

2017-08-08 Thread Stefan Agner
On 2017-08-08 02:15, Stefano Babic wrote:
> Hi Stefan,
> 
> On 07/08/2017 20:06, Stefan Agner wrote:
>> Hi Eric,
>>
>> On 2017-08-06 08:19, Eric Nelson wrote:
>>> Hi Stefan,
>>>
>>> On 08/04/2017 04:38 PM, Stefan Agner wrote:
>>>> From: Stefan Agner <stefan.ag...@toradex.com>
>>>>
>>>> This series adds NXP's Serial Download Protocol (SDP) support via
>>>> USB for SPL/U-Boot. It allows to download U-Boot via USB from a
>>>> (recovered) SPL using the same tools used to download SPL itself
>>>> (specifically imx_usb, but also sb_loader seems to work).
>>>>
>>>
>>> Nice!
>>>
>>>> The idea has been brought up when the first targets started to make
>>>> use of SPL for DDR initialization, see:
>>>> https://lists.denx.de/pipermail/u-boot/2015-July/220330.html
>>>>
>>>
>>> There have been lots of discussions surrounding the use of SDP,
>>> and this seems to be a nice alternative to using the i.MX "plugin"
>>> mode that I explored a while back:
>>>
>>> https://lists.denx.de/pipermail/u-boot/2017-July/thread.html#298266
>>>
>>
>> Hm, wasn't aware of that particular effort, thanks for pointing to it.
>> From a quick glance, it did not work out so far, is this correct?
>>
>> I looked into plugin mode also a little bit, but I did not continue to
>> look into it after reading this sentence in the i.MX 6 RM:
>>
>> 8.7 Plugin Image
>> The boot ROM detects the image type using the plugin flag of the boot
>> data structure (see
>> Boot Data Structure). If the plugin flag is 1, then the ROM uses the
>> image as a plugin
>> function. The function must initialize the boot device and copy the
>> program image to the
>> final location. At the end the plugin function must return with the
>> program image
>> parameters. (See High level boot sequence for details about boot flow).
>>
>>
>> So if SPL should work as a plugin as NXP defines it, SPL is supposed to
>> load the image from somewhere. The boot ROM then only takes care about
>> image verification and further boot steps, but it's the plugins job to
>> get the image from somewhere and store it in RAM.
>>
> 
> Right, and this is also the weak point. There are also some cases (at
> least, in some projects of mine) where this conflicts with the setup of
> the RAM controller. We need to set the RAM controller to load the code
> or to fight with the limitation of the IRAM.
> 
>> Afact this is not really helpful in our case. We would want the boot ROM
>> to go through the boot sequence (again).
> 
> Agree. This makes the whole boot process easier to understand - and not
> to mention the fact that code of BootROM is not officially published,
> and we cannot know what it exactly does.
> 

Yeah, I really wish NXP would add some functionality and document the
boot ROM clearly.

One issue I have currently is when the SPL gets downloaded via USB
serial download when the SoC entered serial download due to unbootable
device, spl_boot_mode cannot detect that.

Downstream uses "circumstantial evidence" to get this info:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

And I just learned that i.MX 7 Boot ROM actually provides a structure
with boot info now, see get_boot_device in arch/arm/mach-imx/mx7/soc.c.

If anybody has a reliable/nicer mechanism than the is_boot_from_usb from
downstream for i.MX 6 that I am all ears.

>>
>> Unless returning an error/invalid image causes the boot ROM to go
>> through boot sequence again?
>>
>>
>> The nice thing with our own SDP implementation is we can reuse it even
>> from within U-Boot again, e.g. to download a kernel/initramfs
> 
> Right - I think SDP is a nice solution, and thanks for your effort !
> 
>>
>>>> The initial SDP implementation (patch 2) requires the payload to
>>>> have the imx specific headers (hence the move of the imx header
>>>> file in patch 1).
>>>>
>>>> Patch 3 extends image header support beyond the SDP specification,
>>>> specifically implements also support for U-Boot headers. This
>>>> allows to use the same SPL/U-Boot binaries for recovery as used on
>>>> the regular boot device (SD/eMMC). For that to work also the host
>>>> side imx_usb tools needed an extension, currently available here:
>>>>
>>>> https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_r

Re: [U-Boot] [PATCH v1 0/7] imx: add USB Serial Download Protocol (SDP) support

2017-08-07 Thread Stefan Agner
Hi Eric,

On 2017-08-06 08:19, Eric Nelson wrote:
> Hi Stefan,
> 
> On 08/04/2017 04:38 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
>> This series adds NXP's Serial Download Protocol (SDP) support via
>> USB for SPL/U-Boot. It allows to download U-Boot via USB from a
>> (recovered) SPL using the same tools used to download SPL itself
>> (specifically imx_usb, but also sb_loader seems to work).
>>
> 
> Nice!
> 
>> The idea has been brought up when the first targets started to make
>> use of SPL for DDR initialization, see:
>> https://lists.denx.de/pipermail/u-boot/2015-July/220330.html
>>
> 
> There have been lots of discussions surrounding the use of SDP,
> and this seems to be a nice alternative to using the i.MX "plugin"
> mode that I explored a while back:
> 
> https://lists.denx.de/pipermail/u-boot/2017-July/thread.html#298266
> 

Hm, wasn't aware of that particular effort, thanks for pointing to it.
From a quick glance, it did not work out so far, is this correct?

I looked into plugin mode also a little bit, but I did not continue to
look into it after reading this sentence in the i.MX 6 RM:

8.7 Plugin Image
The boot ROM detects the image type using the plugin flag of the boot
data structure (see
Boot Data Structure). If the plugin flag is 1, then the ROM uses the
image as a plugin
function. The function must initialize the boot device and copy the
program image to the
final location. At the end the plugin function must return with the
program image
parameters. (See High level boot sequence for details about boot flow).


So if SPL should work as a plugin as NXP defines it, SPL is supposed to
load the image from somewhere. The boot ROM then only takes care about
image verification and further boot steps, but it's the plugins job to
get the image from somewhere and store it in RAM.

Afact this is not really helpful in our case. We would want the boot ROM
to go through the boot sequence (again).

Unless returning an error/invalid image causes the boot ROM to go
through boot sequence again?


The nice thing with our own SDP implementation is we can reuse it even
from within U-Boot again, e.g. to download a kernel/initramfs

>> The initial SDP implementation (patch 2) requires the payload to
>> have the imx specific headers (hence the move of the imx header
>> file in patch 1).
>>
>> Patch 3 extends image header support beyond the SDP specification,
>> specifically implements also support for U-Boot headers. This
>> allows to use the same SPL/U-Boot binaries for recovery as used on
>> the regular boot device (SD/eMMC). For that to work also the host
>> side imx_usb tools needed an extension, currently available here:
>>
>> https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored
>>
>> The full patchset allows to download SPL and U-Boot over USB to a
>> target in recovery mode using the same usb_imx utility:
> 
> imx_usb?
> 

Yeah right, sorry.

>> The usb_imx utility also has a batch mode which allows to download
>> multiple artifacts with a single invocation. The details are
>> outlined in the imx_usb commit message:
>> https://github.com/toradex/imx_loader/commit/5434415d921f1cc4d22332d9558bed6d42db9f60
>>
>> In case this patchset gets accepted in U-Boot, I plan to push the
>> imx_usb changes upstream as well.
>>
> 
> Do you have numbers for how much code/data size this adds to SPL?
> 

Besides the protocol implementation also general USB (gadget) support is
required, hence it adds quite a bit.


Without USB Gadget/SDP support (Apalis iMX6 SPL):

$ arm-linux-gnueabihf-size spl/u-boot-spl
   textdata bss dec hex filename
  245523808  92   284526f24 spl/u-boot-spl


With USB Gadget/SDP support:

$ arm-linux-gnueabihf-size spl/u-boot-spl
   textdata bss dec hex filename
  4254946791984   49212c03c spl/u-boot-spl


> I believe some i.MX users have struggled to stay within the
> size of internal RAM.

Hm, I think the limit is somewhere around 64kiB? In our case we are
still well below...

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


[U-Boot] [PATCH v1 5/7] spl: add serial download protocol (SDP) support

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add USB serial download protocol support to SPL. If the SoC started
in recovery mode the SPL will immediately switch to SDP and wait for
further downloads/commands from the host side.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 common/spl/Kconfig  |  6 ++
 common/spl/Makefile |  1 +
 common/spl/spl_sdp.c| 38 ++
 drivers/usb/gadget/Makefile |  1 +
 4 files changed, 46 insertions(+)
 create mode 100644 common/spl/spl_sdp.c

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4de81392b0..95378b98a0 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -646,6 +646,12 @@ config SPL_DFU_RAM
 
 endchoice
 
+config SPL_USB_SDP_SUPPORT
+   bool "Support SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in SPL. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
 endif
 
 config SPL_WATCHDOG_SUPPORT
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 47a64dd7d0..a979560acf 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -29,4 +29,5 @@ obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o
 obj-$(CONFIG_SPL_SPI_LOAD) += spl_spi.o
 obj-$(CONFIG_SPL_RAM_SUPPORT) += spl_ram.o
+obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += spl_sdp.o
 endif
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
new file mode 100644
index 00..faa74b8bec
--- /dev/null
+++ b/common/spl/spl_sdp.c
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2016 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int spl_sdp_load_image(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
+{
+   int ret;
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init();
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   return -ENODEV;
+   }
+
+   ret = sdp_handle();
+   if (ret) {
+   error("SDP failed: %d", ret);
+   return -ENODEV;
+   }
+
+   return 0;
+}
+SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_UART, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6a007d1bcb..7258099c1c 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += g_dnl.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += f_dfu.o
+obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += f_sdp.o
 endif
 
 # new USB gadget layer dependencies
-- 
2.13.3

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


[U-Boot] [PATCH v1 6/7] apalis/colibri_imx6: use independent USB PID for SPL

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Use a completely independent USB Product ID for SPL. This allows
to differentiate a SDP running in SPL and SDP running in a U-Boot
which could not read the config block successfully.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Max Krummenacher <max.krummenac...@toradex.com>
---

 board/toradex/apalis_imx6/apalis_imx6.c   | 13 +
 board/toradex/colibri_imx6/colibri_imx6.c | 13 +
 2 files changed, 26 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 8e5613cb12..edaca5d346 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1233,6 +1234,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index cbf7aa952a..0cc958a0a8 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1118,6 +1119,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
-- 
2.13.3

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


[U-Boot] [PATCH v1 7/7] apalis/colibri_imx6: enable SDP by default

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Enable Serial Download Protocol (SDP) in SPL and U-Boot. This is
useful to make use of imx_usb to download the complete U-Boot
(u-boot.img) after SPL has been downloaded. The U-Boot command
sdp allows to enumerate as SDP capable device again, e.g. to
download a Linux kernel and/or U-Boot script.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
Acked-by: Max Krummenacher <max.krummenac...@toradex.com>
---

 configs/apalis_imx6_defconfig  | 4 
 configs/colibri_imx6_defconfig | 4 
 2 files changed, 8 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 4d88e70200..2a271f002c 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Apalis iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -31,6 +34,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DFU=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_GPIO=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index a23975f858..d5d3e7a143 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Colibri iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -31,6 +34,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DFU=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_GPIO=y
-- 
2.13.3

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


[U-Boot] [PATCH v1 2/7] usb: gadget: add SDP driver

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add SDP (Serial Downloader Protocol) implementation for U-Boot. The
protocol is used in NXP SoC's boot ROM and allows to download program
images. Beside that, it can also be used to read/write registers and
download complete Device Configuration Data (DCD) sets. This basic
implementation supports downloading images with the imx header format
and reading registers.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/usb/gadget/Kconfig  |   7 +
 drivers/usb/gadget/Makefile |   1 +
 drivers/usb/gadget/f_sdp.c  | 723 
 include/sdp.h   |  16 +
 4 files changed, 747 insertions(+)
 create mode 100644 drivers/usb/gadget/f_sdp.c
 create mode 100644 include/sdp.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 261ed128ac..225b66bc95 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -103,6 +103,13 @@ config USB_GADGET_DOWNLOAD
 
 if USB_GADGET_DOWNLOAD
 
+config USB_FUNCTION_SDP
+   bool "Enable USB SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in U-Boot. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
+
 config G_DNL_MANUFACTURER
string "Vendor name of USB device"
 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 5e316a7cff..6a007d1bcb 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
 obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o
 obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
 obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
+obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
 endif
 endif
 ifdef CONFIG_USB_ETHER
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
new file mode 100644
index 00..eb89695aaf
--- /dev/null
+++ b/drivers/usb/gadget/f_sdp.c
@@ -0,0 +1,723 @@
+/*
+ * f_sdp.c -- USB HID Serial Download Protocol
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * This file implements the Serial Download Protocol (SDP) as specified in
+ * the i.MX 6 Reference Manual. The SDP is a USB HID based protocol and
+ * allows to download images directly to memory. The implementation
+ * works with the imx_loader (imx_usb) USB client software on host side.
+ *
+ * Not all commands are implemented, e.g. WRITE_REGISTER, DCD_WRITE and
+ * SKIP_DCD_HEADER are only stubs.
+ *
+ * Parts of the implementation are based on f_dfu and f_thor.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define HID_REPORT_ID_MASK 0x00ff
+
+/*
+ * HID class requests
+ */
+#define HID_REQ_GET_REPORT 0x01
+#define HID_REQ_GET_IDLE   0x02
+#define HID_REQ_GET_PROTOCOL   0x03
+#define HID_REQ_SET_REPORT 0x09
+#define HID_REQ_SET_IDLE   0x0A
+#define HID_REQ_SET_PROTOCOL   0x0B
+
+#define HID_USAGE_PAGE_LEN 76
+
+struct hid_report {
+   u8 usage_page[HID_USAGE_PAGE_LEN];
+} __packed;
+
+#define SDP_READ_REGISTER  0x0101
+#define SDP_WRITE_REGISTER 0x0202
+#define SDP_WRITE_FILE 0x0404
+#define SDP_ERROR_STATUS   0x0505
+#define SDP_DCD_WRITE  0x0a0a
+#define SDP_JUMP_ADDRESS   0x0b0b
+#define SDP_SKIP_DCD_HEADER0x0c0c
+
+#define SDP_WRITE_FILE_COMPLETE0x
+#define SDP_WRITE_REGISTER_COMPLETE0x128A8A12
+#define SDP_SKIP_DCD_HEADER_COMPLETE   0x900DD009
+#define SDP_ERROR_IMXHEADER0x000a0533
+
+#define SDP_COMMAND_LEN16
+
+struct sdp_command {
+   u16 cmd;
+   u32 addr;
+   u8 format;
+   u32 cnt;
+   u32 data;
+   u8 rsvd;
+} __packed;
+
+enum sdp_state {
+   SDP_STATE_IDLE,
+   SDP_STATE_RX_DCD_DATA,
+   SDP_STATE_RX_FILE_DATA,
+   SDP_STATE_TX_SEC_CONF,
+   SDP_STATE_TX_SEC_CONF_BUSY,
+   SDP_STATE_TX_REGISTER,
+   SDP_STATE_TX_REGISTER_BUSY,
+   SDP_STATE_TX_STATUS,
+   SDP_STATE_TX_STATUS_BUSY,
+   SDP_STATE_JUMP,
+};
+
+struct f_sdp {
+   struct usb_function usb_function;
+
+   struct usb_descriptor_header**function;
+
+   u8  altsetting;
+   enum sdp_state  state;
+   enum sdp_state  next_state;
+   u32 dnl_address;
+   u32 dnl_bytes_remaining;
+   u32 jmp_address;
+   boolalways_send_status;
+   u32 error_status;
+
+   /* EP0

[U-Boot] [PATCH v1 4/7] cmd: add sdp command

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Add a new command to start USB Serial Download Protocol (SDP)
state machine.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 cmd/Kconfig  |  7 +++
 cmd/Makefile |  1 +
 cmd/usb_gadget_sdp.c | 53 
 3 files changed, 61 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index f18efc1e88..87333b3a97 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -665,6 +665,13 @@ config CMD_DFU
  Enables the command "dfu" which is used to have U-Boot create a DFU
  class device via USB.
 
+config CMD_USB_SDP
+   bool "sdp"
+   select USB_FUNCTION_SDP
+   help
+ Enables the command "sdp" which is used to have U-Boot emulating the
+ Serial Download Protocol (SDP) via USB.
+
 config CMD_USB_MASS_STORAGE
bool "UMS usb mass storage"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index bd231f24d8..e0b5940ba6 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -131,6 +131,7 @@ obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
 obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
 
 obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o
+obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
 obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
 obj-$(CONFIG_CMD_XIMG) += ximg.o
 obj-$(CONFIG_YAFFS2) += yaffs2.o
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
new file mode 100644
index 00..09ddb4f3aa
--- /dev/null
+++ b/cmd/usb_gadget_sdp.c
@@ -0,0 +1,53 @@
+/*
+ * cmd_sdp.c -- sdp command
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner <stefan.ag...@toradex.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   int ret = CMD_RET_SUCCESS;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   char *usb_controller = argv[1];
+   int controller_index = simple_strtoul(usb_controller, NULL, 0);
+   board_usb_init(controller_index, USB_INIT_DEVICE);
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init();
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   ret = CMD_RET_FAILURE;
+   goto exit;
+   }
+
+   ret = sdp_handle();
+   if (ret) {
+   error("SDP failed: %d", ret);
+   ret = CMD_RET_FAILURE;
+   goto exit;
+   }
+
+exit:
+   g_dnl_unregister();
+
+   return ret;
+}
+
+U_BOOT_CMD(sdp, 2, 1, do_sdp,
+   "Serial Downloader Protocol",
+   "\n"
+   "  - serial downloader protocol via \n"
+);
-- 
2.13.3

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


[U-Boot] [PATCH v1 3/7] usb: gadget: sdp: extend images compatible for jumps

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Support U-Boot images in SPL so that u-boot.img files can be
directly downloaded and executed. Furthermore support U-Boot
scripts download and execution in full U-Boot so that custom
recovery actions can be downloaded from the host in a third
step.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 drivers/usb/gadget/f_sdp.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index eb89695aaf..9a752843f0 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #define HID_REPORT_ID_MASK 0x00ff
@@ -672,8 +674,22 @@ static void sdp_handle_in_ep(void)
sdp_func->state = SDP_STATE_TX_REGISTER_BUSY;
break;
case SDP_STATE_JUMP:
-   printf("Checking imxheader at 0x%08x\n", f_sdp->jmp_address);
-   status = sdp_jump_imxheader((void *)f_sdp->jmp_address);
+   printf("Jumping to header at 0x%08x\n", sdp_func->jmp_address);
+   status = sdp_jump_imxheader((void *)sdp_func->jmp_address);
+
+   /* If imx header fails, try some U-Boot specific headers */
+   if (status) {
+#ifdef CONFIG_SPL_BUILD
+   /* In SPL, allow jumps to U-Boot images */
+   struct spl_image_info spl_image = {};
+   spl_parse_image_header(_image,
+   (struct image_header *)sdp_func->jmp_address);
+   jump_to_image_no_args(_image);
+#else
+   /* In U-Boot, allow jumps to scripts */
+   source(sdp_func->jmp_address, "script@1");
+#endif
+   }
 
sdp_func->next_state = SDP_STATE_IDLE;
sdp_func->error_status = status;
-- 
2.13.3

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


[U-Boot] [PATCH v1 1/7] imx: move imximage header to common location

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

Move the imximage.h header file to a common location so we can make
use of it from U-Boot too.

Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---

 {tools => include}/imximage.h | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename {tools => include}/imximage.h (100%)

diff --git a/tools/imximage.h b/include/imximage.h
similarity index 100%
rename from tools/imximage.h
rename to include/imximage.h
-- 
2.13.3

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


[U-Boot] [PATCH v1 0/7] imx: add USB Serial Download Protocol (SDP) support

2017-08-04 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

This series adds NXP's Serial Download Protocol (SDP) support via
USB for SPL/U-Boot. It allows to download U-Boot via USB from a
(recovered) SPL using the same tools used to download SPL itself
(specifically imx_usb, but also sb_loader seems to work).

The idea has been brought up when the first targets started to make
use of SPL for DDR initialization, see:
https://lists.denx.de/pipermail/u-boot/2015-July/220330.html

The initial SDP implementation (patch 2) requires the payload to
have the imx specific headers (hence the move of the imx header
file in patch 1).

Patch 3 extends image header support beyond the SDP specification,
specifically implements also support for U-Boot headers. This
allows to use the same SPL/U-Boot binaries for recovery as used on
the regular boot device (SD/eMMC). For that to work also the host
side imx_usb tools needed an extension, currently available here:

https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored

The full patchset allows to download SPL and U-Boot over USB to a
target in recovery mode using the same usb_imx utility:

The usb_imx utility also has a batch mode which allows to download
multiple artifacts with a single invocation. The details are
outlined in the imx_usb commit message:
https://github.com/toradex/imx_loader/commit/5434415d921f1cc4d22332d9558bed6d42db9f60

In case this patchset gets accepted in U-Boot, I plan to push the
imx_usb changes upstream as well.


Stefan Agner (7):
  imx: move imximage header to common location
  usb: gadget: add SDP driver
  usb: gadget: sdp: extend images compatible for jumps
  cmd: add sdp command
  spl: add serial download protocol (SDP) support
  apalis/colibri_imx6: use independent USB PID for SPL
  apalis/colibri_imx6: enable SDP by default

 board/toradex/apalis_imx6/apalis_imx6.c   |  13 +
 board/toradex/colibri_imx6/colibri_imx6.c |  13 +
 cmd/Kconfig   |   7 +
 cmd/Makefile  |   1 +
 cmd/usb_gadget_sdp.c  |  53 +++
 common/spl/Kconfig|   6 +
 common/spl/Makefile   |   1 +
 common/spl/spl_sdp.c  |  38 ++
 configs/apalis_imx6_defconfig |   4 +
 configs/colibri_imx6_defconfig|   4 +
 drivers/usb/gadget/Kconfig|   7 +
 drivers/usb/gadget/Makefile   |   2 +
 drivers/usb/gadget/f_sdp.c| 739 ++
 {tools => include}/imximage.h |   0
 include/sdp.h |  16 +
 15 files changed, 904 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c
 create mode 100644 common/spl/spl_sdp.c
 create mode 100644 drivers/usb/gadget/f_sdp.c
 rename {tools => include}/imximage.h (100%)
 create mode 100644 include/sdp.h

-- 
2.13.3

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


Re: [U-Boot] [PATCH] imx: mx6ull: fix USB bmode for i.MX 6UL and 6ULL

2017-06-12 Thread Stefan Agner
On 2017-06-12 01:51, Esponde, Joel wrote:
> Hi Stefan,
> 
> Why did you take the value 0x20 in the table entry instead of the
> value 0x00 as it is, for example, in the NXP U-Boot?

0x00 would mean b, which is WEIM (OneNAND/NOR flash, which is
probably a likely boot device).

0x20 is no defined boot device, and since it works, it will make sure
that bmode usb works for all users of i.MX 6UL/ULL...

--
Stefan

> 
> Is it because this boot mode does not exist in the iMX6UL SOC?
> 
> Joël Esponde
> Honeywell | Safety and Productivity Solutions
> 
>> -Message d'origine-
>> De : Fabio Estevam [mailto:feste...@gmail.com]
>> Envoyé : samedi 10 juin 2017 00:10
>> À : Stefan Agner <ste...@agner.ch>; Esponde, Joel
>> <joel.espo...@honeywell.com>
>> Cc : Stefano Babic <sba...@denx.de>; Fabio Estevam
>> <fabio.este...@nxp.com>; Stefan Agner <stefan.ag...@toradex.com>; U-
>> Boot-Denx <u-boot@lists.denx.de>
>> Objet : Re: [U-Boot] [PATCH] imx: mx6ull: fix USB bmode for i.MX 6UL and
>> 6ULL
>>
>> On Fri, Jun 9, 2017 at 5:13 PM, Stefan Agner <ste...@agner.ch> wrote:
>> > From: Stefan Agner <stefan.ag...@toradex.com>
>> >
>> > i.MX 6UL and 6ULL have different boot device capabilities and use
>> > therefor use a different boot device selection table than other i.MX 6
>> > devices. Particularly, the value which has been used so far (b0001) is
>> > assigned to QSPI boot for these two devices.
>> >
>> > There is no common reserved value for all i.MX 6devices. Use
>> > b0010 for i.MX 6UL and 6ULL via compile time ifdef.
>> >
>> > Reported-by: Joël Esponde <joel.espo...@honeywell.com>
>> > Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>>
>> Thanks for the patch.
>>
>> Joël, could you please test it and reply with your Tested-by?
>>
>> Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] imx: mx6ull: fix USB bmode for i.MX 6UL and 6ULL

2017-06-09 Thread Stefan Agner
From: Stefan Agner <stefan.ag...@toradex.com>

i.MX 6UL and 6ULL have different boot device capabilities and
use therefor use a different boot device selection table than
other i.MX 6 devices. Particularly, the value which has been
used so far (b0001) is assigned to QSPI boot for these two
devices.

There is no common reserved value for all i.MX 6devices. Use
b0010 for i.MX 6UL and 6ULL via compile time ifdef.

Reported-by: Joël Esponde <joel.espo...@honeywell.com>
Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
---
 arch/arm/cpu/armv7/mx6/soc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index dd94797514..9416bb8947 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -548,7 +548,11 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 const struct boot_mode soc_boot_modes[] = {
{"normal",  MAKE_CFGVAL(0x00, 0x00, 0x00, 0x00)},
/* reserved value should start rom usb */
+#if defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
+   {"usb", MAKE_CFGVAL(0x20, 0x00, 0x00, 0x00)},
+#else
{"usb", MAKE_CFGVAL(0x10, 0x00, 0x00, 0x00)},
+#endif
{"sata",MAKE_CFGVAL(0x20, 0x00, 0x00, 0x00)},
{"ecspi1:0",MAKE_CFGVAL(0x30, 0x00, 0x00, 0x08)},
{"ecspi1:1",MAKE_CFGVAL(0x30, 0x00, 0x00, 0x18)},
-- 
2.13.1

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


Re: [U-Boot] [PATCH v3 6/6] board: toradex: colibri_vf: Add DCU support for Colibri Vybrid

2017-04-12 Thread Stefan Agner
On 2017-04-12 09:14, Stefano Babic wrote:
> Hi Stefan,
> 
> On 11/04/2017 07:42, Sanchayan Maity wrote:
>> From: Stefan Agner <stefan.ag...@toradex.com>
>>
> 
> The series is assigned to Anatolji, that the reason I do not merge.

Oh I see, in this case, Anatolij, any chance to merge in this window?

> Other patches are related to Video, for this one:

Thanks Stefano for reviewing!

--
Stefan

> 
>> The Vybrid SoC family has the same display controller unit (DCU)
>> like the LS1021A SoC. This patch adds platform data, pinmux defines
>> and clock control to enable the driver for Toradex Colibri Vybrid
>> module.
>>
>> Signed-off-by: Stefan Agner <stefan.ag...@toradex.com>
>> Signed-off-by: Sanchayan Maity <maitysancha...@gmail.com>
>> ---
>>  arch/arm/include/asm/arch-vf610/crm_regs.h| 14 +
>>  arch/arm/include/asm/arch-vf610/imx-regs.h|  2 +
>>  arch/arm/include/asm/arch-vf610/iomux-vf610.h | 31 +++
>>  arch/arm/include/asm/imx-common/iomux-v3.h|  3 ++
>>  board/toradex/colibri_vf/Makefile |  1 +
>>  board/toradex/colibri_vf/colibri_vf.c | 76 
>> +--
>>  board/toradex/colibri_vf/dcu.c| 38 ++
>>  configs/colibri_vf_defconfig  |  4 ++
>>  include/configs/colibri_vf.h  | 13 +
>>  9 files changed, 166 insertions(+), 16 deletions(-)
>>  create mode 100644 board/toradex/colibri_vf/dcu.c
>>
>> diff --git a/arch/arm/include/asm/arch-vf610/crm_regs.h 
>> b/arch/arm/include/asm/arch-vf610/crm_regs.h
>> index a46e396f1d..73b1dd2f14 100644
>> --- a/arch/arm/include/asm/arch-vf610/crm_regs.h
>> +++ b/arch/arm/include/asm/arch-vf610/crm_regs.h
>> @@ -9,6 +9,8 @@
>>
>>  #ifndef __ASSEMBLY__
>>
>> +#include 
>> +
>>  /* Clock Controller Module (CCM) */
>>  struct ccm_reg {
>>  u32 ccr;
>> @@ -150,6 +152,9 @@ struct anadig_reg {
>>  #define CCM_CACRR_ARM_CLK_DIV_MASK  0x7
>>  #define CCM_CACRR_ARM_CLK_DIV(v)((v) & 0x7)
>>
>> +#define CCM_CSCMR1_DCU1_CLK_SEL (1 << 29)
>> +#define CCM_CSCMR1_DCU0_CLK_SEL (1 << 28)
>> +
>>  #define CCM_CSCMR1_QSPI0_CLK_SEL_OFFSET 22
>>  #define CCM_CSCMR1_QSPI0_CLK_SEL_MASK   (0x3 << 22)
>>  #define CCM_CSCMR1_QSPI0_CLK_SEL(v) (((v) & 0x3) << 22)
>> @@ -174,6 +179,13 @@ struct anadig_reg {
>>  #define CCM_CSCDR2_ESDHC1_CLK_DIV_MASK  (0xf << 20)
>>  #define CCM_CSCDR2_ESDHC1_CLK_DIV(v)(((v) & 0xf) << 20)
>>
>> +#define CCM_CSCDR3_DCU1_EN  (1 << 23)
>> +#define CCM_CSCDR3_DCU1_DIV_MASK(0x7 << 20)
>> +#define CCM_CSCDR3_DCU1_DIV(v)  (((v) & 0x7) << 20)
>> +#define CCM_CSCDR3_DCU0_EN  (1 << 19)
>> +#define CCM_CSCDR3_DCU0_DIV_MASK(0x7 << 16)
>> +#define CCM_CSCDR3_DCU0_DIV(v)  (((v) & 0x7) << 16)
>> +
>>  #define CCM_CSCDR3_NFC_PRE_DIV_OFFSET   13
>>  #define CCM_CSCDR3_NFC_PRE_DIV_MASK (0x7 << 13)
>>  #define CCM_CSCDR3_NFC_PRE_DIV(v)   (((v) & 0x7) << 13)
>> @@ -193,6 +205,7 @@ struct anadig_reg {
>>  #define CCM_CCGR0_DSPI1_CTRL_MASK   (0x3 << 26)
>>  #define CCM_CCGR1_USBC0_CTRL_MASK   (0x3 << 8)
>>  #define CCM_CCGR1_PIT_CTRL_MASK (0x3 << 14)
>> +#define CCM_CCGR1_TCON0_CTRL_MASK   (0x3 << 26)
>>  #define CCM_CCGR1_WDOGA5_CTRL_MASK  (0x3 << 28)
>>  #define CCM_CCGR2_QSPI0_CTRL_MASK   (0x3 << 8)
>>  #define CCM_CCGR2_IOMUXC_CTRL_MASK  (0x3 << 16)
>> @@ -203,6 +216,7 @@ struct anadig_reg {
>>  #define CCM_CCGR2_PORTE_CTRL_MASK   (0x3 << 26)
>>  #define CCM_CCGR3_ANADIG_CTRL_MASK  0x3
>>  #define CCM_CCGR3_SCSC_CTRL_MASK(0x3 << 4)
>> +#define CCM_CCGR3_DCU0_CTRL_MASK(0x3 << 16)
>>  #define CCM_CCGR4_WKUP_CTRL_MASK(0x3 << 20)
>>  #define CCM_CCGR4_CCM_CTRL_MASK (0x3 << 22)
>>  #define CCM_CCGR4_GPC_CTRL_MASK (0x3 << 24)
>> diff --git a/arch/arm/include/asm/arch-vf610/imx-regs.h 
>> b/arch/arm/include/asm/arch-vf610/imx-regs.h
>> index cac68efde2..ca97462c35 100644
>> --- a/arch/arm/include/asm/arch-vf610/imx-regs.h
>> +++ b/arch/arm/include/asm/arch-vf610/imx-reg

Re: [U-Boot] [PATCH v3 0/6] Introduce DCU support for Vybrid

2017-04-11 Thread Stefan Agner
Stefano,

This patchset has been on the ML for a quite a while, any chance to get
this still into v2017.05?

--
Stefan

On 2017-04-10 22:42, Sanchayan Maity wrote:
> Hello,
> 
> This patchset adds support for the Freescale/NXP Display Controller Unit 
> (DCU4)
> for Vybrid which is found on the LS1021A and Vybrid SoC.
> 
> Patch series is based on top of latest u-boot master.
> 
> First patch in the series renames existing CONFIG_FSL_DCU_FB to
> CONFIG_VIDEO_FSL_DCU_FB and then converts it to Kconfig. All board defconfigs
> affected by this patch have been compile tested.
> 
> Patch 2-5 introduce incremental changes for supporting DCU on Vybrid.
> 
> Patch 6 in the series adds DCU support to Vybrid and has been tested on
> Toradex Colibri VF61 module.
> 
> Will appreciate it if the maintainers or users of LS1021 SoC can test this to
> check and report regressions if any.
> 
> Changes since v2:
> 1. Rebase on top of latest u-boot master
> 2. Drop the fourth patch in earlier series and replace it with a fix for
> DCU_MODE_BLEND_ITER and use the existing DCU_LAYER_MAX_NUM instead of
> introducing DCU_TOTAL_LAYER_NUM as earlier incoporating Stefan's feedback.
> 
> Changes since v1:
> 1. Rebase of top of latest u-boot master
> 2. Fix a bug present in v1 patch series which resulted in noisy screen when
> switching from u-boot to Linux. Patch fixed is second in this series.
> 
> v1:
> https://lists.denx.de/pipermail/u-boot/2017-February/280281.html
> 
> v2:
> https://www.mail-archive.com/u-boot@lists.denx.de/msg243132.html
> 
> Thanks & Regards,
> Sanchayan.
> 
> Sanchayan Maity (1):
>   Convert CONFIG_FSL_DCU_FB to Kconfig
> 
> Stefan Agner (5):
>   video: fsl_dcu_fb: fix framebuffer to the end of memory
>   video: fsl_dcu_fb: Enable pixel clock after initialization
>   video: fsl_dcu_fb: Fix DCU_MODE_BLEND_ITER setting
>   video: fsl_dcu_fb: add additional modes for DCU
>   board: toradex: colibri_vf: Add DCU support for Colibri Vybrid
> 
>  arch/arm/cpu/armv7/ls102xa/soc.c   |   2 +-
>  arch/arm/include/asm/arch-vf610/crm_regs.h |  14 +++
>  arch/arm/include/asm/arch-vf610/imx-regs.h |   2 +
>  arch/arm/include/asm/arch-vf610/iomux-vf610.h  |  31 ++
>  arch/arm/include/asm/imx-common/iomux-v3.h |   3 +
>  board/freescale/ls1021aiot/Makefile|   2 +-
>  board/freescale/ls1021aqds/Makefile|   2 +-
>  board/freescale/ls1021atwr/Makefile|   2 +-
>  board/toradex/colibri_vf/Makefile  |   1 +
>  board/toradex/colibri_vf/colibri_vf.c  |  76 ++---
>  board/toradex/colibri_vf/dcu.c |  38 +++
>  configs/colibri_vf_defconfig   |   4 +
>  configs/ls1021aqds_ddr4_nor_defconfig  |   1 +
>  configs/ls1021aqds_ddr4_nor_lpuart_defconfig   |   1 +
>  configs/ls1021aqds_nand_defconfig  |   1 +
>  configs/ls1021aqds_nor_SECURE_BOOT_defconfig   |   1 +
>  configs/ls1021aqds_nor_defconfig   |   1 +
>  configs/ls1021aqds_nor_lpuart_defconfig|   1 +
>  configs/ls1021aqds_qspi_defconfig  |   1 +
>  configs/ls1021aqds_sdcard_ifc_defconfig|   1 +
>  configs/ls1021aqds_sdcard_qspi_defconfig   |   1 +
>  configs/ls1021atwr_nor_SECURE_BOOT_defconfig   |   1 +
>  configs/ls1021atwr_nor_defconfig   |   1 +
>  configs/ls1021atwr_nor_lpuart_defconfig|   1 +
>  configs/ls1021atwr_qspi_defconfig  |   1 +
>  .../ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig|   1 +
>  configs/ls1021atwr_sdcard_ifc_defconfig|   1 +
>  configs/ls1021atwr_sdcard_qspi_defconfig   |   1 +
>  drivers/video/Kconfig  |  15 +++
>  drivers/video/Makefile |   2 +-
>  drivers/video/fsl_dcu_fb.c | 121 
> ++---
>  include/configs/colibri_vf.h   |  13 +++
>  include/configs/ls1021aqds.h   |   4 +-
>  include/configs/ls1021atwr.h   |   4 +-
>  include/fsl_dcu_fb.h   |   1 +
>  scripts/config_whitelist.txt   |   1 -
>  36 files changed, 313 insertions(+), 41 deletions(-)
>  create mode 100644 board/toradex/colibri_vf/dcu.c
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


<    1   2   3   4   5   6   7   8   >