Re: [U-Boot] [PATCH] mmc: Poll for broken card detection case

2018-01-23 Thread Jaehoon Chung
On 01/23/2018 12:25 PM, Jaehoon Chung wrote:
> On 01/23/2018 12:10 PM, Jun Nie wrote:
>> 2018-01-23 10:00 GMT+08:00 Jaehoon Chung :
>>> On 01/22/2018 09:21 PM, Jun Nie wrote:
 2018-01-22 13:03 GMT+08:00 Jaehoon Chung :
> Hi,
>
> On 01/02/2018 01:25 PM, Jun Nie wrote:
>> Poll for broken card detection case instead of return
>> no card detected.
>
> Sorry for late. i didn't see this patch in my mailbox.
>
> Does it need to add the new config?

 Yes, a new config, CONFIG_MMC_BROKEN_CD is needed for board that does
 not support card detection pin. Not sure whether you mean this.
 Without this config, the logic is not changed so no board is impacted
 by this config.
>>>
>>> Right, there is no impacted by this config.
>>> In Kernel, there is "broken-cd" property. So how about using 'broken-cd' 
>>> property instead of adding config?
>>>
>>> Best Regards,
>>> Jaehoon Chung
>>>
>> Some platforms, if not all, do not support DTB in SPL. So a config is
>> better than dt node property.
> 
> Ok. It make sense...Will apply this patch to u-boot-mmc. Thanks!

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> 
> Best Regards,
> Jaehoon Chung
> 
>>
>> Jun

 Jun

>
> Best Regards,
> Jaehoon Chung
>
>>
>> Signed-off-by: Jun Nie 
>> ---
>>  drivers/mmc/Kconfig | 5 +
>>  drivers/mmc/mmc.c   | 4 
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>> index 8fbeaa7..ed194a3 100644
>> --- a/drivers/mmc/Kconfig
>> +++ b/drivers/mmc/Kconfig
>> @@ -10,6 +10,11 @@ config MMC
>> If you want MMC/SD/SDIO support, you should say Y here and
>> also to your specific host controller driver.
>>
>> +config MMC_BROKEN_CD
>> + bool "Poll for broken card detection case"
>> + help
>> +   If card  detection feature is broken, just poll to detect.
>> +
>>  config DM_MMC
>>   bool "Enable MMC controllers using Driver Model"
>>   depends on DM
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 38d2e07..13c5bf5 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -1650,8 +1650,12 @@ int mmc_start_init(struct mmc *mmc)
>>   bool no_card;
>>   int err;
>>
>> +#if !defined(CONFIG_MMC_BROKEN_CD)
>>   /* we pretend there's no card when init is NULL */
>>   no_card = mmc_getcd(mmc) == 0;
>> +#else
>> + no_card = 0;
>> +#endif
>>  #if !CONFIG_IS_ENABLED(DM_MMC)
>>   no_card = no_card || (mmc->cfg->ops->init == NULL);
>>  #endif
>>
>



>>>
>>
>>
>>
> 
> ___
> 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 1/8] mtd: nand: sunxi: Fix strength minimum value

2018-01-23 Thread Boris Brezillon
On Wed, 24 Jan 2018 01:44:47 +0100
Miquel Raynal  wrote:

> When no requirement in Device Tree is given about the ECC strength and
> step size, the engine should fallback on the minimal working case for
> this engine (16b/1024B) instead of the NAND chip requirement which might
> be simply unreachable.

Actually, this is not what this patch is fixing. It fixes all cases
where the requested ECC strength does not exactly match the strengths
supported by the ECC engine. In this case, the driver is selecting the
closest strength meeting the 'selected_strength > requested_strength'
constraint. The problem was that we were not updating ecc->strength
with the real strength, which is what you're fixing here.

> 
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/mtd/nand/sunxi_nand.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index 8bc3828854..e8e7ad8ac5 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1417,6 +1417,7 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct 
> mtd_info *mtd,
>   goto err;
>   }
>  
> + ecc->strength = strengths[i];
>   data->mode = i;
>  
>   /* HW ECC always request ECC bytes for 1024 bytes blocks */

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


Re: [U-Boot] [PATCH 4/8] spl: nand: sunxi: Enhancements and cleaning

2018-01-23 Thread Maxime Ripard
Hi,

On Wed, Jan 24, 2018 at 01:44:50AM +0100, Miquel Raynal wrote:
> Do some cleaning in sunxi NAND SPL driver like adding helpers and
> clearing flags at the right spot
> 
> Signed-off-by: Miquel Raynal 

I'm not really fond of these kind of wildcard patches, especially
since..

> ---
>  drivers/mtd/nand/sunxi_nand_spl.c | 64 
> +--
>  1 file changed, 41 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/mtd/nand/sunxi_nand_spl.c 
> b/drivers/mtd/nand/sunxi_nand_spl.c
> index 06695fc15f..2488d5cb51 100644
> --- a/drivers/mtd/nand/sunxi_nand_spl.c
> +++ b/drivers/mtd/nand/sunxi_nand_spl.c
> @@ -55,8 +55,8 @@
>  
>  
>  #define NFC_ADDR_NUM_OFFSET16
> -#define NFC_SEND_ADR   (1 << 19)
>  #define NFC_ACCESS_DIR (1 << 20)
> +#define NFC_SEND_ADDR  (1 << 19)
>  #define NFC_DATA_TRANS (1 << 21)
>  #define NFC_SEND_CMD1  (1 << 22)
>  #define NFC_WAIT_FLAG  (1 << 23)

... here you reorder a single value, which means that the set of these
values is not sorted anymore ...

> @@ -155,6 +155,30 @@ static inline int check_value_negated(int offset, int 
> unexpected_bits,
>   return check_value_inner(offset, unexpected_bits, timeout_us, 1);
>  }
>  
> +static int nand_wait_cmd_fifo_empty(void)
> +{
> + if (!check_value_negated(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_FIFO_STAT,
> +  DEFAULT_TIMEOUT_US)) {
> + printf("nand: timeout waiting for empty cmd FIFO\n");
> + return -ETIMEDOUT;
> + }
> +
> + return 0;
> +}
> +
> +static int nand_wait_int(void)
> +{
> + if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
> +  DEFAULT_TIMEOUT_US)) {
> + printf("nand: timeout waiting for interruption\n");
> + return -ETIMEDOUT;
> + }
> +
> + udelay(1);
> +
> + return 0;
> +}
> +

... here you add the helpers that you talked about in your commit log,
good. but ...

>  void nand_init(void)
>  {
>   uint32_t val;
> @@ -172,22 +196,21 @@ void nand_init(void)
>   }
>  
>   /* reset NAND */
> + nand_wait_cmd_fifo_empty();
> +

... here you call one of these helpers where you didn't have that code
before, and that's not mentionned or explained in your commit log.

>   writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
>   writel(NFC_SEND_CMD1 | NFC_WAIT_FLAG | NAND_CMD_RESET,
>  SUNXI_NFC_BASE + NFC_CMD);
>  
> - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
> -  DEFAULT_TIMEOUT_US)) {
> - printf("Error timeout waiting for nand reset\n");
> - return;
> - }
> - writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
> + nand_wait_int();
>  }
>  
>  static void nand_apply_config(const struct nfc_config *conf)
>  {
>   u32 val;
>  
> + nand_wait_cmd_fifo_empty();
> +

Ditto.

>   val = readl(SUNXI_NFC_BASE + NFC_CTL);
>   val &= ~NFC_CTL_PAGE_SIZE_MASK;
>   writel(val | NFC_CTL_RAM_METHOD | NFC_CTL_PAGE_SIZE(conf->page_size),
> @@ -200,6 +223,8 @@ static int nand_load_page(const struct nfc_config *conf, 
> u32 offs)
>  {
>   int page = offs / conf->page_size;
>  
> + nand_wait_cmd_fifo_empty();
> +

Ditto.

>   writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) |
>  (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) |
>  (NFC_CMD_READSTART << NFC_READ_CMD_OFFSET),
> @@ -208,38 +233,32 @@ static int nand_load_page(const struct nfc_config 
> *conf, u32 offs)
>   writel((page >> 16) & 0xFF, SUNXI_NFC_BASE + NFC_ADDR_HIGH);
>   writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
>   writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | NFC_WAIT_FLAG |
> -((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR,
> +((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADDR,

I guess it was a typo fix then?

>  SUNXI_NFC_BASE + NFC_CMD);
>  
> - if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
> -  DEFAULT_TIMEOUT_US)) {
> - printf("Error while initializing dma interrupt\n");
> - return -EIO;
> - }
> -
> - return 0;
> + return nand_wait_int();
>  }
>  
>  static int nand_reset_column(void)
>  {
> + nand_wait_cmd_fifo_empty();
> +

Not mentionned or explained in your commit log.

>   writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) |
>  (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) |
>  (NFC_CMD_RNDOUTSTART << NFC_READ_CMD_OFFSET),
>  SUNXI_NFC_BASE + NFC_RCMD_SET);
> + writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);

Ditto

>   writel(0, SUNXI_NFC_BASE + NFC_ADDR_LOW);
>   writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD |
> -(1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR 

Re: [U-Boot] [PATCH 3/8] sunxi: Allow SPL to be compiled for sun8i platforms

2018-01-23 Thread Maxime Ripard
Hi,

On Wed, Jan 24, 2018 at 01:44:49AM +0100, Miquel Raynal wrote:
> Add some clocks/PLL definitions and the dependency on MACH_SUN8I in
> Kconfig so the SPL could be compiled to boards using A33 SoCs.
> 
> Signed-off-by: Miquel Raynal 

The SPL can already be compiled for these platforms. What you're doing
is allowing the NAND support to be compiled in the SPL.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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


Re: [U-Boot] [PATCH 2/8] spl: nand: sunxi: Fix second case of modulo by zero error

2018-01-23 Thread Maxime Ripard
On Wed, Jan 24, 2018 at 01:44:48AM +0100, Miquel Raynal wrote:
> In the nand_read_buffer() step, the seed is calculated by doing a modulo
> by conf->nseeds which is always zero when not using the randomizer (most
> of SLC NANDs).
> 
> This situation turns out to lead to a run time freeze.
> 
> Derive this seed only when the randomizer is enabled (and conf->nseeds
> logically not zero).

Mentionning the first occurence of that issue in your commit log would
be great, especially since the situation depends on configuration
options.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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


Re: [U-Boot] [PATCH 1/8] mtd: nand: sunxi: Fix strength minimum value

2018-01-23 Thread Maxime Ripard
Hi,

On Wed, Jan 24, 2018 at 01:44:47AM +0100, Miquel Raynal wrote:
> When no requirement in Device Tree is given about the ECC strength and
> step size, the engine should fallback on the minimal working case for
> this engine (16b/1024B) instead of the NAND chip requirement which might
> be simply unreachable.
> 
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/mtd/nand/sunxi_nand.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index 8bc3828854..e8e7ad8ac5 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1417,6 +1417,7 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct 
> mtd_info *mtd,
>   goto err;
>   }
>  
> + ecc->strength = strengths[i];

You should have a comment here as well mentionning why you're doing
this (your commit log would be a good start :))

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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


Re: [U-Boot] [PATCH 3/3] configs: odroid-xu3: enable the configs relevant to regulator

2018-01-23 Thread Jaehoon Chung
On 01/24/2018 01:04 AM, Anand Moon wrote:
> Hi Jaehoon Chung,
> 
> On 16 January 2018 at 12:03, Jaehoon Chung  wrote:
>> Enable the CONFIG_CMD_REGULATOR and CONFIG_DM_REGULATOR_S2MPS11.
>>
>> Signed-off-by: Jaehoon Chung 
>> ---
>>  configs/odroid-xu3_defconfig | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig
>> index 976c06a29d..11b1c8bf11 100644
>> --- a/configs/odroid-xu3_defconfig
>> +++ b/configs/odroid-xu3_defconfig
>> @@ -22,6 +22,7 @@ CONFIG_CMD_CACHE=y
>>  CONFIG_CMD_TIME=y
>>  CONFIG_CMD_PMIC=y
>>  CONFIG_CMD_EXT4_WRITE=y
>> +CONFIG_CMD_REGULATOR=y
>>  CONFIG_ENV_IS_IN_MMC=y
>>  CONFIG_ADC=y
>>  CONFIG_ADC_EXYNOS=y
>> @@ -35,6 +36,7 @@ CONFIG_SMC911X_BASE=0x500
>>  CONFIG_DM_PMIC=y
>>  CONFIG_PMIC_S2MPS11=y
>>  CONFIG_DM_REGULATOR=y
>> +CONFIG_DM_REGULATOR_S2MPS11=y
>>  CONFIG_USB=y
>>  CONFIG_DM_USB=y
>>  CONFIG_USB_XHCI_HCD=y
>> --
>> 2.15.1
>>
> 
> Please add my.
> Tested-by: Anand Moon 

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> 
> Best Regards
> -Anand
> 
> 
> 

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


Re: [U-Boot] [PATCH 2/3] power: pmic: s2mps11: probe the regulator driver

2018-01-23 Thread Jaehoon Chung
On 01/24/2018 01:02 AM, Anand Moon wrote:
> Hi JaeHoon Chung,
> 
> On 16 January 2018 at 12:03, Jaehoon Chung  wrote:
>> Add the probe function to support the s2mps11 regulator driver.
>>
>> Signed-off-by: Jaehoon Chung 
>> ---
>>  drivers/power/pmic/s2mps11.c | 28 
>>  1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/power/pmic/s2mps11.c b/drivers/power/pmic/s2mps11.c
>> index 522105e5ff..3f9525b67d 100644
>> --- a/drivers/power/pmic/s2mps11.c
>> +++ b/drivers/power/pmic/s2mps11.c
>> @@ -15,6 +15,12 @@
>>
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>> +static const struct pmic_child_info pmic_children_info[] = {
>> +   { .prefix = S2MPS11_OF_LDO_PREFIX, .driver = S2MPS11_LDO_DRIVER },
>> +   { .prefix = S2MPS11_OF_BUCK_PREFIX, .driver = S2MPS11_BUCK_DRIVER },
>> +   { },
>> +};
>> +
>>  static int s2mps11_reg_count(struct udevice *dev)
>>  {
>> return S2MPS11_REG_COUNT;
>> @@ -43,6 +49,27 @@ static int s2mps11_read(struct udevice *dev, uint reg, 
>> uint8_t *buff, int len)
>> return ret;
>>  }
>>
>> +static int s2mps11_probe(struct udevice *dev)
>> +{
>> +   ofnode regulators_node;
>> +   int children;
>> +
>> +   regulators_node = dev_read_subnode(dev, "voltage-regulators");
>> +   if (!ofnode_valid(regulators_node)) {
>> +   debug("%s: %s regulators subnode not found!", __func__,
>> +dev->name);
>> +   return -ENXIO;
>> +   }
>> +
>> +   debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
>> +
>> +   children = pmic_bind_children(dev, regulators_node, 
>> pmic_children_info);
>> +   if (!children)
>> +   debug("%s: %s - no child found\n", __func__, dev->name);
>> +
>> +   return 0;
>> +}
>> +
>>  static struct dm_pmic_ops s2mps11_ops = {
>> .reg_count = s2mps11_reg_count,
>> .read = s2mps11_read,
>> @@ -59,4 +86,5 @@ U_BOOT_DRIVER(pmic_s2mps11) = {
>> .id = UCLASS_PMIC,
>> .of_match = s2mps11_ids,
>> .ops = _ops,
>> +   .probe = s2mps11_probe,
>>  };
>> --
>> 2.15.1
>>
> 
> Please add my.
> Tested-by: Anand Moon 


Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> 
> Best Regards
> -Anand
> 
> 
> 

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


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

2018-01-23 Thread Jaehoon Chung
Dear Tom,

Could you pull these patches to u-boot/master?
If there is a problem, let me know, plz.

The following changes since commit 557767ed29968af0294e3aae48433e5d5a298e0b:

  Merge git://git.denx.de/u-boot-marvell (2018-01-20 08:39:47 -0500)

are available in the Git repository at:

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

for you to fetch changes up to 2f516e4aa286eb0203e34ab9be68b08f7a3c44c1:

  mmc: Poll for broken card detection case (2018-01-24 16:12:03 +0900)


Benoît Thébaudeau (1):
  mmc: fsl_esdhc: Fix i.MX53 eSDHCv3 clock

Jaehoon Chung (5):
  mmc: fix the wrong disabling clock
  power: regulator: s2mps11: add a regulator driver for s2mps11
  power: pmic: s2mps11: probe the regulator driver
  configs: odroid-xu3: enable the configs relevant to regulator
  mmc: fix to assign to correct clock value when clock is enabling

Jun Nie (1):
  mmc: Poll for broken card detection case

Masahiro Yamada (8):
  dm: add dev_read_u32()
  mmc: do not overwrite cfg->f_max if "max-frequency" if missing
  mmc: let mmc_of_parse() fail for insane bus-width value
  mmc: sdhci: do not overwrite host_caps in sdhci_setup_cfg()
  mmc: sdhci-cadence: use bitfield access macros for cleanup
  mmc: sdhci-cadence: call mmc_of_parse()
  mmc: sdhci-cadence: add HS200 support
  mmc: sdhci: change data transfer failure into debug message

 configs/odroid-xu3_defconfig|   2 +
 drivers/core/read.c |   5 +
 drivers/mmc/Kconfig |   5 +
 drivers/mmc/fsl_esdhc.c |   7 +-
 drivers/mmc/mmc-uclass.c|   9 +-
 drivers/mmc/mmc.c   |  16 +-
 drivers/mmc/sdhci-cadence.c | 114 +-
 drivers/mmc/sdhci.c |   6 +-
 drivers/power/pmic/s2mps11.c|  28 ++
 drivers/power/regulator/Kconfig |   8 +
 drivers/power/regulator/Makefile|   1 +
 drivers/power/regulator/s2mps11_regulator.c | 597 
 include/dm/read.h   |  16 +
 include/power/s2mps11.h |  55 +++
 14 files changed, 836 insertions(+), 33 deletions(-)
 create mode 100644 drivers/power/regulator/s2mps11_regulator.c

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


Re: [U-Boot] [PATCH] mmc: fix to assign to corret clock value when clock is enabling

2018-01-23 Thread Jaehoon Chung
On 01/24/2018 04:01 AM, Stephen Warren wrote:
> On 01/22/2018 10:04 PM, Jaehoon Chung wrote:
>> When clock is enabling, it's assigned to 0 as mmc->clock.
>> Then it can't initialize any card.
>> Fix to assign to correct clock value as mmc->cfg->f_min or f_max.
> 
> Tested-by: Stephen Warren 
> Thanks!
> 
>> Fixes: 9546eb92cb6 ("mmc: fix the wrong disabling clock")
>>
>> Signed-off-by: Jaehoon Chung 
> 
> Nit: There's usually not a blank line between the Fixes: and Signed-off-by: 
> lines.
> 
> Nit: s/corret/correct/ in the patch subject.

After fixing typo and changing with your commen,
Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung 

> 
> 
> 

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


Re: [U-Boot] [PATCH 1/3] power: regulator: s2mps11: add a regulator driver for s2mps11

2018-01-23 Thread Jaehoon Chung
On 01/24/2018 01:01 AM, Anand Moon wrote:
> Hi JaeHoon Chung,
> 
> On 16 January 2018 at 12:03, Jaehoon Chung  wrote:
>> exynos5422 has the s2mps11 PMIC.
>> s2mps11 pmic has the 10-BUCK and 38-LDO regulators.
>> Each IP and devices in exynos5422 can be controlled by each regulators.
>> This patch is support for s2mps11 regulator driver.
>>
>> Signed-off-by: Jaehoon Chung 
>> ---
>>  drivers/power/regulator/Kconfig |   8 +
>>  drivers/power/regulator/Makefile|   1 +
>>  drivers/power/regulator/s2mps11_regulator.c | 597 
>> 
>>  include/power/s2mps11.h |  55 +++
>>  4 files changed, 661 insertions(+)
>>  create mode 100644 drivers/power/regulator/s2mps11_regulator.c
>>

[..snip..]

> 
> Please add my.
> Tested-by: Anand Moon 

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> 
> Best Regards
> -Anand
> 
> 
> 

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


Re: [U-Boot] Pull request: u-boot-spi/master

2018-01-23 Thread Jagan Teki
On Tue, Jan 23, 2018 at 3:58 PM, Daniel Schwierzeck
 wrote:
>
>
> On 22.01.2018 21:55, Álvaro Fernández Rojas wrote:
>> Hi Daniel,
>>
>>
>> El 22/01/2018 a las 21:26, Daniel Schwierzeck escribió:
>>>
>>> On 22.01.2018 18:14, Tom Rini wrote:
 On Mon, Jan 22, 2018 at 05:49:39PM +0100, Daniel Schwierzeck wrote:
>
> On 22.01.2018 13:58, Tom Rini wrote:
>> On Mon, Jan 22, 2018 at 11:20:56AM +0530, Jagan Teki wrote:
>>
>>> Hi Tom,
>>>
>>> Please pull this PR.
>>>
>>> thanks!
>>> Jagan.
>>>
>>> The following changes since commit
>>> 98691a60abffb44303d7dae6e9e699d0daded930:
>>>
>>>Merge git://git.denx.de/u-boot-rockchip (2018-01-09 13:28:51
>>> -0500)
>>>
>>> are available in the git repository at:
>>>
>>>git://git.denx.de/u-boot-spi.git master
>>>
>>> for you to fetch changes up to
>>> b23c685c6f295da3c01dd487f0e003b70299af91:
>>>
>>>mips: bmips: enable the SPI flash on the Comtrend AR-5387un
>>> (2018-01-22 10:39:13 +0530)
>>>
>> NAK:
>>
>> commit 19e3a4856c1cba751a9ecb3931ff0d96a7f169be
>> Author: Álvaro Fernández Rojas 
>> Date:   Sat Jan 20 02:11:34 2018 +0100
>>
>>  wait_bit: add 8/16/32 BE/LE versions of wait_for_bit
>>
>>  Add 8/16/32 bits and BE/LE versions of wait_for_bit.
>>  This is needed for reading registers that are not aligned to
>> 32 bits, and for
>>  Big Endian platforms.
>>
>>  Signed-off-by: Álvaro Fernández Rojas 
>>  Reviewed-by: Daniel Schwierzeck 
>>  Reviewed-by: Jagan Teki 
>>
>> Adds warnings on almost all platforms:
>> w+(ls1088ardb_qspi_SECURE_BOOT) ../include/wait_bit.h: In function
>> ?wait_for_bit_be16?:
>> w+(ls1088ardb_qspi_SECURE_BOOT) ../include/wait_bit.h:76:31:
>> warning: implicit declaration of function ?readw_be?
>> [-Wimplicit-function-declaration]
>> w+(ls1088ardb_qspi_SECURE_BOOT) ../include/wait_bit.h: In function
>> ?wait_for_bit_be32?: w+(ls1088ardb_qspi_SECURE_BOOT)
>> ../include/wait_bit.h:78:31: warning: implicit declaration of
>> function ?readl_be? [-Wimplicit-function-declaration]
>>
>>
> Tom, would this change to the patch be acceptable?
>
> --- a/include/wait_bit.h
> +++ b/include/wait_bit.h
> @@ -73,8 +73,12 @@ static inline int wait_for_bit_##sfx(const void
> *reg,\
>
>   BUILD_WAIT_FOR_BIT(8, u8, readb)
>   BUILD_WAIT_FOR_BIT(le16, u16, readw)
> +#ifdef readw_be
>   BUILD_WAIT_FOR_BIT(be16, u16, readw_be)
> +#endif
>   BUILD_WAIT_FOR_BIT(le32, u32, readl)
> +#ifdef readl_be
>   BUILD_WAIT_FOR_BIT(be32, u32, readl_be)
> +#endif
>
>   #endif
>
> This wouldn't define wait_bit_be*() on archs which doesn't implement
> readw_be or readl_be.
>
> A build with the updated patch is scheduled at
> https://travis-ci.org/danielschwierzeck/u-boot/builds/331899381
 That seems reasonable, thanks!

>>> Álvaro, could you send a v10 where the patch "wait_bit: add 8/16/32
>>> BE/LE versions of wait_for_bit" is fixed like above? Thanks.
>> Sure, but I think this alternative would be much cleaner:
>> https://gist.github.com/Noltari/3e6ed4648b87484c73ca22e2f533f9b0
>>
>> What do you think?
>>
>
> I had a similar idea at first but a #ifdef within a #define is not possible 
> and AFAIK not implemented in C standards.
>
> Have you tried it? With nested #ifdef I'm getting:
>
> $ ./tools/buildman/buildman -o /tmp/bm -b master..wait_for_bit aarch64
> Building 1 commit for 111 boards (8 threads, 1 job per thread)
>50   11   50 /111lion-rk3368
>
> vs.
>
> $ ./tools/buildman/buildman -o /tmp/bm -b master..wait_for_bit_2 aarch64
> Building 1 commit for 111 boards (8 threads, 1 job per thread)
>98   130 /1110:00:06  : ls1046ardb_emm
>
> Also a Travis CI build already shows several broken builds:
> https://travis-ci.org/danielschwierzeck/u-boot/builds/332205310
>
> Maybe a yet better solution would be if each arch implements the same common 
> set of I/O primitives like Linux is doing.

Recent patch from Alvaro, seems fine to built all [1]

[1] https://travis-ci.org/openedev/u-boot-spi/builds/332390626
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v6 2/2] common: Generic firmware loader for file system

2018-01-23 Thread Simon Goldschmidt



On 24.01.2018 06:13, Chee, Tien Fong wrote:

On Tue, 2018-01-23 at 10:13 +0100, Simon Goldschmidt wrote:

On 23.01.2018 09:31, Chee, Tien Fong wrote:

On Tue, 2018-01-23 at 08:58 +0100, Simon Goldschmidt wrote:

On 27.12.2017 06:04, tien.fong.c...@intel.com wrote:

From: Tien Fong Chee 

This is file system generic loader which can be used to load
the file image from the storage into target such as memory.
The consumer driver would then use this loader to program
whatever,
ie. the FPGA device.

Signed-off-by: Tien Fong Chee 
---
    common/Makefile|   1 +
    common/fs_loader.c | 309
+
    doc/README.firmware_loader |  76 +++
    include/fs_loader.h|  28 
    4 files changed, 414 insertions(+)
    create mode 100644 common/fs_loader.c
    create mode 100644 doc/README.firmware_loader
    create mode 100644 include/fs_loader.h

diff --git a/common/Makefile b/common/Makefile
index cec506f..2934221 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o




diff --git a/include/fs_loader.h b/include/fs_loader.h
new file mode 100644
index 000..83a8b80
--- /dev/null
+++ b/include/fs_loader.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Intel Corporation 
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+#ifndef _FS_LOADER_H_
+#define _FS_LOADER_H_
+
+#include 
+
+struct firmware {
+   size_t size;/* Size of a file */
+   const u8 *data; /* Buffer for file */
+   void *priv; /* Firmware loader private
fields */
+};
+
+struct device_location {
+   char *name; /* Such as mmc, usb,and sata. */

Would it make sense to use 'enum if_type' from blk.h here instead
of
a
"magic" name? Or are the constants passed here "well-known"
enough
to
hide them?


This structure is declared such way so that it can be compatible
with
common/splash.c. It also much more easy to port fs_loader into
common/splash_source.c in later.

OK, but reading splash_source.c, it seems to me that 'enum
splash_storage' is used to detect the device to load from, not 'char
*name'.

However, since these constant strings already seem to be "common
knowledge" for callers of fs.h functions, it might be OK to use them
in
the firmware loader, too. I just wanted to point this out while this
is
in the reviewing process.


Actually this is common interface name used in any fs related. You can
refer more details regarding @ifname in include/fs.h and include part.h
.

So, why this interface name must be in characters string?
It's actually serving in 2 main purposes, and 1 minor purpose:
1. console environment, most commands using those interface name as
their arguments in characters string format such as FPGA loadfs
command.

2. These command interface name is one of the characters string
argument of fs_set_blk_dev too.

3. As identity of default location and its dev_part configuration.


Right. I see that there does not seem to be a way to provide the 
interface type to fs.h without using a string. In most cases, this 
string is provided by the environment or via console, so I see where 
that comes from. It's probably not up to this patch to change it.



Regards,
Simon


+   char *devpart;  /* Use the load command dev:part
conventions */
+   char *mtdpart;  /* MTD partition for ubi part */
+   char *ubivol;   /* UBI volume-name for ubifsmount
*/
+};
+
+int request_firmware_into_buf(struct firmware **firmware_p,
+     const char *name,
+     struct device_location
*location,
+     void *buf, size_t size, u32
offset);
+#endif


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


[U-Boot] [PATCH v3 0/3] cadence-quadspi: Fix issues with non 32bit aligned accesses

2018-01-23 Thread Vignesh R
This series reverts use of bounce_buf.c for non-DMA related alignment
restriction and replaces it with local bounce buffer to handle problems
with non 32 bit aligned writes on TI platforms.
Based on top of Jason's series:
[PATCH v6 0/4] spi: cadence_spi: Adopt Linux DT bindings

Tested on K2G EVM.

v3:
Rebased on top of latest u-boot-spi/master changes.

Goldschmidt Simon (1):
  Revert "spi: cadence_qspi_apb: Use 32 bit indirect read transaction
when possible"

Vignesh R (2):
  Revert "spi: cadence_qspi_apb: Use 32 bit indirect write transaction
when possible"
  spi: cadence_qspi_apb: Make flash writes 32 bit aligned

 drivers/spi/cadence_qspi_apb.c   | 53 
 include/configs/k2g_evm.h|  1 -
 include/configs/socfpga_common.h |  1 -
 include/configs/stv0991.h|  1 -
 4 files changed, 26 insertions(+), 30 deletions(-)

-- 
2.16.0

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


[U-Boot] [PATCH v3 1/3] Revert "spi: cadence_qspi_apb: Use 32 bit indirect read transaction when possible"

2018-01-23 Thread Vignesh R
From: Goldschmidt Simon 

This reverts commit b63b46313ed29e9b0c36b3d6b9407f6eade40c8f.

This commit changed cadence_qspi_apb to use bouncebuf.c, which invalidates
the data cache after reading. This is meant for dma transfers only and
breaks the cadence_qspi driver which copies via cpu only: data that is
copied by the cpu is in cache only and the cache invalidation at the end
throws away this data.

Signed-off-by: Simon Goldschmidt 
Signed-off-by: Vignesh R 
Acked-by: Marek Vasut 
Reviewed-by: Jason Rush 
Acked-by: Jason Rush 
---
 drivers/spi/cadence_qspi_apb.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index 4b1ddd79b30b..82e8a9ec4d1c 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -627,8 +627,6 @@ int cadence_qspi_apb_indirect_read_execute(struct 
cadence_spi_platdata *plat,
 {
unsigned int remaining = n_rx;
unsigned int bytes_to_read = 0;
-   struct bounce_buffer bb;
-   u8 *bb_rxbuf;
int ret;
 
writel(n_rx, plat->regbase + CQSPI_REG_INDIRECTRDBYTES);
@@ -637,11 +635,6 @@ int cadence_qspi_apb_indirect_read_execute(struct 
cadence_spi_platdata *plat,
writel(CQSPI_REG_INDIRECTRD_START,
   plat->regbase + CQSPI_REG_INDIRECTRD);
 
-   ret = bounce_buffer_start(, (void *)rxbuf, n_rx, GEN_BB_WRITE);
-   if (ret)
-   return ret;
-   bb_rxbuf = bb.bounce_buffer;
-
while (remaining > 0) {
ret = cadence_qspi_wait_for_data(plat);
if (ret < 0) {
@@ -655,13 +648,16 @@ int cadence_qspi_apb_indirect_read_execute(struct 
cadence_spi_platdata *plat,
bytes_to_read *= plat->fifo_width;
bytes_to_read = bytes_to_read > remaining ?
remaining : bytes_to_read;
-   readsl(plat->ahbbase, bb_rxbuf, bytes_to_read >> 2);
-   if (bytes_to_read % 4)
-   readsb(plat->ahbbase,
-  bb_rxbuf + rounddown(bytes_to_read, 4),
-  bytes_to_read % 4);
-
-   bb_rxbuf += bytes_to_read;
+   /*
+* Handle non-4-byte aligned access to avoid
+* data abort.
+*/
+   if (((uintptr_t)rxbuf % 4) || (bytes_to_read % 4))
+   readsb(plat->ahbbase, rxbuf, bytes_to_read);
+   else
+   readsl(plat->ahbbase, rxbuf,
+  bytes_to_read >> 2);
+   rxbuf += bytes_to_read;
remaining -= bytes_to_read;
bytes_to_read = cadence_qspi_get_rd_sram_level(plat);
}
@@ -678,7 +674,6 @@ int cadence_qspi_apb_indirect_read_execute(struct 
cadence_spi_platdata *plat,
/* Clear indirect completion status */
writel(CQSPI_REG_INDIRECTRD_DONE,
   plat->regbase + CQSPI_REG_INDIRECTRD);
-   bounce_buffer_stop();
 
return 0;
 
@@ -686,7 +681,6 @@ failrd:
/* Cancel the indirect read */
writel(CQSPI_REG_INDIRECTRD_CANCEL,
   plat->regbase + CQSPI_REG_INDIRECTRD);
-   bounce_buffer_stop();
return ret;
 }
 
-- 
2.16.0

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


[U-Boot] [PATCH v3 3/3] spi: cadence_qspi_apb: Make flash writes 32 bit aligned

2018-01-23 Thread Vignesh R
Make flash writes 32 bit aligned by using bounce buffers to deal with
non 32 bit aligned buffers.
This is required because as per TI K2G TRM[1], the external master is
only permitted to issue 32-bit data interface writes until the last word
of an indirect transfer. Otherwise indirect writes is known to fail
sometimes.

[1] http://www.ti.com/lit/ug/spruhy8g/spruhy8g.pdf

Signed-off-by: Vignesh R 
Acked-by: Marek Vasut 
Acked-by: Simon Goldschmidt 
Reviewed-by: Jason Rush 
Acked-by: Jason Rush 
---
 drivers/spi/cadence_qspi_apb.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index a57109865d29..6d9a7941b470 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "cadence_qspi.h"
 
 #define CQSPI_REG_POLL_US  1 /* 1us */
@@ -719,9 +720,23 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
 {
unsigned int page_size = plat->page_size;
unsigned int remaining = n_tx;
+   const u8 *bb_txbuf = txbuf;
+   void *bounce_buf = NULL;
unsigned int write_bytes;
int ret;
 
+   /*
+* Use bounce buffer for non 32 bit aligned txbuf to avoid data
+* aborts
+*/
+   if ((uintptr_t)txbuf % 4) {
+   bounce_buf = malloc(n_tx);
+   if (!bounce_buf)
+   return -ENOMEM;
+   memcpy(bounce_buf, txbuf, n_tx);
+   bb_txbuf = bounce_buf;
+   }
+
/* Configure the indirect read transfer bytes */
writel(n_tx, plat->regbase + CQSPI_REG_INDIRECTWRBYTES);
 
@@ -731,11 +746,11 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
 
while (remaining > 0) {
write_bytes = remaining > page_size ? page_size : remaining;
-   /* Handle non-4-byte aligned access to avoid data abort. */
-   if (((uintptr_t)txbuf % 4) || (write_bytes % 4))
-   writesb(plat->ahbbase, txbuf, write_bytes);
-   else
-   writesl(plat->ahbbase, txbuf, write_bytes >> 2);
+   writesl(plat->ahbbase, bb_txbuf, write_bytes >> 2);
+   if (write_bytes % 4)
+   writesb(plat->ahbbase,
+   bb_txbuf + rounddown(write_bytes, 4),
+   write_bytes % 4);
 
ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_SDRAMLEVEL,
CQSPI_REG_SDRAMLEVEL_WR_MASK <<
@@ -745,7 +760,7 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
goto failwr;
}
 
-   txbuf += write_bytes;
+   bb_txbuf += write_bytes;
remaining -= write_bytes;
}
 
@@ -760,12 +775,16 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
/* Clear indirect completion status */
writel(CQSPI_REG_INDIRECTWR_DONE,
   plat->regbase + CQSPI_REG_INDIRECTWR);
+   if (bounce_buf)
+   free(bounce_buf);
return 0;
 
 failwr:
/* Cancel the indirect write */
writel(CQSPI_REG_INDIRECTWR_CANCEL,
   plat->regbase + CQSPI_REG_INDIRECTWR);
+   if (bounce_buf)
+   free(bounce_buf);
return ret;
 }
 
-- 
2.16.0

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


[U-Boot] [PATCH v3 2/3] Revert "spi: cadence_qspi_apb: Use 32 bit indirect write transaction when possible"

2018-01-23 Thread Vignesh R
This reverts commit 57897c13de03ac0136d64641a3eab526c6810387.

Using bounce_buf.c to handle non-DMA alignment problems is bad as
bounce_buf.c does cache manipulations which is not required. Therefore
revert this patch in favour of local bounce buffer solution in the next
patch.

Signed-off-by: Vignesh R 
Acked-by: Marek Vasut 
Acked-by: Simon Goldschmidt 
Reviewed-by: Jason Rush 
Acked-by: Jason Rush 
---
 drivers/spi/cadence_qspi_apb.c   | 26 ++
 include/configs/k2g_evm.h|  1 -
 include/configs/socfpga_common.h |  1 -
 include/configs/stv0991.h|  1 -
 4 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index 82e8a9ec4d1c..a57109865d29 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "cadence_qspi.h"
 
 #define CQSPI_REG_POLL_US  1 /* 1us */
@@ -722,17 +721,6 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
unsigned int remaining = n_tx;
unsigned int write_bytes;
int ret;
-   struct bounce_buffer bb;
-   u8 *bb_txbuf;
-
-   /*
-* Handle non-4-byte aligned accesses via bounce buffer to
-* avoid data abort.
-*/
-   ret = bounce_buffer_start(, (void *)txbuf, n_tx, GEN_BB_READ);
-   if (ret)
-   return ret;
-   bb_txbuf = bb.bounce_buffer;
 
/* Configure the indirect read transfer bytes */
writel(n_tx, plat->regbase + CQSPI_REG_INDIRECTWRBYTES);
@@ -743,11 +731,11 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
 
while (remaining > 0) {
write_bytes = remaining > page_size ? page_size : remaining;
-   writesl(plat->ahbbase, bb_txbuf, write_bytes >> 2);
-   if (write_bytes % 4)
-   writesb(plat->ahbbase,
-   bb_txbuf + rounddown(write_bytes, 4),
-   write_bytes % 4);
+   /* Handle non-4-byte aligned access to avoid data abort. */
+   if (((uintptr_t)txbuf % 4) || (write_bytes % 4))
+   writesb(plat->ahbbase, txbuf, write_bytes);
+   else
+   writesl(plat->ahbbase, txbuf, write_bytes >> 2);
 
ret = wait_for_bit_le32(plat->regbase + CQSPI_REG_SDRAMLEVEL,
CQSPI_REG_SDRAMLEVEL_WR_MASK <<
@@ -757,7 +745,7 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
goto failwr;
}
 
-   bb_txbuf += write_bytes;
+   txbuf += write_bytes;
remaining -= write_bytes;
}
 
@@ -768,7 +756,6 @@ int cadence_qspi_apb_indirect_write_execute(struct 
cadence_spi_platdata *plat,
printf("Indirect write completion error (%i)\n", ret);
goto failwr;
}
-   bounce_buffer_stop();
 
/* Clear indirect completion status */
writel(CQSPI_REG_INDIRECTWR_DONE,
@@ -779,7 +766,6 @@ failwr:
/* Cancel the indirect write */
writel(CQSPI_REG_INDIRECTWR_CANCEL,
   plat->regbase + CQSPI_REG_INDIRECTWR);
-   bounce_buffer_stop();
return ret;
 }
 
diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h
index 535e7124fc80..0a38922a519e 100644
--- a/include/configs/k2g_evm.h
+++ b/include/configs/k2g_evm.h
@@ -93,7 +93,6 @@
 #ifndef CONFIG_SPL_BUILD
 #define CONFIG_CADENCE_QSPI
 #define CONFIG_CQSPI_REF_CLK 38400
-#define CONFIG_BOUNCE_BUFFER
 #endif
 
 #define SPI_MTD_PARTS  KEYSTONE_SPI1_MTD_PARTS
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index ec8bb500504a..f6607b101ec5 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -184,7 +184,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
 unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_CQSPI_REF_CLK   cm_get_qspi_controller_clk_hz()
 #endif
-#define CONFIG_BOUNCE_BUFFER
 
 /*
  * Designware SPI support
diff --git a/include/configs/stv0991.h b/include/configs/stv0991.h
index fd96979bf897..beb8f1ae9a92 100644
--- a/include/configs/stv0991.h
+++ b/include/configs/stv0991.h
@@ -64,7 +64,6 @@
 + */
 #ifdef CONFIG_OF_CONTROL   /* QSPI is controlled via DT */
 #define CONFIG_CQSPI_REF_CLK   ((30/4)/2)*1000*1000
-#define CONFIG_BOUNCE_BUFFER
 
 #endif
 
-- 
2.16.0

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


Re: [U-Boot] [PATCH v6 2/2] common: Generic firmware loader for file system

2018-01-23 Thread Chee, Tien Fong
On Tue, 2018-01-23 at 10:13 +0100, Simon Goldschmidt wrote:
> On 23.01.2018 09:31, Chee, Tien Fong wrote:
> > 
> > On Tue, 2018-01-23 at 08:58 +0100, Simon Goldschmidt wrote:
> > > 
> > > On 27.12.2017 06:04, tien.fong.c...@intel.com wrote:
> > > > 
> > > > From: Tien Fong Chee 
> > > > 
> > > > This is file system generic loader which can be used to load
> > > > the file image from the storage into target such as memory.
> > > > The consumer driver would then use this loader to program
> > > > whatever,
> > > > ie. the FPGA device.
> > > > 
> > > > Signed-off-by: Tien Fong Chee 
> > > > ---
> > > >    common/Makefile|   1 +
> > > >    common/fs_loader.c | 309
> > > > +
> > > >    doc/README.firmware_loader |  76 +++
> > > >    include/fs_loader.h|  28 
> > > >    4 files changed, 414 insertions(+)
> > > >    create mode 100644 common/fs_loader.c
> > > >    create mode 100644 doc/README.firmware_loader
> > > >    create mode 100644 include/fs_loader.h
> > > > 
> > > > diff --git a/common/Makefile b/common/Makefile
> > > > index cec506f..2934221 100644
> > > > --- a/common/Makefile
> > > > +++ b/common/Makefile
> > > > @@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
> > > 
> > > 
> > > > 
> > > > diff --git a/include/fs_loader.h b/include/fs_loader.h
> > > > new file mode 100644
> > > > index 000..83a8b80
> > > > --- /dev/null
> > > > +++ b/include/fs_loader.h
> > > > @@ -0,0 +1,28 @@
> > > > +/*
> > > > + * Copyright (C) 2017 Intel Corporation 
> > > > + *
> > > > + * SPDX-License-Identifier:GPL-2.0
> > > > + */
> > > > +#ifndef _FS_LOADER_H_
> > > > +#define _FS_LOADER_H_
> > > > +
> > > > +#include 
> > > > +
> > > > +struct firmware {
> > > > +   size_t size;/* Size of a file */
> > > > +   const u8 *data; /* Buffer for file */
> > > > +   void *priv; /* Firmware loader private
> > > > fields */
> > > > +};
> > > > +
> > > > +struct device_location {
> > > > +   char *name; /* Such as mmc, usb,and sata. */
> > > Would it make sense to use 'enum if_type' from blk.h here instead
> > > of
> > > a
> > > "magic" name? Or are the constants passed here "well-known"
> > > enough
> > > to
> > > hide them?
> > > 
> > This structure is declared such way so that it can be compatible
> > with
> > common/splash.c. It also much more easy to port fs_loader into
> > common/splash_source.c in later.
> OK, but reading splash_source.c, it seems to me that 'enum 
> splash_storage' is used to detect the device to load from, not 'char
> *name'.
> 
> However, since these constant strings already seem to be "common 
> knowledge" for callers of fs.h functions, it might be OK to use them
> in 
> the firmware loader, too. I just wanted to point this out while this
> is 
> in the reviewing process.
> 
Actually this is common interface name used in any fs related. You can
refer more details regarding @ifname in include/fs.h and include part.h
.

So, why this interface name must be in characters string?
It's actually serving in 2 main purposes, and 1 minor purpose:
1. console environment, most commands using those interface name as
their arguments in characters string format such as FPGA loadfs
command.

2. These command interface name is one of the characters string
argument of fs_set_blk_dev too.

3. As identity of default location and its dev_part configuration.

> > 
> > > 
> > > Regards,
> > > Simon
> > > 
> > > > 
> > > > +   char *devpart;  /* Use the load command dev:part
> > > > conventions */
> > > > +   char *mtdpart;  /* MTD partition for ubi part */
> > > > +   char *ubivol;   /* UBI volume-name for ubifsmount
> > > > */
> > > > +};
> > > > +
> > > > +int request_firmware_into_buf(struct firmware **firmware_p,
> > > > +     const char *name,
> > > > +     struct device_location
> > > > *location,
> > > > +     void *buf, size_t size, u32
> > > > offset);
> > > > +#endif
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V2] Convert CONFIG_CMD_NAND to Kconfig

2018-01-23 Thread Adam Ford
On Tue, Jan 23, 2018 at 8:09 PM, Adam Ford  wrote:
> This converts the following to Kconfig:
>CONFIG_CMD_NAND
>
> Signed-off-by: Adam Ford 
> ---
> V2:  Remove SUNXI default since this is selected when NAND_SUNXI is
>  Since they cannot both recursively check each other.  This was
>  causing some trouble.
>

Sorry for all the noise.  Many of the boards are recursively calling
CMD_NAND from CONFIG_NAND and vice versa, so I'm going to completely
change my approach.  Go ahead and nak this

> V1:  Several boards check for the presence of CONFIG_CMD_NAND instead of
>  CONFIG_NAND when setting up their NAND parameters.  This will now
>  define CONFIG_NAND if CMD_NAND is set.
>
>  cmd/Kconfig  | 2 +-
>  configs/ls1088aqds_qspi_SECURE_BOOT_defconfig| 1 +
>  configs/ls1088aqds_qspi_defconfig| 1 +
>  configs/ls1088aqds_sdcard_qspi_defconfig | 1 +
>  configs/ls1088ardb_qspi_SECURE_BOOT_defconfig| 1 +
>  configs/ls1088ardb_qspi_defconfig| 1 +
>  configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 1 +
>  configs/ls1088ardb_sdcard_qspi_defconfig | 1 +
>  configs/pfla02_defconfig | 1 +
>  include/configs/ls1088aqds.h | 1 -
>  include/configs/ls1088ardb.h | 1 -
>  include/configs/pfla02.h | 1 -
>  include/configs/sama5d27_som1_ek.h   | 1 -
>  13 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 35fe9d5..a16cf74 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -763,7 +763,7 @@ config CMD_MMC
>
>  config CMD_NAND
> bool "nand"
> -   default y if NAND_SUNXI
> +   select NAND
> help
>   NAND support.
>
> diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
> b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
> index e464951..28c9029 100644
> --- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
> +++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
> @@ -12,6 +12,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
>  CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
>  # CONFIG_CMD_SETEXPR is not set
> diff --git a/configs/ls1088aqds_qspi_defconfig 
> b/configs/ls1088aqds_qspi_defconfig
> index 1e368d7..7acd747 100644
> --- a/configs/ls1088aqds_qspi_defconfig
> +++ b/configs/ls1088aqds_qspi_defconfig
> @@ -11,6 +11,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
>  CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
>  # CONFIG_CMD_SETEXPR is not set
> diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
> b/configs/ls1088aqds_sdcard_qspi_defconfig
> index 659bc4f..cb8b426 100644
> --- a/configs/ls1088aqds_sdcard_qspi_defconfig
> +++ b/configs/ls1088aqds_sdcard_qspi_defconfig
> @@ -22,6 +22,7 @@ CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
>  CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
>  # CONFIG_CMD_SETEXPR is not set
> diff --git a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig 
> b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
> index 19c76b6..5cc652c 100644
> --- a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
> +++ b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
> @@ -13,6 +13,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
>  # CONFIG_DISPLAY_BOARDINFO is not set
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
>  # CONFIG_CMD_SETEXPR is not set
> diff --git a/configs/ls1088ardb_qspi_defconfig 
> b/configs/ls1088ardb_qspi_defconfig
> index 8a08846..62128ed 100644
> --- a/configs/ls1088ardb_qspi_defconfig
> +++ b/configs/ls1088ardb_qspi_defconfig
> @@ -12,6 +12,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
>  # CONFIG_DISPLAY_BOARDINFO is not set
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  CONFIG_CMD_USB=y
>  # CONFIG_CMD_SETEXPR is not set
> diff --git a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig 
> b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
> index a7466f1..ccba0fc 100644
> --- a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
> +++ b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
> @@ -26,6 +26,7 @@ CONFIG_SPL_I2C_SUPPORT=y
>  CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_NAND=y
>  CONFIG_CMD_SF=y
>  # CONFIG_CMD_SETEXPR is not set
>  CONFIG_OF_CONTROL=y
> diff --git a/configs/ls1088ardb_sdcard_qspi_defconfig 
> b/configs/ls1088ardb_sdcard_qspi_defconfig
> index 2e3c287..c72992e 100644
> --- a/configs/ls1088ardb_sdcard_qspi_defconfig
> +++ b/configs/ls1088ardb_sdcard_qspi_defconfig
> @@ -23,6 +23,7 @@ CONFIG_SPL_I2C_SUPPORT=y
>  

[U-Boot] [PATCH V2] Convert CONFIG_CMD_NAND to Kconfig

2018-01-23 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_CMD_NAND

Signed-off-by: Adam Ford 
---
V2:  Remove SUNXI default since this is selected when NAND_SUNXI is
 Since they cannot both recursively check each other.  This was
 causing some trouble.

V1:  Several boards check for the presence of CONFIG_CMD_NAND instead of
 CONFIG_NAND when setting up their NAND parameters.  This will now
 define CONFIG_NAND if CMD_NAND is set.

 cmd/Kconfig  | 2 +-
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088aqds_qspi_defconfig| 1 +
 configs/ls1088aqds_sdcard_qspi_defconfig | 1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088ardb_qspi_defconfig| 1 +
 configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls1088ardb_sdcard_qspi_defconfig | 1 +
 configs/pfla02_defconfig | 1 +
 include/configs/ls1088aqds.h | 1 -
 include/configs/ls1088ardb.h | 1 -
 include/configs/pfla02.h | 1 -
 include/configs/sama5d27_som1_ek.h   | 1 -
 13 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 35fe9d5..a16cf74 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -763,7 +763,7 @@ config CMD_MMC
 
 config CMD_NAND
bool "nand"
-   default y if NAND_SUNXI
+   select NAND
help
  NAND support.
 
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index e464951..28c9029 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -12,6 +12,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index 1e368d7..7acd747 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -11,6 +11,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
b/configs/ls1088aqds_sdcard_qspi_defconfig
index 659bc4f..cb8b426 100644
--- a/configs/ls1088aqds_sdcard_qspi_defconfig
+++ b/configs/ls1088aqds_sdcard_qspi_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
index 19c76b6..5cc652c 100644
--- a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
@@ -13,6 +13,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/ls1088ardb_qspi_defconfig 
b/configs/ls1088ardb_qspi_defconfig
index 8a08846..62128ed 100644
--- a/configs/ls1088ardb_qspi_defconfig
+++ b/configs/ls1088ardb_qspi_defconfig
@@ -12,6 +12,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT"
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
index a7466f1..ccba0fc 100644
--- a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
diff --git a/configs/ls1088ardb_sdcard_qspi_defconfig 
b/configs/ls1088ardb_sdcard_qspi_defconfig
index 2e3c287..c72992e 100644
--- a/configs/ls1088ardb_sdcard_qspi_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/pfla02_defconfig b/configs/pfla02_defconfig
index 029c9de..59ee623 100644
--- a/configs/pfla02_defconfig
+++ b/configs/pfla02_defconfig
@@ -26,6 +26,7 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
diff --git 

[U-Boot] Please pull u-boot-fsl-qoriq master

2018-01-23 Thread York Sun
Tom,

The following changes since commit 485c13c7536731991c59f7b3432bc33c9dafb0f0:

  Merge git://git.denx.de/u-boot-dm (2018-01-21 20:13:29 -0500)

are available in the git repository at:

  git://git.denx.de/u-boot-fsl-qoriq.git
6c8945ec41cb7bff27fbacc88316e3e557c20240

for you to fetch changes up to 6c8945ec41cb7bff27fbacc88316e3e557c20240:

  armv8: ls1088a: Add IFC and eMMC as qixis boot sources (2018-01-23
11:26:21 -0800)


Ashish Kumar (2):
  fsl: common: qixis: Add ifc and emmc switching via qixis
  armv8: ls1088a: Add IFC and eMMC as qixis boot sources

Breno Lima (1):
  crypto/fsl: Fix HW accelerated hash commands

Pankaj Bansal (1):
  ARM: dts: Freescale: re-license device tree files under GPLv2+/X11

Rajesh Bhagat (11):
  armv8: lsch3: Add serdes and DDR voltage setup
  board: common:vid: Add LS1088A VID Supported voltage values
  board: common: vid: Add board specific vdd adjust API
  board: common: vid: Move IR chip specific code in flag
  Kconfig: Add LTC3882 voltage regulator config
  board: common: vid: Add support for LTC3882 voltage regulator chip
  ddr: fsl: set cdr1 first in case 0.9v VDD is enabled for some SoCs
  ls1088a: ddr: configure DDR for 0.9v for VID support
  common: board_f: vid: Add VID specific API to adjust core voltage
  ls1088a: Add VID support for QDS and RDB platforms
  armv8: ls1088a: vid: Compiling VID specific functions for SPL

 .../cpu/armv8/fsl-layerscape/fsl_lsch3_serdes.c| 287
+
 arch/arm/cpu/armv8/fsl-layerscape/soc.c|  39 +++
 arch/arm/cpu/armv8/fsl-layerscape/spl.c|   3 +
 arch/arm/dts/fsl-ls1012a-frdm.dts  |   2 +-
 arch/arm/dts/fsl-ls1012a-frdm.dtsi |   2 +-
 arch/arm/dts/fsl-ls1012a-qds.dts   |   2 +-
 arch/arm/dts/fsl-ls1012a-qds.dtsi  |   2 +-
 arch/arm/dts/fsl-ls1012a-rdb.dts   |   2 +-
 arch/arm/dts/fsl-ls1012a-rdb.dtsi  |   4 +-
 arch/arm/dts/fsl-ls1012a.dtsi  |   2 +-
 arch/arm/dts/fsl-ls1043a-qds-duart.dts |   2 +-
 arch/arm/dts/fsl-ls1043a-qds-lpuart.dts|   2 +-
 arch/arm/dts/fsl-ls1043a-qds.dtsi  |   4 +-
 arch/arm/dts/fsl-ls1043a-rdb.dts   |   4 +-
 arch/arm/dts/fsl-ls1043a.dtsi  |   4 +-
 arch/arm/dts/fsl-ls1046a-qds-duart.dts |   2 +-
 arch/arm/dts/fsl-ls1046a-qds-lpuart.dts|   2 +-
 arch/arm/dts/fsl-ls1046a-qds.dtsi  |   4 +-
 arch/arm/dts/fsl-ls1046a-rdb.dts   |   4 +-
 arch/arm/dts/fsl-ls1046a.dtsi  |   4 +-
 arch/arm/dts/fsl-ls1088a-qds.dts   |   2 +-
 arch/arm/dts/fsl-ls1088a-rdb.dts   |   2 +-
 arch/arm/dts/fsl-ls1088a.dtsi  |   2 +-
 arch/arm/dts/fsl-ls2080a-qds.dts   |   2 +-
 arch/arm/dts/fsl-ls2080a-rdb.dts   |   2 +-
 arch/arm/dts/fsl-ls2080a.dtsi  |   2 +-
 arch/arm/dts/fsl-ls2081a-rdb.dts   |   2 +-
 arch/arm/dts/fsl-ls2088a-rdb-qspi.dts  |   2 +-
 .../include/asm/arch-fsl-layerscape/fsl_serdes.h   |   2 +-
 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  |  43 ++-
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |   1 +
 board/freescale/common/Kconfig |  16 ++
 board/freescale/common/Makefile|   2 +-
 board/freescale/common/qixis.c |  22 ++
 board/freescale/common/vid.c   | 147 ++-
 board/freescale/ls1088a/ddr.c  |  21 ++
 board/freescale/ls1088a/ls1088a.c  | 131 ++
 common/board_f.c   |  10 +
 common/hash.c  |   7 +-
 drivers/crypto/fsl/fsl_hash.c  |  20 +-
 drivers/ddr/fsl/fsl_ddr_gen4.c |   4 +-
 include/common.h   |   3 +
 include/configs/ls1088aqds.h   |  31 +++
 include/configs/ls1088ardb.h   |  29 +++
 44 files changed, 835 insertions(+), 47 deletions(-)

Thanks.

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


Re: [U-Boot] [PATCH] cmd: Kconfig: Make CMD_NAND select NAND

2018-01-23 Thread Adam Ford
On Tue, Jan 23, 2018 at 12:10 PM, Andrew F. Davis  wrote:
> On 01/23/2018 12:01 PM, Adam Ford wrote:
>> On Tue, Jan 23, 2018 at 11:15 AM, Andrew F. Davis  wrote:
>>> On 01/23/2018 04:40 AM, Adam Ford wrote:
 Many boards check for CONFIG_CMD_NAND instead of CONFIG_NAND, so
 let's make CMD_NAND select NAND to make some Kconfig migration
 easier

 Signed-off-by: Adam Ford 

 diff --git a/cmd/Kconfig b/cmd/Kconfig
 index 35fe9d5..9f6b351 100644
 --- a/cmd/Kconfig
 +++ b/cmd/Kconfig
 @@ -764,6 +764,7 @@ config CMD_MMC
  config CMD_NAND
   bool "nand"
   default y if NAND_SUNXI
 + select NAND
>>>
>>> Should be depends on
>>
>> On the surface, I would agree with you, but many boards are looking
>> for CONFIG_CMD_NAND and not looking for (or dependant on) CONFIG_NAND
>> to set their NAND parameters. I was hoping to do some NAND parameter
>> migration and I was going to make those parameters dependent on
>> CONFIG_NAND by setting CONFIG_NAND from CMD_NAND, it makes this
>> migration a lot smoother.  Otherwise, I have to go through a bunch of
>> configs and enable CONFIG_NAND in each one.
>>
>
>
> Well as long as it helps the migration and can/will be fixed up after, I
> don't object.

I think I am going to re-spin this.  There are some issues with SUNXI
dependency issues.  I'll fix those and re-submit the CONFIG_NAND stuff
by itself which should then allow for a subsequent set of
CONFIG_NAND_xx changes and other items dependent on NAND_X drivers.

adam

>
>
>> adam
>>>
   help
 NAND support.


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


[U-Boot] [PATCH 7/8] sunxi: dts: Add NAND node to sun8i DTSI

2018-01-23 Thread Miquel Raynal
Add the NAND controller node, as well as the definition of the missing
pins and clock.

Signed-off-by: Miquel Raynal 
---
 arch/arm/dts/sun8i-a23-a33.dtsi | 31 +++
 arch/arm/dts/sun8i-a33.dtsi |  8 
 2 files changed, 39 insertions(+)

diff --git a/arch/arm/dts/sun8i-a23-a33.dtsi b/arch/arm/dts/sun8i-a23-a33.dtsi
index f97c38f097..fe6ea82cb3 100644
--- a/arch/arm/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/dts/sun8i-a23-a33.dtsi
@@ -325,6 +325,19 @@
#size-cells = <0>;
};
 
+   nfc: nand@01c03000 {
+   compatible = "allwinner,sun4i-a10-nand";
+   reg = <0x01c03000 0x1000>;
+   interrupts = ;
+   clocks = <_gates 25>, <_clk>;
+   clock-names = "ahb", "mod";
+   resets = <_rst 10>;
+   reset-names = "ahb";
+   status = "disabled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
+
ehci0: usb@01c1a000 {
compatible = "allwinner,sun8i-a23-ehci", "generic-ehci";
reg = <0x01c1a000 0x100>;
@@ -364,6 +377,24 @@
allwinner,pull = ;
};
 
+   nand_pins_a: nand-base0@0 {
+   allwinner,pins = "PC0", "PC1", "PC2",
+   "PC5", "PC8", "PC9", "PC10",
+   "PC11", "PC12", "PC13", "PC14",
+   "PC15";
+   allwinner,function = "nand0";
+   };
+
+   nand_cs0_pins_a: nand-cs@0 {
+   allwinner,pins = "PC4";
+   allwinner,function = "nand0";
+   };
+
+   nand_rb0_pins_a: nand-rb@0 {
+   allwinner,pins = "PC6";
+   allwinner,function = "nand0";
+   };
+
mmc0_pins_a: mmc0@0 {
allwinner,pins = "PF0", "PF1", "PF2",
 "PF3", "PF4", "PF5";
diff --git a/arch/arm/dts/sun8i-a33.dtsi b/arch/arm/dts/sun8i-a33.dtsi
index 001d8402ca..2ef817a679 100644
--- a/arch/arm/dts/sun8i-a33.dtsi
+++ b/arch/arm/dts/sun8i-a33.dtsi
@@ -99,6 +99,14 @@
"ahb1_sat";
};
 
+   nand_clk: clk@01c20080 {
+   #clock-cells = <0>;
+   compatible = "allwinner,sun4i-a10-mod0-clk";
+   reg = <0x01c20080 0x4>;
+   clocks = <>, < 1>, < 1>;
+   clock-output-names = "nand";
+   };
+
ss_clk: clk@01c2009c {
#clock-cells = <0>;
compatible = "allwinner,sun4i-a10-mod0-clk";
-- 
2.11.0

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


[U-Boot] [PATCH 6/8] configs: Add NAND support for NES Classic

2018-01-23 Thread Miquel Raynal
Add NAND parameters to the Nintendo NES Classic configuration file.

Signed-off-by: Miquel Raynal 
---
 configs/Nintendo_NES_Classic_Edition_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/configs/Nintendo_NES_Classic_Edition_defconfig 
b/configs/Nintendo_NES_Classic_Edition_defconfig
index d05375d0db..467055279c 100644
--- a/configs/Nintendo_NES_Classic_Edition_defconfig
+++ b/configs/Nintendo_NES_Classic_Edition_defconfig
@@ -9,6 +9,10 @@ CONFIG_AXP_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-nintendo-nes-classic-edition"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y
+CONFIG_SPL_NAND_SUPPORT=y
+CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCK_SIZE=0x2,SYS_NAND_PAGE_SIZE=2048,SYS_NAND_OOBSIZE=64"
+CONFIG_NAND=y
+CONFIG_NAND_SUNXI=y
 CONFIG_FASTBOOT_FLASH=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
-- 
2.11.0

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


[U-Boot] [PATCH 5/8] spl: nand: sunxi: use PIO instead of DMA

2018-01-23 Thread Miquel Raynal
Because using DMA implementation is not generic and was not developped
to work on SoCs like A33, migrate the SPL to use PIO.

Signed-off-by: Miquel Raynal 
---
 board/sunxi/board.c   |   4 +-
 drivers/mtd/nand/sunxi_nand_spl.c | 167 +-
 2 files changed, 79 insertions(+), 92 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 70e01437c4..512e2c17a6 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -266,11 +266,13 @@ static void nand_clock_setup(void)
struct sunxi_ccm_reg *const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 
-   setbits_le32(>ahb_gate0, (CLK_GATE_OPEN << AHB_GATE_OFFSET_NAND0));
+   setbits_le32(>ahb_gate0, (1 << AHB_GATE_OFFSET_NAND0));
+   setbits_le32(>ahb_reset0_cfg, (1 << AHB_GATE_OFFSET_NAND0));
 #ifdef CONFIG_MACH_SUN9I
setbits_le32(>ahb_gate1, (1 << AHB_GATE_OFFSET_DMA));
 #else
setbits_le32(>ahb_gate0, (1 << AHB_GATE_OFFSET_DMA));
+   setbits_le32(>ahb_reset0_cfg, (1 << AHB_GATE_OFFSET_DMA));
 #endif
setbits_le32(>nand0_clk_cfg, CCM_NAND_CTRL_ENABLE | AHB_DIV_1);
 }
diff --git a/drivers/mtd/nand/sunxi_nand_spl.c 
b/drivers/mtd/nand/sunxi_nand_spl.c
index 2488d5cb51..5de6825994 100644
--- a/drivers/mtd/nand/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/sunxi_nand_spl.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* registers */
 #define NFC_CTL0x
@@ -45,32 +46,22 @@
 #define NFC_CTL_PAGE_SIZE_MASK (0xf << 8)
 #define NFC_CTL_PAGE_SIZE(a)   ((fls(a) - 11) << 8)
 
-
 #define NFC_ECC_EN (1 << 0)
-#define NFC_ECC_PIPELINE   (1 << 3)
 #define NFC_ECC_EXCEPTION  (1 << 4)
 #define NFC_ECC_BLOCK_SIZE (1 << 5)
 #define NFC_ECC_RANDOM_EN  (1 << 9)
-#define NFC_ECC_RANDOM_DIRECTION   (1 << 10)
-
 
 #define NFC_ADDR_NUM_OFFSET16
-#define NFC_ACCESS_DIR (1 << 20)
 #define NFC_SEND_ADDR  (1 << 19)
 #define NFC_DATA_TRANS (1 << 21)
 #define NFC_SEND_CMD1  (1 << 22)
 #define NFC_WAIT_FLAG  (1 << 23)
 #define NFC_SEND_CMD2  (1 << 24)
-#define NFC_SEQ(1 << 25)
-#define NFC_DATA_SWAP_METHOD   (1 << 26)
-#define NFC_ROW_AUTO_INC   (1 << 27)
-#define NFC_SEND_CMD3  (1 << 28)
-#define NFC_SEND_CMD4  (1 << 29)
 #define NFC_RAW_CMD(0 << 30)
-#define NFC_PAGE_CMD   (2 << 30)
+#define NFC_ECC_CMD(1 << 30)
 
 #define NFC_ST_CMD_INT_FLAG(1 << 1)
-#define NFC_ST_DMA_INT_FLAG(1 << 2)
+#define NFC_ST_CMD_FIFO_STAT   (1 << 3)
 
 #define NFC_READ_CMD_OFFSET 0
 #define NFC_RANDOM_READ_CMD0_OFFSET 8
@@ -80,22 +71,6 @@
 #define NFC_CMD_RNDOUT 0x05
 #define NFC_CMD_READSTART  0x30
 
-#define SUNXI_DMA_CFG_REG0  0x300
-#define SUNXI_DMA_SRC_START_ADDR_REG0   0x304
-#define SUNXI_DMA_DEST_START_ADDRR_REG0 0x308
-#define SUNXI_DMA_DDMA_BC_REG0  0x30C
-#define SUNXI_DMA_DDMA_PARA_REG00x318
-
-#define SUNXI_DMA_DDMA_CFG_REG_LOADING  (1 << 31)
-#define SUNXI_DMA_DDMA_CFG_REG_DMA_DEST_DATA_WIDTH_32 (2 << 25)
-#define SUNXI_DMA_DDMA_CFG_REG_DDMA_DST_DRQ_TYPE_DRAM (1 << 16)
-#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_DATA_WIDTH_32 (2 << 9)
-#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_ADDR_MODE_IO (1 << 5)
-#define SUNXI_DMA_DDMA_CFG_REG_DDMA_SRC_DRQ_TYPE_NFC (3 << 0)
-
-#define SUNXI_DMA_DDMA_PARA_REG_SRC_WAIT_CYC (0x0F << 0)
-#define SUNXI_DMA_DDMA_PARA_REG_SRC_BLK_SIZE (0x7F << 8)
-
 struct nfc_config {
int page_size;
int ecc_strength;
@@ -254,7 +229,23 @@ static int nand_reset_column(void)
   SUNXI_NFC_BASE + NFC_CMD);
 
return nand_wait_int();
+}
 
+static int nand_change_column(u16 column)
+{
+   nand_wait_cmd_fifo_empty();
+
+   writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) |
+  (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) |
+  (NFC_CMD_RNDOUTSTART << NFC_READ_CMD_OFFSET),
+  SUNXI_NFC_BASE + NFC_RCMD_SET);
+   writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
+   writel(column, SUNXI_NFC_BASE + NFC_ADDR_LOW);
+   writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD |
+  (1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADDR | NFC_CMD_RNDOUT,
+  SUNXI_NFC_BASE + NFC_CMD);
+
+   return nand_wait_int();
 }
 
 static const int ecc_bytes[] = {32, 46, 54, 60, 74, 88, 102, 110, 116};
@@ -262,86 +253,80 @@ static const int ecc_bytes[] = {32, 46, 54, 60, 74, 88, 
102, 110, 116};
 static int nand_read_page(const struct nfc_config *conf, u32 offs,
  void *dest, int len)
 {
-   dma_addr_t dst = (dma_addr_t)dest;
int nsectors = len / conf->ecc_size;
u16 rand_seed = 0;
-   u32 val;
-   int page;
-
-   page = offs / conf->page_size;
+ 

[U-Boot] [PATCH 3/8] sunxi: Allow SPL to be compiled for sun8i platforms

2018-01-23 Thread Miquel Raynal
Add some clocks/PLL definitions and the dependency on MACH_SUN8I in
Kconfig so the SPL could be compiled to boards using A33 SoCs.

Signed-off-by: Miquel Raynal 
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 6 ++
 drivers/mtd/nand/Kconfig  | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h 
b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index d328df9597..d35aa479f7 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -192,6 +192,7 @@ struct sunxi_ccm_reg {
 #define ATB_DIV_1  0
 #define ATB_DIV_2  1
 #define ATB_DIV_4  2
+#define AHB_DIV_1  0
 #define CPU_CLK_SRC_OSC24M 1
 #define CPU_CLK_SRC_PLL1   2
 
@@ -317,6 +318,11 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_LCD0   3
 #endif
 
+#define CCM_NAND_CTRL_M(x) ((x) - 1)
+#define CCM_NAND_CTRL_N(x) ((x) << 16)
+#define CCM_NAND_CTRL_PLL6 (0x1 << 24)
+#define CCM_NAND_CTRL_ENABLE   (0x1 << 31)
+
 #define CCM_MMC_CTRL_M(x)  ((x) - 1)
 #define CCM_MMC_CTRL_OCLK_DLY(x)   ((x) << 8)
 #define CCM_MMC_CTRL_N(x)  ((x) << 16)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 85b26d6088..2f37a8014d 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -78,7 +78,7 @@ config NAND_PXA3XX
 
 config NAND_SUNXI
bool "Support for NAND on Allwinner SoCs"
-   depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+   depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I
select SYS_NAND_SELF_INIT
select SYS_NAND_U_BOOT_LOCATIONS
imply CMD_NAND
-- 
2.11.0

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


[U-Boot] [PATCH 8/8] sunxi: dts: Enable NAND on NES classic

2018-01-23 Thread Miquel Raynal
Let the Nintendo NES Classic use the Macronix NAND chip on it.

Signed-off-by: Miquel Raynal 
---
 arch/arm/dts/sun8i-r16-nintendo-nes-classic-edition.dts | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/dts/sun8i-r16-nintendo-nes-classic-edition.dts 
b/arch/arm/dts/sun8i-r16-nintendo-nes-classic-edition.dts
index dce688ec8e..b8535d3dac 100644
--- a/arch/arm/dts/sun8i-r16-nintendo-nes-classic-edition.dts
+++ b/arch/arm/dts/sun8i-r16-nintendo-nes-classic-edition.dts
@@ -61,3 +61,17 @@
pinctrl-0 = <_pins_a>;
status = "okay";
 };
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_a _cs0_pins_a _rb0_pins_a>;
+   status = "okay";
+
+   nand@0 {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   reg = <0>;
+   allwinner,rb = <0>;
+   nand-ecc-mode = "hw";
+   };
+};
-- 
2.11.0

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


[U-Boot] [PATCH 4/8] spl: nand: sunxi: Enhancements and cleaning

2018-01-23 Thread Miquel Raynal
Do some cleaning in sunxi NAND SPL driver like adding helpers and
clearing flags at the right spot

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/nand/sunxi_nand_spl.c | 64 +--
 1 file changed, 41 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand_spl.c 
b/drivers/mtd/nand/sunxi_nand_spl.c
index 06695fc15f..2488d5cb51 100644
--- a/drivers/mtd/nand/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/sunxi_nand_spl.c
@@ -55,8 +55,8 @@
 
 
 #define NFC_ADDR_NUM_OFFSET16
-#define NFC_SEND_ADR   (1 << 19)
 #define NFC_ACCESS_DIR (1 << 20)
+#define NFC_SEND_ADDR  (1 << 19)
 #define NFC_DATA_TRANS (1 << 21)
 #define NFC_SEND_CMD1  (1 << 22)
 #define NFC_WAIT_FLAG  (1 << 23)
@@ -155,6 +155,30 @@ static inline int check_value_negated(int offset, int 
unexpected_bits,
return check_value_inner(offset, unexpected_bits, timeout_us, 1);
 }
 
+static int nand_wait_cmd_fifo_empty(void)
+{
+   if (!check_value_negated(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_FIFO_STAT,
+DEFAULT_TIMEOUT_US)) {
+   printf("nand: timeout waiting for empty cmd FIFO\n");
+   return -ETIMEDOUT;
+   }
+
+   return 0;
+}
+
+static int nand_wait_int(void)
+{
+   if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
+DEFAULT_TIMEOUT_US)) {
+   printf("nand: timeout waiting for interruption\n");
+   return -ETIMEDOUT;
+   }
+
+   udelay(1);
+
+   return 0;
+}
+
 void nand_init(void)
 {
uint32_t val;
@@ -172,22 +196,21 @@ void nand_init(void)
}
 
/* reset NAND */
+   nand_wait_cmd_fifo_empty();
+
writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
writel(NFC_SEND_CMD1 | NFC_WAIT_FLAG | NAND_CMD_RESET,
   SUNXI_NFC_BASE + NFC_CMD);
 
-   if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
-DEFAULT_TIMEOUT_US)) {
-   printf("Error timeout waiting for nand reset\n");
-   return;
-   }
-   writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
+   nand_wait_int();
 }
 
 static void nand_apply_config(const struct nfc_config *conf)
 {
u32 val;
 
+   nand_wait_cmd_fifo_empty();
+
val = readl(SUNXI_NFC_BASE + NFC_CTL);
val &= ~NFC_CTL_PAGE_SIZE_MASK;
writel(val | NFC_CTL_RAM_METHOD | NFC_CTL_PAGE_SIZE(conf->page_size),
@@ -200,6 +223,8 @@ static int nand_load_page(const struct nfc_config *conf, 
u32 offs)
 {
int page = offs / conf->page_size;
 
+   nand_wait_cmd_fifo_empty();
+
writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) |
   (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) |
   (NFC_CMD_READSTART << NFC_READ_CMD_OFFSET),
@@ -208,38 +233,32 @@ static int nand_load_page(const struct nfc_config *conf, 
u32 offs)
writel((page >> 16) & 0xFF, SUNXI_NFC_BASE + NFC_ADDR_HIGH);
writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD | NFC_WAIT_FLAG |
-  ((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR,
+  ((conf->addr_cycles - 1) << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADDR,
   SUNXI_NFC_BASE + NFC_CMD);
 
-   if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
-DEFAULT_TIMEOUT_US)) {
-   printf("Error while initializing dma interrupt\n");
-   return -EIO;
-   }
-
-   return 0;
+   return nand_wait_int();
 }
 
 static int nand_reset_column(void)
 {
+   nand_wait_cmd_fifo_empty();
+
writel((NFC_CMD_RNDOUTSTART << NFC_RANDOM_READ_CMD1_OFFSET) |
   (NFC_CMD_RNDOUT << NFC_RANDOM_READ_CMD0_OFFSET) |
   (NFC_CMD_RNDOUTSTART << NFC_READ_CMD_OFFSET),
   SUNXI_NFC_BASE + NFC_RCMD_SET);
+   writel(NFC_ST_CMD_INT_FLAG, SUNXI_NFC_BASE + NFC_ST);
writel(0, SUNXI_NFC_BASE + NFC_ADDR_LOW);
writel(NFC_SEND_CMD1 | NFC_SEND_CMD2 | NFC_RAW_CMD |
-  (1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADR | NFC_CMD_RNDOUT,
+  (1 << NFC_ADDR_NUM_OFFSET) | NFC_SEND_ADDR | NFC_CMD_RNDOUT,
   SUNXI_NFC_BASE + NFC_CMD);
 
-   if (!check_value(SUNXI_NFC_BASE + NFC_ST, NFC_ST_CMD_INT_FLAG,
-DEFAULT_TIMEOUT_US)) {
-   printf("Error while initializing dma interrupt\n");
-   return -1;
-   }
+   return nand_wait_int();
 
-   return 0;
 }
 
+static const int ecc_bytes[] = {32, 46, 54, 60, 74, 88, 102, 110, 116};
+
 static int nand_read_page(const struct nfc_config *conf, u32 offs,
  void *dest, int len)
 {
@@ -327,7 +346,6 @@ static int nand_read_page(const struct nfc_config *conf, 
u32 offs,
 
 static int 

[U-Boot] [PATCH 2/8] spl: nand: sunxi: Fix second case of modulo by zero error

2018-01-23 Thread Miquel Raynal
In the nand_read_buffer() step, the seed is calculated by doing a modulo
by conf->nseeds which is always zero when not using the randomizer (most
of SLC NANDs).

This situation turns out to lead to a run time freeze.

Derive this seed only when the randomizer is enabled (and conf->nseeds
logically not zero).

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/nand/sunxi_nand_spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand_spl.c 
b/drivers/mtd/nand/sunxi_nand_spl.c
index eed4472bdc..06695fc15f 100644
--- a/drivers/mtd/nand/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/sunxi_nand_spl.c
@@ -475,11 +475,12 @@ static int nand_detect_config(struct nfc_config *conf, 
u32 offs, void *dest)
 static int nand_read_buffer(struct nfc_config *conf, uint32_t offs,
unsigned int size, void *dest)
 {
-   int first_seed, page, ret;
+   int first_seed = 0, page, ret;
 
size = ALIGN(size, conf->page_size);
page = offs / conf->page_size;
-   first_seed = page % conf->nseeds;
+   if (conf->randomize)
+   first_seed = page % conf->nseeds;
 
for (; size; size -= conf->page_size) {
if (nand_load_page(conf, offs))
-- 
2.11.0

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


[U-Boot] [PATCH 1/8] mtd: nand: sunxi: Fix strength minimum value

2018-01-23 Thread Miquel Raynal
When no requirement in Device Tree is given about the ECC strength and
step size, the engine should fallback on the minimal working case for
this engine (16b/1024B) instead of the NAND chip requirement which might
be simply unreachable.

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/nand/sunxi_nand.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 8bc3828854..e8e7ad8ac5 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1417,6 +1417,7 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct 
mtd_info *mtd,
goto err;
}
 
+   ecc->strength = strengths[i];
data->mode = i;
 
/* HW ECC always request ECC bytes for 1024 bytes blocks */
-- 
2.11.0

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


[U-Boot] [PATCH 0/8] Bring NAND support to Nintendo NES Classic

2018-01-23 Thread Miquel Raynal
Hello,

This series adds fixes to sunxi NAND drivers (SPL and U-Boot), in order
to later migrate the SPL driver to use PIO instead of DMA to have more
generic code (working also on a A33). Finally, NAND support is added to
Nintendo NES Classic through Kconfig and DT additions.

Thanks,
Miquèl

Miquel Raynal (8):
  mtd: nand: sunxi: Fix strength minimum value
  spl: nand: sunxi: Fix second case of modulo by zero error
  sunxi: Allow SPL to be compiled for sun8i platforms
  spl: nand: sunxi: Enhancements and cleaning
  spl: nand: sunxi: use PIO instead of DMA
  configs: Add NAND support for NES Classic
  sunxi: dts: Add NAND node to sun8i DTSI
  sunxi: dts: Enable NAND on NES classic

 arch/arm/dts/sun8i-a23-a33.dtsi|  31 +++
 arch/arm/dts/sun8i-a33.dtsi|   8 +
 .../dts/sun8i-r16-nintendo-nes-classic-edition.dts |  14 ++
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h  |   6 +
 board/sunxi/board.c|   4 +-
 configs/Nintendo_NES_Classic_Edition_defconfig |   4 +
 drivers/mtd/nand/Kconfig   |   2 +-
 drivers/mtd/nand/sunxi_nand.c  |   1 +
 drivers/mtd/nand/sunxi_nand_spl.c  | 236 +++--
 9 files changed, 188 insertions(+), 118 deletions(-)

-- 
2.11.0

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


Re: [U-Boot] [PATCH 1/1] efi_loader: always call Exit after an image returns.

2018-01-23 Thread Alexander Graf


> Am 24.01.2018 um 01:05 schrieb Heinrich Schuchardt :
> 
>> On 01/24/2018 12:31 AM, Alexander Graf wrote:
>> 
>> 
>>> On 23.01.18 23:46, Heinrich Schuchardt wrote:
>>> If an application or driver started via StartImage returns without
>>> calling Exit, StartImage has to call Exit. This is mandated by the
>>> UEFI spec and we do the same in efi_do_enter().
>>> 
>>> The patch looks bigger than it is. To avoid a forward declaration function
>>> efi_exit() was moved up. Only one (void*) was replaced by (void *).
>>> The only real change is in efi_start_image().
>>> 
>>> Signed-off-by: Heinrich Schuchardt 
>>> ---
>>> Without this patch on Ubuntu 16.04 a crash could be observed in
>>> efi_selftest_startimage_return.c. With the patch it is gone.
>>> But this could be coincidence.
>>> ---
>>> lib/efi_loader/efi_boottime.c | 99 
>>> ++-
>>> 1 file changed, 51 insertions(+), 48 deletions(-)
>>> 
>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>> index 0ac5b44..62a24bf 100644
>>> --- a/lib/efi_loader/efi_boottime.c
>>> +++ b/lib/efi_loader/efi_boottime.c
>>> @@ -1519,6 +1519,54 @@ failure:
>>> }
>>> 
>>> /*
>>> + * Leave an EFI application or driver.
>>> + *
>>> + * This function implements the Exit service.
>>> + * See the Unified Extensible Firmware Interface (UEFI) specification
>>> + * for details.
>>> + *
>>> + * @image_handlehandle of the application or driver that is exiting
>>> + * @exit_statusstatus code
>>> + * @exit_data_sizesize of the buffer in bytes
>>> + * @exit_databuffer with data describing an error
>>> + * @returnstatus code
>>> + */
>>> +static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
>>> +efi_status_t exit_status, unsigned long exit_data_size,
>>> +int16_t *exit_data)
>>> +{
>>> +/*
>>> + * We require that the handle points to the original loaded
>>> + * image protocol interface.
>>> + *
>>> + * For getting the longjmp address this is safer than locating
>>> + * the protocol because the protocol may have been reinstalled
>>> + * pointing to another memory location.
>>> + *
>>> + * TODO: We should call the unload procedure of the loaded
>>> + * image protocol.
>>> + */
>>> +struct efi_loaded_image *loaded_image_info = (void *)image_handle;
>>> +
>>> +EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
>>> +  exit_data_size, exit_data);
>>> +
>>> +/* Make sure entry/exit counts for EFI world cross-overs match */
>>> +EFI_EXIT(exit_status);
>>> +
>>> +/*
>>> + * But longjmp out with the U-Boot gd, not the application's, as
>>> + * the other end is a setjmp call inside EFI context.
>>> + */
>>> +efi_restore_gd();
>>> +
>>> +loaded_image_info->exit_status = exit_status;
>>> +longjmp(_image_info->exit_jmp, 1);
>>> +
>>> +panic("EFI application exited");
>>> +}
>>> +
>>> +/*
>>>  * Call the entry point of an image.
>>>  *
>>>  * This function implements the StartImage service.
>>> @@ -1575,59 +1623,14 @@ static efi_status_t EFIAPI 
>>> efi_start_image(efi_handle_t image_handle,
>>> 
>>>ret = EFI_CALL(entry(image_handle, ));
>>> 
>>> +/* Clean up the image */
>>> +ret = EFI_CALL(efi_exit(image_handle, ret, 0, NULL));
>> 
>> Just use the systab here, like we do in efi_do_enter().
> 
> No, efi_do_enter passes image_handle to efi_exit().
> 
> The UEFI API requires the image handle. It is the same image handle that
> the application would pass when calling Exit.
> 
> efi_exit() uses the handle as pointer to the loaded image information.

I mean use the systab to get to efi_exit instead of shuffling code around :). 
It‘s what we do in bootefi as well.


Alex


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


Re: [U-Boot] [PATCH 1/1] efi_loader: always call Exit after an image returns.

2018-01-23 Thread Heinrich Schuchardt
On 01/24/2018 12:31 AM, Alexander Graf wrote:
> 
> 
> On 23.01.18 23:46, Heinrich Schuchardt wrote:
>> If an application or driver started via StartImage returns without
>> calling Exit, StartImage has to call Exit. This is mandated by the
>> UEFI spec and we do the same in efi_do_enter().
>>
>> The patch looks bigger than it is. To avoid a forward declaration function
>> efi_exit() was moved up. Only one (void*) was replaced by (void *).
>> The only real change is in efi_start_image().
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>> Without this patch on Ubuntu 16.04 a crash could be observed in
>> efi_selftest_startimage_return.c. With the patch it is gone.
>> But this could be coincidence.
>> ---
>>  lib/efi_loader/efi_boottime.c | 99 
>> ++-
>>  1 file changed, 51 insertions(+), 48 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>> index 0ac5b44..62a24bf 100644
>> --- a/lib/efi_loader/efi_boottime.c
>> +++ b/lib/efi_loader/efi_boottime.c
>> @@ -1519,6 +1519,54 @@ failure:
>>  }
>>  
>>  /*
>> + * Leave an EFI application or driver.
>> + *
>> + * This function implements the Exit service.
>> + * See the Unified Extensible Firmware Interface (UEFI) specification
>> + * for details.
>> + *
>> + * @image_handlehandle of the application or driver that is exiting
>> + * @exit_status status code
>> + * @exit_data_size  size of the buffer in bytes
>> + * @exit_data   buffer with data describing an error
>> + * @return  status code
>> + */
>> +static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
>> +efi_status_t exit_status, unsigned long exit_data_size,
>> +int16_t *exit_data)
>> +{
>> +/*
>> + * We require that the handle points to the original loaded
>> + * image protocol interface.
>> + *
>> + * For getting the longjmp address this is safer than locating
>> + * the protocol because the protocol may have been reinstalled
>> + * pointing to another memory location.
>> + *
>> + * TODO: We should call the unload procedure of the loaded
>> + *   image protocol.
>> + */
>> +struct efi_loaded_image *loaded_image_info = (void *)image_handle;
>> +
>> +EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
>> +  exit_data_size, exit_data);
>> +
>> +/* Make sure entry/exit counts for EFI world cross-overs match */
>> +EFI_EXIT(exit_status);
>> +
>> +/*
>> + * But longjmp out with the U-Boot gd, not the application's, as
>> + * the other end is a setjmp call inside EFI context.
>> + */
>> +efi_restore_gd();
>> +
>> +loaded_image_info->exit_status = exit_status;
>> +longjmp(_image_info->exit_jmp, 1);
>> +
>> +panic("EFI application exited");
>> +}
>> +
>> +/*
>>   * Call the entry point of an image.
>>   *
>>   * This function implements the StartImage service.
>> @@ -1575,59 +1623,14 @@ static efi_status_t EFIAPI 
>> efi_start_image(efi_handle_t image_handle,
>>  
>>  ret = EFI_CALL(entry(image_handle, ));
>>  
>> +/* Clean up the image */
>> +ret = EFI_CALL(efi_exit(image_handle, ret, 0, NULL));
> 
> Just use the systab here, like we do in efi_do_enter().

No, efi_do_enter passes image_handle to efi_exit().

The UEFI API requires the image handle. It is the same image handle that
the application would pass when calling Exit.

efi_exit() uses the handle as pointer to the loaded image information.

> 
> While I think the change is reasonable, as it brings the bootefi and the
> start_image calls together, I can't really see an obvious reason why
> this code would work and the one without longjmp would not...

Yes analyzing the crash observed on Ubuntu is a different story.

This shouldn't stop us from making efi_start_image standard compliant.

Maybe you want to put this patch into an branch for 2018.05-rc1.

Regards

Heinrich


> 
> 
> Alex
> 

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


[U-Boot] Please pull u-boot-coldfire/master

2018-01-23 Thread Angelo Dureghello
The following changes since commit c761a7e29d703d60208585bb7d8415e00aa22556:

  Revert "travis-ci: Add qemu-x86_64 target" (2018-01-22 21:06:41 -0500)

are available in the Git repository at:

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

for you to fetch changes up to b9153fe3088a4ea295d6cd23dd44bed51224679a:

  common/board_f.c: align m68k arch to use CONFIG_DISPLAY_CPUINFO (2018-01-23 
23:47:02 +0100)


Angelo Dureghello (1):
  common/board_f.c: align m68k arch to use CONFIG_DISPLAY_CPUINFO

 arch/m68k/cpu/mcf5227x/cpu.c   |  4 +++-
 arch/m68k/cpu/mcf523x/cpu.c|  4 +++-
 arch/m68k/cpu/mcf52x2/cpu.c| 29 +
 arch/m68k/cpu/mcf530x/cpu.c|  4 +++-
 arch/m68k/cpu/mcf532x/cpu.c|  4 +++-
 arch/m68k/cpu/mcf5445x/cpu.c   |  4 +++-
 arch/m68k/cpu/mcf547x_8x/cpu.c |  4 +++-
 common/Kconfig |  2 +-
 common/board_f.c   |  3 +--
 9 files changed, 41 insertions(+), 17 deletions(-)


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


Re: [U-Boot] [PATCH 1/1] efi_loader: always call Exit after an image returns.

2018-01-23 Thread Alexander Graf


On 23.01.18 23:46, Heinrich Schuchardt wrote:
> If an application or driver started via StartImage returns without
> calling Exit, StartImage has to call Exit. This is mandated by the
> UEFI spec and we do the same in efi_do_enter().
> 
> The patch looks bigger than it is. To avoid a forward declaration function
> efi_exit() was moved up. Only one (void*) was replaced by (void *).
> The only real change is in efi_start_image().
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
> Without this patch on Ubuntu 16.04 a crash could be observed in
> efi_selftest_startimage_return.c. With the patch it is gone.
> But this could be coincidence.
> ---
>  lib/efi_loader/efi_boottime.c | 99 
> ++-
>  1 file changed, 51 insertions(+), 48 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 0ac5b44..62a24bf 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1519,6 +1519,54 @@ failure:
>  }
>  
>  /*
> + * Leave an EFI application or driver.
> + *
> + * This function implements the Exit service.
> + * See the Unified Extensible Firmware Interface (UEFI) specification
> + * for details.
> + *
> + * @image_handle handle of the application or driver that is exiting
> + * @exit_status  status code
> + * @exit_data_size   size of the buffer in bytes
> + * @exit_databuffer with data describing an error
> + * @return   status code
> + */
> +static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
> + efi_status_t exit_status, unsigned long exit_data_size,
> + int16_t *exit_data)
> +{
> + /*
> +  * We require that the handle points to the original loaded
> +  * image protocol interface.
> +  *
> +  * For getting the longjmp address this is safer than locating
> +  * the protocol because the protocol may have been reinstalled
> +  * pointing to another memory location.
> +  *
> +  * TODO: We should call the unload procedure of the loaded
> +  *   image protocol.
> +  */
> + struct efi_loaded_image *loaded_image_info = (void *)image_handle;
> +
> + EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
> +   exit_data_size, exit_data);
> +
> + /* Make sure entry/exit counts for EFI world cross-overs match */
> + EFI_EXIT(exit_status);
> +
> + /*
> +  * But longjmp out with the U-Boot gd, not the application's, as
> +  * the other end is a setjmp call inside EFI context.
> +  */
> + efi_restore_gd();
> +
> + loaded_image_info->exit_status = exit_status;
> + longjmp(_image_info->exit_jmp, 1);
> +
> + panic("EFI application exited");
> +}
> +
> +/*
>   * Call the entry point of an image.
>   *
>   * This function implements the StartImage service.
> @@ -1575,59 +1623,14 @@ static efi_status_t EFIAPI 
> efi_start_image(efi_handle_t image_handle,
>  
>   ret = EFI_CALL(entry(image_handle, ));
>  
> + /* Clean up the image */
> + ret = EFI_CALL(efi_exit(image_handle, ret, 0, NULL));

Just use the systab here, like we do in efi_do_enter().

While I think the change is reasonable, as it brings the bootefi and the
start_image calls together, I can't really see an obvious reason why
this code would work and the one without longjmp would not...


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


Re: [U-Boot] [PATCH v4 13/18] efi_loader: fix StartImage bootservice

2018-01-23 Thread Alexander Graf


On 24.01.18 00:16, Heinrich Schuchardt wrote:
> On 01/24/2018 12:04 AM, Alexander Graf wrote:
>>
>>
>> On 23.01.18 22:35, Heinrich Schuchardt wrote:
>>> On 01/19/2018 09:16 PM, xypron.g...@gmx.de wrote:
 From: Heinrich Schuchardt 

 The calling convention for the entry point of an EFI image
 is always 'asmlinkage'.

 Signed-off-by: Heinrich Schuchardt 
 ---
 v4
rebase according to https://github.com/agraf/efi_next
 v3
Use efi_handle_t as type of the image handle.
 v2
no change
 ---

  lib/efi_loader/efi_boottime.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
 index 7c61dfb3a7..324abe4d48 100644
 --- a/lib/efi_loader/efi_boottime.c
 +++ b/lib/efi_loader/efi_boottime.c
 @@ -1530,7 +1530,8 @@ static efi_status_t EFIAPI 
 efi_start_image(efi_handle_t image_handle,
   unsigned long *exit_data_size,
   s16 **exit_data)
  {
 -  ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st);
 +  asmlinkage ulong (*entry)(efi_handle_t image_handle,
 +struct efi_system_table *st);
>>>
>>> Alex,
>>>
>>> could you once again carefully review this change.
>>>
>>> Have a look at the definition of EFIAPI in include/efi.h
>>>
>>> In cmd/bootefi.c we assume the entry point is asmlinkage.
>>> In lib/efi_loader/helloworld.c we assume it is EFIAPI.
>>>
>>> The definition of EFIAPI depends on CONFIG_EFI_STUB_64BIT, which is only
>>> defined in configs/qemu-x86_efi_payload64_defconfig.
>>>
>>> Why should the definition of EFIAPI depend on whether we are consuming
>>> or offering the API? Shouldn't EFIAPI have the same definition when
>>> compiling qemu-x86_64_defconfig?
>>
>> Because EFI supported started as payload support.
>>
>>>
>>> Am I right that the entry point should in cmd/bootefi.c, helloworld.c,
>>> efi_start_image() should always be defined as
>>>
>>> EFIAPI efi_status_t (*entry)(efi_handle_t image_handle
>>>
>>> and further when compiling for x86_64 we should always define EFIAPI as
>>>
>>> __attribute__((ms_abi))
>>>
>>> and on other systems as
>>>
>>> asmlinkage
>>
>> Not quite. I guess we basically want to have EFI_LOADER select
>> EFI_STUB_64BIT on x86_64. So maybe something like the patch below?
>>
>>
>> Alex
>>
>>
>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
>> index 51213c0293..c579b76b4b 100644
>> --- a/cmd/bootefi.c
>> +++ b/cmd/bootefi.c
>> @@ -126,8 +126,8 @@ static void *copy_fdt(void *fdt)
>>
>>  static efi_status_t efi_do_enter(
>>  efi_handle_t image_handle, struct efi_system_table *st,
>> -asmlinkage ulong (*entry)(efi_handle_t image_handle,
>> -  struct efi_system_table *st))
>> +EFIAPI ulong (*entry)(efi_handle_t image_handle,
>> +  struct efi_system_table *st))
>>  {
>>  efi_status_t ret = EFI_LOAD_ERROR;
>>
>> @@ -138,7 +138,7 @@ static efi_status_t efi_do_enter(
>>  }
>>
>>  #ifdef CONFIG_ARM64
>> -static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)(
>> +static efi_status_t efi_run_in_el2(EFIAPI ulong (*entry)(
> 
> We should use efi_status_t and not ulong here (and below). It dislike if
> the same property gets different names.

Sure.

> 
>>  efi_handle_t image_handle, struct efi_system_table *st),
>>  efi_handle_t image_handle, struct efi_system_table *st)
>>  {
>> @@ -163,7 +163,7 @@ static efi_status_t do_bootefi_exec(void *efi, void
>> *fdt,
>>  ulong ret;
>>
>>  ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st)
>> -asmlinkage;
>> +EFIAPI;
>>  ulong fdt_pages, fdt_size, fdt_start, fdt_end;
>>  const efi_guid_t fdt_guid = EFI_FDT_GUID;
>>  bootm_headers_t img = { 0 };
>> diff --git a/include/efi.h b/include/efi.h
>> index 2f0be9c86c..29f6930f53 100644
>> --- a/include/efi.h
>> +++ b/include/efi.h
>> @@ -19,7 +19,7 @@
>>  #include 
>>  #include 
>>
>> -#ifdef CONFIG_EFI_STUB_64BIT
>> +#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined
>> (__x86_64__))
>>  /* EFI uses the Microsoft ABI which is not the default for GCC */
>>  #define EFIAPI __attribute__((ms_abi))
>>  #else
>> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
>> index d2b6327119..827c267b60 100644
>> --- a/lib/efi_loader/Kconfig
>> +++ b/lib/efi_loader/Kconfig
>> @@ -1,6 +1,10 @@
>>  config EFI_LOADER
>>  bool "Support running EFI Applications in U-Boot"
>>  depends on (ARM || X86) && OF_LIBFDT
>> +# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
>> +depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
>> +# We need EFI_STUB_32BIT to be set 

Re: [U-Boot] [PATCH v4 13/18] efi_loader: fix StartImage bootservice

2018-01-23 Thread Heinrich Schuchardt
On 01/24/2018 12:04 AM, Alexander Graf wrote:
> 
> 
> On 23.01.18 22:35, Heinrich Schuchardt wrote:
>> On 01/19/2018 09:16 PM, xypron.g...@gmx.de wrote:
>>> From: Heinrich Schuchardt 
>>>
>>> The calling convention for the entry point of an EFI image
>>> is always 'asmlinkage'.
>>>
>>> Signed-off-by: Heinrich Schuchardt 
>>> ---
>>> v4
>>> rebase according to https://github.com/agraf/efi_next
>>> v3
>>> Use efi_handle_t as type of the image handle.
>>> v2
>>> no change
>>> ---
>>>
>>>  lib/efi_loader/efi_boottime.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>> index 7c61dfb3a7..324abe4d48 100644
>>> --- a/lib/efi_loader/efi_boottime.c
>>> +++ b/lib/efi_loader/efi_boottime.c
>>> @@ -1530,7 +1530,8 @@ static efi_status_t EFIAPI 
>>> efi_start_image(efi_handle_t image_handle,
>>>unsigned long *exit_data_size,
>>>s16 **exit_data)
>>>  {
>>> -   ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st);
>>> +   asmlinkage ulong (*entry)(efi_handle_t image_handle,
>>> + struct efi_system_table *st);
>>
>> Alex,
>>
>> could you once again carefully review this change.
>>
>> Have a look at the definition of EFIAPI in include/efi.h
>>
>> In cmd/bootefi.c we assume the entry point is asmlinkage.
>> In lib/efi_loader/helloworld.c we assume it is EFIAPI.
>>
>> The definition of EFIAPI depends on CONFIG_EFI_STUB_64BIT, which is only
>> defined in configs/qemu-x86_efi_payload64_defconfig.
>>
>> Why should the definition of EFIAPI depend on whether we are consuming
>> or offering the API? Shouldn't EFIAPI have the same definition when
>> compiling qemu-x86_64_defconfig?
> 
> Because EFI supported started as payload support.
> 
>>
>> Am I right that the entry point should in cmd/bootefi.c, helloworld.c,
>> efi_start_image() should always be defined as
>>
>> EFIAPI efi_status_t (*entry)(efi_handle_t image_handle
>>
>> and further when compiling for x86_64 we should always define EFIAPI as
>>
>> __attribute__((ms_abi))
>>
>> and on other systems as
>>
>> asmlinkage
> 
> Not quite. I guess we basically want to have EFI_LOADER select
> EFI_STUB_64BIT on x86_64. So maybe something like the patch below?
> 
> 
> Alex
> 
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 51213c0293..c579b76b4b 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -126,8 +126,8 @@ static void *copy_fdt(void *fdt)
> 
>  static efi_status_t efi_do_enter(
>   efi_handle_t image_handle, struct efi_system_table *st,
> - asmlinkage ulong (*entry)(efi_handle_t image_handle,
> -   struct efi_system_table *st))
> + EFIAPI ulong (*entry)(efi_handle_t image_handle,
> +   struct efi_system_table *st))
>  {
>   efi_status_t ret = EFI_LOAD_ERROR;
> 
> @@ -138,7 +138,7 @@ static efi_status_t efi_do_enter(
>  }
> 
>  #ifdef CONFIG_ARM64
> -static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)(
> +static efi_status_t efi_run_in_el2(EFIAPI ulong (*entry)(

We should use efi_status_t and not ulong here (and below). It dislike if
the same property gets different names.

>   efi_handle_t image_handle, struct efi_system_table *st),
>   efi_handle_t image_handle, struct efi_system_table *st)
>  {
> @@ -163,7 +163,7 @@ static efi_status_t do_bootefi_exec(void *efi, void
> *fdt,
>   ulong ret;
> 
>   ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st)
> - asmlinkage;
> + EFIAPI;
>   ulong fdt_pages, fdt_size, fdt_start, fdt_end;
>   const efi_guid_t fdt_guid = EFI_FDT_GUID;
>   bootm_headers_t img = { 0 };
> diff --git a/include/efi.h b/include/efi.h
> index 2f0be9c86c..29f6930f53 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -19,7 +19,7 @@
>  #include 
>  #include 
> 
> -#ifdef CONFIG_EFI_STUB_64BIT
> +#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined
> (__x86_64__))
>  /* EFI uses the Microsoft ABI which is not the default for GCC */
>  #define EFIAPI __attribute__((ms_abi))
>  #else
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index d2b6327119..827c267b60 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -1,6 +1,10 @@
>  config EFI_LOADER
>   bool "Support running EFI Applications in U-Boot"
>   depends on (ARM || X86) && OF_LIBFDT
> + # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
> + depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
> + # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
> + depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT

Wouldn't it be better to let EFI_API depend on CONFIG_X86_64?

Why 

[U-Boot] [PATCH v6 2/4] dts: cadence_spi: Sync DT bindings with Linux

2018-01-23 Thread Jason Rush
Adopt the Linux DT bindings and clean-up duplicate
and unused values.

Fix indentation of the QSPI node in the keystone k2g
device tree.

Tested on TI K2G platform:
Tested-by: Vignesh R 

Tested on a socfpga-cyclonev board:
Tested-by: Simon Goldschmidt 

Signed-off-by: Jason Rush 
Reviewed-by: Jagan Teki 
Acked-by: Simon Goldschmidt 
Acked-by: Marek Vasut 
---
Changes for v6:
   - Squashed fix for indentation in k2g dts
Changes for v5:
   - Rebased
Changes for v4:
   - Rebased
Changes for v3:
   - Update the DT bindings in keystone-k2g-evm.dts

 arch/arm/dts/keystone-k2g-evm.dts | 75 +--
 arch/arm/dts/keystone-k2g.dtsi|  5 +-
 arch/arm/dts/socfpga.dtsi |  5 +-
 arch/arm/dts/socfpga_arria10.dtsi |  4 +-
 arch/arm/dts/socfpga_arria5_socdk.dts |  9 ++--
 arch/arm/dts/socfpga_cyclone5_is1.dts |  9 ++--
 arch/arm/dts/socfpga_cyclone5_socdk.dts   |  9 ++--
 arch/arm/dts/socfpga_cyclone5_sockit.dts  |  9 ++--
 arch/arm/dts/socfpga_cyclone5_socrates.dts|  9 ++--
 arch/arm/dts/socfpga_cyclone5_sr1500.dts  |  9 ++--
 arch/arm/dts/socfpga_cyclone5_vining_fpga.dts | 18 +++
 arch/arm/dts/stv0991.dts  | 12 +++--
 12 files changed, 84 insertions(+), 89 deletions(-)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index de208b3613..ad746c7311 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -68,46 +68,45 @@
  {
status = "okay";
 
-flash0: m25p80@0 {
-compatible = "s25fl512s","spi-flash";
-reg = <0>;
-spi-tx-bus-width = <1>;
-spi-rx-bus-width = <4>;
-spi-max-frequency = <9600>;
-#address-cells = <1>;
-#size-cells = <1>;
-tshsl-ns = <392>;
-tsd2d-ns = <392>;
-tchsh-ns = <100>;
-tslch-ns = <100>;
+   flash0: m25p80@0 {
+   compatible = "s25fl512s","spi-flash";
+   reg = <0>;
+   spi-tx-bus-width = <1>;
+   spi-rx-bus-width = <4>;
+   spi-max-frequency = <9600>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   cdns,tshsl-ns = <392>;
+   cdns,tsd2d-ns = <392>;
+   cdns,tchsh-ns = <100>;
+   cdns,tslch-ns = <100>;
block-size = <18>;
 
-
-partition@0 {
-label = "QSPI.u-boot-spl-os";
-reg = <0x 0x0010>;
-};
-partition@1 {
-label = "QSPI.u-boot-env";
-reg = <0x0010 0x0004>;
-};
-partition@2 {
-label = "QSPI.skern";
-reg = <0x0014 0x004>;
-};
-partition@3 {
-label = "QSPI.pmmc-firmware";
-reg = <0x0018 0x004>;
-};
-partition@4 {
-label = "QSPI.kernel";
-reg = <0x001C 0x080>;
-};
-partition@5 {
-label = "QSPI.file-system";
-reg = <0x009C 0x364>;
-};
-};
+   partition@0 {
+   label = "QSPI.u-boot-spl-os";
+   reg = <0x 0x0010>;
+   };
+   partition@1 {
+   label = "QSPI.u-boot-env";
+   reg = <0x0010 0x0004>;
+   };
+   partition@2 {
+   label = "QSPI.skern";
+   reg = <0x0014 0x004>;
+   };
+   partition@3 {
+   label = "QSPI.pmmc-firmware";
+   reg = <0x0018 0x004>;
+   };
+   partition@4 {
+   label = "QSPI.kernel";
+   reg = <0x001C 0x080>;
+   };
+   partition@5 {
+   label = "QSPI.file-system";
+   reg = <0x009C 0x364>;
+   };
+   };
 };
 
  {
diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index 7b2fae6860..9bcfea6d86 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -92,8 +92,9 @@
  <0x2400 0x400>;
interrupts = ;
num-cs = <4>;
-   fifo-depth = <256>;
-   sram-size = <256>;
+

[U-Boot] [PATCH v6 4/4] dts: cadence_spi: Update documentation for DT bindings

2018-01-23 Thread Jason Rush
Update documentation to reflect adopting the Linux DT bindings.

Tested on TI K2G platform:
Tested-by: Vignesh R 

Tested on a socfpga-cyclonev board:
Tested-by: Simon Goldschmidt 

Signed-off-by: Jason Rush 
Reviewed-by: Jagan Teki 
Acked-by: Simon Goldschmidt 
Acked-by: Marek Vasut 
---
Changes for v6:
   - None
Changes for v5:
   - Rebased
Changes for v4:
   - Updated documentation

 doc/device-tree-bindings/spi/spi-cadence.txt | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/doc/device-tree-bindings/spi/spi-cadence.txt 
b/doc/device-tree-bindings/spi/spi-cadence.txt
index c1e2233d7c..74c82080fc 100644
--- a/doc/device-tree-bindings/spi/spi-cadence.txt
+++ b/doc/device-tree-bindings/spi/spi-cadence.txt
@@ -6,7 +6,10 @@ Required properties:
 - reg  : 1.Physical base address and size of SPI registers map.
  2. Physical base address & size of NOR Flash.
 - clocks   : Clock phandles (see clock bindings for details).
-- sram-size: spi controller sram size.
+- cdns,fifo-depth  : Size of the data FIFO in words.
+- cdns,fifo-width  : Bus width of the data FIFO in bytes.
+- cdns,trigger-address : 32-bit indirect AHB trigger address.
+- cdns,is-decoded-cs   : Flag to indicate whether decoder is used or not.
 - status   : enable in requried dts.
 
 connected flash properties
@@ -15,14 +18,14 @@ connected flash properties
 - spi-max-frequency: Max supported spi frequency.
 - page-size: Flash page size.
 - block-size   : Flash memory block size.
-- tshsl-ns : Added delay in master reference clocks (ref_clk) for
+- cdns,tshsl-ns: Added delay in master reference clocks 
(ref_clk) for
  the length that the master mode chip select outputs
  are de-asserted between transactions.
-- tsd2d-ns : Delay in master reference clocks (ref_clk) between one
+- cdns,tsd2d-ns: Delay in master reference clocks (ref_clk) 
between one
  chip select being de-activated and the activation of
  another.
-- tchsh-ns : Delay in master reference clocks between last bit of
+- cdns,tchsh-ns: Delay in master reference clocks between last 
bit of
  current transaction and de-asserting the device chip
  select (n_ss_out).
-- tslch-ns : Delay in master reference clocks between setting
+- cdns,tslch-ns: Delay in master reference clocks between 
setting
  n_ss_out low and first bit transfer
-- 
2.11.0

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


[U-Boot] [PATCH v6 1/4] spi: cadence_spi: Sync DT bindings with Linux

2018-01-23 Thread Jason Rush
Adopt the Linux DT bindings. This also fixes an issue
with the indaddrtrig register on the Cadence QSPI
device being programmed with the wrong value for the
socfpga arch.

Tested on TI K2G platform:
Tested-by: Vignesh R 

Tested on a socfpga-cyclonev board:
Tested-by: Simon Goldschmidt 

Signed-off-by: Jason Rush 
Reviewed-by: Jagan Teki 
Acked-by: Simon Goldschmidt 
Acked-by: Marek Vasut 
---
Changes for v6:
   - Fixed single line comment and indentation
Changes for v5:
   - Rebased
Changes for v4:
   - Rebased
Changes for v3:
   - None

 drivers/spi/cadence_qspi.c | 20 
 drivers/spi/cadence_qspi.h |  6 +-
 drivers/spi/cadence_qspi_apb.c | 15 ---
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index 9a6e41f330..7b312f8e3e 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -212,7 +212,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned 
int bitlen,
 
/* Set Chip select */
cadence_qspi_apb_chipselect(base, spi_chip_select(dev),
-   CONFIG_CQSPI_DECODER);
+   plat->is_decoded_cs);
 
if ((flags & SPI_XFER_END) || (flags == 0)) {
if (priv->cmd_len == 0) {
@@ -296,7 +296,11 @@ static int cadence_spi_ofdata_to_platdata(struct udevice 
*bus)
 
plat->regbase = (void *)data[0];
plat->ahbbase = (void *)data[2];
-   plat->sram_size = fdtdec_get_int(blob, node, "sram-size", 128);
+   plat->is_decoded_cs = fdtdec_get_bool(blob, node, "cdns,is-decoded-cs");
+   plat->fifo_depth = fdtdec_get_uint(blob, node, "cdns,fifo-depth", 128);
+   plat->fifo_width = fdtdec_get_uint(blob, node, "cdns,fifo-width", 4);
+   plat->trigger_address = fdtdec_get_uint(blob, node,
+   "cdns,trigger-address", 0);
 
/* All other paramters are embedded in the child node */
subnode = fdt_first_subnode(blob, node);
@@ -310,12 +314,12 @@ static int cadence_spi_ofdata_to_platdata(struct udevice 
*bus)
   50);
 
/* Read other parameters from DT */
-   plat->page_size = fdtdec_get_int(blob, subnode, "page-size", 256);
-   plat->block_size = fdtdec_get_int(blob, subnode, "block-size", 16);
-   plat->tshsl_ns = fdtdec_get_int(blob, subnode, "tshsl-ns", 200);
-   plat->tsd2d_ns = fdtdec_get_int(blob, subnode, "tsd2d-ns", 255);
-   plat->tchsh_ns = fdtdec_get_int(blob, subnode, "tchsh-ns", 20);
-   plat->tslch_ns = fdtdec_get_int(blob, subnode, "tslch-ns", 20);
+   plat->page_size = fdtdec_get_uint(blob, subnode, "page-size", 256);
+   plat->block_size = fdtdec_get_uint(blob, subnode, "block-size", 16);
+   plat->tshsl_ns = fdtdec_get_uint(blob, subnode, "cdns,tshsl-ns", 200);
+   plat->tsd2d_ns = fdtdec_get_uint(blob, subnode, "cdns,tsd2d-ns", 255);
+   plat->tchsh_ns = fdtdec_get_uint(blob, subnode, "cdns,tchsh-ns", 20);
+   plat->tslch_ns = fdtdec_get_uint(blob, subnode, "cdns,tslch-ns", 20);
 
debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
  __func__, plat->regbase, plat->ahbbase, plat->max_hz,
diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h
index d1927a4003..9106b09d29 100644
--- a/drivers/spi/cadence_qspi.h
+++ b/drivers/spi/cadence_qspi.h
@@ -18,14 +18,18 @@ struct cadence_spi_platdata {
unsigned intmax_hz;
void*regbase;
void*ahbbase;
+   boolis_decoded_cs;
+   u32 fifo_depth;
+   u32 fifo_width;
+   u32 trigger_address;
 
+   /* Flash parameters */
u32 page_size;
u32 block_size;
u32 tshsl_ns;
u32 tsd2d_ns;
u32 tchsh_ns;
u32 tslch_ns;
-   u32 sram_size;
 };
 
 struct cadence_spi_priv {
diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index e02f2217f4..e29c988312 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -37,10 +37,6 @@
 #define CQSPI_REG_RETRY1
 #define CQSPI_POLL_IDLE_RETRY  3
 
-#define CQSPI_FIFO_WIDTH   4
-
-#define CQSPI_REG_SRAM_THRESHOLD_WORDS 50
-
 /* Transfer mode */
 #define CQSPI_INST_TYPE_SINGLE 0
 #define CQSPI_INST_TYPE_DUAL   1
@@ -51,9 +47,6 @@
 #define CQSPI_DUMMY_CLKS_PER_BYTE  8
 #define CQSPI_DUMMY_BYTES_MAX  4
 
-#define CQSPI_REG_SRAM_FILL_THRESHOLD  \
-   ((CQSPI_REG_SRAM_SIZE_WORD / 2) * CQSPI_FIFO_WIDTH)
-
 

[U-Boot] [PATCH v6 3/4] config: cadence_spi: Remove defines read from DT

2018-01-23 Thread Jason Rush
Cleanup unused #define values that are read from the DT.

Tested on TI K2G platform:
Tested-by: Vignesh R 

Tested on a socfpga-cyclonev board:
Tested-by: Simon Goldschmidt 

Signed-off-by: Jason Rush 
Reviewed-by: Jagan Teki 
Acked-by: Simon Goldschmidt 
Acked-by: Marek Vasut 
---
Changes for v6:
   - None
Changes for v5:
   - Rebased
Changes for v4:
   - Rebased
Changes for v3:
   - None

 include/configs/k2g_evm.h| 1 -
 include/configs/socfpga_common.h | 1 -
 include/configs/stv0991.h| 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h
index 4e43104fac..852c30cf8f 100644
--- a/include/configs/k2g_evm.h
+++ b/include/configs/k2g_evm.h
@@ -95,7 +95,6 @@
 #ifndef CONFIG_SPL_BUILD
 #define CONFIG_CADENCE_QSPI
 #define CONFIG_CQSPI_REF_CLK 38400
-#define CONFIG_CQSPI_DECODER 0x0
 #define CONFIG_BOUNCE_BUFFER
 #endif
 
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 66e7c4fc8b..ec8bb50050 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -184,7 +184,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
 unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_CQSPI_REF_CLK   cm_get_qspi_controller_clk_hz()
 #endif
-#define CONFIG_CQSPI_DECODER   0
 #define CONFIG_BOUNCE_BUFFER
 
 /*
diff --git a/include/configs/stv0991.h b/include/configs/stv0991.h
index c99fb676cb..fd96979bf8 100644
--- a/include/configs/stv0991.h
+++ b/include/configs/stv0991.h
@@ -63,7 +63,6 @@
 + * QSPI support
 + */
 #ifdef CONFIG_OF_CONTROL   /* QSPI is controlled via DT */
-#define CONFIG_CQSPI_DECODER   0
 #define CONFIG_CQSPI_REF_CLK   ((30/4)/2)*1000*1000
 #define CONFIG_BOUNCE_BUFFER
 
-- 
2.11.0

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


[U-Boot] [PATCH v6 0/4] spi: cadence_spi: Adopt Linux DT bindings

2018-01-23 Thread Jason Rush
Adopt the Linux DT bindings. This also fixes an issue
with the indaddrtrig register on the Cadence QSPI
device being programmed with the wrong value for the
socfpga arch.

Tested on TI K2G platform:
Tested-by: Vignesh R 

Tested on a socfpga-cyclonev board:
Tested-by: Simon Goldschmidt 

Signed-off-by: Jason Rush 
Reviewed-by: Jagan Teki 
Acked-by: Simon Goldschmidt 
Acked-by: Marek Vasut 

Jason Rush (4):
  spi: cadence_spi: Sync DT bindings with Linux
  dts: cadence_spi: Sync DT bindings with Linux
  config: cadence_spi: Remove defines read from DT
  dts: cadence_spi: Update documentation for DT bindings

 arch/arm/dts/keystone-k2g-evm.dts | 75 +--
 arch/arm/dts/keystone-k2g.dtsi|  5 +-
 arch/arm/dts/socfpga.dtsi |  5 +-
 arch/arm/dts/socfpga_arria10.dtsi |  4 +-
 arch/arm/dts/socfpga_arria5_socdk.dts |  9 ++--
 arch/arm/dts/socfpga_cyclone5_is1.dts |  9 ++--
 arch/arm/dts/socfpga_cyclone5_socdk.dts   |  9 ++--
 arch/arm/dts/socfpga_cyclone5_sockit.dts  |  9 ++--
 arch/arm/dts/socfpga_cyclone5_socrates.dts|  9 ++--
 arch/arm/dts/socfpga_cyclone5_sr1500.dts  |  9 ++--
 arch/arm/dts/socfpga_cyclone5_vining_fpga.dts | 18 +++
 arch/arm/dts/stv0991.dts  | 12 +++--
 doc/device-tree-bindings/spi/spi-cadence.txt  | 13 +++--
 drivers/spi/cadence_qspi.c| 20 ---
 drivers/spi/cadence_qspi.h|  6 ++-
 drivers/spi/cadence_qspi_apb.c| 15 ++
 include/configs/k2g_evm.h |  1 -
 include/configs/socfpga_common.h  |  1 -
 include/configs/stv0991.h |  1 -
 19 files changed, 113 insertions(+), 117 deletions(-)

-- 
2.11.0

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


Re: [U-Boot] [PATCH v4 13/18] efi_loader: fix StartImage bootservice

2018-01-23 Thread Alexander Graf


On 23.01.18 22:35, Heinrich Schuchardt wrote:
> On 01/19/2018 09:16 PM, xypron.g...@gmx.de wrote:
>> From: Heinrich Schuchardt 
>>
>> The calling convention for the entry point of an EFI image
>> is always 'asmlinkage'.
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>> v4
>>  rebase according to https://github.com/agraf/efi_next
>> v3
>>  Use efi_handle_t as type of the image handle.
>> v2
>>  no change
>> ---
>>
>>  lib/efi_loader/efi_boottime.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>> index 7c61dfb3a7..324abe4d48 100644
>> --- a/lib/efi_loader/efi_boottime.c
>> +++ b/lib/efi_loader/efi_boottime.c
>> @@ -1530,7 +1530,8 @@ static efi_status_t EFIAPI 
>> efi_start_image(efi_handle_t image_handle,
>> unsigned long *exit_data_size,
>> s16 **exit_data)
>>  {
>> -ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st);
>> +asmlinkage ulong (*entry)(efi_handle_t image_handle,
>> +  struct efi_system_table *st);
> 
> Alex,
> 
> could you once again carefully review this change.
> 
> Have a look at the definition of EFIAPI in include/efi.h
> 
> In cmd/bootefi.c we assume the entry point is asmlinkage.
> In lib/efi_loader/helloworld.c we assume it is EFIAPI.
> 
> The definition of EFIAPI depends on CONFIG_EFI_STUB_64BIT, which is only
> defined in configs/qemu-x86_efi_payload64_defconfig.
> 
> Why should the definition of EFIAPI depend on whether we are consuming
> or offering the API? Shouldn't EFIAPI have the same definition when
> compiling qemu-x86_64_defconfig?

Because EFI supported started as payload support.

> 
> Am I right that the entry point should in cmd/bootefi.c, helloworld.c,
> efi_start_image() should always be defined as
> 
> EFIAPI efi_status_t (*entry)(efi_handle_t image_handle
> 
> and further when compiling for x86_64 we should always define EFIAPI as
> 
> __attribute__((ms_abi))
> 
> and on other systems as
> 
> asmlinkage

Not quite. I guess we basically want to have EFI_LOADER select
EFI_STUB_64BIT on x86_64. So maybe something like the patch below?


Alex


diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 51213c0293..c579b76b4b 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -126,8 +126,8 @@ static void *copy_fdt(void *fdt)

 static efi_status_t efi_do_enter(
efi_handle_t image_handle, struct efi_system_table *st,
-   asmlinkage ulong (*entry)(efi_handle_t image_handle,
- struct efi_system_table *st))
+   EFIAPI ulong (*entry)(efi_handle_t image_handle,
+ struct efi_system_table *st))
 {
efi_status_t ret = EFI_LOAD_ERROR;

@@ -138,7 +138,7 @@ static efi_status_t efi_do_enter(
 }

 #ifdef CONFIG_ARM64
-static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)(
+static efi_status_t efi_run_in_el2(EFIAPI ulong (*entry)(
efi_handle_t image_handle, struct efi_system_table *st),
efi_handle_t image_handle, struct efi_system_table *st)
 {
@@ -163,7 +163,7 @@ static efi_status_t do_bootefi_exec(void *efi, void
*fdt,
ulong ret;

ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st)
-   asmlinkage;
+   EFIAPI;
ulong fdt_pages, fdt_size, fdt_start, fdt_end;
const efi_guid_t fdt_guid = EFI_FDT_GUID;
bootm_headers_t img = { 0 };
diff --git a/include/efi.h b/include/efi.h
index 2f0be9c86c..29f6930f53 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -19,7 +19,7 @@
 #include 
 #include 

-#ifdef CONFIG_EFI_STUB_64BIT
+#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined
(__x86_64__))
 /* EFI uses the Microsoft ABI which is not the default for GCC */
 #define EFIAPI __attribute__((ms_abi))
 #else
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d2b6327119..827c267b60 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,10 @@
 config EFI_LOADER
bool "Support running EFI Applications in U-Boot"
depends on (ARM || X86) && OF_LIBFDT
+   # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
+   depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
+   # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
+   depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
default y
help
  Select this option if you want to run EFI applications (like grub2)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 39d8511fe3..5b78740bff 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1534,8 +1534,8 @@ static efi_status_t EFIAPI
efi_start_image(efi_handle_t 

Re: [U-Boot] extract size of FIT image

2018-01-23 Thread Anatolij Gustschin
On Tue, 23 Jan 2018 22:25:04 +
Bishop, Mark (STRT) mbis...@smithsinterconnectinc.com wrote:

> Is there an easy way or an existing mechanism to look inside of a FIT
> image and get the size of the complete image?

=> fdt addr 
=> fdt header

'totalsize' is the complete image size.

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


[U-Boot] [PATCH 1/1] efi_loader: always call Exit after an image returns.

2018-01-23 Thread Heinrich Schuchardt
If an application or driver started via StartImage returns without
calling Exit, StartImage has to call Exit. This is mandated by the
UEFI spec and we do the same in efi_do_enter().

The patch looks bigger than it is. To avoid a forward declaration function
efi_exit() was moved up. Only one (void*) was replaced by (void *).
The only real change is in efi_start_image().

Signed-off-by: Heinrich Schuchardt 
---
Without this patch on Ubuntu 16.04 a crash could be observed in
efi_selftest_startimage_return.c. With the patch it is gone.
But this could be coincidence.
---
 lib/efi_loader/efi_boottime.c | 99 ++-
 1 file changed, 51 insertions(+), 48 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 0ac5b44..62a24bf 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1519,6 +1519,54 @@ failure:
 }
 
 /*
+ * Leave an EFI application or driver.
+ *
+ * This function implements the Exit service.
+ * See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * @image_handle   handle of the application or driver that is exiting
+ * @exit_statusstatus code
+ * @exit_data_size size of the buffer in bytes
+ * @exit_data  buffer with data describing an error
+ * @return status code
+ */
+static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
+   efi_status_t exit_status, unsigned long exit_data_size,
+   int16_t *exit_data)
+{
+   /*
+* We require that the handle points to the original loaded
+* image protocol interface.
+*
+* For getting the longjmp address this is safer than locating
+* the protocol because the protocol may have been reinstalled
+* pointing to another memory location.
+*
+* TODO: We should call the unload procedure of the loaded
+*   image protocol.
+*/
+   struct efi_loaded_image *loaded_image_info = (void *)image_handle;
+
+   EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
+ exit_data_size, exit_data);
+
+   /* Make sure entry/exit counts for EFI world cross-overs match */
+   EFI_EXIT(exit_status);
+
+   /*
+* But longjmp out with the U-Boot gd, not the application's, as
+* the other end is a setjmp call inside EFI context.
+*/
+   efi_restore_gd();
+
+   loaded_image_info->exit_status = exit_status;
+   longjmp(_image_info->exit_jmp, 1);
+
+   panic("EFI application exited");
+}
+
+/*
  * Call the entry point of an image.
  *
  * This function implements the StartImage service.
@@ -1575,59 +1623,14 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t 
image_handle,
 
ret = EFI_CALL(entry(image_handle, ));
 
+   /* Clean up the image */
+   ret = EFI_CALL(efi_exit(image_handle, ret, 0, NULL));
+
/* Should usually never get here */
return EFI_EXIT(ret);
 }
 
 /*
- * Leave an EFI application or driver.
- *
- * This function implements the Exit service.
- * See the Unified Extensible Firmware Interface (UEFI) specification
- * for details.
- *
- * @image_handle   handle of the application or driver that is exiting
- * @exit_statusstatus code
- * @exit_data_size size of the buffer in bytes
- * @exit_data  buffer with data describing an error
- * @return status code
- */
-static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
-   efi_status_t exit_status, unsigned long exit_data_size,
-   int16_t *exit_data)
-{
-   /*
-* We require that the handle points to the original loaded
-* image protocol interface.
-*
-* For getting the longjmp address this is safer than locating
-* the protocol because the protocol may have been reinstalled
-* pointing to another memory location.
-*
-* TODO: We should call the unload procedure of the loaded
-*   image protocol.
-*/
-   struct efi_loaded_image *loaded_image_info = (void*)image_handle;
-
-   EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
- exit_data_size, exit_data);
-
-   /* Make sure entry/exit counts for EFI world cross-overs match */
-   EFI_EXIT(exit_status);
-
-   /*
-* But longjmp out with the U-Boot gd, not the application's, as
-* the other end is a setjmp call inside EFI context.
-*/
-   efi_restore_gd();
-
-   loaded_image_info->exit_status = exit_status;
-   longjmp(_image_info->exit_jmp, 1);
-
-   panic("EFI application exited");
-}
-
-/*
  * Unload an EFI image.
  *
  * This function implements the UnloadImage service.
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de

[U-Boot] [PATCH 5/7] sun50i: h5: Clean up OrangePi PC 2 device tree

2018-01-23 Thread Samuel Holland
Sort nodes alphabetically, and remove the ethernet alias duplicated from
the SoC device tree.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sun50i-h5-orangepi-pc2.dts | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts 
b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
index 780d59a096..fd8cfc6ff3 100644
--- a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
+++ b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
@@ -60,7 +60,6 @@
 
aliases {
serial0 = 
-   ethernet0 = 
};
 
soc {
@@ -73,6 +72,22 @@
};
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii_pins>;
+   phy-mode = "rgmii";
+   phy = <>;
+   status = "okay";
+
+   phy1: ethernet-phy@1 {
+   reg = <1>;
+   };
+};
+
  {
compatible = "allwinner,sun50i-h5-mmc",
 "allwinner,sun50i-a64-mmc",
@@ -86,32 +101,16 @@
status = "okay";
 };
 
- {
-   pinctrl-names = "default";
-   pinctrl-0 = <_pins_a>;
-   status = "okay";
-};
-
- {
-   status = "okay";
-};
-
  {
status = "okay";
 };
 
- {
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_a>;
status = "okay";
 };
 
- {
-   pinctrl-names = "default";
-   pinctrl-0 = <_rgmii_pins>;
-   phy-mode = "rgmii";
-   phy = <>;
+ {
status = "okay";
-
-   phy1: ethernet-phy@1 {
-   reg = <1>;
-   };
 };
-- 
2.13.6

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


[U-Boot] [PATCH 7/7] sun50i: h5: Add support for the Orange Pi Zero Plus

2018-01-23 Thread Samuel Holland
The Orange Pi Zero Plus is a single board computer based on the
Allwinner H5 SoC. It has 512MiB RAM, gigabit Ethernet, and one USB 2.0
port, with headers for two additional ports.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts  | 115 +
 arch/arm/dts/sun50i-h5-orangepi-zero-plus2.dts |   1 +
 board/sunxi/MAINTAINERS|   6 ++
 configs/orangepi_zero_plus_defconfig   |  18 
 5 files changed, 141 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts
 create mode 100644 configs/orangepi_zero_plus_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9540ba4313..67635662cb 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -356,6 +356,7 @@ dtb-$(CONFIG_MACH_SUN50I_H5) += \
sun50i-h5-nanopi-neo-plus2.dtb \
sun50i-h5-orangepi-pc2.dtb \
sun50i-h5-orangepi-prime.dtb \
+   sun50i-h5-orangepi-zero-plus.dtb \
sun50i-h5-orangepi-zero-plus2.dtb
 dtb-$(CONFIG_MACH_SUN50I) += \
sun50i-a64-bananapi-m64.dtb \
diff --git a/arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts 
b/arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts
new file mode 100644
index 00..bcdde8b3f2
--- /dev/null
+++ b/arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2017 Jagan Teki 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "sun50i-h5.dtsi"
+
+#include 
+
+/ {
+   model = "OrangePi Zero Plus";
+   compatible = "xunlong,orangepi-zero-plus", "allwinner,sun50i-h5";
+
+   aliases {
+   ethernet0 = 
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   reg = <0x4000 0x2000>;
+   };
+
+   reg_vcc3v3: vcc3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii_pins>;
+   phy-mode = "rgmii";
+   phy = <>;
+   status = "okay";
+
+   phy1: ethernet-phy@1 {
+   reg = <1>;
+   };
+};
+
+ {
+   compatible = "allwinner,sun50i-h5-mmc",
+"allwinner,sun50i-a64-mmc",
+"allwinner,sun5i-a13-mmc";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_a>, <_cd_pin>;
+   vmmc-supply = <_vcc3v3>;
+   bus-width = <4>;
+   cd-gpios = < 5 6 GPIO_ACTIVE_HIGH>;
+   cd-inverted;
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_a>;
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/sun50i-h5-orangepi-zero-plus2.dts 

[U-Boot] [PATCH 3/7] sun50i: a64: Move ethernet nodes to SoC DTS

2018-01-23 Thread Samuel Holland
These nodes were previously in an unused file specific to the Pine64.
Move them to the base SoC device tree for use by other boards. Require
individual boards to enable the emac and provide a pin configuration.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi | 50 -
 arch/arm/dts/sun50i-a64.dtsi| 28 ++
 2 files changed, 28 insertions(+), 50 deletions(-)
 delete mode 100644 arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi

diff --git a/arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi 
b/arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi
deleted file mode 100644
index 9c61beac01..00
--- a/arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi
+++ /dev/null
@@ -1,50 +0,0 @@
-/ {
-   aliases {
-   ethernet0 = 
-   };
-
-   soc {
-   emac: ethernet@01c3 {
-   compatible = "allwinner,sun50i-a64-emac";
-   reg = <0x01c3 0x2000>, <0x01c00030 0x4>;
-   reg-names = "emac", "syscon";
-   interrupts = ;
-   resets = < RST_BUS_EMAC>;
-   reset-names = "ahb";
-   clocks = < CLK_BUS_EMAC>;
-   clock-names = "ahb";
-   #address-cells = <1>;
-   #size-cells = <0>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_pins>;
-   phy-mode = "rgmii";
-   phy = <>;
-   status = "okay";
-
-   phy1: ethernet-phy@1 {
-   reg = <1>;
-   };
-   };
-   };
-};
-
- {
-   rmii_pins: rmii_pins {
-   allwinner,pins = "PD10", "PD11", "PD13", "PD14",
-"PD17", "PD18", "PD19", "PD20",
-"PD22", "PD23";
-   allwinner,function = "emac";
-   allwinner,drive = <3>;
-   allwinner,pull = <0>;
-   };
-
-   rgmii_pins: rgmii_pins {
-   allwinner,pins = "PD8", "PD9", "PD10", "PD11",
-"PD12", "PD13", "PD15",
-"PD16", "PD17", "PD18", "PD19",
-"PD20", "PD21", "PD22", "PD23";
-   allwinner,function = "emac";
-   allwinner,drive = <3>;
-   allwinner,pull = <0>;
-   };
-};
diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi
index 02061cc608..c686707cf5 100644
--- a/arch/arm/dts/sun50i-a64.dtsi
+++ b/arch/arm/dts/sun50i-a64.dtsi
@@ -51,6 +51,10 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   aliases {
+   ethernet0 = 
+   };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -267,6 +271,16 @@
interrupt-controller;
#interrupt-cells = <3>;
 
+   emac_rgmii_pins: emac_rgmii_pins {
+   allwinner,pins = "PD8", "PD9", "PD10", "PD11",
+"PD12", "PD13", "PD15",
+"PD16", "PD17", "PD18", "PD19",
+"PD20", "PD21", "PD22", "PD23";
+   allwinner,function = "emac";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
+
i2c1_pins: i2c1_pins {
pins = "PH2", "PH3";
function = "i2c1";
@@ -401,6 +415,20 @@
#size-cells = <0>;
};
 
+   emac: ethernet@01c3 {
+   compatible = "allwinner,sun50i-a64-emac";
+   reg = <0x01c3 0x2000>, <0x01c00030 0x4>;
+   reg-names = "emac", "syscon";
+   interrupts = ;
+   resets = < RST_BUS_EMAC>;
+   reset-names = "ahb";
+   clocks = < CLK_BUS_EMAC>;
+   clock-names = "ahb";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
gic: interrupt-controller@1c81000 {
compatible = "arm,gic-400";
reg = <0x01c81000 0x1000>,
-- 
2.13.6

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


[U-Boot] [PATCH 4/7] sun50i: a64: Update OrangePi Win defconfig and DTS

2018-01-23 Thread Samuel Holland
Enable Ethernet support in the device tree and add the necessary MACPWR
configuration. Also fix spacing in USB device tree nodes and add the
relevant configuration options.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sun50i-a64-orangepi-win.dts | 18 +++---
 configs/orangepi_win_defconfig   |  5 -
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/arm/dts/sun50i-a64-orangepi-win.dts 
b/arch/arm/dts/sun50i-a64-orangepi-win.dts
index cf76c35237..41bad328f0 100644
--- a/arch/arm/dts/sun50i-a64-orangepi-win.dts
+++ b/arch/arm/dts/sun50i-a64-orangepi-win.dts
@@ -67,7 +67,19 @@
 };
 
  {
-   status = "okay";
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii_pins>;
+   phy-mode = "rgmii";
+   phy = <>;
+   status = "okay";
+
+   phy1: ethernet-phy@1 {
+   reg = <1>;
+   };
 };
 
  {
@@ -80,7 +92,7 @@
 };
 
  {
-   status = "okay";
+   status = "okay";
 };
 
  {
@@ -90,5 +102,5 @@
 };
 
  {
-   status = "okay";
+   status = "okay";
 };
diff --git a/configs/orangepi_win_defconfig b/configs/orangepi_win_defconfig
index f9c3d4acf9..670c1868b2 100644
--- a/configs/orangepi_win_defconfig
+++ b/configs/orangepi_win_defconfig
@@ -1,7 +1,10 @@
 CONFIG_ARM=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_DRAM_ZQ=3881977
+CONFIG_MACPWR="PD14"
+CONFIG_USB0_ID_DET="PH9"
+CONFIG_USB1_VBUS_PIN="PD7"
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y
-- 
2.13.6

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


[U-Boot] [PATCH 6/7] sun50i: h5: Enable remaining USB ports on OrangePi PC2

2018-01-23 Thread Samuel Holland
The OrangePi PC 2 has three USB type A ports, with one connected to each
EHCI/OHCI controller. Enable the controllers for the other two ports.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sun50i-h5-orangepi-pc2.dts | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts 
b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
index fd8cfc6ff3..dd0cb2dc50 100644
--- a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
+++ b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
@@ -76,6 +76,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_rgmii_pins>;
@@ -105,6 +113,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pins_a>;
-- 
2.13.6

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


[U-Boot] [PATCH 2/7] sun50i: a64: Fix USB clock/reset properties

2018-01-23 Thread Samuel Holland
Move the CLK_USB_OHCI0/1 clocks to the OHCI nodes where they belong, and
make the format consistent with the H3/H5 nodes. While here, also remove
leading zeros from the USB nodes' unit addresses.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sun50i-a64.dtsi | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi
index 65a344d9ce..02061cc608 100644
--- a/arch/arm/dts/sun50i-a64.dtsi
+++ b/arch/arm/dts/sun50i-a64.dtsi
@@ -171,7 +171,7 @@
#size-cells = <0>;
};
 
-   usb_otg: usb@01c19000 {
+   usb_otg: usb@1c19000 {
compatible = "allwinner,sun8i-a33-musb";
reg = <0x01c19000 0x0400>;
clocks = < CLK_BUS_OTG>;
@@ -184,7 +184,7 @@
status = "disabled";
};
 
-   usbphy: phy@01c19400 {
+   usbphy: phy@1c19400 {
compatible = "allwinner,sun50i-a64-usb-phy";
reg = <0x01c19400 0x14>,
  <0x01c1a800 0x4>,
@@ -204,49 +204,43 @@
#phy-cells = <1>;
};
 
-   ehci0: usb@01c1a000 {
+   ehci0: usb@1c1a000 {
compatible = "allwinner,sun50i-a64-ehci", 
"generic-ehci";
reg = <0x01c1a000 0x100>;
interrupts = ;
-   clocks = < CLK_BUS_OHCI0>,
-< CLK_BUS_EHCI0>,
-< CLK_USB_OHCI0>;
-   resets = < RST_BUS_OHCI0>,
-< RST_BUS_EHCI0>;
+   clocks = < CLK_BUS_EHCI0>, < CLK_BUS_OHCI0>;
+   resets = < RST_BUS_EHCI0>, < RST_BUS_OHCI0>;
status = "disabled";
};
 
-   ohci0: usb@01c1a400 {
+   ohci0: usb@1c1a400 {
compatible = "allwinner,sun50i-a64-ohci", 
"generic-ohci";
reg = <0x01c1a400 0x100>;
interrupts = ;
-   clocks = < CLK_BUS_OHCI0>,
+   clocks = < CLK_BUS_EHCI0>, < CLK_BUS_OHCI0>,
 < CLK_USB_OHCI0>;
-   resets = < RST_BUS_OHCI0>;
+   resets = < RST_BUS_EHCI0>, < RST_BUS_OHCI0>;
status = "disabled";
};
 
-   ehci1: usb@01c1b000 {
+   ehci1: usb@1c1b000 {
compatible = "allwinner,sun50i-a64-ehci", 
"generic-ehci";
reg = <0x01c1b000 0x100>;
interrupts = ;
-   clocks = < CLK_BUS_OHCI1>,
-< CLK_BUS_EHCI1>,
-< CLK_USB_OHCI1>;
-   resets = < RST_BUS_OHCI1>,
-< RST_BUS_EHCI1>;
+   clocks = < CLK_BUS_EHCI1>, < CLK_BUS_OHCI1>;
+   resets = < RST_BUS_EHCI1>, < RST_BUS_OHCI1>;
phys = < 1>;
phy-names = "usb";
status = "disabled";
};
 
-   ohci1: usb@01c1b400 {
+   ohci1: usb@1c1b400 {
compatible = "allwinner,sun50i-a64-ohci", 
"generic-ohci";
reg = <0x01c1b400 0x100>;
interrupts = ;
-   clocks = < CLK_BUS_OHCI1>,
+   clocks = < CLK_BUS_EHCI1>, < CLK_BUS_OHCI1>,
 < CLK_USB_OHCI1>;
-   resets = < RST_BUS_OHCI1>;
+   resets = < RST_BUS_EHCI1>, < RST_BUS_OHCI1>;
phys = < 1>;
phy-names = "usb";
status = "disabled";
-- 
2.13.6

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


[U-Boot] [PATCH 1/7] sunxi: binman: Fix U-Boot binary size check

2018-01-23 Thread Samuel Holland
If raw mode is disabled, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR is not
defined, which breaks compiling the device trees. Only enable the size
check when it actually matters--that is, when MMC raw mode is enabled.

Signed-off-by: Samuel Holland 
---
 arch/arm/dts/sunxi-u-boot.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 72e95afd78..996f391030 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -17,7 +17,7 @@
filename = "spl/sunxi-spl.bin";
};
u-boot-img {
-#ifdef CONFIG_MMC
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
size = ;
 #endif
pos = ;
-- 
2.13.6

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


[U-Boot] [PATCH 0/7] sun50i device tree changes

2018-01-23 Thread Samuel Holland
These patches fix one general build issue, improve support for two
existing boards, and add support for the Orange Pi Zero Plus.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] gpio: sunxi: Add compatible string for H5 PIO

2018-01-23 Thread Chris Blake
On Tue, Jan 23, 2018 at 1:15 PM, Jagan Teki  wrote:
> On Wed, Jan 24, 2018 at 12:42 AM, Chris Blake  wrote:
>> On Tue, Jan 23, 2018 at 1:09 PM, Jagan Teki  wrote:
>>> On Tue, Jan 16, 2018 at 3:58 AM, Chris Blake  
>>> wrote:
 Due to the changes in 
 https://github.com/linux-sunxi/u-boot-sunxi/commit/8faac0941cd409c6ff3738fbf658de2296f48e9a,
  allwinner,sun50i-h5-pinctrl needs to be defined otherwise PIO does not 
 work on H5 based boards.
>>>
>>> What is the issue observed w/o this?
>>
>> Without this, H5 boards that rely on CONFIG_MACPWR for Ethernet do not
>> support networking in u-boot. This also breaks access to GPIOs via the
>> gpio cmd.
>
> Ok, did you verify it on opi-pc2?

This was verified on a FriendlyARM NanoPi Neo2 and FriendlyARM NanoPi Neo Core2.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] gpio: sunxi: Add compatible string for H5 PIO

2018-01-23 Thread Chris Blake
On Tue, Jan 23, 2018 at 1:09 PM, Jagan Teki  wrote:
> On Tue, Jan 16, 2018 at 3:58 AM, Chris Blake  wrote:
>> Due to the changes in 
>> https://github.com/linux-sunxi/u-boot-sunxi/commit/8faac0941cd409c6ff3738fbf658de2296f48e9a,
>>  allwinner,sun50i-h5-pinctrl needs to be defined otherwise PIO does not work 
>> on H5 based boards.
>
> What is the issue observed w/o this?

Without this, H5 boards that rely on CONFIG_MACPWR for Ethernet do not
support networking in u-boot. This also breaks access to GPIOs via the
gpio cmd.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] extract size of FIT image

2018-01-23 Thread Bishop, Mark (STRT)
Is there an easy way or an existing mechanism to look inside of a FIT image and 
get the size of the complete image?

Mark Bishop
Sr. Firmware/Software Engineer - Microwave Subsystems

[cid:image001.png@01D281ED.A45F0A90]

4726 Eisenhower Blvd.
Tampa, FL 33634
USA


T  +1 813 901 7293

mbis...@smithsinterconnectinc.com

smithsinterconnect.com

TRAK MICROWAVE IS NOW SMITHS INTERCONNECT!





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


Re: [U-Boot] [PATCH v4 13/18] efi_loader: fix StartImage bootservice

2018-01-23 Thread Heinrich Schuchardt
On 01/19/2018 09:16 PM, xypron.g...@gmx.de wrote:
> From: Heinrich Schuchardt 
> 
> The calling convention for the entry point of an EFI image
> is always 'asmlinkage'.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
> v4
>   rebase according to https://github.com/agraf/efi_next
> v3
>   Use efi_handle_t as type of the image handle.
> v2
>   no change
> ---
> 
>  lib/efi_loader/efi_boottime.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 7c61dfb3a7..324abe4d48 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1530,7 +1530,8 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t 
> image_handle,
>  unsigned long *exit_data_size,
>  s16 **exit_data)
>  {
> - ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st);
> + asmlinkage ulong (*entry)(efi_handle_t image_handle,
> +   struct efi_system_table *st);

Alex,

could you once again carefully review this change.

Have a look at the definition of EFIAPI in include/efi.h

In cmd/bootefi.c we assume the entry point is asmlinkage.
In lib/efi_loader/helloworld.c we assume it is EFIAPI.

The definition of EFIAPI depends on CONFIG_EFI_STUB_64BIT, which is only
defined in configs/qemu-x86_efi_payload64_defconfig.

Why should the definition of EFIAPI depend on whether we are consuming
or offering the API? Shouldn't EFIAPI have the same definition when
compiling qemu-x86_64_defconfig?

Am I right that the entry point should in cmd/bootefi.c, helloworld.c,
efi_start_image() should always be defined as

EFIAPI efi_status_t (*entry)(efi_handle_t image_handle

and further when compiling for x86_64 we should always define EFIAPI as

__attribute__((ms_abi))

and on other systems as

asmlinkage

Best regards

Heinrich

>   struct efi_loaded_image *info = image_handle;
>   efi_status_t ret;
>  
> 

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


[U-Boot] [PATCH 2/2] warp7 : run sec_init for CAAM RNG

2018-01-23 Thread Bryan O'Donoghue
This patch adds a sec_init call into board_init. Doing so in conjunction
with the patch "drivers/crypto/fsl: assign job-rings to non-TrustZone"
enables use of the CAAM in Linux when OPTEE/TrustZone is active.

u-boot will initialise the RNG and assign ownership of the job-ring
registers to a non-TrustZone context. Linux then simply has to detect or be
told to skip RNG initialisation.

This change is safe both for the OPTEE/TrustZone boot path and the regular
non-OPTEE/TrustZone boot path.

Signed-off-by: Bryan O'Donoghue 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Marco Franchi 
Cc: Vanessa Maegima 
Cc: Stefano Babic 
---
 board/warp7/warp7.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c
index 337e76b..219ab6f 100644
--- a/board/warp7/warp7.c
+++ b/board/warp7/warp7.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -225,6 +226,10 @@ int board_init(void)
setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, _pad_info1);
#endif
 
+   #ifdef CONFIG_FSL_CAAM
+   sec_init();
+   #endif
+
return 0;
 }
 
@@ -366,5 +371,4 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, 
const char *name)
 
return 0;
 }
-
 #endif /* ifdef CONFIG_USB_GADGET */
-- 
2.7.4

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


[U-Boot] [PATCH 1/2] drivers/crypto/fsl: assign job-rings to non-TrustZone

2018-01-23 Thread Bryan O'Donoghue
After enabling TrustZone various parts of the CAAM silicon become
inaccessible to non TrustZone contexts. The job-ring registers are designed
to allow non TrustZone contexts like Linux to still submit jobs to CAAM
even after TrustZone has been enabled.

The default job-ring permissions after the BootROM look like this for
job-ring zero.

ms=0x8001 ls=0x8001

The MS field is JRaMIDR_MS (job ring MID most significant).

Referring to "Security Reference Manual for i.MX 7Dual and 7Solo
Applications Processors, Rev. 0, 03/2017" section 8.10.4 we see that
JROWN_NS controls whether or not a job-ring is accessible from non
TrustZone.

Bit 15 (TrustZone) is the logical inverse of bit 3 hence the above value of
0x8001 shows that JROWN_NS=0 and TrustZone=1.

Clearly then as soon as TrustZone becomes active the job-ring registers are
no longer accessible from Linux, which is not what we want.

This patch explicitly sets all job-ring registers to JROWN_NS=1 (non
TrustZone) by default. If a piece of TrustZone firmware requires ownership
of job-ring registers it can unset the JROWN_NS bit itself.

This patch in conjunction with a modification of the Linux kernel to skip
HWRNG initialisation makes CAAM usable to Linux with TrustZone enabled.

Signed-off-by: Bryan O'Donoghue 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Alex Porosanu 
Cc: Ruchika Gupta 
Cc: Aneesh Bansal 
Link: https://github.com/OP-TEE/optee_os/issues/1408
Link: https://tinyurl.com/yam5gv9a
---
 drivers/crypto/fsl/jr.c | 9 +
 drivers/crypto/fsl/jr.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 986eabf..cbf570d 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -566,6 +566,8 @@ int sec_init_idx(uint8_t sec_idx)
 {
ccsr_sec_t *sec = (void *)SEC_ADDR(sec_idx);
uint32_t mcr = sec_in32(>mcfgr);
+   uint32_t jrown_ns;
+   int i;
int ret = 0;
 
 #ifdef CONFIG_FSL_CORENET
@@ -621,6 +623,13 @@ int sec_init_idx(uint8_t sec_idx)
 #endif
 #endif
 
+   /* Set ownership of job rings to non-TrustZone mode by default */
+   for (i = 0; i < ARRAY_SIZE(sec->jrliodnr); i++) {
+   jrown_ns = sec_in32(>jrliodnr[i].ms);
+   jrown_ns |= JROWN_NS;
+   sec_out32(>jrliodnr[i].ms, jrown_ns);
+   }
+
ret = jr_init(sec_idx);
if (ret < 0) {
printf("SEC initialization failed\n");
diff --git a/drivers/crypto/fsl/jr.h b/drivers/crypto/fsl/jr.h
index d897e57..72f7501 100644
--- a/drivers/crypto/fsl/jr.h
+++ b/drivers/crypto/fsl/jr.h
@@ -34,6 +34,7 @@
 #define JRNSLIODN_MASK 0x0fff
 #define JRSLIODN_SHIFT 0
 #define JRSLIODN_MASK  0x0fff
+#define JROWN_NS   0x0008
 
 #define JQ_DEQ_ERR -1
 #define JQ_DEQ_TO_ERR  -2
-- 
2.7.4

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


[U-Boot] [PATCH 0/2] Fix CAAM for TrustZone enable for warp7

2018-01-23 Thread Bryan O'Donoghue
This series is the u-boot fix to a problem we encountered when enabling
OPTEE/TrustZone on the WaRP7. The symptom is once TrustZone is activated
the first page of CAAM registers becomes read-only, read-zero from the
perspective of Linux and other non TrustZone contexts.

Offlining the problem with Peng Fan[1] we eventually came to realise the
problem could be worked around by

1. Making Linux skip RNG initialisation - a set of patches should be
   hitting LKML to do just that.

2. Initialising the RNG either from u-boot or OPTEE. In this case u-boot is
   the right place to-do that because there's upstream code in u-boot that
   just works. Patch #2 does that for the WaRP7.

3. Ensuring the job-ring registers are assigned to the non TrustZone mode.
   On the i.MX7 after the BootROM runs the job-ring registers are assigned
   to TrustZone. Patch #1 does that for all CAAM hardware.

On point #3 this ordinarily isn't a problem because unless TrustZone is
activated the restrictions on the job-ring registers don't kick in, its
only after enabling TrustZone that Linux will loose access to the job-ring
registers.

Finally should OPTEE or another TEE want to do things with the job-ring
registers it will have sufficient privilege to assign whichever job-ring
registers it wants to OPTEE/TEE but will naturally then have to arbitrate
with Linux to inform the Kernel CAAM driver which job-ring registers it can
and cannot access.

That arbitration process is for a future putative OPTEE/TEE CAAM driver to
solve and is out of scope of this patchset.

[1] Thanks for all of your help BTW - Peng, there's no way this would be
working without you giving direction on how.

Bryan O'Donoghue (2):
  drivers/crypto/fsl: assign job-rings to non-TrustZone
  warp7 : run sec_init for CAAM RNG

 board/warp7/warp7.c | 6 +-
 drivers/crypto/fsl/jr.c | 9 +
 drivers/crypto/fsl/jr.h | 1 +
 3 files changed, 15 insertions(+), 1 deletion(-)

-- 
2.7.4

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


[U-Boot] [PATCH v3 9/9] bootm: optee: Add mechanism to validate an OPTEE image before boot

2018-01-23 Thread Bryan O'Donoghue
This patch makes it possible to verify the contents and location of an
OPTEE image in DRAM prior to handing off control to that image. If image
verification fails we won't try to boot any further.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 common/bootm.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index adb1213..d528844 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #if defined(CONFIG_CMD_USB)
 #include 
 #endif
@@ -201,6 +202,12 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int 
argc,
if (images.os.type == IH_TYPE_KERNEL_NOLOAD) {
images.os.load = images.os.image_start;
images.ep += images.os.load;
+   } else if (images.os.type == IH_TYPE_OPTEE) {
+   ret = optee_verify_bootm_image(images.os.image_start,
+  images.os.load,
+  images.os.image_len);
+   if (ret)
+   return ret;
}
 
images.os.start = map_to_sysmem(os_hdr);
@@ -275,7 +282,8 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int 
argc,
 {
if (((images.os.type == IH_TYPE_KERNEL) ||
 (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
-(images.os.type == IH_TYPE_MULTI)) &&
+(images.os.type == IH_TYPE_MULTI) ||
+(images.os.type == IH_TYPE_OPTEE)) &&
(images.os.os == IH_OS_LINUX ||
 images.os.os == IH_OS_VXWORKS))
return bootm_find_images(flag, argc, argv);
@@ -827,6 +835,7 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int 
flag, int argc,
switch (image_get_type(hdr)) {
case IH_TYPE_KERNEL:
case IH_TYPE_KERNEL_NOLOAD:
+   case IH_TYPE_OPTEE:
*os_data = image_get_data(hdr);
*os_len = image_get_data_size(hdr);
break;
-- 
2.7.4

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


[U-Boot] [PATCH v3 5/9] optee: Add optee_image_get_load_addr()

2018-01-23 Thread Bryan O'Donoghue
This patch adds optee_image_get_load_addr() a helper function used to
calculate the load-address of an OPTEE image based on the lower
entry-point address given in the OPTEE header.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 include/tee/optee.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/tee/optee.h b/include/tee/optee.h
index eb328d3..e782cb0 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -36,6 +36,11 @@ static inline uint32_t optee_image_get_entry_point(const 
image_header_t *hdr)
return optee_hdr->init_load_addr_lo;
 }
 
+static inline uint32_t optee_image_get_load_addr(const image_header_t *hdr)
+{
+   return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
+}
+
 #if defined(CONFIG_OPTEE)
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
   unsigned long tzdram_len, unsigned long image_len);
-- 
2.7.4

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


Re: [U-Boot] [PATCH] arm64 :show_regs: show the real hardware register even after relocation

2018-01-23 Thread Karl Beldan
On Tue, Jan 23, 2018 at 10:47:11AM +0800, Peng Fan wrote:
> Not only show the calculated value after relocation, also show
> the real hardware register value.
> 
> Signed-off-by: Peng Fan 
> Reported-by: Karl Beldan 
> ---
>  arch/arm/lib/interrupts_64.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
> index cbcfeec2b0..843d9fcd54 100644
> --- a/arch/arm/lib/interrupts_64.c
> +++ b/arch/arm/lib/interrupts_64.c
> @@ -30,13 +30,14 @@ void show_regs(struct pt_regs *regs)
>  {
>   int i;
>  
> + printf("ELR: %lx\n", regs->elr);
> + printf("LR:  %lx\n", regs->regs[30]);
>   if (gd->flags & GD_FLG_RELOC) {
> - printf("ELR: %lx\n", regs->elr - gd->reloc_off);
> - printf("LR:  %lx\n", regs->regs[30] - gd->reloc_off);
> - } else {
> - printf("ELR: %lx\n", regs->elr);
> - printf("LR:  %lx\n", regs->regs[30]);
> + printf("reloc ELR: %lxlr: %lx\n",

While formatting is often subjective, the other contributors took care
of properly aligning all reg names and vals for other archs as much as
possible in an homogeneous way, but it doesn't seem to be the case here.

With your change our stack traces would now look like: {

ELR: cff00ff
LR:  ab00
reloc ELR: fffc0cff00fflr: fffcab00
x0 : 000a x1 : 000a
[...]
x28:  x29: 

} instead of e.g.: {

elr: 0cff00ff lr : ab00
elr: fffc0cff00ff lr : fffcab00 (reloc)
x0 : 000a x1 : 000a
[...]
x28:  x29: 

}

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


[U-Boot] [PATCH v3 7/9] optee: Add optee_verify_bootm_image()

2018-01-23 Thread Bryan O'Donoghue
This patch adds optee_verify_bootm_image() which will be subsequently used
to verify the parameters encoded in the OPTEE header match the memory
allocated to the OPTEE region, OPTEE header magic and version prior to
handing off control to the OPTEE image.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 include/tee/optee.h | 13 +
 lib/optee/optee.c   | 20 
 2 files changed, 33 insertions(+)

diff --git a/include/tee/optee.h b/include/tee/optee.h
index e782cb0..4b9e94c 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -55,4 +55,17 @@ static inline int optee_verify_image(struct optee_header 
*hdr,
 
 #endif
 
+#if defined(CONFIG_OPTEE)
+int optee_verify_bootm_image(unsigned long image_addr,
+unsigned long image_load_addr,
+unsigned long image_len);
+#else
+static inline int optee_verify_bootm_image(unsigned long image_addr,
+  unsigned long image_load_addr,
+  unsigned long image_len)
+{
+   return -EPERM;
+}
+#endif
+
 #endif /* _OPTEE_H */
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index 2cc16d7..365c078 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -29,3 +29,23 @@ int optee_verify_image(struct optee_header *hdr, unsigned 
long tzdram_start,
 
return 0;
 }
+
+int optee_verify_bootm_image(unsigned long image_addr,
+unsigned long image_load_addr,
+unsigned long image_len)
+{
+   struct optee_header *hdr = (struct optee_header *)image_addr;
+   unsigned long tzdram_start = CONFIG_OPTEE_TZDRAM_BASE;
+   unsigned long tzdram_len = CONFIG_OPTEE_TZDRAM_SIZE;
+
+   int ret;
+
+   ret = optee_verify_image(hdr, tzdram_start, tzdram_len, image_len);
+   if (ret)
+   return ret;
+
+   if (image_load_addr + sizeof(*hdr) != hdr->init_load_addr_lo)
+   ret = -EINVAL;
+
+   return ret;
+}
-- 
2.7.4

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


[U-Boot] [PATCH v3 8/9] optee: Add error printout

2018-01-23 Thread Bryan O'Donoghue
When encountering an error in OPTEE verification print out various details
of the OPTEE header to aid in further debugging of encountered errors.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 lib/optee/optee.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index 365c078..78a15e8 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -8,6 +8,12 @@
 #include 
 #include 
 
+#define optee_hdr_err_msg \
+   "OPTEE verification error:" \
+   "\n\thdr=%p image=0x%08lx magic=0x%08x tzdram 0x%08lx-0x%08lx " \
+   "\n\theader lo=0x%08x hi=0x%08x size=0x%08lx arch=0x%08x" \
+   "\n\tuimage params 0x%08lx-0x%08lx\n"
+
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
   unsigned long tzdram_len, unsigned long image_len)
 {
@@ -42,10 +48,19 @@ int optee_verify_bootm_image(unsigned long image_addr,
 
ret = optee_verify_image(hdr, tzdram_start, tzdram_len, image_len);
if (ret)
-   return ret;
+   goto error;
 
-   if (image_load_addr + sizeof(*hdr) != hdr->init_load_addr_lo)
+   if (image_load_addr + sizeof(*hdr) != hdr->init_load_addr_lo) {
ret = -EINVAL;
+   goto error;
+   }
+
+   return ret;
+error:
+   printf(optee_hdr_err_msg, hdr, image_addr, hdr->magic, tzdram_start,
+  tzdram_start + tzdram_len, hdr->init_load_addr_lo,
+  hdr->init_load_addr_hi, image_len, hdr->arch, image_load_addr,
+  image_load_addr + image_len);
 
return ret;
 }
-- 
2.7.4

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


[U-Boot] [PATCH v3 6/9] tools: mkimage: add optee image type

2018-01-23 Thread Bryan O'Donoghue
This patch adds support for bootable OPTEE images to mkimage. Currently
there is a (Trusted Execution Environment) TEE image type, the TEE image
type is installed to a memory location control is passed to the TEE and
then the TEE returns to u-boot.

flow #0:
BootROM -> u-boot -> tee -> u-boot -> onwards

For some TEE implementations, such as upstream OPTEE for i.MX6 and i.MX7
the boot flow is

flow #1:
BootROM -> u-boot -> optee -> kernel

This patch adds a new image type to mkimage -  IH_TYPE_OPTEE to reflect
this TEE boot flow and to facilitate additional OPTEE specific verification
of that image type - prior to handing control to that image.

The new image type enables us to more easily generate and validate a
bootable OPTEE image also, for example instead of generating an OPTEE image
like this:

mkimage -A arm -O linux -C none -a 0x9c0fffe4 -e 0x9c10 -d
./out/arm-plat-imx/core/tee.bin uTee

we can instead generate images like this:
mkimage -A arm -T optee -C none -d ./out/arm-plat-imx/core/tee.bin
uTee.optee

That OPTEE image then will have a specific image type that bootm can
automatically identify and consequently perform additional optee-header
checks on.

Subsequent patches add logic to perform those optee-specific changes prior
to handing over control as described in flow #1 above.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Link: http://mrvan.github.io/optee-imx6ul
Tested-by: Peng Fan 
---
 common/image.c|  1 +
 include/image.h   |  1 +
 tools/default_image.c | 25 +++--
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/common/image.c b/common/image.c
index e9609cd..14e738b 100644
--- a/common/image.c
+++ b/common/image.c
@@ -161,6 +161,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_TEE,"tee","Trusted Execution 
Environment Image",},
{   IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" 
},
{   IH_TYPE_PMMC,"pmmc","TI Power Management 
Micro-Controller Firmware",},
+   {   IH_TYPE_OPTEE,   "optee", "OPTEE Boot Image",},
{   -1, "",   "",   },
 };
 
diff --git a/include/image.h b/include/image.h
index b2b23a9..0b72d28 100644
--- a/include/image.h
+++ b/include/image.h
@@ -272,6 +272,7 @@ enum {
IH_TYPE_TEE,/* Trusted Execution Environment OS Image */
IH_TYPE_FIRMWARE_IVT,   /* Firmware Image with HABv4 IVT */
IH_TYPE_PMMC,/* TI Power Management Micro-Controller 
Firmware */
+   IH_TYPE_OPTEE,  /* OPTEE Boot Image */
 
IH_TYPE_COUNT,  /* Number of image types */
 };
diff --git a/tools/default_image.c b/tools/default_image.c
index 4e5568e..5653933 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -18,6 +18,7 @@
 #include "mkimage.h"
 
 #include 
+#include 
 #include 
 
 static image_header_t header;
@@ -25,7 +26,8 @@ static image_header_t header;
 static int image_check_image_types(uint8_t type)
 {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
-   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
+   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) ||
+   (type == IH_TYPE_OPTEE))
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
@@ -90,6 +92,8 @@ static void image_set_header(void *ptr, struct stat *sbuf, 
int ifd,
uint32_t checksum;
time_t time;
uint32_t imagesize;
+   uint32_t ep;
+   uint32_t addr;
 
image_header_t * hdr = (image_header_t *)ptr;
 
@@ -99,18 +103,27 @@ static void image_set_header(void *ptr, struct stat *sbuf, 
int ifd,
sbuf->st_size - sizeof(image_header_t));
 
time = imagetool_get_source_date(params, sbuf->st_mtime);
-   if (params->type == IH_TYPE_FIRMWARE_IVT)
+   ep = params->ep;
+   addr = params->addr;
+   imagesize = sbuf->st_size - sizeof(image_header_t);
+
+   switch (params->type) {
+   case IH_TYPE_FIRMWARE_IVT:
/* Add size of CSF minus IVT */
imagesize = sbuf->st_size - sizeof(image_header_t) + 0x1FE0;
-   else
-   imagesize = sbuf->st_size - sizeof(image_header_t);
+   break;
+   case IH_TYPE_OPTEE:
+   addr = optee_image_get_load_addr(hdr);
+   ep = optee_image_get_entry_point(hdr);
+   break;
+   }
 
/* Build new header */
image_set_magic(hdr, IH_MAGIC);
image_set_time(hdr, time);
image_set_size(hdr, imagesize);
-   

[U-Boot] [PATCH v3 4/9] optee: Add optee_image_get_entry_point()

2018-01-23 Thread Bryan O'Donoghue
Add a helper function for extracting the least significant 32 bits from the
OPTEE entry point address, which will be good enough to load OPTEE binaries
up to (2^32)-1 bytes.

We may need to extend this out later on but for now (2^32)-1 should be
fine.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 include/tee/optee.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/tee/optee.h b/include/tee/optee.h
index 8943afb..eb328d3 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -29,6 +29,13 @@ struct optee_header {
uint32_t paged_size;
 };
 
+static inline uint32_t optee_image_get_entry_point(const image_header_t *hdr)
+{
+   struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
+
+   return optee_hdr->init_load_addr_lo;
+}
+
 #if defined(CONFIG_OPTEE)
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
   unsigned long tzdram_len, unsigned long image_len);
-- 
2.7.4

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


[U-Boot] [PATCH v3 2/9] optee: Add CONFIG_OPTEE_TZDRAM_SIZE

2018-01-23 Thread Bryan O'Donoghue
OPTEE is currently linked to a specific area of memory called the TrustZone
DRAM. This patch adds a CONFIG entry for the default size of TrustZone DRAM
that a board-port can over-ride. The region that U-Boot sets aside for the
OPTEE run-time should be verified before attempting to hand off to the
OPTEE run-time. Each board-port should carefully ensure that the TZDRAM
size specified in the OPTEE build and the TZDRAM size specified in U-Boot
match-up.

Further patches will use TZDRAM size with other defines and variables to
carry out a degree of automated verification in U-Boot prior to trying to
boot an OPTEE image.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 lib/optee/Kconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig
index 2e406fe..41c0ab7 100644
--- a/lib/optee/Kconfig
+++ b/lib/optee/Kconfig
@@ -6,3 +6,11 @@ config OPTEE
   enable an OPTEE specific bootm command that will perform additional
   OPTEE specific checks before booting an OPTEE image created with
   mkimage.
+
+config OPTEE_TZDRAM_SIZE
+   hex "Amount of Trust-Zone RAM for the OPTEE image"
+   depends on OPTEE
+   default 0x300
+   help
+ The size of pre-allocated Trust Zone DRAM to allocate for the OPTEE
+ runtime.
-- 
2.7.4

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


[U-Boot] [PATCH v3 3/9] optee: Add CONFIG_OPTEE_TZDRAM_BASE

2018-01-23 Thread Bryan O'Donoghue
OPTEE is currently linked to a specific area of memory called the TrustZone
DRAM. This patch adds a CONFIG entry for the default address of TrustZone
DRAM that a board-port can over-ride. The region that U-Boot sets aside for
the OPTEE run-time should be verified before attempting to hand off to the
OPTEE run-time. Each board-port should carefully ensure that the TZDRAM
address specified in the OPTEE build and the TZDRAM address specified in
U-Boot match-up.

Further patches will use TZDRAM address with other defines and variables to
carry out a degree of automated verification in U-Boot prior to trying to
boot an OPTEE image.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
---
 lib/optee/Kconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig
index 41c0ab7..a3b7332 100644
--- a/lib/optee/Kconfig
+++ b/lib/optee/Kconfig
@@ -14,3 +14,11 @@ config OPTEE_TZDRAM_SIZE
help
  The size of pre-allocated Trust Zone DRAM to allocate for the OPTEE
  runtime.
+
+config OPTEE_TZDRAM_BASE
+   hex "Base address of Trust-Zone RAM for the OPTEE image"
+   depends on OPTEE
+   default 0x9d00
+   help
+ The base address of pre-allocated Trust Zone DRAM for
+ the OPTEE runtime.
-- 
2.7.4

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


[U-Boot] [PATCH v3 1/9] optee: Add lib entries for sharing OPTEE code across ports

2018-01-23 Thread Bryan O'Donoghue
This patch adds code to lib to enable sharing of useful OPTEE code between
board-ports and architectures. The code on lib/optee/optee.c comes from the
TI omap2 port. Eventually the OMAP2 code will be patched to include the
shared code. The intention here is to add more useful OPTEE specific code
as more functionality gets added.

Signed-off-by: Bryan O'Donoghue 
Cc: Harinarayan Bhatta 
Cc: Andrew F. Davis 
Cc: Tom Rini 
Cc: Kever Yang 
Cc: Philipp Tomsich 
Cc: Peng Fan 
Tested-by: Peng Fan 
---
 include/tee/optee.h | 16 
 lib/Kconfig |  1 +
 lib/Makefile|  1 +
 lib/optee/Kconfig   |  8 
 lib/optee/Makefile  |  7 +++
 lib/optee/optee.c   | 31 +++
 6 files changed, 64 insertions(+)
 create mode 100644 lib/optee/Kconfig
 create mode 100644 lib/optee/Makefile
 create mode 100644 lib/optee/optee.c

diff --git a/include/tee/optee.h b/include/tee/optee.h
index 9ab0d08..8943afb 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -10,6 +10,8 @@
 #ifndef_OPTEE_H
 #define _OPTEE_H
 
+#include 
+
 #define OPTEE_MAGIC 0x4554504f
 #define OPTEE_VERSION   1
 #define OPTEE_ARCH_ARM320
@@ -27,4 +29,18 @@ struct optee_header {
uint32_t paged_size;
 };
 
+#if defined(CONFIG_OPTEE)
+int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
+  unsigned long tzdram_len, unsigned long image_len);
+#else
+static inline int optee_verify_image(struct optee_header *hdr,
+unsigned long tzdram_start,
+unsigned long tzdram_len,
+unsigned long image_len)
+{
+   return -EPERM;
+}
+
+#endif
+
 #endif /* _OPTEE_H */
diff --git a/lib/Kconfig b/lib/Kconfig
index 00ac650..2077f9c 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -288,5 +288,6 @@ endmenu
 
 source lib/efi/Kconfig
 source lib/efi_loader/Kconfig
+source lib/optee/Kconfig
 
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 8cd779f..46813b6 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_FIT) += libfdt/
 obj-$(CONFIG_OF_LIVE) += of_live.o
 obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
+obj-$(CONFIG_OPTEE) += optee/
 
 obj-$(CONFIG_AES) += aes.o
 obj-y += charset.o
diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig
new file mode 100644
index 000..2e406fe
--- /dev/null
+++ b/lib/optee/Kconfig
@@ -0,0 +1,8 @@
+config OPTEE
+   bool "Support OPTEE images"
+   help
+ U-Boot can be configured to boot OPTEE images.
+ Selecting this option will enable shared OPTEE library code and
+  enable an OPTEE specific bootm command that will perform additional
+  OPTEE specific checks before booting an OPTEE image created with
+  mkimage.
diff --git a/lib/optee/Makefile b/lib/optee/Makefile
new file mode 100644
index 000..03e832f
--- /dev/null
+++ b/lib/optee/Makefile
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2017 Linaro
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_OPTEE) += optee.o
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
new file mode 100644
index 000..2cc16d7
--- /dev/null
+++ b/lib/optee/optee.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 Linaro
+ * Bryan O'Donoghue 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+
+int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
+  unsigned long tzdram_len, unsigned long image_len)
+{
+   unsigned long tzdram_end = tzdram_start + tzdram_len;
+   uint32_t tee_file_size;
+
+   tee_file_size = hdr->init_size + hdr->paged_size +
+   sizeof(struct optee_header);
+
+   if (hdr->magic != OPTEE_MAGIC ||
+   hdr->version != OPTEE_VERSION ||
+   hdr->init_load_addr_hi > tzdram_end ||
+   hdr->init_load_addr_lo < tzdram_start ||
+   tee_file_size > tzdram_len ||
+   tee_file_size != image_len ||
+   (hdr->init_load_addr_lo + tee_file_size) > tzdram_end) {
+   return -EINVAL;
+   }
+
+   return 0;
+}
-- 
2.7.4

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


[U-Boot] [PATCH v3 0/9] Add new OPTEE bootm support to u-boot

2018-01-23 Thread Bryan O'Donoghue
v3:

- Rework printout to be added at the end as opposed to churn over three
  separate patches - Andrew

- Reword patch 006 to better explain the thinking behind new image type
  - Andrew

v2:
- Added CONFIG_OPTEE_TZDRAM_BASE instead of #ifndef OPTEE_TZDRAM_BASE
  as an error. - Tom Rini

- Added Tested-by: Peng Fan  - as indicated

- Added better explanation text to patch 6/9
  "tools: mkimage: add optee image type"

- Fixed some checkpatch warnings in optee.c

v1:
This series adds a new OPTEE bootable image type to u-boot, which is
directly bootable with the bootm command.

There is already a TEE image type but, in this case the TEE firmware is
loaded into RAM, jumped into and then back out of. This image type is a
directly bootable image as described here :
http://mrvan.github.io/optee-imx6ul

Instead of reusing the Linux bootable image type instead a new image type
is defined, which allows us to perform additional image verification, prior
to handing off control via bootm.

OPTEE images get linked to a specific address at compile time and must be
loaded to this address too. This series extends out mkimage with a new
image type that allows the OPTEE binary link location to be validated
against CONFIG_OPTEE_TZDRAM_BASE and CONFIG_OPTEE_TZDRAM_SIZE respectively
prior to proceeding through the bootm phase.

Once applied you can generate a bootable OPTEE image like this

mkimage -A arm -T optee -C none -d ./out/arm-plat-imx/core/tee.bin uTee.optee

That image can then be booted directly by bootm. bootm will verify the
header contents of the OPTEE binary against the DRAM area carved out in
u-boot. If the defined DRAM area does not match the link address specified
we refuse to boot.

Kever - I'd like to suggest that your OPTEE SPL image takes a different
image type IH_TYPE_OPTEE_SPL ? to indicate the different behavior your
image type has versus a directly bootable bootm image.

Bryan O'Donoghue (9):
  optee: Add lib entries for sharing OPTEE code across ports
  optee: Add CONFIG_OPTEE_TZDRAM_SIZE
  optee: Add CONFIG_OPTEE_TZDRAM_BASE
  optee: Add optee_image_get_entry_point()
  optee: Add optee_image_get_load_addr()
  tools: mkimage: add optee image type
  optee: Add optee_verify_bootm_image()
  optee: Add error printout
  bootm: optee: Add mechanism to validate an OPTEE image before boot

 common/bootm.c| 11 -
 common/image.c|  1 +
 include/image.h   |  1 +
 include/tee/optee.h   | 41 
 lib/Kconfig   |  1 +
 lib/Makefile  |  1 +
 lib/optee/Kconfig | 24 +++
 lib/optee/Makefile|  7 ++
 lib/optee/optee.c | 66 +++
 tools/default_image.c | 25 ++-
 10 files changed, 171 insertions(+), 7 deletions(-)
 create mode 100644 lib/optee/Kconfig
 create mode 100644 lib/optee/Makefile
 create mode 100644 lib/optee/optee.c

-- 
2.7.4

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


[U-Boot] [PATCH v3 11/15] env: mmc: depends on the MMC framework

2018-01-23 Thread Maxime Ripard
The raw MMC environment directly calls into the MMC framework. Make sure
it's enabled before we can select it.

Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/env/Kconfig b/env/Kconfig
index bef6e89bfc3c..ad5ccc253762 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -156,6 +156,7 @@ config ENV_IS_IN_FLASH
 config ENV_IS_IN_MMC
bool "Environment in an MMC device"
depends on !CHAIN_OF_TRUST
+   depends on MMC
help
  Define this if you have an MMC device which you want to use for the
  environment.
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 09/15] env: Support multiple environments

2018-01-23 Thread Maxime Ripard
Now that we have everything in place to support multiple environment, let's
make sure the current code can use it.

The priority used between the various environment is the same one that was
used in the code previously.

At read / init times, the highest priority environment is going to be
detected, and we'll use the same one without lookup during writes. This
should implement the same behaviour than we currently have.

Reviewed-by: Andre Przywara 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 80 +++-
 1 file changed, 50 insertions(+), 30 deletions(-)

diff --git a/env/env.c b/env/env.c
index 906f28ee50a1..1182fdb545db 100644
--- a/env/env.c
+++ b/env/env.c
@@ -26,6 +26,41 @@ static struct env_driver *_env_driver_lookup(enum 
env_location loc)
return NULL;
 }
 
+static enum env_location env_locations[] = {
+#ifdef CONFIG_ENV_IS_IN_EEPROM
+   ENVL_EEPROM,
+#endif
+#ifdef CONFIG_ENV_IS_IN_FAT
+   ENVL_FAT,
+#endif
+#ifdef CONFIG_ENV_IS_IN_FLASH
+   ENVL_FLASH,
+#endif
+#ifdef CONFIG_ENV_IS_IN_MMC
+   ENVL_MMC,
+#endif
+#ifdef CONFIG_ENV_IS_IN_NAND
+   ENVL_NAND,
+#endif
+#ifdef CONFIG_ENV_IS_IN_NVRAM
+   ENVL_NVRAM,
+#endif
+#ifdef CONFIG_ENV_IS_IN_REMOTE
+   ENVL_REMOTE,
+#endif
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   ENVL_SPI_FLASH,
+#endif
+#ifdef CONFIG_ENV_IS_IN_UBI
+   ENVL_UBI,
+#endif
+#ifdef CONFIG_ENV_IS_NOWHERE
+   ENVL_NOWHERE,
+#endif
+};
+
+static enum env_location env_load_location = ENVL_UNKNOWN;
+
 /**
  * env_get_location() - Returns the best env location for a board
  * @op: operations performed on the environment
@@ -45,36 +80,21 @@ static struct env_driver *_env_driver_lookup(enum 
env_location loc)
  */
 static enum env_location env_get_location(enum env_operation op, int prio)
 {
-   /*
-* We support a single environment, so any environment asked
-* with a priority that is not zero is out of our supported
-* bounds.
-*/
-   if (prio >= 1)
-   return ENVL_UNKNOWN;
-
-   if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
-   return ENVL_EEPROM;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
-   return ENVL_FAT;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH)
-   return ENVL_FLASH;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC)
-   return ENVL_MMC;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND)
-   return ENVL_NAND;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM)
-   return ENVL_NVRAM;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE)
-   return ENVL_REMOTE;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)
-   return ENVL_SPI_FLASH;
-   else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI)
-   return ENVL_UBI;
-   else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
-   return ENVL_NOWHERE;
-   else
-   return ENVL_UNKNOWN;
+   switch (op) {
+   case ENVOP_GET_CHAR:
+   case ENVOP_INIT:
+   case ENVOP_LOAD:
+   if (prio >= ARRAY_SIZE(env_locations))
+   return ENVL_UNKNOWN;
+
+   env_load_location = env_locations[prio];
+   return env_load_location;
+
+   case ENVOP_SAVE:
+   return env_load_location;
+   }
+
+   return ENVL_UNKNOWN;
 }
 
 
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 05/15] env: Make it explicit where we're loading our environment from

2018-01-23 Thread Maxime Ripard
Since we can have multiple environments now, it's better to provide a
decent indication on what environments were tried and which were the one to
fail and succeed.

Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/env/env.c b/env/env.c
index 11667a3cbc71..906f28ee50a1 100644
--- a/env/env.c
+++ b/env/env.c
@@ -144,12 +144,15 @@ int env_load(void)
if (!drv->load)
continue;
 
+   printf("Loading Environment from %s... ", drv->name);
ret = drv->load();
+   if (ret)
+   printf("Failed (%d)\n", ret);
+   else
+   printf("OK\n");
+
if (!ret)
return 0;
-
-   debug("%s: Environment %s failed to load (err=%d)\n", __func__,
- drv->name, ret);
}
 
return -ENODEV;
@@ -168,12 +171,13 @@ int env_save(void)
 
printf("Saving Environment to %s... ", drv->name);
ret = drv->save();
-   printf("%s\n", ret ? "Failed" : "OK");
+   if (ret)
+   printf("Failed (%d)\n", ret);
+   else
+   printf("OK\n");
+
if (!ret)
return 0;
-
-   debug("%s: Environment %s failed to save (err=%d)\n", __func__,
- drv->name, ret);
}
 
return -ENODEV;
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 07/15] env: mmc: Make the debug messages play a little nicer

2018-01-23 Thread Maxime Ripard
Since we have global messages to indicate what's going on, the custom
messages in the environment drivers only make the output less readable.

Make MMC play a little nicer by removing all the extra \n and formatting
that is redundant with the global output.

Reviewed-by: Andre Przywara 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/mmc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/env/mmc.c b/env/mmc.c
index ed7bcf16ae0e..528fbf978162 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -233,7 +233,6 @@ static int env_mmc_save(void)
goto fini;
}
 
-   puts("done\n");
ret = 0;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 14/15] sunxi: Transition from the MMC to a FAT-based environment

2018-01-23 Thread Maxime Ripard
The current environment has been hardcoded to an offset that starts to be
an issue given the current size of our main U-Boot binary.

By implementing a custom environment location routine, we can always favor
the FAT-based environment, and fallback to the MMC if we don't find
something in the FAT partition. We also implement the same order when
saving the environment, so that hopefully we can slowly migrate the users
over to FAT-based environment and away from the raw MMC one.

Eventually, and hopefully before we reach that limit again, we will have
most of our users using that setup, and we'll be able to retire the raw
environment, and gain more room for the U-Boot binary.

Reviewed-by: Lukasz Majewski 
Signed-off-by: Maxime Ripard 
---
 board/sunxi/board.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index dcacdf3e626d..8891961dcc6b 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -173,6 +173,22 @@ void i2c_init_board(void)
 #endif
 }
 
+#if defined(CONFIG_ENV_IS_IN_MMC) && defined(CONFIG_ENV_IS_IN_FAT)
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   switch (prio) {
+   case 0:
+   return ENVL_FAT;
+
+   case 1:
+   return ENVL_MMC;
+
+   default:
+   return ENVL_UNKNOWN;
+   }
+}
+#endif
+
 /* add board specific code here */
 int board_init(void)
 {
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 15/15] env: sunxi: Enable FAT-based environment support by default

2018-01-23 Thread Maxime Ripard
Now that we have everything in place to implement the transition scheme,
let's enable it by default.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Signed-off-by: Maxime Ripard 
---
 env/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 6e2fbf416c12..d1bf75ab41ca 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -55,6 +55,7 @@ config ENV_IS_IN_FAT
bool "Environment is in a FAT filesystem"
depends on !CHAIN_OF_TRUST
default y if ARCH_BCM283X
+   default y if ARCH_SUNXI && MMC
default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS
select FAT_WRITE
help
@@ -363,6 +364,7 @@ config ENV_IS_IN_UBI
 config ENV_FAT_INTERFACE
string "Name of the block device for the environment"
depends on ENV_IS_IN_FAT
+   default "mmc" if ARCH_SUNXI
default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91
help
  Define this to a string that is the name of the block device.
@@ -372,6 +374,8 @@ config ENV_FAT_DEVICE_AND_PART
depends on ENV_IS_IN_FAT
default "0:1" if TI_COMMON_CMD_OPTIONS
default "0:auto" if ARCH_ZYNQMP
+   default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
+   default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
default "0" if ARCH_AT91
help
  Define this to a string to specify the partition of the device. It can
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 08/15] env: common: Make the debug messages play a little nicer

2018-01-23 Thread Maxime Ripard
Since we have global messages to indicate what's going on, the custom
messages in the environment drivers only make the output less readable.

Make the common code play a little nicer by removing all the extra output
in the standard case.

Reviewed-by: Andre Przywara 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/common.c b/env/common.c
index 8167ea299264..c633502d68bb 100644
--- a/env/common.c
+++ b/env/common.c
@@ -78,7 +78,7 @@ void set_default_env(const char *s)
puts(s);
}
} else {
-   puts("Using default environment\n\n");
+   debug("Using default environment\n");
}
 
if (himport_r(_htab, (char *)default_environment,
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 10/15] env: Initialise all the environments

2018-01-23 Thread Maxime Ripard
Since we want to have multiple environments, we will need to initialise
all the environments since we don't know at init time what drivers might
fail when calling load.

Let's init all of them, and only consider for further operations the ones
that have not reported any errors at init time.

Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 36 +---
 include/asm-generic/global_data.h |  1 +-
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/env/env.c b/env/env.c
index 1182fdb545db..2ea581cbedd6 100644
--- a/env/env.c
+++ b/env/env.c
@@ -61,6 +61,23 @@ static enum env_location env_locations[] = {
 
 static enum env_location env_load_location = ENVL_UNKNOWN;
 
+static bool env_has_inited(enum env_location location)
+{
+   return gd->env_has_init & BIT(location);
+}
+
+static void env_set_inited(enum env_location location)
+{
+   /*
+* We're using a 32-bits bitmask stored in gd (env_has_init)
+* using the above enum value as the bit index. We need to
+* make sure that we're not overflowing it.
+*/
+   BUILD_BUG_ON(ARRAY_SIZE(env_locations) > BITS_PER_LONG);
+
+   gd->env_has_init |= BIT(location);
+}
+
 /**
  * env_get_location() - Returns the best env location for a board
  * @op: operations performed on the environment
@@ -142,6 +159,9 @@ int env_get_char(int index)
if (!drv->get_char)
continue;
 
+   if (!env_has_inited(drv->location))
+   continue;
+
ret = drv->get_char(index);
if (!ret)
return 0;
@@ -164,6 +184,9 @@ int env_load(void)
if (!drv->load)
continue;
 
+   if (!env_has_inited(drv->location))
+   continue;
+
printf("Loading Environment from %s... ", drv->name);
ret = drv->load();
if (ret)
@@ -189,6 +212,9 @@ int env_save(void)
if (!drv->save)
continue;
 
+   if (!env_has_inited(drv->location))
+   continue;
+
printf("Saving Environment to %s... ", drv->name);
ret = drv->save();
if (ret)
@@ -210,14 +236,10 @@ int env_init(void)
int prio;
 
for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) {
-   if (!drv->init)
-   continue;
-
-   ret = drv->init();
-   if (!ret)
-   return 0;
+   if (!drv->init || !(ret = drv->init()))
+   env_set_inited(drv->location);
 
-   debug("%s: Environment %s failed to init (err=%d)\n", __func__,
+   debug("%s: Environment %s init done (ret=%d)\n", __func__,
  drv->name, ret);
}
 
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 73e036d6fd4a..fd8cd45b050e 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -50,6 +50,7 @@ typedef struct global_data {
 #endif
unsigned long env_addr; /* Address  of Environment struct */
unsigned long env_valid;/* Environment valid? enum env_valid */
+   unsigned long env_has_init; /* Bitmask of boolean of struct 
env_location offsets */
 
unsigned long ram_top;  /* Top address of RAM used by U-Boot */
unsigned long relocaddr;/* Start address of U-Boot in RAM */
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 06/15] env: fat: Make the debug messages play a little nicer

2018-01-23 Thread Maxime Ripard
Since we have global messages to indicate what's going on, the custom
messages in the environment drivers only make the output less readable.

Make FAT play a little nicer by removing all the extra \n and formatting
that is redundant with the global output.

Reviewed-by: Andre Przywara 
Signed-off-by: Maxime Ripard 
---
 env/fat.c | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/env/fat.c b/env/fat.c
index ec49c3905369..158a9a34357b 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -55,7 +55,11 @@ static int env_fat_save(void)
 
dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, ) != 0) {
-   printf("\n** Unable to use %s %d:%d for saveenv **\n",
+   /*
+* This printf is embedded in the messages from env_save that
+* will calling it. The missing \n is intentional.
+*/
+   printf("Unable to use %s %d:%d... ",
   CONFIG_ENV_FAT_INTERFACE, dev, part);
return 1;
}
@@ -63,12 +67,15 @@ static int env_fat_save(void)
err = file_fat_write(CONFIG_ENV_FAT_FILE, (void *)_new, 0, 
sizeof(env_t),
 );
if (err == -1) {
-   printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
+   /*
+* This printf is embedded in the messages from env_save that
+* will calling it. The missing \n is intentional.
+*/
+   printf("Unable to write \"%s\" from %s%d:%d... ",
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, 
part);
return 1;
}
 
-   puts("done\n");
return 0;
 }
 #endif /* CMD_SAVEENV */
@@ -90,14 +97,22 @@ static int env_fat_load(void)
 
dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, ) != 0) {
-   printf("\n** Unable to use %s %d:%d for loading the env **\n",
+   /*
+* This printf is embedded in the messages from env_save that
+* will calling it. The missing \n is intentional.
+*/
+   printf("Unable to use %s %d:%d... ",
   CONFIG_ENV_FAT_INTERFACE, dev, part);
goto err_env_relocate;
}
 
err = file_fat_read(CONFIG_ENV_FAT_FILE, buf, CONFIG_ENV_SIZE);
if (err == -1) {
-   printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
+   /*
+* This printf is embedded in the messages from env_save that
+* will calling it. The missing \n is intentional.
+*/
+   printf("Unable to read \"%s\" from %s%d:%d... ",
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, 
part);
goto err_env_relocate;
}
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 01/15] cmd: nvedit: Get rid of the env lookup

2018-01-23 Thread Maxime Ripard
The nvedit command is the only user of env_driver_lookup_default outside of
the environment code itself, and it uses it only to print the environment
it's about to save to during env save.

As we're about to rework the environment to be able to handle multiple
environment sources, we might not have an idea of what environment backend
is going to be used before trying (and possibly failing for some).

Therefore, it makes sense to remove that message and move it to the
env_save function itself. As a side effect, we also can get rid of the call
to env_driver_lookup_default that is also about to get refactored.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 cmd/nvedit.c  | 4 
 env/env.c | 4 +++-
 include/environment.h | 7 ---
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 4e79d03856fe..a690d743cd46 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -708,10 +708,6 @@ ulong env_get_ulong(const char *name, int base, ulong 
default_val)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
   char * const argv[])
 {
-   struct env_driver *env = env_driver_lookup_default();
-
-   printf("Saving Environment to %s...\n", env->name);
-
return env_save() ? 1 : 0;
 }
 
diff --git a/env/env.c b/env/env.c
index 76a5608628fc..094538ff5b62 100644
--- a/env/env.c
+++ b/env/env.c
@@ -52,7 +52,7 @@ static enum env_location env_get_default_location(void)
return ENVL_UNKNOWN;
 }
 
-struct env_driver *env_driver_lookup_default(void)
+static struct env_driver *env_driver_lookup_default(void)
 {
enum env_location loc = env_get_default_location();
struct env_driver *drv;
@@ -115,6 +115,8 @@ int env_save(void)
return -ENODEV;
if (!drv->save)
return -ENOSYS;
+
+   printf("Saving Environment to %s...\n", drv->name);
ret = drv->save();
if (ret) {
debug("%s: Environment failed to save (err=%d)\n", __func__,
diff --git a/include/environment.h b/include/environment.h
index d29f82cb5d6f..a2015c299aa9 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -293,13 +293,6 @@ int env_import_redund(const char *buf1, const char *buf2);
 #endif
 
 /**
- * env_driver_lookup_default() - Look up the default environment driver
- *
- * @return pointer to driver, or NULL if none (which should not happen)
- */
-struct env_driver *env_driver_lookup_default(void);
-
-/**
  * env_get_char() - Get a character from the early environment
  *
  * This reads from the pre-relocation environemnt
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 13/15] env: Mark env_get_location as weak

2018-01-23 Thread Maxime Ripard
Allow boards and architectures to override the default environment lookup
code by overriding env_get_location.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/env/env.c b/env/env.c
index 2ea581cbedd6..9564522e76a5 100644
--- a/env/env.c
+++ b/env/env.c
@@ -85,6 +85,7 @@ static void env_set_inited(enum env_location location)
  *highest priority
  *
  * This will return the preferred environment for the given priority.
+ * This is overridable by boards if they need to.
  *
  * All implementations are free to use the operation, the priority and
  * any other data relevant to their choice, but must take into account
@@ -95,7 +96,7 @@ static void env_set_inited(enum env_location location)
  * Returns:
  * an enum env_location value on success, a negative error code otherwise
  */
-static enum env_location env_get_location(enum env_operation op, int prio)
+__weak enum env_location env_get_location(enum env_operation op, int prio)
 {
switch (op) {
case ENVOP_GET_CHAR:
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 04/15] env: Make the env save message a bit more explicit

2018-01-23 Thread Maxime Ripard
Since we'll soon have support for multiple environments, the environment
saving message might end up being printed multiple times if the higher
priority environment cannot be used.

That might confuse the user, so let's make it explicit if the operation
failed or not.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/env/env.c b/env/env.c
index 73da149fd8ca..11667a3cbc71 100644
--- a/env/env.c
+++ b/env/env.c
@@ -166,8 +166,9 @@ int env_save(void)
if (!drv->save)
continue;
 
-   printf("Saving Environment to %s...\n", drv->name);
+   printf("Saving Environment to %s... ", drv->name);
ret = drv->save();
+   printf("%s\n", ret ? "Failed" : "OK");
if (!ret)
return 0;
 
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 12/15] env: Allow to build multiple environments in Kconfig

2018-01-23 Thread Maxime Ripard
Now that we have everything in place in the code, let's allow to build
multiple environments backend through Kconfig.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 configs/MPC8313ERDB_NAND_33_defconfig |  1 +-
 configs/MPC8313ERDB_NAND_66_defconfig |  1 +-
 configs/cl-som-imx7_defconfig |  1 +-
 configs/microblaze-generic_defconfig  |  1 +-
 env/Kconfig   | 65 +---
 5 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/configs/MPC8313ERDB_NAND_33_defconfig 
b/configs/MPC8313ERDB_NAND_33_defconfig
index 823001583447..b761516d126a 100644
--- a/configs/MPC8313ERDB_NAND_33_defconfig
+++ b/configs/MPC8313ERDB_NAND_33_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_DATE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=e280.flash"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=e280.flash:512k(uboot),128k(env),6m@1m(kernel),-(fs)"
+# CONFIG_ENV_IS_IN_FLASH is not set
 CONFIG_ENV_IS_IN_NAND=y
 # CONFIG_MMC is not set
 CONFIG_MTD_NOR_FLASH=y
diff --git a/configs/MPC8313ERDB_NAND_66_defconfig 
b/configs/MPC8313ERDB_NAND_66_defconfig
index 2639926ab814..0f2a675ae2cf 100644
--- a/configs/MPC8313ERDB_NAND_66_defconfig
+++ b/configs/MPC8313ERDB_NAND_66_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_DATE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=e280.flash"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=e280.flash:512k(uboot),128k(env),6m@1m(kernel),-(fs)"
+# CONFIG_ENV_IS_IN_FLASH is not set
 CONFIG_ENV_IS_IN_NAND=y
 # CONFIG_MMC is not set
 CONFIG_MTD_NOR_FLASH=y
diff --git a/configs/cl-som-imx7_defconfig b/configs/cl-som-imx7_defconfig
index d37c82cafac1..0c93159032e5 100644
--- a/configs/cl-som-imx7_defconfig
+++ b/configs/cl-som-imx7_defconfig
@@ -41,6 +41,7 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ENV_IS_IN_MMC is not set
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/microblaze-generic_defconfig 
b/configs/microblaze-generic_defconfig
index 5254c0da790a..cc80e8a027c8 100644
--- a/configs/microblaze-generic_defconfig
+++ b/configs/microblaze-generic_defconfig
@@ -40,7 +40,6 @@ CONFIG_CMD_UBI=y
 # CONFIG_CMD_UBIFS is not set
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_EMBED=y
-CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_DM=y
 CONFIG_MTD_NOR_FLASH=y
diff --git a/env/Kconfig b/env/Kconfig
index ad5ccc253762..6e2fbf416c12 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -1,38 +1,18 @@
 menu "Environment"
 
-choice
-   prompt "Select the location of the environment"
-   default ENV_IS_IN_MMC if ARCH_SUNXI
-   default ENV_IS_IN_MMC if ARCH_EXYNOS4
-   default ENV_IS_IN_MMC if MX6SX || MX7D
-   default ENV_IS_IN_MMC if TEGRA30 || TEGRA124
-   default ENV_IS_IN_MMC if TEGRA_ARMV8_COMMON
-   default ENV_IS_IN_FLASH if ARCH_CINTEGRATOR
-   default ENV_IS_IN_FLASH if ARCH_INTEGRATOR_CP
-   default ENV_IS_IN_FLASH if M548x || M547x || M5282 || MCF547x_8x
-   default ENV_IS_IN_FLASH if MCF532x || MCF52x2
-   default ENV_IS_IN_FLASH if MPC86xx || MPC83xx
-   default ENV_IS_IN_FLASH if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641
-   default ENV_IS_IN_FLASH if SH && !CPU_SH4
-   default ENV_IS_IN_SPI_FLASH if ARMADA_XP
-   default ENV_IS_IN_SPI_FLASH if INTEL_BAYTRAIL
-   default ENV_IS_IN_SPI_FLASH if INTEL_BRASWELL
-   default ENV_IS_IN_SPI_FLASH if INTEL_BROADWELL
-   default ENV_IS_IN_SPI_FLASH if NORTHBRIDGE_INTEL_IVYBRIDGE
-   default ENV_IS_IN_SPI_FLASH if INTEL_QUARK
-   default ENV_IS_IN_SPI_FLASH if INTEL_QUEENSBAY
-   default ENV_IS_IN_FAT if ARCH_BCM283X
-   default ENV_IS_IN_FAT if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS
-   default ENV_IS_NOWHERE
-   help
- At present the environment can be stored in only one place. Use this
- option to select the location. This is either a device (where the
- environemnt information is simply written to a fixed location or
- partition on the device) or a filesystem (where the environment
- information is written to a file).
-
 config ENV_IS_NOWHERE
bool "Environment is not stored"
+   depends on !ENV_IS_IN_EEPROM
+   depends on !ENV_IS_IN_FAT
+   depends on !ENV_IS_IN_FLASH
+   depends on !ENV_IS_IN_MMC
+   depends on !ENV_IS_IN_NAND
+   depends on !ENV_IS_IN_NVRAM
+   depends on !ENV_IS_IN_ONENAND
+   depends on !ENV_IS_IN_REMOTE
+   depends on !ENV_IS_IN_SPI_FLASH
+   depends on !ENV_IS_IN_UBI
+   default y
help
  Define this if you don't want to or can't have an environment stored
  on a storage medium. In this case the environemnt will still exist
@@ -74,6 +54,8 @@ config ENV_IS_IN_EEPROM
 config ENV_IS_IN_FAT
bool "Environment 

[U-Boot] [PATCH v3 03/15] env: Pass additional parameters to the env lookup function

2018-01-23 Thread Maxime Ripard
In preparation for the multiple environment support, let's introduce two
new parameters to the environment driver lookup function: the priority and
operation.

The operation parameter is meant to identify, obviously, the operation you
might want to perform on the environment.

The priority is a number passed to identify the environment priority you
want to retrieve. The lowest priority parameter (0) will be the primary
source.

Combining the two parameters allow you to support multiple environments
through different priorities, and to change those priorities between read
and writes operations.

This is especially useful to implement migration mechanisms where you want
to always use the same environment first, be it to read or write, while the
common case is more likely to use the same environment it has read from to
write it to.

Signed-off-by: Maxime Ripard 
---
 env/env.c | 157 +--
 include/environment.h |   8 ++-
 2 files changed, 116 insertions(+), 49 deletions(-)

diff --git a/env/env.c b/env/env.c
index 97ada5b5a6fd..73da149fd8ca 100644
--- a/env/env.c
+++ b/env/env.c
@@ -26,8 +26,33 @@ static struct env_driver *_env_driver_lookup(enum 
env_location loc)
return NULL;
 }
 
-static enum env_location env_get_location(void)
+/**
+ * env_get_location() - Returns the best env location for a board
+ * @op: operations performed on the environment
+ * @prio: priority between the multiple environments, 0 being the
+ *highest priority
+ *
+ * This will return the preferred environment for the given priority.
+ *
+ * All implementations are free to use the operation, the priority and
+ * any other data relevant to their choice, but must take into account
+ * the fact that the lowest prority (0) is the most important location
+ * in the system. The following locations should be returned by order
+ * of descending priorities, from the highest to the lowest priority.
+ *
+ * Returns:
+ * an enum env_location value on success, a negative error code otherwise
+ */
+static enum env_location env_get_location(enum env_operation op, int prio)
 {
+   /*
+* We support a single environment, so any environment asked
+* with a priority that is not zero is out of our supported
+* bounds.
+*/
+   if (prio >= 1)
+   return ENVL_UNKNOWN;
+
if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
return ENVL_EEPROM;
else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
@@ -52,11 +77,27 @@ static enum env_location env_get_location(void)
return ENVL_UNKNOWN;
 }
 
-static struct env_driver *env_driver_lookup(void)
+
+/**
+ * env_driver_lookup() - Finds the most suited environment location
+ * @op: operations performed on the environment
+ * @prio: priority between the multiple environments, 0 being the
+ *highest priority
+ *
+ * This will try to find the available environment with the highest
+ * priority in the system.
+ *
+ * Returns:
+ * NULL on error, a pointer to a struct env_driver otherwise
+ */
+static struct env_driver *env_driver_lookup(enum env_operation op, int prio)
 {
-   enum env_location loc = env_get_location();
+   enum env_location loc = env_get_location(op, prio);
struct env_driver *drv;
 
+   if (loc == ENVL_UNKNOWN)
+   return NULL;
+
drv = _env_driver_lookup(loc);
if (!drv) {
debug("%s: No environment driver for location %d\n", __func__,
@@ -69,83 +110,101 @@ static struct env_driver *env_driver_lookup(void)
 
 int env_get_char(int index)
 {
-   struct env_driver *drv = env_driver_lookup();
-   int ret;
+   struct env_driver *drv;
+   int prio;
 
if (gd->env_valid == ENV_INVALID)
return default_environment[index];
-   if (!drv)
-   return -ENODEV;
-   if (!drv->get_char)
-   return *(uchar *)(gd->env_addr + index);
-   ret = drv->get_char(index);
-   if (ret < 0) {
-   debug("%s: Environment failed to load (err=%d)\n",
- __func__, ret);
+
+   for (prio = 0; (drv = env_driver_lookup(ENVOP_GET_CHAR, prio)); prio++) 
{
+   int ret;
+
+   if (!drv->get_char)
+   continue;
+
+   ret = drv->get_char(index);
+   if (!ret)
+   return 0;
+
+   debug("%s: Environment %s failed to load (err=%d)\n", __func__,
+ drv->name, ret);
}
 
-   return ret;
+   return -ENODEV;
 }
 
 int env_load(void)
 {
-   struct env_driver *drv = env_driver_lookup();
-   int ret = 0;
+   struct env_driver *drv;
+   int prio;
 
-   if (!drv)
-   return -ENODEV;
-   if (!drv->load)
-   return 0;
-   ret = drv->load();
-   if (ret) {
-   debug("%s: Environment failed to load (err=%d)\n", 

[U-Boot] [PATCH v3 02/15] env: Rename env_driver_lookup_default and env_get_default_location

2018-01-23 Thread Maxime Ripard
The env_driver_lookup_default and env_get_default_location functions are
about to get refactored to support loading from multiple environment.

The name is therefore not really well suited anymore. Drop the default
part to be a bit more relevant.

Reviewed-by: Andre Przywara 
Reviewed-by: Lukasz Majewski 
Reviewed-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 env/env.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/env/env.c b/env/env.c
index 094538ff5b62..97ada5b5a6fd 100644
--- a/env/env.c
+++ b/env/env.c
@@ -10,7 +10,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct env_driver *env_driver_lookup(enum env_location loc)
+static struct env_driver *_env_driver_lookup(enum env_location loc)
 {
struct env_driver *drv;
const int n_ents = ll_entry_count(struct env_driver, env_driver);
@@ -26,7 +26,7 @@ static struct env_driver *env_driver_lookup(enum env_location 
loc)
return NULL;
 }
 
-static enum env_location env_get_default_location(void)
+static enum env_location env_get_location(void)
 {
if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
return ENVL_EEPROM;
@@ -52,12 +52,12 @@ static enum env_location env_get_default_location(void)
return ENVL_UNKNOWN;
 }
 
-static struct env_driver *env_driver_lookup_default(void)
+static struct env_driver *env_driver_lookup(void)
 {
-   enum env_location loc = env_get_default_location();
+   enum env_location loc = env_get_location();
struct env_driver *drv;
 
-   drv = env_driver_lookup(loc);
+   drv = _env_driver_lookup(loc);
if (!drv) {
debug("%s: No environment driver for location %d\n", __func__,
  loc);
@@ -69,7 +69,7 @@ static struct env_driver *env_driver_lookup_default(void)
 
 int env_get_char(int index)
 {
-   struct env_driver *drv = env_driver_lookup_default();
+   struct env_driver *drv = env_driver_lookup();
int ret;
 
if (gd->env_valid == ENV_INVALID)
@@ -89,7 +89,7 @@ int env_get_char(int index)
 
 int env_load(void)
 {
-   struct env_driver *drv = env_driver_lookup_default();
+   struct env_driver *drv = env_driver_lookup();
int ret = 0;
 
if (!drv)
@@ -108,7 +108,7 @@ int env_load(void)
 
 int env_save(void)
 {
-   struct env_driver *drv = env_driver_lookup_default();
+   struct env_driver *drv = env_driver_lookup();
int ret;
 
if (!drv)
@@ -129,7 +129,7 @@ int env_save(void)
 
 int env_init(void)
 {
-   struct env_driver *drv = env_driver_lookup_default();
+   struct env_driver *drv = env_driver_lookup();
int ret = -ENOENT;
 
if (!drv)
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 00/15] env: Multiple env support and env transition for sunxi

2018-01-23 Thread Maxime Ripard
Hi,

Here is a second attempt at transitioning away from the MMC raw environment
to a FAT-based one for Allwinner SoCs. Since the RFC was quite well
received, I actually tested it and fixed a few rough edges.

You'll find the first RFC here for reference:
https://lists.denx.de/pipermail/u-boot/2017-October/310111.html

And the second that originated in this series:
https://lists.denx.de/pipermail/u-boot/2017-November/311608.html

I gave it a travis run, and it passes all tests:
https://travis-ci.org/mripard/u-boot

Thanks!
Maxime

Original description of the patches:

The fundamental issue I'm trying to adress is that we've had for a
very long time the assumption that the main U-Boot binary wouldn't
exceed around 500 bytes.

However, we're starting to get real close to that limit, and are
running out of silver bullets to deal with the consequences of having
a bigger U-Boot binary, the main consequence being that we would
have some overlap between the environment and U-Boot.

One way to address this that has been suggested by Tom is to move away
from the raw MMC environment to a FAT-based one. This would allow us
to slowly migrate away, and eventually remove the MMC-raw option
entirely to reclaim that space for the binary.

That cannot be done in a single release however, since we might have
environments in the wild already that people rely on. And since we
always encouraged people to use the raw MMC environment, noone would
expect that.

This is even worse since some platforms are using the U-Boot
environment to deal with implement their upgrade mechanism, such as
mender.io, and force moving the environment would break any further
upgrade.

The suggested implementation is to allow U-Boot to compile multiple
environments backend at once, based on the work done by Simon. The
default behaviour shouldn't change obviously. We can then piggy-back
on this to tweak on a per-board basis the environment lookup algorithm
to always favour the FAT-based environment and then fallback to the
MMC. It will allow us to migrate a raw-MMC user to a FAT based
solution as soon as they update their environment (assuming that there
is a bootable FAT partition in the system).

This has just been compile tested on sunxi so far, and I'd like
general comments on the approach taken. Obviously, this will need to
work properly before being merged.

Changes from v2:
  - Fix a bug showing up on travis that resulted in the vexpress_ca_15 DHCP
unit test failing. This was due to an improper return of ENVL_UNKNOWN.
  - Added Simon reviewed-by tag

Changes from v1:
  - Collect tags
  - Rebased on v2018.01
  - Fixed build failures on a couple of boards
  - Added back the message and the error code when an environment is
failing
  - Added some comments about the printf in environments
  - Added a build time check about the number of our locations array to see
if we're overflowing the location variable
  - Fixed the drv->init return code being ignored
  - Added helpers to manage the init status
  - Changed the ENVO prefix for the operations to ENVOP
  - Added some comments and documentation

Changes from the RFC:
  - Added more useful messages to see where we're loading / saving
  - Init all the environments no matter what, and the deal with whatever
env we want to pick at load time
  - Added the various tags collected

Maxime Ripard (15):
  cmd: nvedit: Get rid of the env lookup
  env: Rename env_driver_lookup_default and env_get_default_location
  env: Pass additional parameters to the env lookup function
  env: Make the env save message a bit more explicit
  env: Make it explicit where we're loading our environment from
  env: fat: Make the debug messages play a little nicer
  env: mmc: Make the debug messages play a little nicer
  env: common: Make the debug messages play a little nicer
  env: Support multiple environments
  env: Initialise all the environments
  env: mmc: depends on the MMC framework
  env: Allow to build multiple environments in Kconfig
  env: Mark env_get_location as weak
  sunxi: Transition from the MMC to a FAT-based environment
  env: sunxi: Enable FAT-based environment support by default

 board/sunxi/board.c   |  16 ++-
 cmd/nvedit.c  |   4 +-
 configs/MPC8313ERDB_NAND_33_defconfig |   1 +-
 configs/MPC8313ERDB_NAND_66_defconfig |   1 +-
 configs/cl-som-imx7_defconfig |   1 +-
 configs/microblaze-generic_defconfig  |   1 +-
 env/Kconfig   |  70 
 env/common.c  |   2 +-
 env/env.c | 251 +++
 env/fat.c |  25 ++-
 env/mmc.c |   1 +-
 include/asm-generic/global_data.h |   1 +-
 include/environment.h |  15 +-
 13 files changed, 266 insertions(+), 123 deletions(-)

base-commit: f3dd87e0b98999a78e500e8c6d2b063ebadf535a
-- 
git-series 0.9.1

Re: [U-Boot] List of architectures no longer printed

2018-01-23 Thread Wolfgang Denk
Dear Nathan,

In message 

 you wrote:
> 
> "mkimage -A -h" no longer prints  architectures. Is there another way to get 
> a list of architectures?

I confirm this is a regression.  Old versions of U-=Boot used to
print a helpful list of available options (for all "type" arguments,
include -A, -O, -T, and -C):

-> mkimage -V
mkimage version 2011.03
-> mkimage -A -h

Invalid CPU Type - valid names are: alpha, arm, x86, ia64, m68k, microblaze, 
mips, mips64, nios2, powerpc, ppc, s390, sh, sparc, sparc64, blackfin, avr32
Usage: mkimage -l image
  -l ==> list image header information
   mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d 
data_file[:data_file...] image
  -A ==> set architecture to 'arch'
  -O ==> set operating system to 'os'
  -T ==> set image type to 'type'
  -C ==> set compression type 'comp'
  -a ==> set load address to 'addr' (hex)
  -e ==> set entry point to 'ep' (hex)
  -n ==> set image name to 'name'
  -d ==> use image data from 'datafile'
  -x ==> set XIP (execute in place)
   mkimage [-D dtc_options] -f fit-image.its fit-image
   mkimage -V ==> print version information and exit

Now not only the list of available, supported options is missing,
instead when asking for "-A" the unrelated and useless message:

> Use -T to see a list of available image types

is printed.

This should really be fixed.

Thanks.

Best regards,

Wolfgang Denk

-- 
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
The day-to-day travails of the IBM programmer are so amusing to  most
of us who are fortunate enough never to have been one - like watching
Charlie Chaplin trying to cook a shoe.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] List of architectures no longer printed

2018-01-23 Thread Nathan Holder
Hi,

"mkimage -A -h" no longer prints  architectures. Is there another way to get a 
list of architectures?

Reference:
http://manpages.ubuntu.com/manpages/xenial/man1/mkimage.1.html
https://linux.die.net/man/1/mkimage
"-A [architecture]
Set architecture. Pass -h as the architecture to see the list of supported 
architectures."

Using Ubuntu 16LTS, here is result:

$ mkimage -A -h
Usage: mkimage -l image
  -l ==> list image header information
   mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d 
data_file[:data_file...] image
  -A ==> set architecture to 'arch'
  -O ==> set operating system to 'os'
  -T ==> set image type to 'type'
  -C ==> set compression type 'comp'
  -a ==> set load address to 'addr' (hex)
  -e ==> set entry point to 'ep' (hex)
  -n ==> set image name to 'name'
  -d ==> use image data from 'datafile'
  -x ==> set XIP (execute in place)
   mkimage [-D dtc_options] [-f fit-image.its|-F] fit-image
  -D => set all options for device tree compiler
  -f => input filename for FIT source
Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)
   mkimage -V ==> print version information and exit
Use -T to see a list of available image types
This email and any files transmitted with it are confidential and are intended 
solely for the use of the individual or entity to whom they are addressed. If 
you are not the intended recipient or the person responsible for delivering the 
email to the intended recipient, be advised that you have received this email 
in error and that any use, dissemination, forwarding, printing or copying of 
this email is strictly prohibited. If you have received this email in error, 
please immediately notify the Network Administrator by telephone at 
336.615.8555. You will be reimbursed for reasonable costs incurred in notifying 
us.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] gpio: sunxi: Add compatible string for H5 PIO

2018-01-23 Thread Jagan Teki
On Wed, Jan 24, 2018 at 12:42 AM, Chris Blake  wrote:
> On Tue, Jan 23, 2018 at 1:09 PM, Jagan Teki  wrote:
>> On Tue, Jan 16, 2018 at 3:58 AM, Chris Blake  wrote:
>>> Due to the changes in 
>>> https://github.com/linux-sunxi/u-boot-sunxi/commit/8faac0941cd409c6ff3738fbf658de2296f48e9a,
>>>  allwinner,sun50i-h5-pinctrl needs to be defined otherwise PIO does not 
>>> work on H5 based boards.
>>
>> What is the issue observed w/o this?
>
> Without this, H5 boards that rely on CONFIG_MACPWR for Ethernet do not
> support networking in u-boot. This also breaks access to GPIOs via the
> gpio cmd.

Ok, did you verify it on opi-pc2?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] gpio: sunxi: Add compatible string for H5 PIO

2018-01-23 Thread Jagan Teki
On Tue, Jan 16, 2018 at 3:58 AM, Chris Blake  wrote:
> Due to the changes in 
> https://github.com/linux-sunxi/u-boot-sunxi/commit/8faac0941cd409c6ff3738fbf658de2296f48e9a,
>  allwinner,sun50i-h5-pinctrl needs to be defined otherwise PIO does not work 
> on H5 based boards.

What is the issue observed w/o this?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: fix to assign to corret clock value when clock is enabling

2018-01-23 Thread Stephen Warren

On 01/22/2018 10:04 PM, Jaehoon Chung wrote:

When clock is enabling, it's assigned to 0 as mmc->clock.
Then it can't initialize any card.
Fix to assign to correct clock value as mmc->cfg->f_min or f_max.


Tested-by: Stephen Warren 
Thanks!


Fixes: 9546eb92cb6 ("mmc: fix the wrong disabling clock")

Signed-off-by: Jaehoon Chung 


Nit: There's usually not a blank line between the Fixes: and 
Signed-off-by: lines.


Nit: s/corret/correct/ in the patch subject.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] cmd: Kconfig: Make CMD_NAND select NAND

2018-01-23 Thread Andrew F. Davis
On 01/23/2018 12:01 PM, Adam Ford wrote:
> On Tue, Jan 23, 2018 at 11:15 AM, Andrew F. Davis  wrote:
>> On 01/23/2018 04:40 AM, Adam Ford wrote:
>>> Many boards check for CONFIG_CMD_NAND instead of CONFIG_NAND, so
>>> let's make CMD_NAND select NAND to make some Kconfig migration
>>> easier
>>>
>>> Signed-off-by: Adam Ford 
>>>
>>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>>> index 35fe9d5..9f6b351 100644
>>> --- a/cmd/Kconfig
>>> +++ b/cmd/Kconfig
>>> @@ -764,6 +764,7 @@ config CMD_MMC
>>>  config CMD_NAND
>>>   bool "nand"
>>>   default y if NAND_SUNXI
>>> + select NAND
>>
>> Should be depends on
> 
> On the surface, I would agree with you, but many boards are looking
> for CONFIG_CMD_NAND and not looking for (or dependant on) CONFIG_NAND
> to set their NAND parameters. I was hoping to do some NAND parameter
> migration and I was going to make those parameters dependent on
> CONFIG_NAND by setting CONFIG_NAND from CMD_NAND, it makes this
> migration a lot smoother.  Otherwise, I have to go through a bunch of
> configs and enable CONFIG_NAND in each one.
> 


Well as long as it helps the migration and can/will be fixed up after, I
don't object.


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


Re: [U-Boot] [PATCH] cmd: Kconfig: Make CMD_NAND select NAND

2018-01-23 Thread Adam Ford
On Tue, Jan 23, 2018 at 11:15 AM, Andrew F. Davis  wrote:
> On 01/23/2018 04:40 AM, Adam Ford wrote:
>> Many boards check for CONFIG_CMD_NAND instead of CONFIG_NAND, so
>> let's make CMD_NAND select NAND to make some Kconfig migration
>> easier
>>
>> Signed-off-by: Adam Ford 
>>
>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>> index 35fe9d5..9f6b351 100644
>> --- a/cmd/Kconfig
>> +++ b/cmd/Kconfig
>> @@ -764,6 +764,7 @@ config CMD_MMC
>>  config CMD_NAND
>>   bool "nand"
>>   default y if NAND_SUNXI
>> + select NAND
>
> Should be depends on

On the surface, I would agree with you, but many boards are looking
for CONFIG_CMD_NAND and not looking for (or dependant on) CONFIG_NAND
to set their NAND parameters. I was hoping to do some NAND parameter
migration and I was going to make those parameters dependent on
CONFIG_NAND by setting CONFIG_NAND from CMD_NAND, it makes this
migration a lot smoother.  Otherwise, I have to go through a bunch of
configs and enable CONFIG_NAND in each one.

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


[U-Boot] [PATCH v4] arm: add support for PDU001

2018-01-23 Thread Felix Brack
This patch adds support for the PDU001 board.

Signed-off-by: Felix Brack 
---

Changes in v4:
- move remaining U-Boot specific parts from DTS to DTSI file

Changes in v3:
- revert to deprecated SPDX license identifier GPL-2.0+
- maintain alphabetical order in Kconfig files
- move U-Boot specific parts from DTS to new DTSI file to simplify
  longterm maintenance

Changes in v2:
- use DT to configure the board
- use new single-register pin controller
- use new TPS65910 PMIC driver
- eliminate the need of CONFIG_DM_I2C_COMPAT, i.e. use DM for i2c
- clarify the function of the 'Run LED'
- fix ordering of include files
- replace deprecated SPDX license identifiers

 arch/arm/Kconfig   |   1 +
 arch/arm/dts/Makefile  |   3 +-
 arch/arm/dts/am335x-pdu001-u-boot.dtsi |  39 +++
 arch/arm/dts/am335x-pdu001.dts | 595 +
 arch/arm/mach-omap2/am33xx/Kconfig |   9 +
 board/eets/pdu001/Kconfig  |  66 
 board/eets/pdu001/MAINTAINERS  |   6 +
 board/eets/pdu001/Makefile |  13 +
 board/eets/pdu001/README   |  35 ++
 board/eets/pdu001/board.c  | 276 +++
 board/eets/pdu001/board.h  |  38 +++
 board/eets/pdu001/mux.c| 120 +++
 configs/am335x_pdu001_defconfig|  55 +++
 include/configs/pdu001.h   |  87 +
 14 files changed, 1342 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/am335x-pdu001-u-boot.dtsi
 create mode 100644 arch/arm/dts/am335x-pdu001.dts
 create mode 100644 board/eets/pdu001/Kconfig
 create mode 100644 board/eets/pdu001/MAINTAINERS
 create mode 100644 board/eets/pdu001/Makefile
 create mode 100644 board/eets/pdu001/README
 create mode 100644 board/eets/pdu001/board.c
 create mode 100644 board/eets/pdu001/board.h
 create mode 100644 board/eets/pdu001/mux.c
 create mode 100644 configs/am335x_pdu001_defconfig
 create mode 100644 include/configs/pdu001.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f6d57f5..e793482 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1290,6 +1290,7 @@ 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"
 source "board/freescale/ls2080ardb/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9540ba4..02b3c36 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -161,7 +161,8 @@ dtb-$(CONFIG_AM33XX) += am335x-boneblack.dtb 
am335x-bone.dtb \
am335x-bonegreen.dtb \
am335x-icev2.dtb \
am335x-pxm50.dtb \
-   am335x-rut.dtb
+   am335x-rut.dtb \
+   am335x-pdu001.dtb
 dtb-$(CONFIG_AM43XX) += am437x-gp-evm.dtb am437x-sk-evm.dtb\
am43x-epos-evm.dtb \
am437x-idk-evm.dtb
diff --git a/arch/arm/dts/am335x-pdu001-u-boot.dtsi 
b/arch/arm/dts/am335x-pdu001-u-boot.dtsi
new file mode 100644
index 000..0dcffd5
--- /dev/null
+++ b/arch/arm/dts/am335x-pdu001-u-boot.dtsi
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 EETS GmbH - https://www.eets.ch/
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/ {
+   ocp {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+_wkup {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+_pinmux {
+   u-boot,dm-pre-reloc;
+};
+
+_pins {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+_pins {
+   u-boot,dm-pre-reloc;
+};
+
+_pins {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/am335x-pdu001.dts b/arch/arm/dts/am335x-pdu001.dts
new file mode 100644
index 000..bdf3b27
--- /dev/null
+++ b/arch/arm/dts/am335x-pdu001.dts
@@ -0,0 +1,595 @@
+/*
+ * pdu001.dts
+ *
+ * EETS GmbH PDU001 board device tree file
+ *
+ * Copyright (C) 2018 EETS GmbH - http://www.eets.ch/
+ *
+ * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:  GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "am33xx.dtsi"
+#include 
+#include 
+
+/ {
+   model = "EETS,PDU001";
+   compatible = "eets,pdu001", "ti,am33xx";
+
+   chosen {
+   stdout-path = 
+   };
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = <_reg>;
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   vbat: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vbat";
+   regulator-min-microvolt = <360>;
+   regulator-max-microvolt = <360>;
+   regulator-boot-on;
+   };
+
+   lis3_reg: fixedregulator@1 {
+   compatible = "regulator-fixed";
+   regulator-name = "lis3_reg";
+  

Re: [U-Boot] [PATCH] cmd: Kconfig: Make CMD_NAND select NAND

2018-01-23 Thread Andrew F. Davis
On 01/23/2018 04:40 AM, Adam Ford wrote:
> Many boards check for CONFIG_CMD_NAND instead of CONFIG_NAND, so
> let's make CMD_NAND select NAND to make some Kconfig migration
> easier
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 35fe9d5..9f6b351 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -764,6 +764,7 @@ config CMD_MMC
>  config CMD_NAND
>   bool "nand"
>   default y if NAND_SUNXI
> + select NAND

Should be depends on

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


Re: [U-Boot] [PATCH v2 1/2] spi: zynqmp_qspi: Add support for ZynqMP qspi driver

2018-01-23 Thread Jagan Teki
On Thu, Jan 4, 2018 at 1:07 PM, Siva Durga Prasad Paladugu
 wrote:
> This patch adds qspi driver support for ZynqMP SoC. This
> driver is responsible for communicating with qspi flash
> devices.
>
> Signed-off-by: Siva Durga Prasad Paladugu 
> ---
> Changes from v1:
> - Rebased on top of latest master
> - Moved macro definitions to .h file as per comment
> - Fixed magic values with macros as per comment
> ---
>  arch/arm/cpu/armv8/zynqmp/Kconfig  |   7 +
>  arch/arm/include/asm/arch-zynqmp/zynqmp_qspi.h | 154 ++
>  drivers/spi/Makefile   |   1 +
>  drivers/spi/zynqmp_qspi.c  | 678 
> +

Was this gqspi like linux spi-zynqmp-gqspi.c or different?

>  4 files changed, 840 insertions(+)
>  create mode 100644 arch/arm/include/asm/arch-zynqmp/zynqmp_qspi.h
>  create mode 100644 drivers/spi/zynqmp_qspi.c
>
> diff --git a/arch/arm/cpu/armv8/zynqmp/Kconfig 
> b/arch/arm/cpu/armv8/zynqmp/Kconfig
> index 3f922b4..2fe4f71 100644
> --- a/arch/arm/cpu/armv8/zynqmp/Kconfig
> +++ b/arch/arm/cpu/armv8/zynqmp/Kconfig
> @@ -65,6 +65,13 @@ config PMUFW_INIT_FILE
>   Include external PMUFW (Platform Management Unit FirmWare) to
>   a Xilinx bootable image (boot.bin).
>
> +config ZYNQMP_QSPI
> +   bool "Configure ZynqMP QSPI"
> +   select DM_SPI
> +   help
> + This option is used to enable ZynqMP QSPI controller driver which
> + is used to communicate with qspi flash devices.

I've commented this before, what is the reason for adding spi kconfig
entry in arch area instead of drivers/spi?

> +
>  config ZYNQMP_USB
> bool "Configure ZynqMP USB"
>
> diff --git a/arch/arm/include/asm/arch-zynqmp/zynqmp_qspi.h 
> b/arch/arm/include/asm/arch-zynqmp/zynqmp_qspi.h
> new file mode 100644
> index 000..5e2926e
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-zynqmp/zynqmp_qspi.h
> @@ -0,0 +1,154 @@
> +/*
> + * (C) Copyright 2014 - 2015 Xilinx
> + *
> + * Xilinx ZynqMP Quad-SPI(QSPI) controller driver (master mode only)
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#ifndef _ASM_ARCH_ZYNQMP_QSPI_H_
> +#define _ASM_ARCH_ZYNQMP_QSPI_H_
> +
> +#define ZYNQMP_QSPI_GFIFO_STRT_MODE_MASK   BIT(29)
> +#define ZYNQMP_QSPI_CONFIG_MODE_EN_MASK(3 << 30)
> +#define ZYNQMP_QSPI_CONFIG_DMA_MODE(2 << 30)
> +#define ZYNQMP_QSPI_CONFIG_CPHA_MASK   BIT(2)
> +#define ZYNQMP_QSPI_CONFIG_CPOL_MASK   BIT(1)
> +
> +/* QSPI MIO's count for different connection topologies */
> +#define ZYNQMP_QSPI_MIO_NUM_QSPI0  6
> +#define ZYNQMP_QSPI_MIO_NUM_QSPI1  5
> +#define ZYNQMP_QSPI_MIO_NUM_QSPI1_CS   1
> +
> +/*
> + * QSPI Interrupt Registers bit Masks
> + *
> + * All the four interrupt registers (Status/Mask/Enable/Disable) have the 
> same
> + * bit definitions.
> + */
> +#define ZYNQMP_QSPI_IXR_TXNFULL_MASK   0x0004 /* QSPI TX FIFO Overflow */
> +#define ZYNQMP_QSPI_IXR_TXFULL_MASK0x0008 /* QSPI TX FIFO is full */
> +#define ZYNQMP_QSPI_IXR_RXNEMTY_MASK   0x0010 /* QSPI RX FIFO Not Empty 
> */
> +#define ZYNQMP_QSPI_IXR_GFEMTY_MASK0x0080 /* QSPI Generic FIFO Empty 
> */
> +#define ZYNQMP_QSPI_IXR_ALL_MASK   (ZYNQMP_QSPI_IXR_TXNFULL_MASK | \
> +   ZYNQMP_QSPI_IXR_RXNEMTY_MASK)
> +
> +/*
> + * QSPI Enable Register bit Masks
> + *
> + * This register is used to enable or disable the QSPI controller
> + */
> +#define ZYNQMP_QSPI_ENABLE_ENABLE_MASK 0x0001 /* QSPI Enable Bit Mask */
> +
> +#define ZYNQMP_QSPI_GFIFO_LOW_BUS  BIT(14)
> +#define ZYNQMP_QSPI_GFIFO_CS_LOWER BIT(12)
> +#define ZYNQMP_QSPI_GFIFO_UP_BUS   BIT(15)
> +#define ZYNQMP_QSPI_GFIFO_CS_UPPER BIT(13)
> +#define ZYNQMP_QSPI_SPI_MODE_QSPI  (3 << 10)
> +#define ZYNQMP_QSPI_SPI_MODE_SPI   BIT(10)
> +#define ZYNQMP_QSPI_SPI_MODE_DUAL_SPI  (2 << 10)
> +#define ZYNQMP_QSPI_IMD_DATA_CS_ASSERT 5
> +#define ZYNQMP_QSPI_IMD_DATA_CS_DEASSERT   5
> +#define ZYNQMP_QSPI_GFIFO_TX   BIT(16)
> +#define ZYNQMP_QSPI_GFIFO_RX   BIT(17)
> +#define ZYNQMP_QSPI_GFIFO_STRIPE_MASK  BIT(18)
> +#define ZYNQMP_QSPI_GFIFO_IMD_MASK 0xFF
> +#define ZYNQMP_QSPI_GFIFO_EXP_MASK BIT(9)
> +#define ZYNQMP_QSPI_GFIFO_DATA_XFR_MASKBIT(8)
> +#define ZYNQMP_QSPI_STRT_GEN_FIFO  BIT(28)
> +#define ZYNQMP_QSPI_GEN_FIFO_STRT_MOD  BIT(29)
> +#define ZYNQMP_QSPI_GFIFO_WP_HOLD  BIT(19)
> +#define ZYNQMP_QSPI_BAUD_DIV_MASK  (7 << 3)
> +#define ZYNQMP_QSPI_DFLT_BAUD_RATE_DIV BIT(3)
> +#define ZYNQMP_QSPI_GFIFO_ALL_INT_MASK 0xFBE
> +#define ZYNQMP_QSPI_DMA_DST_I_STS_DONE BIT(1)
> +#define ZYNQMP_QSPI_DMA_DST_I_STS_MASK 0xFE
> +#define MODEBITS   0x6
> +
> +#define QUAD_OUT_READ_CMD  0x6B
> +#define QUAD_PAGE_PROGRAM_CMD  0x32
> +#define DUAL_OUTPUT_FASTRD_CMD 0x3B
> +
> +#define 

[U-Boot] [PATCH v3 2/2] mmc: Add bcm2835 sdhost controller

2018-01-23 Thread Alexander Graf
The BCM2835 family of SoCs has 2 different SD controllers: One based on
the SDHCI spec and a custom, home-grown one.

This patch implements a driver for the latter based on the Linux driver.
This is needed so that we can make use of device trees that assume driver
presence of both SD controllers.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Remove hand written pinctrl support
  - Checkpatch fixes

v2 -> v3:

  - Use SPDX license identifier
  - Sort headers
  - Remove useless comments
  - Comment style fixes
  - Add magic constant defines (SDHSTS_CLEAR_MASK, SDEDM_FIFO_FILL*,
edm_fifo_fill, SDHST_TIMEOUT_MAX_USEC)
  - Add comments in bcm2835_reset_internal()
  - Replace "r" with "ret"
  - Remove one useless while() indirection in bcm2835_transfer_block_pio()
  - Add comments what each loop does in bcm2835_transfer_block_pio()
  - Remove max_ms parameter in bcm2835_read_wait_sdcmd()
  - Only read once with full timeout in bcm2835_read_wait_sdcmd()
  - Check unsupported response type early in bcm2835_send_command()
  - Return -EBUSY on incomplete command in bcm2835_send_command()
  - Combine SDHSTS_REW_TIME_OUT and SDHSTS_CMD_TIME_OUT cases in
bcm2835_check_cmd_error()
  - Unfold irq_* check/set in bcm2835_threaded_irq()
  - Declare bcm2835_add_host() as void
---
 MAINTAINERS  |   1 +
 drivers/mmc/Kconfig  |  14 +
 drivers/mmc/Makefile |   1 +
 drivers/mmc/bcm2835_sdhost.c | 979 +++
 4 files changed, 995 insertions(+)
 create mode 100644 drivers/mmc/bcm2835_sdhost.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 1f2545191b..728d38aebf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -97,6 +97,7 @@ S:Orphaned (Since 2017-07)
 F: arch/arm/mach-bcm283x/
 F: drivers/gpio/bcm2835_gpio.c
 F: drivers/mmc/bcm2835_sdhci.c
+F: drivers/mmc/bcm2835_sdhost.c
 F: drivers/serial/serial_bcm283x_mu.c
 F: drivers/video/bcm2835.c
 F: include/dm/platform_data/serial_bcm283x_mu.h
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index ab0627a8af..9b90db908b 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -256,6 +256,20 @@ config MMC_UNIPHIER
  This selects support for the Matsushita SD/MMC Host Controller on
  SocioNext UniPhier and Renesas RCar SoCs.
 
+config MMC_BCM2835
+   bool "BCM2835 family custom SD/MMC Host Controller support"
+   depends on ARCH_BCM283X
+   depends on BLK && DM_MMC
+   depends on OF_CONTROL
+   default y
+   help
+ This selects support for the custom SD host controller in the BCM2835
+ family of devices.
+
+ If you have a BCM2835 platform with SD or MMC devices, say Y here.
+
+ If unsure, say N.
+
 config MMC_SANDBOX
bool "Sandbox MMC support"
depends on SANDBOX
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 64b6f21c61..42113e2603 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -64,3 +64,4 @@ obj-$(CONFIG_MMC_SDHCI_ZYNQ)  += zynq_sdhci.o
 
 obj-$(CONFIG_MMC_SUNXI)+= sunxi_mmc.o
 obj-$(CONFIG_MMC_UNIPHIER) += uniphier-sd.o
+obj-$(CONFIG_MMC_BCM2835)  += bcm2835_sdhost.o
diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c
new file mode 100644
index 00..1bf52a3019
--- /dev/null
+++ b/drivers/mmc/bcm2835_sdhost.c
@@ -0,0 +1,979 @@
+/*
+ * bcm2835 sdhost driver.
+ *
+ * The 2835 has two SD controllers: The Arasan sdhci controller
+ * (supported by the iproc driver) and a custom sdhost controller
+ * (supported by this driver).
+ *
+ * The sdhci controller supports both sdcard and sdio.  The sdhost
+ * controller supports the sdcard only, but has better performance.
+ * Also note that the rpi3 has sdio wifi, so driving the sdcard with
+ * the sdhost controller allows to use the sdhci controller for wifi
+ * support.
+ *
+ * The configuration is done by devicetree via pin muxing.  Both
+ * SD controller are available on the same pins (2 pin groups = pin 22
+ * to 27 + pin 48 to 53).  So it's possible to use both SD controllers
+ * at the same time with different pin groups.
+ *
+ * This code was ported to U-Boot by
+ *  Alexander Graf 
+ * and is based on drivers/mmc/host/bcm2835.c in Linux which is written by
+ *  Phil Elwell 
+ *  Copyright (C) 2015-2016 Raspberry Pi (Trading) Ltd.
+ * which is based on
+ *  mmc-bcm2835.c by Gellert Weisz
+ * which is, in turn, based on
+ *  sdhci-bcm2708.c by Broadcom
+ *  sdhci-bcm2835.c by Stephen Warren and Oleksandr Tymoshenko
+ *  sdhci.c and sdhci-pci.c by Pierre Ossman
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define msleep(a) udelay(a * 1000)
+
+#define SDCMD  0x00 /* Command to SD 

[U-Boot] [PATCH v3 1/2] bcm283x: Add pinctrl driver

2018-01-23 Thread Alexander Graf
The bcm283x family of SoCs have a GPIO controller that also acts as
pinctrl controller.

This patch introduces a new pinctrl driver that can actually properly mux
devices into their device tree defined pin states and is now the primary
owner of the gpio device. The previous GPIO driver gets moved into a
subdevice of the pinctrl driver, bound to the same OF node.

That way whenever a device asks for pinctrl support, it gets it
automatically from the pinctrl driver and GPIO support is still available
in the normal command line phase.

Signed-off-by: Alexander Graf 

---

v2 -> v3:

  - use dev_read
  - add comment on why GPIO failure is non-fatal
---
 MAINTAINERS|   1 +
 arch/arm/mach-bcm283x/include/mach/gpio.h  |   2 -
 board/raspberrypi/rpi/rpi.c|   5 +-
 configs/rpi_0_w_defconfig  |   4 +
 configs/rpi_2_defconfig|   4 +
 configs/rpi_3_32b_defconfig|   4 +
 configs/rpi_3_defconfig|   4 +
 configs/rpi_defconfig  |   4 +
 drivers/gpio/bcm2835_gpio.c|  29 ++
 drivers/pinctrl/Kconfig|   1 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/broadcom/Kconfig   |   7 ++
 drivers/pinctrl/broadcom/Makefile  |   7 ++
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 152 +
 14 files changed, 202 insertions(+), 23 deletions(-)
 create mode 100644 drivers/pinctrl/broadcom/Kconfig
 create mode 100644 drivers/pinctrl/broadcom/Makefile
 create mode 100644 drivers/pinctrl/broadcom/pinctrl-bcm283x.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 754db5553d..1f2545191b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -100,6 +100,7 @@ F:  drivers/mmc/bcm2835_sdhci.c
 F: drivers/serial/serial_bcm283x_mu.c
 F: drivers/video/bcm2835.c
 F: include/dm/platform_data/serial_bcm283x_mu.h
+F: drivers/pinctrl/broadcom/
 
 ARM FREESCALE IMX
 M: Stefano Babic 
diff --git a/arch/arm/mach-bcm283x/include/mach/gpio.h 
b/arch/arm/mach-bcm283x/include/mach/gpio.h
index daaee52f81..7b4ddc9246 100644
--- a/arch/arm/mach-bcm283x/include/mach/gpio.h
+++ b/arch/arm/mach-bcm283x/include/mach/gpio.h
@@ -61,6 +61,4 @@ struct bcm2835_gpio_platdata {
unsigned long base;
 };
 
-int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio);
-
 #endif /* _BCM2835_GPIO_H_ */
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 3b7a54f519..c8924d4362 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -24,6 +24,7 @@
 #include 
 #endif
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -430,10 +431,10 @@ static bool rpi_is_serial_active(void)
 * out whether it is available is to check if the RX pin is muxed.
 */
 
-   if (uclass_first_device(UCLASS_GPIO, ) || !dev)
+   if (uclass_first_device(UCLASS_PINCTRL, ) || !dev)
return true;
 
-   if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5)
+   if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT5)
return false;
 
return true;
diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig
index 12482944af..8ed7a58659 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -32,3 +32,7 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_FULL=y
+# CONFIG_PINCTRL_GENERIC is not set
+CONFIG_PINCTRL_BCM283X=y
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index c45ffb65af..b30e6e144c 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -32,3 +32,7 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_FULL=y
+# CONFIG_PINCTRL_GENERIC is not set
+CONFIG_PINCTRL_BCM283X=y
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
index f7aed35797..bb40644064 100644
--- a/configs/rpi_3_32b_defconfig
+++ b/configs/rpi_3_32b_defconfig
@@ -34,3 +34,7 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_FULL=y
+# CONFIG_PINCTRL_GENERIC is not set
+CONFIG_PINCTRL_BCM283X=y
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
index 9416e3b8fe..8306bc251d 100644
--- a/configs/rpi_3_defconfig
+++ b/configs/rpi_3_defconfig
@@ -34,3 +34,7 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_FULL=y
+# CONFIG_PINCTRL_GENERIC is not set
+CONFIG_PINCTRL_BCM283X=y
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
index 3bfa745c2e..a7a079ddab 100644
--- a/configs/rpi_defconfig
+++ b/configs/rpi_defconfig
@@ -32,3 +32,7 @@ 

[U-Boot] [PATCH v3 0/2] Rpi: Add support for second sd host controller

2018-01-23 Thread Alexander Graf
The Raspberry Pi (bcm283x SoC) family contains 2 IP blocks to drive SD
peripherals: A pretty standard SDHCI one called iProc and a home grown
one called "sdhost".

When driving U-Boot by the same device tree that we use for Linux, we
end up in situations where only the "sdhost" device is available for use.
In those situations, current U-Boot can simply not drive the SD card,
because the device tree disables the SDHCI device.

This patch set also adds a full pinctrl driver for pinmuxing the SD
devices properly to their respective pins. This is necessary because
the RPi firmware doesn't mux the SD pins according to the device tree
but instead expects the payload (usually Linux, U-Boot for us) to do that.

With this patch set, I can successfully use U-Boot on a RPi3 Compute
Module with CONFIG_OF_BOARD=y and a device tree generated by the RPi
firmware (plus a few overlays in config.txt for vc4, serial, etc).

v1 -> v2:

  - Introduce real pinctrl driver
  - Checkpatch fixes
  - Remove hand written pinctrl support

v2 -> v3:

  - Use SPDX license identifier
  - Sort headers
  - Remove useless comments
  - Comment style fixes
  - Add magic constant defines (SDHSTS_CLEAR_MASK, SDEDM_FIFO_FILL*,
edm_fifo_fill, SDHST_TIMEOUT_MAX_USEC)
  - Add comments in bcm2835_reset_internal()
  - Replace "r" with "ret"
  - Remove one useless while() indirection in bcm2835_transfer_block_pio()
  - Add comments what each loop does in bcm2835_transfer_block_pio()
  - Remove max_ms parameter in bcm2835_read_wait_sdcmd()
  - Only read once with full timeout in bcm2835_read_wait_sdcmd()
  - Check unsupported response type early in bcm2835_send_command()
  - Return -EBUSY on incomplete command in bcm2835_send_command()
  - Combine SDHSTS_REW_TIME_OUT and SDHSTS_CMD_TIME_OUT cases in
bcm2835_check_cmd_error()
  - Unfold irq_* check/set in bcm2835_threaded_irq()
  - Declare bcm2835_add_host() as void
  - use dev_read
  - add comment on why GPIO failure is non-fatal

Alexander Graf (2):
  bcm283x: Add pinctrl driver
  mmc: Add bcm2835 sdhost controller

 MAINTAINERS|   2 +
 arch/arm/mach-bcm283x/include/mach/gpio.h  |   2 -
 board/raspberrypi/rpi/rpi.c|   5 +-
 configs/rpi_0_w_defconfig  |   4 +
 configs/rpi_2_defconfig|   4 +
 configs/rpi_3_32b_defconfig|   4 +
 configs/rpi_3_defconfig|   4 +
 configs/rpi_defconfig  |   4 +
 drivers/gpio/bcm2835_gpio.c|  29 +-
 drivers/mmc/Kconfig|  14 +
 drivers/mmc/Makefile   |   1 +
 drivers/mmc/bcm2835_sdhost.c   | 979 +
 drivers/pinctrl/Kconfig|   1 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/broadcom/Kconfig   |   7 +
 drivers/pinctrl/broadcom/Makefile  |   7 +
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 152 +
 17 files changed, 1197 insertions(+), 23 deletions(-)
 create mode 100644 drivers/mmc/bcm2835_sdhost.c
 create mode 100644 drivers/pinctrl/broadcom/Kconfig
 create mode 100644 drivers/pinctrl/broadcom/Makefile
 create mode 100644 drivers/pinctrl/broadcom/pinctrl-bcm283x.c

-- 
2.12.3

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


  1   2   >