Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread Simon Goldschmidt


Pepperl+Fuchs GmbH, Mannheim
Geschaeftsfuehrer/Managing Directors: Dr.-Ing. Gunther Kegel (Vors./CEO), 
Werner Guthier, Mehmet Hatiboglu
Vorsitzender des Aufsichtsrats/Chairman of the supervisory board: Claus Michael
Registergericht/Register Court: AG Mannheim HRB 4713
On 18.01.2018 06:07, Jason Rush wrote:

On 1/17/2018 7:46 AM, RB23 wrote:

i checked, and if you mean these patches:
https://patchwork.ozlabs.org/patch/765992/
https://patchwork.ozlabs.org/patch/765996/
https://patchwork.ozlabs.org/patch/765997/
https://patchwork.ozlabs.org/patch/765998/

i already applied them, and they didn't work as well.

i also found these patches which i didn't try yet:
https://lists.denx.de/pipermail/u-boot/2017-May/292230.html

should i try those instead?

2018-01-17 15:09 GMT+02:00 Marek Vasut :


On 01/17/2018 02:06 PM, Simon Goldschmidt wrote:

On 17.01.2018 14:01, RB23 wrote:

hey, i downloaded the september and november versions and i applied
the patches on both of them, re-compiled the u boot,
and still, it gives me the same error when trying the command "sf probe"
i'm not sure what to do, is it possible that i missed something? like
a define or something in the make menuconfig?
i did some debugging and it seems that the crash happens on this line:
div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
thanks.


I don't know exactly which patches you are talking about, but the
divide-by-zero problem is still present with all patches I applied. To
fix it, you need to set up your device tree correctly so that the speed
is initialized.

If I remember correctly, you need need to have a flash chip below the
qspi in the device tree. Check Jason's changes to the various socfpga
dts files.


Er, maybe a patch which checks this condition wouldn't hurt ?

--
Best regards,
Marek Vasut


I re-tested on a Cyclone V SoCKit devboard and a custom Arria V board using the 
DTS
patches I submitted (the 4 you mentioned above) and Vignesh's patch to fix the 
cache
invalidation problem, and I don't get the divide-by-zero problem.  This looks 
like the
clock rate for the flash part isn't getting set and is defaulting to 0 for some 
reason.
I would look at your device tree.  Are you using a stock device tree, or is 
this a custom
board? Make sure the 'spi-max-frequency' is being set for the flash part that 
is a child
to the cadence qspi node in the device tree.


Note that in addition to the 'spi-max-frequency' property, the flash 
part (child of the cadence qspi node) also must have 'compatible = 
"spi-flash";'.


This only seems to fail in U-Boot when loading the environment or 
executing 'sf probe' without speed argument. SPL succeeds to load U-Boot 
from qspi without a 'spi-max-frequency' because the cadence qspi driver 
has a fallback to 500 kHz which gets overridden by the code from U-Boot.


Regards,
Simon


Wichtiger Hinweis:
Diese E-Mail einschliesslich ihrer Anhaenge enthaelt vertrauliche und rechtlich geschuetzte Informationen, die nur fuer den Adressaten bestimmt sind. 
Sollten Sie nicht der bezeichnete Adressat sein, so teilen Sie dies bitte dem Absender umgehend mit und loeschen Sie diese Nachricht und ihre Anhaenge. Die unbefugte Weitergabe, das Anfertigen von Kopien und jede Veraenderung der E-Mail ist untersagt. Der Absender haftet nicht fuer Inhalte von veraenderten E-Mails.



Important Information:
This e-mail message including its attachments contains confidential and legally 
protected information solely intended for the addressee. If you are not the 
intended addressee of this message, please contact the addresser immediately 
and delete this message including its attachments. The unauthorized 
dissemination, copying and change of this e-mail are strictly forbidden. The 
addresser shall not be liable for the content of such changed e-mails.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()

2018-01-17 Thread Patrice CHOTARD
Hi Vikas

On 01/17/2018 08:55 PM, Vikas Manocha wrote:
> Hi Patrice,
> 
> On 01/17/2018 12:46 AM, patrice.chot...@st.com wrote:
>> From: Patrice Chotard 
>>
>> Move SYSCFG clock setup into configure_clocks() instead of calling
>> clock_setup() from drivers.
> 
> It is in board configuration.

Yes, my comment is badly formulated.

The idea is to remove clock_setup() from clock driver.

> 
>> Move the RMII setup from board_early_init_f() to board_init()
>> to insure that RMII bit is set only when clock driver is initialized.
>>
>> Signed-off-by: Patrice Chotard 
>> ---
>>   arch/arm/include/asm/arch-stm32f7/stm32_periph.h |  1 -
>>   board/st/stm32f746-disco/stm32f746-disco.c   | 19 ++-
>>   drivers/clk/clk_stm32f.c | 10 --
>>   3 files changed, 10 insertions(+), 20 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h 
>> b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
>> index 13f9c9b..7b8f66a 100644
>> --- a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
>> +++ b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
>> @@ -21,7 +21,6 @@ enum periph_id {
>>   };
>>   
>>   enum periph_clock {
>> -SYSCFG_CLOCK_CFG,
>>  TIMER2_CLOCK_CFG,
>>   };
>>   
>> diff --git a/board/st/stm32f746-disco/stm32f746-disco.c 
>> b/board/st/stm32f746-disco/stm32f746-disco.c
>> index 58a5ef0..8da7028 100644
>> --- a/board/st/stm32f746-disco/stm32f746-disco.c
>> +++ b/board/st/stm32f746-disco/stm32f746-disco.c
>> @@ -69,23 +69,10 @@ int dram_init_banksize(void)
>>  return 0;
>>   }
>>   
>> -#ifdef CONFIG_ETH_DESIGNWARE
>> -static int stmmac_setup(void)
>> -{
>> -clock_setup(SYSCFG_CLOCK_CFG);
>> -/* Set >RMII mode */
>> -STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
>> -
>> -return 0;
>> -}
>> -
>>   int board_early_init_f(void)
>>   {
>> -stmmac_setup();
>> -
>>  return 0;
>>   }
>> -#endif
>>   
>>   #ifdef CONFIG_SPL_BUILD
>>   #ifdef CONFIG_SPL_OS_BOOT
>> @@ -162,5 +149,11 @@ int board_late_init(void)
>>   int board_init(void)
>>   {
>>  gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
>> +
>> +#ifdef CONFIG_ETH_DESIGNWARE
>> +/* Set >RMII mode */
>> +STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
>> +#endif
>> +
>>  return 0;
>>   }
>> diff --git a/drivers/clk/clk_stm32f.c b/drivers/clk/clk_stm32f.c
>> index d0c7a90..1ae5b70 100644
>> --- a/drivers/clk/clk_stm32f.c
>> +++ b/drivers/clk/clk_stm32f.c
>> @@ -67,8 +67,6 @@
>>   #define RCC_DCKCFGRX_SDMMC1SEL BIT(28)
>>   #define RCC_DCKCFGR2_SDMMC2SEL BIT(29)
>>   
>> -#define RCC_APB2ENR_SAI1EN  BIT(22)
>> -
>>   /*
>>* RCC AHB1ENR specific definitions
>>*/
>> @@ -86,9 +84,9 @@
>>* RCC APB2ENR specific definitions
>>*/
>>   #define RCC_APB2ENR_SYSCFGEN   BIT(14)
>> +#define RCC_APB2ENR_SAI1EN  BIT(22)
>>   
>>   enum periph_clock {
>> -SYSCFG_CLOCK_CFG,
>>  TIMER2_CLOCK_CFG,
>>   };
>>   
>> @@ -227,6 +225,9 @@ static int configure_clocks(struct udevice *dev)
>>  /* gate the SAI clock, needed for MMC 1&2 clocks */
>>  setbits_le32(>apb2enr, RCC_APB2ENR_SAI1EN);
>>   
>> +/* gate the SYSCFG clock, needed to set RMII ethernet interface */
> 
> RMII interface only required for f746 disco board.
> 
>> +setbits_le32(>apb2enr, RCC_APB2ENR_SYSCFGEN);
> 
> RMII & Syscfg is board specific requirement, here it will configure it for 
> all stm32f devices.

You are right, i will update this. As it is currently only needed for 
ethernet, i will add the CONFIG_ETH_DESIGNWARE flag around.

For information, i will add new stm32f429-evaluation board (already 
supported in kernel) which provide ethernet connection.

Thanks for reviewing

Patrice

> 
> Cheers,
> Vikas
> 
>> +
>>  return 0;
>>   }
>>   
>> @@ -352,9 +353,6 @@ static int stm32_clk_enable(struct clk *clk)
>>   void clock_setup(int peripheral)
>>   {
>>  switch (peripheral) {
>> -case SYSCFG_CLOCK_CFG:
>> -setbits_le32(_RCC->apb2enr, RCC_APB2ENR_SYSCFGEN);
>> -break;
>>  case TIMER2_CLOCK_CFG:
>>  setbits_le32(_RCC->apb1enr, RCC_APB1ENR_TIM2EN);
>>  break;
>>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] efi_selftest: test start image

2018-01-17 Thread Heinrich Schuchardt
This test checks the StartImage boot service.
An EFI application is loaded into memory and started.

The test is not built on x86_64 because the relocation code for the efi
binary cannot be created.

Signed-off-by: Heinrich Schuchardt 
---
v2
Do not build test on x86_64.
---
 arch/arm/lib/Makefile   |   1 +
 lib/efi_selftest/.gitignore |   2 +
 lib/efi_selftest/Makefile   |  26 +
 lib/efi_selftest/efi_selftest_miniapp.c |  34 +++
 lib/efi_selftest/efi_selftest_start_image.c | 144 
 5 files changed, 207 insertions(+)
 create mode 100644 lib/efi_selftest/.gitignore
 create mode 100644 lib/efi_selftest/efi_selftest_miniapp.c
 create mode 100644 lib/efi_selftest/efi_selftest_start_image.c

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index abffa10c85..876024fc15 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -112,4 +112,5 @@ CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI)
 CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI)
 
 extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC)
+extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC)
 extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)
diff --git a/lib/efi_selftest/.gitignore b/lib/efi_selftest/.gitignore
new file mode 100644
index 00..c527e464e5
--- /dev/null
+++ b/lib/efi_selftest/.gitignore
@@ -0,0 +1,2 @@
+efi_miniapp_file_image.h
+*.efi
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 20f614d6ba..d7a9865a02 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -7,6 +7,9 @@
 # This file only gets included with CONFIG_EFI_LOADER set, so all
 # object inclusion implicitly depends on it
 
+CFLAGS_efi_selftest_miniapp.o := $(CFLAGS_EFI) -Os -ffreestanding
+CFLAGS_REMOVE_efi_selftest_miniapp.o := $(CFLAGS_NON_EFI) -Os
+
 obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += \
 efi_selftest.o \
 efi_selftest_controllers.o \
@@ -25,3 +28,26 @@ efi_selftest_watchdog.o
 ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
 obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += efi_selftest_block_device.o
 endif
+
+# TODO: As of v2018.01 the relocation code for the EFI application cannot
+# be built on x86_64.
+ifeq ($(CONFIG_X86_64),)
+
+ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),)
+
+obj-y += \
+efi_selftest_start_image.o
+
+targets += \
+efi_miniapp_file_image.h \
+efi_selftest_miniapp.efi
+
+$(obj)/efi_miniapp_file_image.h: $(obj)/efi_selftest_miniapp.efi
+   $(obj)/../../tools/file2include $(obj)/efi_selftest_miniapp.efi > \
+   $(obj)/efi_miniapp_file_image.h
+
+$(obj)/efi_selftest_start_image.o: $(obj)/efi_miniapp_file_image.h
+
+endif
+
+endif
diff --git a/lib/efi_selftest/efi_selftest_miniapp.c 
b/lib/efi_selftest/efi_selftest_miniapp.c
new file mode 100644
index 00..bcdb37e86b
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_miniapp.c
@@ -0,0 +1,34 @@
+/*
+ * efi_selftest_miniapp
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This EFI application is run by the StartImage selftest.
+ */
+
+#include 
+#include 
+
+/*
+ * Entry point of the EFI application.
+ *
+ * @handle handle of the loaded image
+ * @systable   system table
+ * @return status code
+ */
+efi_status_t EFIAPI efi_main(efi_handle_t handle,
+struct efi_system_table *systable)
+{
+   struct efi_simple_text_output_protocol *con_out = systable->con_out;
+
+   con_out->set_attribute(con_out, EFI_BACKGROUND_BROWN | EFI_WHITE);
+   con_out->output_string(con_out, L"Entering EFI application");
+   con_out->set_attribute(con_out, EFI_LIGHTGRAY);
+   con_out->output_string(con_out, L"\n");
+
+   systable->boottime->exit(handle, EFI_SUCCESS, 0, NULL);
+
+   return EFI_SUCCESS;
+}
diff --git a/lib/efi_selftest/efi_selftest_start_image.c 
b/lib/efi_selftest/efi_selftest_start_image.c
new file mode 100644
index 00..02f8ccf9c5
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_start_image.c
@@ -0,0 +1,144 @@
+/*
+ * efi_selftest_start_image
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This test checks the StartImage boot service.
+ * The efi_selftest_miniapp.efi application is loaded into memory and started.
+ */
+
+#include 
+/* Include containing the miniapp.efi application */
+#include "efi_miniapp_file_image.h"
+
+/* Block size of compressed disk image */
+#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8
+
+/* Binary logarithm of the block size */
+#define LB_BLOCK_SIZE 9
+
+static efi_handle_t image_handle;
+static struct efi_boot_services *boottime;
+
+/* One 8 byte block of the compressed disk image */
+struct line {
+   size_t addr;
+   char *line;
+};
+
+/* Compressed file image */
+struct compressed_file_image {
+   size_t length;
+   struct line lines[];
+};
+
+static struct compressed_file_image img = 

[U-Boot] [PATCH v2 1/2] efi_loader: correctly call images

2018-01-17 Thread Heinrich Schuchardt
Avoid a failed assertion when an EFI app calls an EFI app.

Avoid that the indent level increases when calling 'bootefi hello'
repeatedly.

Avoid negative indent level when an EFI app calls an EFI app that
calls an EFI app (e.g. iPXE loads grub which starts the kernel).

Return the status code of a loaded image that returns without
calling the Exit boot service.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_boottime.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 2c5499e0c8..538cc55d20 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1537,6 +1537,7 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t 
image_handle,
asmlinkage ulong (*entry)(efi_handle_t image_handle,
  struct efi_system_table *st);
struct efi_loaded_image *info = image_handle;
+   efi_status_t ret;
 
EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
entry = info->reserved;
@@ -1546,17 +1547,23 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t 
image_handle,
/* call the image! */
if (setjmp(>exit_jmp)) {
/* We returned from the child image */
+#ifdef CONFIG_ARM
+   /* efi_exit() called efi_restore_gd() */
+   gd = app_gd;
+#endif
+   /* Execute the return part of EFI_CALL */
+   assert(__efi_entry_check());
+   debug("%sEFI: %lu returned by started image\n",
+ __efi_nesting_dec(),
+ (unsigned long)((uintptr_t)info->exit_status &
+ ~EFI_ERROR_MASK));
return EFI_EXIT(info->exit_status);
}
 
-   __efi_nesting_dec();
-   __efi_exit_check();
-   entry(image_handle, );
-   __efi_entry_check();
-   __efi_nesting_inc();
+   ret = EFI_CALL(entry(image_handle, ));
 
/* Should usually never get here */
-   return EFI_EXIT(EFI_SUCCESS);
+   return EFI_EXIT(ret);
 }
 
 /*
@@ -1593,7 +1600,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t 
image_handle,
  exit_data_size, exit_data);
 
/* Make sure entry/exit counts for EFI world cross-overs match */
-   __efi_exit_check();
+   EFI_EXIT(exit_status);
 
/*
 * But longjmp out with the U-Boot gd, not the application's, as
-- 
2.14.2

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


[U-Boot] [PATCH v2 0/2] efi_loader: correctly call images

2018-01-17 Thread Heinrich Schuchardt
This patch series fixes various problems with the StartImage boot
service. It further provides a unit test.

v2
Do not build test on x68_64 due to a problem with the build
system for EFI images.

Heinrich Schuchardt (2):
  efi_loader: correctly call images
  efi_selftest: test start image

 arch/arm/lib/Makefile   |   1 +
 lib/efi_loader/efi_boottime.c   |  21 ++--
 lib/efi_selftest/.gitignore |   2 +
 lib/efi_selftest/Makefile   |  26 +
 lib/efi_selftest/efi_selftest_miniapp.c |  34 +++
 lib/efi_selftest/efi_selftest_start_image.c | 144 
 6 files changed, 221 insertions(+), 7 deletions(-)
 create mode 100644 lib/efi_selftest/.gitignore
 create mode 100644 lib/efi_selftest/efi_selftest_miniapp.c
 create mode 100644 lib/efi_selftest/efi_selftest_start_image.c

-- 
2.14.2

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


Re: [U-Boot] X86 Broadwell-DE override FSP configuration

2018-01-17 Thread Bin Meng
Hi Vincenzo,

On Thu, Jan 18, 2018 at 4:45 AM, vnktux  wrote:
> Thank you Bin,
>
> I managed to fully boot Broadwell-DE on platform with memory down enabled :)
>
> Now before submitting the patch I have to solve a small problem.
> In either case memory down is enable or not the booting process takes 1 hour
> and 20 minutes. On the output there are no error at all. I tried to
> enable/disable fastboot and  MRC but this didn't solve the problem.
>

1 hour and 20 minutes seems too long.

Is this Intel CamelbackMountain CRB or your custom board?

Please avoid top-posting next time. Thanks!

Regards,
Bin
___
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-17 Thread Simon Goldschmidt

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





+#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD)
+static int init_mmc(void)
+{
+   /* Just for the case MMC is not yet initialized */
+   struct mmc *mmc = NULL;
+   int err;
+
+   spl_mmc_find_device(, spl_boot_device());
+
+   err = mmc_init(mmc);
+   if (err) {
+   printf("spl: mmc init failed with error: %d\n", err);
+   return err;
+   }
+
+   return err;
+}


I see two problems here: First, you're ignoring the return value of 
spl_mmc_find_device() and initialize 'mmc' to NULL instead. Wouldn't it 
be better to let 'mmc' be uninitialized and return the error code 
returned by spl_mmc_find_device() if there is one?


Second, using spl_boot_device() would prevent making the loader work on 
mach-socfpga when spl is not loaded from mmc, right?


E.g. for the case I'm currently trying to fix (boot from qspi), this 
loader would not work although there's technically no reason since the 
platform only has one mmc. The call to spl_boot_device() could be 
replaced by the exact value here for platforms that only have one mmc. I 
don't know how to fix that, though.


Regards,
Simon

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


[U-Boot] [RFC PATCH] mmc: Skipping the MMC initialization at the boot time

2018-01-17 Thread Siva Durga Prasad Paladugu
From: Vipul Kumar 

By enabling CONFIG_SKIP_EARLY_MMC_INIT config, user can skip the MMC
initialization at the boot time. After getting the u-boot console,
user can select the device using mmc dev and can communicate with that.
This is useful where user don't want to perform mmc initialization
while booting and can do explicitly later as per choice.

Signed-off-by: Vipul Kumar 
Signed-off-by: Siva Durga Prasad Paladugu 
---
 common/board_r.c| 4 ++--
 drivers/mmc/Kconfig | 7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 2a9df6b..8727b93 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -421,7 +421,7 @@ static int initr_onenand(void)
 }
 #endif

-#ifdef CONFIG_MMC
+#if defined(CONFIG_MMC) && !defined(CONFIG_SKIP_EARLY_MMC_INIT)
 static int initr_mmc(void)
 {
puts("MMC:   ");
@@ -768,7 +768,7 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_CMD_ONENAND
initr_onenand,
 #endif
-#ifdef CONFIG_MMC
+#if defined(CONFIG_MMC) && !defined(CONFIG_SKIP_EARLY_MMC_INIT)
initr_mmc,
 #endif
initr_env,
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index ab0627a..05b1503 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -40,6 +40,13 @@ config SPL_DM_MMC

 if MMC

+config SKIP_EARLY_MMC_INIT
+   bool "Skip the MMC initialization at boot time"
+   help
+ Skip the MMC initialization at the boot time. After getting the u-boot
+ console, user need to set mmc device and after setting the mmc dev, 
user
+ can communicate with that device.
+
 config ARM_PL180_MMCI
bool "ARM AMBA Multimedia Card Interface and compatible support"
depends on DM_MMC && OF_CONTROL
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread Simon Goldschmidt

On 18.01.2018 06:07, Jason Rush wrote:

On 1/17/2018 7:46 AM, RB23 wrote:

i checked, and if you mean these patches:
https://patchwork.ozlabs.org/patch/765992/
https://patchwork.ozlabs.org/patch/765996/
https://patchwork.ozlabs.org/patch/765997/
https://patchwork.ozlabs.org/patch/765998/

i already applied them, and they didn't work as well.

i also found these patches which i didn't try yet:
https://lists.denx.de/pipermail/u-boot/2017-May/292230.html

should i try those instead?

2018-01-17 15:09 GMT+02:00 Marek Vasut :


On 01/17/2018 02:06 PM, Simon Goldschmidt wrote:

On 17.01.2018 14:01, RB23 wrote:

hey, i downloaded the september and november versions and i applied
the patches on both of them, re-compiled the u boot,
and still, it gives me the same error when trying the command "sf probe"
i'm not sure what to do, is it possible that i missed something? like
a define or something in the make menuconfig?
i did some debugging and it seems that the crash happens on this line:
div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
thanks.


I don't know exactly which patches you are talking about, but the
divide-by-zero problem is still present with all patches I applied. To
fix it, you need to set up your device tree correctly so that the speed
is initialized.

If I remember correctly, you need need to have a flash chip below the
qspi in the device tree. Check Jason's changes to the various socfpga
dts files.


Er, maybe a patch which checks this condition wouldn't hurt ?


Hmm, the problem here is not specific to cadence_qspi, but to the clock 
rate calculation in an upper layer (as Jason wrote below). From the ML, 
I got the impression it's OK like that (which I don't think it is, it 
should at least give a hint what's going wrong instead of a data abort). 
However, I'll try to prepare a patch for that as soon as I find the time.


Regards,
Simon



--
Best regards,
Marek Vasut


I re-tested on a Cyclone V SoCKit devboard and a custom Arria V board using the 
DTS
patches I submitted (the 4 you mentioned above) and Vignesh's patch to fix the 
cache
invalidation problem, and I don't get the divide-by-zero problem.  This looks 
like the
clock rate for the flash part isn't getting set and is defaulting to 0 for some 
reason.
I would look at your device tree.  Are you using a stock device tree, or is 
this a custom
board? Make sure the 'spi-max-frequency' is being set for the flash part that 
is a child
to the cadence qspi node in the device tree.

-- Jason



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


Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread Jason Rush
On 1/17/2018 7:46 AM, RB23 wrote:
> i checked, and if you mean these patches:
> https://patchwork.ozlabs.org/patch/765992/
> https://patchwork.ozlabs.org/patch/765996/
> https://patchwork.ozlabs.org/patch/765997/
> https://patchwork.ozlabs.org/patch/765998/
>
> i already applied them, and they didn't work as well.
>
> i also found these patches which i didn't try yet:
> https://lists.denx.de/pipermail/u-boot/2017-May/292230.html
>
> should i try those instead?
>
> 2018-01-17 15:09 GMT+02:00 Marek Vasut :
>
>> On 01/17/2018 02:06 PM, Simon Goldschmidt wrote:
>>> On 17.01.2018 14:01, RB23 wrote:
 hey, i downloaded the september and november versions and i applied
 the patches on both of them, re-compiled the u boot,
 and still, it gives me the same error when trying the command "sf probe"
 i'm not sure what to do, is it possible that i missed something? like
 a define or something in the make menuconfig?
 i did some debugging and it seems that the crash happens on this line:
 div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
 thanks.

>>> I don't know exactly which patches you are talking about, but the
>>> divide-by-zero problem is still present with all patches I applied. To
>>> fix it, you need to set up your device tree correctly so that the speed
>>> is initialized.
>>>
>>> If I remember correctly, you need need to have a flash chip below the
>>> qspi in the device tree. Check Jason's changes to the various socfpga
>>> dts files.
>>>
>> Er, maybe a patch which checks this condition wouldn't hurt ?
>>
>> --
>> Best regards,
>> Marek Vasut
>>
I re-tested on a Cyclone V SoCKit devboard and a custom Arria V board using the 
DTS
patches I submitted (the 4 you mentioned above) and Vignesh's patch to fix the 
cache
invalidation problem, and I don't get the divide-by-zero problem.  This looks 
like the
clock rate for the flash part isn't getting set and is defaulting to 0 for some 
reason.
I would look at your device tree.  Are you using a stock device tree, or is 
this a custom
board? Make sure the 'spi-max-frequency' is being set for the flash part that 
is a child
to the cadence qspi node in the device tree.

-- Jason

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


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

2018-01-17 Thread Jaehoon Chung
On 01/18/2018 08:33 AM, Alexander Graf wrote:
> 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
> ---
>  MAINTAINERS  |   1 +
>  drivers/mmc/Kconfig  |  14 +
>  drivers/mmc/Makefile |   1 +
>  drivers/mmc/bcm2835_sdhost.c | 994 
> +++
>  4 files changed, 1010 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..ad9c7adb5a
> --- /dev/null
> +++ b/drivers/mmc/bcm2835_sdhost.c
> @@ -0,0 +1,994 @@
> +/*
> + * 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
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see .

Can be replaced to SPDX-License-Identifier?

> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Ordering.

> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define msleep(a) udelay(a * 1000)
> +
> +#define SDCMD  0x00 /* Command to SD card  

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

2018-01-17 Thread Chee, Tien Fong
On Tue, 2018-01-16 at 15:41 +0100, Marek Vasut wrote:
> On 12/27/2017 06:04 AM, tien.fong.c...@intel.com wrote:
> 
> Whoa, this improved substantially since last time I checked. Minor
> nitpicks below.
> 
> [...]
> 
> > 
> > +/* USB build is not supported yet in SPL */
> > +#ifndef CONFIG_SPL_BUILD
> > +#ifdef CONFIG_USB_STORAGE
> > +static int init_usb(void)
> > +{
> > +   int err;
> > +
> > +   err = usb_init();
> > +   if (err)
> > +   return err;
> > +
> > +#ifndef CONFIG_DM_USB
> > +   err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
> if (err)
>   return err;
> ?
> 
This is last line code of the function, so it's always return the
result regardless error or not.
> > 
> > +#endif
> > +
> > +   return err;
> > +}
> > +#else
> > +static int init_usb(void)
> > +{
> > +   printf("Error: Cannot load flash image: no USB
> > support\n");
> debug() ? Fix globally ...
> 
okay.
> > 
> > +   return -ENOSYS;
> > +}
> > +#endif
> > +#endif
> > +
> > +#ifdef CONFIG_SATA
> > +static int init_storage_sata(void)
> > +{
> > +   return sata_probe(0);
> > +}
> > +#else
> > +static int init_storage_sata(void)
> > +{
> > +   printf("Error: Cannot load image: no SATA support\n");
> > +   return -ENOSYS;
> > +}
> > +#endif
> > +
> > +#ifdef CONFIG_CMD_UBIFS
> > +static int mount_ubifs(struct device_location *location)
> > +{
> > +   int ret;
> > +   char cmd[32];
> > +
> > +   sprintf(cmd, "ubi part %s", location->mtdpart);
> snprintf() ...
> 
okay.
> > 
> > +   ret = run_command(cmd, 0);
> > +   if (ret)
> > +   return ret;
> > +
> > +   sprintf(cmd, "ubifsmount %s", location->ubivol);
> > +
> > +   ret = run_command(cmd, 0);
> > +
> > +   return ret;
> > +}
> > +
> > +static int umount_ubifs(void)
> > +{
> > +   return run_command("ubifsumount", 0);
> Just call the function directly ?
> 
There are some checking like ubifs_initialized in the cmd/ubifs.c.
Direct callng the function would bypass those checking.
> > 
> > +}
> > +#else
> > +static int mount_ubifs(struct device_location *location)
> > +{
> > +   printf("Error: Cannot load image: no UBIFS support\n");
> > +   return -ENOSYS;
> > +}
> > +#endif
> > +
> > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD)
> > +static int init_mmc(void)
> > +{
> > +   /* Just for the case MMC is not yet initialized */
> > +   struct mmc *mmc = NULL;
> > +   int err;
> > +
> > +   spl_mmc_find_device(, spl_boot_device());
> > +
> > +   err = mmc_init(mmc);
> > +   if (err) {
> > +   printf("spl: mmc init failed with error: %d\n",
> > err);
> > +   return err;
> > +   }
> > +
> > +   return err;
> > +}
> > +#else
> > +static int init_mmc(void)
> > +{
> > +   /* Expect somewhere already initialize MMC */
> > +   return 0;
> > +}
> > +#endif
> > +
> > +static int select_fs_dev(struct device_location *location)
> > +{
> > +   int ret;
> > +
> > +   if (!strcmp("mmc", location->name)) {
> > +   ret = fs_set_blk_dev("mmc", location->devpart,
> > FS_TYPE_ANY);
> > +   } else if (!strcmp("usb", location->name)) {
> > +   ret = fs_set_blk_dev("usb", location->devpart,
> > FS_TYPE_ANY);
> > +   } else if (!strcmp("sata", location->name)) {
> > +   ret = fs_set_blk_dev("sata", location->devpart,
> > FS_TYPE_ANY);
> > +   } else if (!strcmp("ubi", location->name)) {
> > +   if (location->ubivol != NULL)
> > +   ret = fs_set_blk_dev("ubi", NULL,
> > FS_TYPE_UBIFS);
> > +   else
> > +   ret = -ENODEV;
> > +   } else {
> > +   printf("Error: unsupported location storage.\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   if (ret)
> > +   printf("Error: could not access storage.\n");
> > +
> > +   return ret;
> > +}
> > +
> > +static int init_storage_device(struct device_location *location)
> > +{
> > +   int ret;
> > +
> > +   if (!strcmp("mmc", location->name)) {
> > +   ret = init_mmc();
> > +   } else if (!strcmp("sata", location->name)) {
> > +   ret = init_storage_sata();
> > +   } else if (location->ubivol != NULL) {
> > +   ret = mount_ubifs(location);
> > +#ifndef CONFIG_SPL_BUILD
> > +   /* USB build is not supported yet in SPL */
> > +   } else if (!strcmp("usb", location->name)) {
> > +   ret = init_usb();
> > +#endif
> > +   } else {
> > +   printf("Error: no supported storage device is
> > available.\n");
> > +   ret = -ENODEV;
> > +   }
> > +
> > +   return ret;
> > +}
> > +
> > +static void set_storage_devpart(char *name, char *devpart)
> > +{
> > +   size_t i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(default_locations); i++) {
> > +   if (!strcmp(default_locations[i].name, name))
> > +   default_locations[i].devpart = devpart;
> > +   }
> > +}
> > +
> > +/*
> > + * Prepare firmware struct;
> > + * return -ve if fail.
> Use kerneldoc and keep it consistent.
> 
kerneldoc doesn't has explanation for this function, and this function
is not for user. Or you means i shouldn't 

[U-Boot] [PATCH v2 3/4] ddr: marvell: update additional ODT setting

2018-01-17 Thread Chris Packham
The RD_SAMPLE_DELAY field is 5 bits so it needs to be masked with 0x1f
instead of 0xf. Rather than checking the read sample delay for all DDR
chip selects use the values for the chip selects that are actually
configured. Finally continue searching for the max_phase value even if the
current read_sample is the same as the max_read_sample.

Signed-off-by: Chris Packham 
---

Changes in v2:
- new

 drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c 
b/drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c
index 56fce174d4c0..1fc173b60020 100644
--- a/drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c
+++ b/drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c
@@ -17,7 +17,7 @@
 #define VREF_MAX_INDEX 7
 #define MAX_VALUE  (1024 - 1)
 #define MIN_VALUE  (-MAX_VALUE)
-#define GET_RD_SAMPLE_DELAY(data, cs)  ((data >> rd_sample_mask[cs]) & 0xf)
+#define GET_RD_SAMPLE_DELAY(data, cs)  ((data >> rd_sample_mask[cs]) & 0x1f)
 
 u32 ck_delay = (u32)-1, ck_delay_16 = (u32)-1;
 u32 ca_delay;
@@ -49,7 +49,7 @@ static u32 rd_sample_mask[] = {
  */
 int ddr3_tip_write_additional_odt_setting(u32 dev_num, u32 if_id)
 {
-   u32 cs_num = 0, max_read_sample = 0, min_read_sample = 0;
+   u32 cs_num = 0, max_cs = 0, max_read_sample = 0, min_read_sample = 0x1f;
u32 data_read[MAX_INTERFACE_NUM] = { 0 };
u32 read_sample[MAX_CS_NUM];
u32 val;
@@ -66,15 +66,19 @@ int ddr3_tip_write_additional_odt_setting(u32 dev_num, u32 
if_id)
  data_read, MASK_ALL_BITS));
val = data_read[if_id];
 
-   for (cs_num = 0; cs_num < MAX_CS_NUM; cs_num++) {
+   max_cs = hws_ddr3_tip_max_cs_get();
+
+   for (cs_num = 0; cs_num < max_cs; cs_num++) {
read_sample[cs_num] = GET_RD_SAMPLE_DELAY(val, cs_num);
 
/* find maximum of read_samples */
if (read_sample[cs_num] >= max_read_sample) {
-   if (read_sample[cs_num] == max_read_sample)
-   max_phase = MIN_VALUE;
-   else
+   if (read_sample[cs_num] == max_read_sample) {
+   /* search for max phase */;
+   } else {
max_read_sample = read_sample[cs_num];
+   max_phase = MIN_VALUE;
+   }
 
for (pup_index = 0;
 pup_index < tm->num_of_bus_per_interface;
@@ -97,10 +101,12 @@ int ddr3_tip_write_additional_odt_setting(u32 dev_num, u32 
if_id)
min_read_sample = read_sample[cs_num];
}
 
+   if (min_read_sample <= tm->interface_params[if_id].cas_l) {
+   min_read_sample = (int)tm->interface_params[if_id].cas_l;
+   }
+
min_read_sample = min_read_sample - 1;
max_read_sample = max_read_sample + 4 + (max_phase + 1) / 2 + 1;
-   if (min_read_sample >= 0xf)
-   min_read_sample = 0xf;
if (max_read_sample >= 0x1f)
max_read_sample = 0x1f;
 
-- 
2.15.1

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


[U-Boot] [PATCH v2 4/4] ddr: marvell: update ddr controller init and freq

2018-01-17 Thread Chris Packham
Update the calculation for tWR and tPD. This improves the DDR refresh
interval and brings the initialization into line with the binary blobs
currently being supplied by Marvell.

Signed-off-by: Chris Packham 
---

Changes in v2:
- new

 drivers/ddr/marvell/a38x/ddr3_topology_def.h |  3 ++-
 drivers/ddr/marvell/a38x/ddr3_training.c | 33 ++--
 drivers/ddr/marvell/a38x/ddr3_training_db.c  | 19 +---
 3 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/drivers/ddr/marvell/a38x/ddr3_topology_def.h 
b/drivers/ddr/marvell/a38x/ddr3_topology_def.h
index 64a0447dd15b..a17eca041878 100644
--- a/drivers/ddr/marvell/a38x/ddr3_topology_def.h
+++ b/drivers/ddr/marvell/a38x/ddr3_topology_def.h
@@ -70,7 +70,8 @@ enum speed_bin_table_elements {
SPEED_BIN_TWTR,
SPEED_BIN_TRTP,
SPEED_BIN_TWR,
-   SPEED_BIN_TMOD
+   SPEED_BIN_TMOD,
+   SPEED_BIN_TXPDLL
 };
 
 #endif /* _DDR3_TOPOLOGY_DEF_H */
diff --git a/drivers/ddr/marvell/a38x/ddr3_training.c 
b/drivers/ddr/marvell/a38x/ddr3_training.c
index 2eb6e05783d4..ef471e565efd 100644
--- a/drivers/ddr/marvell/a38x/ddr3_training.c
+++ b/drivers/ddr/marvell/a38x/ddr3_training.c
@@ -22,6 +22,8 @@
 #define GET_CS_FROM_MASK(mask) (cs_mask2_num[mask])
 #define CS_CBE_VALUE(cs_num)   (cs_cbe_reg[cs_num])
 
+#define TIMES_9_TREFI_CYCLES   0x8
+
 u32 window_mem_addr = 0;
 u32 phy_reg0_val = 0;
 u32 phy_reg1_val = 8;
@@ -508,7 +510,9 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
DEBUG_TRAINING_IP(DEBUG_LEVEL_TRACE,
  ("cl_value 0x%x cwl_val 
0x%x\n",
   cl_value, cwl_val));
-
+   t_wr = 
TIME_2_CLOCK_CYCLES(speed_bin_table(speed_bin_index,
+  
SPEED_BIN_TWR),
+  t_ckclk);
data_value =
((cl_mask_table[cl_value] & 0x1) << 2) |
((cl_mask_table[cl_value] & 0xe) << 3);
@@ -518,8 +522,9 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
  (0x7 << 4) | (1 << 2)));
CHECK_STATUS(ddr3_tip_if_write
 (dev_num, access_type, if_id,
- MR0_REG, twr_mask_table[t_wr + 1],
- 0xe00));
+ MR0_REG, twr_mask_table[t_wr + 1] 
<< 9,
+ (0x7 << 9)));
+
 
/*
 * MR1: Set RTT and DIC Design GL values
@@ -590,16 +595,15 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
  DDR_CONTROL_LOW_REG, t2t << 3,
  0x3 << 3));
/* move the block to ddr3_tip_set_timing - start */
-   t_pd = GET_MAX_VALUE(t_ckclk * 3,
-speed_bin_table(speed_bin_index,
-SPEED_BIN_TPD));
-   t_pd = TIME_2_CLOCK_CYCLES(t_pd, t_ckclk);
-   txpdll = GET_MAX_VALUE(t_ckclk * 10, 24);
+   t_pd = TIMES_9_TREFI_CYCLES;
+   txpdll = GET_MAX_VALUE(t_ckclk * 10,
+  speed_bin_table(speed_bin_index,
+  
SPEED_BIN_TXPDLL));
txpdll = CEIL_DIVIDE((txpdll - 1), t_ckclk);
CHECK_STATUS(ddr3_tip_if_write
 (dev_num, access_type, if_id,
- DDR_TIMING_REG, txpdll << 4,
- 0x1f << 4));
+ DDR_TIMING_REG, txpdll << 4 | t_pd,
+ 0x1f << 4 | 0xf));
CHECK_STATUS(ddr3_tip_if_write
 (dev_num, access_type, if_id,
  DDR_TIMING_REG, 0x28 << 9, 0x3f << 9));
@@ -1227,6 +1231,7 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type 
access_type,
u32 cl_value = 0, cwl_value = 0, mem_mask = 0, val = 0,
bus_cnt = 0, t_hclk = 0, t_wr = 0,
refresh_interval_cnt = 0, cnt_id;
+   u32 t_ckclk;
u32 t_refi = 0, end_if, start_if;
u32 bus_index = 0;
int is_dll_off = 0;
@@ -1393,8 +1398,12 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type 
access_type,
 

[U-Boot] [PATCH v2 1/4] ddr: marvell: only assert M_ODT[0] on write for a single CS

2018-01-17 Thread Chris Packham
When using only a single DDR chip select only assert M_ODT[0] on write.
Do not assert it on read and do not assert M_ODT[1] at all. Also set
tODT_OFF_WR to 0x9 which contradicts the recommendation from the
functional spec but is what Marvell's binary training blob does and
seems to give better results when ODT is active during writes.

Signed-off-by: Chris Packham 
---

Changes in v2:
- Update tODT_OFF_WR as well

 drivers/ddr/marvell/a38x/ddr3_init.h|  3 ++-
 drivers/ddr/marvell/a38x/ddr3_training.c| 15 +--
 drivers/ddr/marvell/a38x/ddr3_training_static.c |  3 ++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/ddr/marvell/a38x/ddr3_init.h 
b/drivers/ddr/marvell/a38x/ddr3_init.h
index 8cb08864c292..a4c75a9fa68f 100644
--- a/drivers/ddr/marvell/a38x/ddr3_init.h
+++ b/drivers/ddr/marvell/a38x/ddr3_init.h
@@ -183,7 +183,8 @@ extern u32 g_znodt_data;
 extern u32 g_zpodt_ctrl;
 extern u32 g_znodt_ctrl;
 extern u32 g_dic;
-extern u32 g_odt_config;
+extern u32 g_odt_config_2cs;
+extern u32 g_odt_config_1cs;
 extern u32 g_rtt_nom;
 
 extern u8 debug_training_access;
diff --git a/drivers/ddr/marvell/a38x/ddr3_training.c 
b/drivers/ddr/marvell/a38x/ddr3_training.c
index e70ca4b42551..043143adf08a 100644
--- a/drivers/ddr/marvell/a38x/ddr3_training.c
+++ b/drivers/ddr/marvell/a38x/ddr3_training.c
@@ -315,6 +315,7 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
enum hws_access_type access_type = ACCESS_TYPE_UNICAST;
u32 data_read[MAX_INTERFACE_NUM];
struct hws_topology_map *tm = ddr3_get_topology_map();
+   u32 odt_config = g_odt_config_2cs;
 
DEBUG_TRAINING_IP(DEBUG_LEVEL_TRACE,
  ("Init_controller, do_mrs_phy=%d, is_ctrl64_bit=%d\n",
@@ -570,6 +571,9 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
  DUNIT_CONTROL_HIGH_REG,
  (init_cntr_prm->msys_init << 7), (1 << 
7)));
 
+   /* calculate number of CS (per interface) */
+   CHECK_STATUS(calc_cs_num
+(dev_num, if_id, _num));
timing = tm->interface_params[if_id].timing;
 
if (mode2_t != 0xff) {
@@ -578,9 +582,6 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
/* Board topology map is forcing timing */
t2t = (timing == HWS_TIM_2T) ? 1 : 0;
} else {
-   /* calculate number of CS (per interface) */
-   CHECK_STATUS(calc_cs_num
-(dev_num, if_id, _num));
t2t = (cs_num == 1) ? 0 : 1;
}
 
@@ -623,9 +624,11 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct 
init_cntr_param *init_cntr_
  (1 << 11)));
 
/* Set Active control for ODT write transactions */
+   if (cs_num == 1)
+   odt_config = g_odt_config_1cs;
CHECK_STATUS(ddr3_tip_if_write
 (dev_num, ACCESS_TYPE_MULTICAST,
- PARAM_NOT_CARE, 0x1494, g_odt_config,
+ PARAM_NOT_CARE, 0x1494, odt_config,
  MASK_ALL_BITS));
}
} else {
@@ -1539,7 +1542,7 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type 
access_type,
CHECK_STATUS(ddr3_tip_if_write(dev_num, access_type,
   if_id, ODT_TIMING_LOW,
   val, 0x0));
-   val = 0x71 | ((cwl_value - 1) << 8) | ((cwl_value + 5) << 12);
+   val = 0x91 | ((cwl_value - 1) << 8) | ((cwl_value + 5) << 12);
CHECK_STATUS(ddr3_tip_if_write(dev_num, access_type,
   if_id, ODT_TIMING_HI_REG,
   val, 0x));
@@ -1591,7 +1594,7 @@ static int ddr3_tip_write_odt(u32 dev_num, enum 
hws_access_type access_type,
 
CHECK_STATUS(ddr3_tip_if_write(dev_num, access_type, if_id,
   ODT_TIMING_LOW, val, 0x0));
-   val = 0x71 | ((cwl_value - 1) << 8) | ((cwl_value + 5) << 12);
+   val = 0x91 | ((cwl_value - 1) << 8) | ((cwl_value + 5) << 12);
CHECK_STATUS(ddr3_tip_if_write(dev_num, access_type, if_id,
   ODT_TIMING_HI_REG, val, 0x));
if (odt_additional == 1) {
diff --git a/drivers/ddr/marvell/a38x/ddr3_training_static.c 
b/drivers/ddr/marvell/a38x/ddr3_training_static.c
index 

[U-Boot] [PATCH v2 2/4] ddr: marvell: use correct TREFI value

2018-01-17 Thread Chris Packham
The ternary operation had the HIGH/LOW values the
wrong way round. Update it to use the correct value.

Signed-off-by: Chris Packham 
---

Changes in v2:
- new

 drivers/ddr/marvell/a38x/ddr3_training.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ddr/marvell/a38x/ddr3_training.c 
b/drivers/ddr/marvell/a38x/ddr3_training.c
index 043143adf08a..2eb6e05783d4 100644
--- a/drivers/ddr/marvell/a38x/ddr3_training.c
+++ b/drivers/ddr/marvell/a38x/ddr3_training.c
@@ -1375,7 +1375,7 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type 
access_type,
 
/* adjust t_refi to new frequency */
t_refi = (tm->interface_params[if_id].interface_temp ==
- HWS_TEMP_HIGH) ? TREFI_LOW : TREFI_HIGH;
+ HWS_TEMP_HIGH) ? TREFI_HIGH : TREFI_LOW;
t_refi *= 1000; /*psec */
 
/* HCLK in[ps] */
-- 
2.15.1

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


[U-Boot] [PATCH v2 0/4] ddr: marvell: update DDR driver

2018-01-17 Thread Chris Packham
I have a custom board that sees correctable ECC errors (when running
memtester[1] from Linux). When I used Marvell's bootloader I didn't
see the errors.

I've also had a tame hardware engineer (if there is such a thing)
looking at the timing waveforms comparing the stock u-boot behaviour
against Marvell's bootloader.

The changes for this series have been derived by comparing scope
captures and register output between the same system running stock
u-boot and Marvell's USP.

Changes in v2:
- Update tODT_OFF_WR as well
- Added patches 2-4

Chris Packham (4):
  ddr: marvell: only assert M_ODT[0] on write for a single CS
  ddr: marvell: use correct TREFI value
  ddr: marvell: update additional ODT setting
  ddr: marvell: update ddr controller init and freq

 drivers/ddr/marvell/a38x/ddr3_init.h |  3 +-
 drivers/ddr/marvell/a38x/ddr3_topology_def.h |  3 +-
 drivers/ddr/marvell/a38x/ddr3_training.c | 50 +++-
 drivers/ddr/marvell/a38x/ddr3_training_db.c  | 19 +
 drivers/ddr/marvell/a38x/ddr3_training_hw_algo.c | 22 +++
 drivers/ddr/marvell/a38x/ddr3_training_static.c  |  3 +-
 6 files changed, 62 insertions(+), 38 deletions(-)

-- 
2.15.1

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


[U-Boot] [PATCH v2] ARM: dts: Freescale: re-license device tree files under GPLv2+/X11

2018-01-17 Thread Pankaj Bansal
The current GPL only licensing on the device trees makes it very
impractical for other software components licensed under another
license.

To make it easier to reuse them, re-license the the device trees for
Freescale (now NXP) SoCs and boards under GPLv2+/X11 dual license.

Same trend is followed in linux.

Cc: Priyanka Jain 
Cc: Mingkai Hu 
Cc: York Sun 
Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- Change license from X11 only to GPL2.0+/X11 dual license.
- Updated the commit message accordingly.

V1:
- Change the license of freescale (now nxp) dtsi/dts files from GPL2.0+ to 
X11.

 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 +-
 25 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/arch/arm/dts/fsl-ls1012a-frdm.dts 
b/arch/arm/dts/fsl-ls1012a-frdm.dts
index 983e599..6ea5f82 100644
--- a/arch/arm/dts/fsl-ls1012a-frdm.dts
+++ b/arch/arm/dts/fsl-ls1012a-frdm.dts
@@ -3,7 +3,7 @@
  *
  * Copyright 2016, Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /dts-v1/;
diff --git a/arch/arm/dts/fsl-ls1012a-frdm.dtsi 
b/arch/arm/dts/fsl-ls1012a-frdm.dtsi
index 25dcdd2..d453f5d 100644
--- a/arch/arm/dts/fsl-ls1012a-frdm.dtsi
+++ b/arch/arm/dts/fsl-ls1012a-frdm.dtsi
@@ -3,7 +3,7 @@
  *
  * Copyright 2016, Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /include/ "fsl-ls1012a.dtsi"
diff --git a/arch/arm/dts/fsl-ls1012a-qds.dts b/arch/arm/dts/fsl-ls1012a-qds.dts
index 76db36c..ccc9023 100644
--- a/arch/arm/dts/fsl-ls1012a-qds.dts
+++ b/arch/arm/dts/fsl-ls1012a-qds.dts
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016 Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /dts-v1/;
diff --git a/arch/arm/dts/fsl-ls1012a-qds.dtsi 
b/arch/arm/dts/fsl-ls1012a-qds.dtsi
index d17cd99..908fbed 100644
--- a/arch/arm/dts/fsl-ls1012a-qds.dtsi
+++ b/arch/arm/dts/fsl-ls1012a-qds.dtsi
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016 Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /include/ "fsl-ls1012a.dtsi"
diff --git a/arch/arm/dts/fsl-ls1012a-rdb.dts b/arch/arm/dts/fsl-ls1012a-rdb.dts
index f683812..400cd9e 100644
--- a/arch/arm/dts/fsl-ls1012a-rdb.dts
+++ b/arch/arm/dts/fsl-ls1012a-rdb.dts
@@ -3,7 +3,7 @@
  *
  * Copyright 2016, Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /dts-v1/;
diff --git a/arch/arm/dts/fsl-ls1012a-rdb.dtsi 
b/arch/arm/dts/fsl-ls1012a-rdb.dtsi
index bf407ae..c4b6adf 100644
--- a/arch/arm/dts/fsl-ls1012a-rdb.dtsi
+++ b/arch/arm/dts/fsl-ls1012a-rdb.dtsi
@@ -3,9 +3,7 @@
  *
  * Copyright 2016, Freescale Semiconductor
  *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /include/ "fsl-ls1012a.dtsi"
diff --git a/arch/arm/dts/fsl-ls1012a.dtsi b/arch/arm/dts/fsl-ls1012a.dtsi
index 23b3cec..215e095 100644
--- a/arch/arm/dts/fsl-ls1012a.dtsi
+++ b/arch/arm/dts/fsl-ls1012a.dtsi
@@ -1,7 +1,7 @@
 /*
  * Copyright 2016 Freescale Semiconductor
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * SPDX-License-Identifier:GPL-2.0+X11
  */
 
 /include/ "skeleton64.dtsi"
diff --git a/arch/arm/dts/fsl-ls1043a-qds-duart.dts 
b/arch/arm/dts/fsl-ls1043a-qds-duart.dts
index 2124e38..cf53ab0 100644
--- a/arch/arm/dts/fsl-ls1043a-qds-duart.dts
+++ b/arch/arm/dts/fsl-ls1043a-qds-duart.dts
@@ 

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

2018-01-17 Thread Chee, Tien Fong
On Tue, 2018-01-16 at 09:35 -0500, Tom Rini wrote:
> On Tue, Jan 16, 2018 at 07:58:00AM +, Chee, Tien Fong wrote:
> > 
> > On Mon, 2018-01-15 at 11:36 -0500, Tom Rini wrote:
> > > 
> > > On Wed, Dec 27, 2017 at 01:04:38PM +0800, tien.fong.c...@intel.co
> > > m
> > > 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 
> > > Please add Lothar's Reviewed-by for v7.  There's a number of
> > > minor
> > > checkpatch.pl issues that checkpatch.pl can in turn fixup itself,
> > > please
> > > correct them.
> > > 
> > I have ran the checkpatch.pl on this patch, i didn't see any error.
> When I ran it, it was pointing out cases where you have:
> if (foo->bar != NULL)
> when you can just use:
> if (foo->bar)
> 
It's weird for checkpatch.pl not showing the same. I would fix the code
with above example.
> [snip]
> > 
> > > 
> > > > 
> > > > diff --git a/common/fs_loader.c b/common/fs_loader.c
> > > > new file mode 100644
> > > > index 000..56d29b6
> > > > --- /dev/null
> > > > +++ b/common/fs_loader.c
> > > > @@ -0,0 +1,309 @@
> > > > +/*
> > > > + * Copyright (C) 2017 Intel Corporation 
> > > > + *
> > > > + * SPDX-License-Identifier:GPL-2.0
> > > > + */
> > > > +
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > This wants  which is not globally available, so you
> > > need
> > > to
> > > come up with something here.  At least making this Kconfig-
> > > enabled
> > > will
> > > be a start and perhaps OK for now.
> > > 
> > I can enable the Kconfig, and put the caution about dependency on
> >  in document.
> Well, you need to make that part of the code depend on CONFIG_SPL as
> SPL
> support requires  to exist.   Perhaps part of the code
> needs
> to be refactored to more easily deal with SPL not always being
> present?
> 
How about i just move the whole enum { } from line 17 to line 35 in
asm/spl.h to fs.h, and then enum{} above replaced with #include ?

asm/spl.h
--
#if defined(CONFIG_ARCH_OMAP2PLUS) \
|| defined(CONFIG_EXYNOS4) || defined(CONFIG_EXYNOS5) \
|| defined(CONFIG_EXYNOS4210)
/* Platform-specific defines */
#include 

#else
#include   <-- replacement
#endif
[...]

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


[U-Boot] [PATCH v2 1/1] dm: video: Correct color ANSI escape sequence support

2018-01-17 Thread Heinrich Schuchardt
Support special rendition code 0 - reset attributes.
Support special rendition code 1 - increased intensity (bold).
Get RGB sequence in pixels right (swap blue and red).
Do not set reserved bits.
Use u32 instead of unsigned for color bit mask.

qemu-system-i386 -display sdl -vga virtio and
qemu-system-i386 -display sdl -vga cirrus
now display the same colors as
qemu-system-i386 -nographic

Testing is possible via

setenv efi_selftest test output
bootefi selftest

Signed-off-by: Heinrich Schuchardt 
---
v2:
SGR 0 should reset the colors and the attributes.
---
 drivers/video/vidconsole-uclass.c | 53 ++
 drivers/video/video-uclass.c  | 54 +--
 include/video.h   | 13 --
 test/dm/video.c   |  2 +-
 4 files changed, 94 insertions(+), 28 deletions(-)

diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index 5f63c12d6c..3c39ee06dd 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -114,28 +114,35 @@ static const struct {
unsigned b;
 } colors[] = {
{ 0x00, 0x00, 0x00 },  /* black */
-   { 0xff, 0x00, 0x00 },  /* red */
-   { 0x00, 0xff, 0x00 },  /* green */
+   { 0xc0, 0x00, 0x00 },  /* red */
+   { 0x00, 0xc0, 0x00 },  /* green */
+   { 0xc0, 0x60, 0x00 },  /* brown */
+   { 0x00, 0x00, 0xc0 },  /* blue */
+   { 0xc0, 0x00, 0xc0 },  /* magenta */
+   { 0x00, 0xc0, 0xc0 },  /* cyan */
+   { 0xc0, 0xc0, 0xc0 },  /* light gray */
+   { 0x80, 0x80, 0x80 },  /* gray */
+   { 0xff, 0x00, 0x00 },  /* bright red */
+   { 0x00, 0xff, 0x00 },  /* bright green */
{ 0xff, 0xff, 0x00 },  /* yellow */
-   { 0x00, 0x00, 0xff },  /* blue */
-   { 0xff, 0x00, 0xff },  /* magenta */
-   { 0x00, 0xff, 0xff },  /* cyan */
+   { 0x00, 0x00, 0xff },  /* bright blue */
+   { 0xff, 0x00, 0xff },  /* bright magenta */
+   { 0x00, 0xff, 0xff },  /* bright cyan */
{ 0xff, 0xff, 0xff },  /* white */
 };
 
-static void set_color(struct video_priv *priv, unsigned idx, unsigned *c)
+static void set_color(struct video_priv *priv, unsigned int idx, u32 *c)
 {
switch (priv->bpix) {
case VIDEO_BPP16:
-   *c = ((colors[idx].r >> 3) << 0) |
-((colors[idx].g >> 2) << 5) |
-((colors[idx].b >> 3) << 11);
+   *c = ((colors[idx].r >> 3) << 11) |
+((colors[idx].g >> 2) <<  5) |
+((colors[idx].b >> 3) <<  0);
break;
case VIDEO_BPP32:
-   *c = 0xff00 |
-(colors[idx].r << 0) |
-(colors[idx].g << 8) |
-(colors[idx].b << 16);
+   *c = (colors[idx].r << 16) |
+(colors[idx].g <<  8) |
+(colors[idx].b <<  0);
break;
default:
/* unsupported, leave current color in place */
@@ -270,18 +277,30 @@ static void vidconsole_escape_char(struct udevice *dev, 
char ch)
s++;
 
switch (val) {
+   case 0:
+   /* all attributes off */
+   video_set_default_colors(vid_priv);
+   break;
+   case 1:
+   /* bold */
+   vid_priv->fg |= 8;
+   set_color(vid_priv, vid_priv->fg,
+ (unsigned int *)_priv->colour_fg);
+   break;
case 30 ... 37:
/* fg color */
-   set_color(vid_priv, val - 30,
- (unsigned *)_priv->colour_fg);
+   vid_priv->fg &= ~7;
+   vid_priv->fg |= val - 30;
+   set_color(vid_priv, vid_priv->fg,
+ _priv->colour_fg);
break;
case 40 ... 47:
/* bg color */
set_color(vid_priv, val - 40,
- (unsigned *)_priv->colour_bg);
+ _priv->colour_bg);
break;
default:
-   /* unknown/unsupported */
+   /* ignore unsupported SGR parameter */
break;
}
}
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index dcaceed42c..ec6ee10c67 100644
--- a/drivers/video/video-uclass.c
+++ 

Re: [U-Boot] [PATCH] ARM: dts: Freescale: re-license device tree files under X11

2018-01-17 Thread Tom Rini
On Wed, Jan 17, 2018 at 07:26:00PM +, Leo Li wrote:
> 
> 
> > -Original Message-
> > From: Pankaj Bansal
> > Sent: Monday, January 15, 2018 11:06 PM
> > To: Leo Li 
> > Cc: u-boot@lists.denx.de; albert.u.b...@aribaud.net; Tom Rini
> > ; Priyanka Jain ; Varun Sethi
> > ; Mingkai Hu 
> > Subject: RE: [U-Boot] [PATCH] ARM: dts: Freescale: re-license device tree
> > files under X11
> > 
> > ++ Leo
> > 
> > Hi Leo. Can you please reply to this question ?
> > 
> > > -Original Message-
> > > From: Tom Rini [mailto:tr...@konsulko.com]
> > > Sent: Tuesday, January 16, 2018 8:59 AM
> > > To: Pankaj Bansal 
> > > Cc: u-boot@lists.denx.de; albert.u.b...@aribaud.net; Priyanka Jain
> > > ; Varun Sethi ; Mingkai Hu
> > > 
> > > Subject: Re: [U-Boot] [PATCH] ARM: dts: Freescale: re-license device
> > > tree files under X11
> > >
> > > On Tue, Jan 16, 2018 at 03:27:09AM +, Pankaj Bansal wrote:
> > > > HI,
> > > >
> > > > > -Original Message-
> > > > > From: Tom Rini [mailto:tr...@konsulko.com]
> > > > > Sent: Tuesday, January 16, 2018 8:32 AM
> > > > > To: Pankaj Bansal 
> > > > > Cc: u-boot@lists.denx.de; albert.u.b...@aribaud.net; Priyanka Jain
> > > > > ; Varun Sethi ; Mingkai
> > Hu
> > > > > 
> > > > > Subject: Re: [U-Boot] [PATCH] ARM: dts: Freescale: re-license
> > > > > device tree files under X11
> > > > >
> > > > > On Tue, Jan 16, 2018 at 08:03:54AM +0530, Pankaj Bansal wrote:
> > > > >
> > > > > > The current GPL only licensing on the device trees makes it very
> > > > > > impractical for other software components licensed under another
> > > > > > license.
> > > > > >
> > > > > > To make it easier to reuse them, re-license the the device trees
> > > > > > for Freescale (now NXP) SoCs and boards under license X11.
> > > > > >
> > > > > > Cc: Priyanka Jain 
> > > > > > Cc: Mingkai Hu 
> > > > > > Cc: York Sun 
> > > > > > Signed-off-by: Pankaj Bansal 
> > > > > > ---
> > > > > >  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 +-
> > > > > >  25 files changed, 25 insertions(+), 39 deletions(-)
> > > > >
> > > > > How do these changes match up to the kernel?  Thanks!
> > > >
> > > > The kernel dts files are GPLv2 and X11 dual licensed. E.g.
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.
> > > > gi t/tree/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi
> > > >
> > > > To avoid dual licensing, we used X11 only. See
> > > > https://www.gnu.org/licenses/license-list.en.html#X11License
> > >
> > > Why would we not want to match the kernel here?
> 
> As we are working with Qualcomm for the potential acquisition, their
> legal team mentioned that they are against using dual license.  So as
> we are updating the license we would like to take that concern too.

I want these to be kept in-sync with what is in the Linux kernel.  So,
whatever you get done there is fine here (and follow the usual rules in
the commit message when syncing), thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v4, 07/11] spl: add support to booting with OP-TEE

2018-01-17 Thread Kever Yang

Bryan,


On 01/18/2018 01:48 AM, Bryan O'Donoghue wrote:



On 15/01/18 04:48, Peng Fan wrote:

On Mon, Jan 15, 2018 at 11:25:00AM +0800, Kever Yang wrote:

Bryan,


On 01/12/2018 11:10 PM, Bryan O'Donoghue wrote:



On 12/01/18 11:27, Philipp Tomsich wrote:

OP-TEE is an open source trusted OS, in armv7, its loading and
running are like this:
loading:
- SPL load both OP-TEE and U-Boot
running:
- SPL run into OP-TEE in secure mode;
- OP-TEE run into U-Boot in non-secure mode;

More detail:
https://github.com/OP-TEE/optee_os
and search for 'boot arguments' for detail entry parameter in:
core/arch/arm/kernel/generic_entry_a32.S

Signed-off-by: Kever Yang 
---

Changes in v4:
- use NULL instead of '0'
- add fdt_addr as arg2 of entry

Changes in v3: None
Changes in v2:
- Using new image type for op-tee

  common/spl/Kconfig |  7 +++
  common/spl/Makefile|  1 +
  common/spl/spl.c   |  9 +
  common/spl/spl_optee.S | 13 +
  include/spl.h  | 13 +
  5 files changed, 43 insertions(+)
  create mode 100644 common/spl/spl_optee.S



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



Kever, Philipp

I have patches that define a IH_TYPE_OPTEE as a bootable OPTEE
image (one that never returns to u-boot).


I don't understand how you use OP-TEE in your project.
You are using U-Boot 'bootm' cmd to run into OP-TEE and 'PC' never
get out of the OP-TEE os?
The upstream OP-TEE will always be back to the pointer in 'lr'.

We are using boot flow like ARMv8 for OP-TEE in armv7, could you
introduce your flow?


The flow is ROM->U-Boot->OP-TEE->Linux.


Hi Kever, this got buried in my mailbox...

Which I believe is the preferred flow for armv7

That said - if you look at the TI commits for IH_TYPE_TEE I believe 
*that* is the appropriate type for what you are doing with SPL.


As I read the TI code the TEE is installed into memory - jumped into 
and returned out of, which is the model you are using with SPL here.


Basically that's what 
arch/arm/mach-omap2/sec-common.c::secure_tee_install() does.


So, I think the SPL solution you have can co-exist quite easily with 
the model we have described above for imx7.


My only suggestion here is that you probably don't need to define a 
new image type for SPL - you can reuse IH_TYPE_TEE for SPL as below.


I don't think we can reuse IH_TYPE_TEE, it use a optee.img type create 
by mkimage and it seem use more then one cpu.
We use fit to pack uboot and optee into one itb file, and we use only 
one cpu now.
I may prefer to use what I have send with the type update to 
IH_TYPE_OPTEE_SPL.


Thanks,
- Kever


Other than that I think the SPL/bootm or indeed the TI method of 
installing a TEE are entirely able to (and should) live side-by-side.



+#if CONFIG_IS_ENABLED(OPTEE)
+case IH_TYPE_TEE:
+debug("Jumping to U-Boot via OP-TEE\n");
+spl_optee_entry(NULL, NULL, spl_image->fdt_addr,
+(void *)spl_image.entry_point);
+break;
+#endif





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


Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-01-17 Thread Peng Fan
Hi Stefano,

Do you have any comments on this v5 patchset?  I would like this patchset
could catch up 2018.03.

Thanks,
Peng.

> -Original Message-
> From: Peng Fan
> Sent: Wednesday, January 10, 2018 1:20 PM
> To: sba...@denx.de; Fabio Estevam 
> Cc: van.free...@gmail.com; u-boot@lists.denx.de; Peng Fan
> 
> Subject: [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK
> 
> This patchset is to add i.MX8M and i.MX8MQ-EVK support
> 
> V5:
>  Drop wait_mask_set/clr_timeout and switch to use readl_poll_timeout in  the
> patchset.
> 
> V4:
>  Regenerate patchset based on Tom's master tree.
>  In this patchset, https://patchwork.ozlabs.org/patch/855027/
>  "arm: imx: Rework i.MX specific commands to be excluded from SPL" from
> Tom is included to avoid merge conflicts because the i.mx8m change  also has
> some modification to bootaux and arch/arm/mach-imx/Makefile.
>  Because CONFIG_GPT_TIMER change, I did a small modification to apply  Tom's
> patch, no function change.
> 
>  Include ATF link in README.
> 
> V3:
>  This patchset based on https://patchwork.ozlabs.org/patch/855027/
>  "arm: imx: Rework i.MX specific commands to be excluded from SPL" from
> Tom to avoid this patchset fail apply after Tom's patch merged.
> 
>  Previously "power: pmic/regulator allow dm be omited by SPL" broke other
> boards, in V3 patchset, only touch pfuze100 related options.
> 
>  Sharing code about get mac from fuse between mx7/mx8m  Sharing code
> about bootaux between mx6/7/mx8m  Sharing code about cpu speed grade
> between mx7/mx8m  Sharing code about get boot device between mx7/mx8m
> Sharding code about mmc env between mx7/mx8m
> 
>  Introduce wait_mask_set/clr_timeout to avoid deadloop in clock pll
> configuration
> 
>  Correct authorship of fix building warning on fec arm64, patch 27/31.
> 
>  Switch to use structure for DDR Controller. For DDR PHY registers,  there are
> about more than 10 thousands registers, I could not convert  them with
> detailed register name, and the script is generated from IC team,  So I use
> regs[0x] arrays here fo easily converting between IC team  released script
> and uboot ddr phy cod.
> 
>  Improve REAMME file to include where to download firmware and imx-
> mkimage  and how to build
> 
>  Add review tags on the V2 patchset.
> 
>  Hope this patchset could catch up next release :)
> 
> V2:
> 
>  patch 02/23: convert to structure, drop is_boot_from_usb and
> disconnect_from_usb
>  patch 04/23: conver to use structure for the clock driver, removed the
>   CCM_xxx macros. Add static for local functons.
> Add init_usdhc_clk, init_uart_clk and etc to not enable
> them all at default.
>  patch 05/23: Add more commit msg for the sip part.
>  patch 08/23: Merge the spl boot device with i.MX7  patch 12/23: Typo fix and
> return error fix from Heiko for the SoC related part  patch 22/23: Use a weak
> function ddr_init. If patch 23/23 could not be
>   accepted at current stage, to make others still be could be
> compiled.
> 
> The patchset depends on
> https://patchwork.ozlabs.org/patch/841934/
> https://patchwork.ozlabs.org/patch/841958/
> to be tested on real hardware.
> 
> V1:
> 
> patch: "power: pmic.h: include dm/ofnode.h" and
> "power: pmic/regulator allow dm be omited by SPL" is previously reviewed in
> mailist to not merged. If no issue, you may pick it up.
> 
> The board support is a large patch because of the ddr related code.
> If it is not good, please first review/pick-up other patches if they are ok.
> 
> 
> 
> Peng Fan (29):
>   imx: add i.MX8M into Kconfig
>   imx: mx8m: add register definition header file
>   imx: mx8m: add pin header file
>   imx: mx8m: add clock driver
>   imx: add sip function
>   imx: boot_mode: add USB_BOOT entry
>   imx: cpu: update cpu file to support i.MX8M
>   imx: spl: implement spl_boot_device for i.MX8M
>   imx: add i.MX8MQ SoC Revision and is_mx8m helper
>   imx: add pad settings bit definition for i.MX8M
>   imx: cpu: move speed/temp to common cpu
>   imx: cpu: add cpu speed/grade for i.MX8M
>   imx: refactor imx_get_mac_from_fuse
>   imx: cleanup bootaux
>   imx: bootaux: support i.MX8M
>   imx: mx7: move get_boot_device to cpu.c
>   imx: cpu: support get_boot_device for i.MX8M
>   imx: mx7: move mmc env code to mmc_env.c
>   imx: mx8m: add soc related settings and files
>   imx: makefile: compile files for i.MX8M
>   misc: ocotp: add i.MX8M support
>   mmc: fsl_esdhc: support i.MX8M
>   imx: lcdif: include i.MX8M
>   gpio: mxc: add i.MX8M support
>   net: fec: do not access reserved register for i.MX8M
>   imx: imx8mq: add dtsi file
>   power: pmic/regulator allow dm be omitted by SPL
>   imx: mx8m: add ddr controller memory map
>   imx: add i.MX8MQ EVK support
> 
> Tom Rini (1):
>   arm: imx: Rework i.MX specific commands to be excluded from SPL
> 
> Ye Li (1):
>   net: fec: fix build warnings for 64bits support
> 
>  

Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-01-17 Thread Peng Fan


> -Original Message-
> From: Diego Dorta [mailto:diegohdo...@gmail.com]
> Sent: Wednesday, January 17, 2018 11:00 PM
> To: Peng Fan 
> Cc: Peng Fan ; Fabio Estevam
> ; U-Boot-Denx ; Diego
> Dorta 
> Subject: Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and
> i.MX8MQ EVK
> 
> Hi Peng,
> 
> 2018-01-16 10:25 GMT-02:00 Peng Fan :
> >
> >
> >> -Original Message-
> >> From: Diego Dorta [mailto:diegohdo...@gmail.com]
> >> Sent: Tuesday, January 16, 2018 8:15 PM
> >> To: Peng Fan 
> >> Cc: Peng Fan ; Fabio Estevam
> >> ; U-Boot-Denx 
> >> Subject: Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and
> >> i.MX8MQ EVK
> >>
> >> Hi Peng,
> >>
> >> 2018-01-13 8:55 GMT-02:00 Peng Fan :
> >> > Hi Diego,
> >> > On Thu, Jan 11, 2018 at 10:36:02AM -0200, Diego Dorta wrote:
> >> >>Hi Peng,
> >> >>
> >> >>2018-01-10 23:16 GMT-02:00 Peng Fan :
> >> >>> Hi Diego,
> >> >>>
> >> >>> On Wed, Jan 10, 2018 at 11:08:54AM -0200, Diego Dorta wrote:
> >> Hi Peng,
> >> 
> >> 2018-01-10 3:20 GMT-02:00 Peng Fan :
> >> > This patchset is to add i.MX8M and i.MX8MQ-EVK support
> >> >
> >> > V5:
> >> >  Drop wait_mask_set/clr_timeout and switch to use
> >> > readl_poll_timeout in  the patchset.
> >> >
> >> > V4:
> >> >  Regenerate patchset based on Tom's master tree.
> >> >  In this patchset,
> >> >
> >> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2
> >> >
> >>
> Fpatchwork.ozlabs.org%2Fpatch%2F855027%2F=02%7C01%7Cpeng.fan%
> >> >
> >>
> 40nxp.com%7C7ff0a80d79454c1eb43608d55cdad59d%7C686ea1d3bc2b4c6fa92
> >> >
> >>
> cd99c5c301635%7C0%7C1%7C636517017329353990=ukU9u%2B99GtYbM
> >> Pu
> >> > 1F18ZK2FvUpwWJI5ge4Hb607OPMk%3D=0
> >> >  "arm: imx: Rework i.MX specific commands to be excluded from
> SPL"
> >> > from  Tom is included to avoid merge conflicts because the
> >> > i.mx8m change  also has some modification to bootaux and
> >> > arch/arm/mach-
> >> imx/Makefile.
> >> >  Because CONFIG_GPT_TIMER change, I did a small modification to
> >> > apply  Tom's patch, no function change.
> >> >
> >> >  Include ATF link in README.
> >> >
> >> > V3:
> >> >  This patchset based on
> >> >
> >> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2
> >> >
> >>
> Fpatchwork.ozlabs.org%2Fpatch%2F855027%2F=02%7C01%7Cpeng.fan%
> >> >
> >>
> 40nxp.com%7C7ff0a80d79454c1eb43608d55cdad59d%7C686ea1d3bc2b4c6fa92
> >> >
> >>
> cd99c5c301635%7C0%7C1%7C636517017329353990=ukU9u%2B99GtYbM
> >> Pu
> >> > 1F18ZK2FvUpwWJI5ge4Hb607OPMk%3D=0
> >> >  "arm: imx: Rework i.MX specific commands to be excluded from
> SPL"
> >> > from  Tom to avoid this patchset fail apply after Tom's patch merged.
> >> >
> >> >  Previously "power: pmic/regulator allow dm be omited by SPL"
> >> > broke other  boards, in V3 patchset, only touch pfuze100 related
> options.
> >> >
> >> >  Sharing code about get mac from fuse between mx7/mx8m  Sharing
> >> > code about bootaux between mx6/7/mx8m  Sharing code about cpu
> >> > speed grade between mx7/mx8m  Sharing code about get boot
> >> > device between mx7/mx8m  Sharding code about mmc env between
> >> mx7/mx8m
> >> >
> >> >  Introduce wait_mask_set/clr_timeout to avoid deadloop in clock
> >> > pll configuration
> >> >
> >> >  Correct authorship of fix building warning on fec arm64, patch 
> >> > 27/31.
> >> >
> >> >  Switch to use structure for DDR Controller. For DDR PHY
> >> > registers,  there are about more than 10 thousands registers, I
> >> > could not convert  them with detailed register name, and the
> >> > script is generated from IC team,  So I use regs[0x] arrays
> >> > here fo easily converting between IC team  released script and
> >> > uboot
> >> ddr phy cod.
> >> >
> >> >  Improve REAMME file to include where to download firmware and
> >> > imx-mkimage  and how to build
> >> >
> >> >  Add review tags on the V2 patchset.
> >> >
> >> >  Hope this patchset could catch up next release :)
> >> >
> >> > V2:
> >> >
> >> >  patch 02/23: convert to structure, drop is_boot_from_usb and
> >> >   disconnect_from_usb  patch 04/23: conver to use
> >> > structure for the clock driver, removed the
> >> >   CCM_xxx macros. Add static for local functons.
> >> >   Add init_usdhc_clk, init_uart_clk and etc to not enable
> >> >   them all at default.
> >> >  patch 05/23: Add more commit msg for the sip part.
> >> >  patch 08/23: Merge the spl boot device with i.MX7  patch 

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

2018-01-17 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
---
 MAINTAINERS  |   1 +
 drivers/mmc/Kconfig  |  14 +
 drivers/mmc/Makefile |   1 +
 drivers/mmc/bcm2835_sdhost.c | 994 +++
 4 files changed, 1010 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..ad9c7adb5a
--- /dev/null
+++ b/drivers/mmc/bcm2835_sdhost.c
@@ -0,0 +1,994 @@
+/*
+ * 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
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+#include 
+#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 card  - 16 R/W */
+#define SDARG  0x04 /* Argument to SD card - 32 R/W */
+#define SDTOUT 0x08 /* Start value for timeout counter - 32 R/W */
+#define SDCDIV 0x0c /* Start value for clock divider   - 11 R/W */
+#define SDRSP0 0x10 /* SD card response (31:0) - 32 R   */
+#define SDRSP1 0x14 /* SD card 

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

2018-01-17 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 
---
 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 | 150 +
 14 files changed, 200 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 9a6d24be22..e8df255679 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -25,3 +25,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 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
 

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

2018-01-17 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

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   | 994 +
 drivers/pinctrl/Kconfig|   1 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/broadcom/Kconfig   |   7 +
 drivers/pinctrl/broadcom/Makefile  |   7 +
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 150 +
 17 files changed, 1210 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


Re: [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 15:08, Alexander Graf  wrote:
>
>
> On 17.01.18 20:40, Simon Glass wrote:
>> Hi Alex,
>>
>> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>>> The serial devices on the raspberry pi are based on clocks we can't easily
>>> read and influence in U-Boot. However, the serial devices are always already
>>> properly set up when coming up, so all we need to do is leave them alone.
>>>
>>> The way to do that is to specify "skip-init" in device tree usually, but
>>> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
>>> that does not have skip-init properly set.
>>>
>>> So instead we just force it in board specific code. That way serial devices
>>> also work fine when skip-init is not passed explicitly in DT.
>>>
>>> Signed-off-by: Alexander Graf 
>>> ---
>>>  board/raspberrypi/rpi/rpi.c| 7 +++
>>>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>>>  drivers/serial/serial_pl01x.c  | 2 +-
>>>  3 files changed, 9 insertions(+), 2 deletions(-)
>>
>> Would you mind converting these drivers to livetree before adding these 
>> patches?
>
> Uh, why? I don't quite see how it's related - and I'm not sure I'll make
> the rc1 cut-off even with just the pile I have right now :)

I'm trying to make sure that people that touch drivers convert them,
since otherwise it won't get done. I hope we can accept v2/v3 patches
which just miss rc1.

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


Re: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 14:37, Alexander Graf  wrote:
>
>
> On 17.01.18 23:11, Simon Glass wrote:
>> Hi Alex,
>>
>> On 17 January 2018 at 15:03, Alexander Graf  wrote:
>>>
>>>
>>> On 17.01.18 20:39, Simon Glass wrote:
 Hi Alex,

 On 17 January 2018 at 00:54, Alexander Graf  wrote:
> On some boards, serial devices may or may not be muxed properly to actual
> pins, depending on firmware configuration. To determine whether we should
> use a serial device for U-Boot in-/output, we need to check whether it
> is muxed properly.
>
> This is something only the board file can do, so let's expose a weak
> function that a board can override to explicitly allow or disallow
> usage of certain serial devices.
>
> Signed-off-by: Alexander Graf 
> ---
>  drivers/serial/serial-uclass.c | 11 +++
>  include/serial.h   | 11 +++
>  2 files changed, 22 insertions(+)
>

 Can we please figure out how handle this in the serial driver / driver
 model itself? I want to avoid weak functions with driver model.
>>>
>>> I'm very happy to see suggestions :). The reason I went with the weak
>>> function is really because I couldn't think of anything better.
>>
>> The serial driver is proprietary so you should be able to put a call
>> into the pinctrl driver from that. The pinctrl driver can return the
>> state of a pin - maybe get_gpio_mux() or a new pinmux_get()?
>
> The SoC has 2 serial drivers: a proprietary one and a pl011. Would you
> think it's ok to put an architecture specific hack into the generic
> pl011 code with an #ifdef?

Normally in this situation we create an outer driver which uses the
other one - see serial_rockchip.c for example. That way the base
driver doesn't have to know about arch-specific things.

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


Re: [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 15:05, Alexander Graf  wrote:
>
>
> On 17.01.18 20:46, Simon Glass wrote:
>> Hi Alex,
>>
>> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>>> Now that we have all infrastructure in place to dynamically determine 
>>> whether
>>> a serial device is actually usable (read: routed to user accessible pins), 
>>> we
>>> can wire it up to the board.
>>>
>>> This patch adds support to determine whether the pl011 or mini-uart or no 
>>> serial
>>> is routed to the UART RX/TX pins on the Raspberry Pi family of boards.
>>>
>>> Signed-off-by: Alexander Graf 
>>> ---
>>>  board/raspberrypi/rpi/rpi.c | 69 
>>> +
>>>  1 file changed, 69 insertions(+)
>>>
>>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>>> index a96d5d8952..b0cdad70f7 100644
>>> --- a/board/raspberrypi/rpi/rpi.c
>>> +++ b/board/raspberrypi/rpi/rpi.c
>>> @@ -24,9 +24,16 @@
>>>  #include 
>>>  #endif
>>>  #include 
>>> +#include 
>>>
>>>  DECLARE_GLOBAL_DATA_PTR;
>>>
>>> +/*
>>> + * This is the GPIO pin that the user facing UART RX line is attached to.
>>> + * We use this pin to determine which serial device is available.
>>> + */
>>> +#define BCM2835_GPIO_RX15
>>> +
>>>  /* From lowlevel_init.S */
>>>  extern unsigned long fw_dtb_pointer;
>>>
>>> @@ -419,6 +426,68 @@ static void get_board_rev(void)
>>> printf("RPI %s (0x%x)\n", model->name, revision);
>>>  }
>>>
>>> +/*
>>> + * We may get called before the device model is initialized, so we can not
>>> + * rely on the GPIO driver.
>>> + */
>>> +int get_func_id(unsigned gpio)
>>> +{
>>> +   u32 val;
>>> +   u32 node;
>>> +   u32 *gpfsel;
>>> +   fdt_addr_t addr;
>>> +   fdt_size_t size;
>>> +
>>> +   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, 
>>> "brcm,bcm2835-gpio");
>>> +   if (node < 0)
>>> +   return -EINVAL;
>>> +
>>> +   addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg",
>>> + 0, , true);
>>> +   gpfsel = (void*)addr;
>>> +
>>> +   val = readl([BCM2835_GPIO_FSEL_BANK(gpio)]);
>>> +
>>> +   return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & 
>>> BCM2835_GPIO_FSEL_MASK);
>>> +}
>>
>> Ick, this should be done in the GPIO driver and use gpio_get_function().
>
> Yes, but what if users specify the serial device to be pre-reloc and
> don't do that for the GPIO (or really pinctrl) one? Then we'd not have
> the driver around to determine whether serial is active, right?

We have control of that in the DT so just need to set it up correctly.
I suppose worst case you could add the pre-reloc flag to each driver's
decl instead of in DT. But I'm not sure why the DT would be wrong.

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


Re: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable

2018-01-17 Thread Alexander Graf


On 17.01.18 23:11, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 15:03, Alexander Graf  wrote:
>>
>>
>> On 17.01.18 20:39, Simon Glass wrote:
>>> Hi Alex,
>>>
>>> On 17 January 2018 at 00:54, Alexander Graf  wrote:
 On some boards, serial devices may or may not be muxed properly to actual
 pins, depending on firmware configuration. To determine whether we should
 use a serial device for U-Boot in-/output, we need to check whether it
 is muxed properly.

 This is something only the board file can do, so let's expose a weak
 function that a board can override to explicitly allow or disallow
 usage of certain serial devices.

 Signed-off-by: Alexander Graf 
 ---
  drivers/serial/serial-uclass.c | 11 +++
  include/serial.h   | 11 +++
  2 files changed, 22 insertions(+)

>>>
>>> Can we please figure out how handle this in the serial driver / driver
>>> model itself? I want to avoid weak functions with driver model.
>>
>> I'm very happy to see suggestions :). The reason I went with the weak
>> function is really because I couldn't think of anything better.
> 
> The serial driver is proprietary so you should be able to put a call
> into the pinctrl driver from that. The pinctrl driver can return the
> state of a pin - maybe get_gpio_mux() or a new pinmux_get()?

The SoC has 2 serial drivers: a proprietary one and a pl011. Would you
think it's ok to put an architecture specific hack into the generic
pl011 code with an #ifdef?


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


Re: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 15:03, Alexander Graf  wrote:
>
>
> On 17.01.18 20:39, Simon Glass wrote:
>> Hi Alex,
>>
>> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>>> On some boards, serial devices may or may not be muxed properly to actual
>>> pins, depending on firmware configuration. To determine whether we should
>>> use a serial device for U-Boot in-/output, we need to check whether it
>>> is muxed properly.
>>>
>>> This is something only the board file can do, so let's expose a weak
>>> function that a board can override to explicitly allow or disallow
>>> usage of certain serial devices.
>>>
>>> Signed-off-by: Alexander Graf 
>>> ---
>>>  drivers/serial/serial-uclass.c | 11 +++
>>>  include/serial.h   | 11 +++
>>>  2 files changed, 22 insertions(+)
>>>
>>
>> Can we please figure out how handle this in the serial driver / driver
>> model itself? I want to avoid weak functions with driver model.
>
> I'm very happy to see suggestions :). The reason I went with the weak
> function is really because I couldn't think of anything better.

The serial driver is proprietary so you should be able to put a call
into the pinctrl driver from that. The pinctrl driver can return the
state of a pin - maybe get_gpio_mux() or a new pinmux_get()?

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


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

2018-01-17 Thread Simon Glass
On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> 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 
> Signed-off-by: Maxime Ripard 
> ---
>  env/common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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


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

2018-01-17 Thread Simon Glass
On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> The raw MMC environment directly calls into the MMC framework. Make sure
> it's enabled before we can select it.
>
> Signed-off-by: Maxime Ripard 
> ---
>  env/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

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


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

2018-01-17 Thread Simon Glass
Hi Maxime,

On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> Allow boards and architectures to override the default environment lookup
> code by overriding env_get_location.
>
> Reviewed-by: Andre Przywara 
> Reviewed-by: Lukasz Majewski 
> Signed-off-by: Maxime Ripard 
> ---
>  env/env.c | 20 +++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>

I still don't really understand why this needs to be a weak function.
If the board knows the priority order, can it not put it into
global_data? We could have a little u8 array of 4 items with a
terminator?

> diff --git a/env/env.c b/env/env.c
> index 75da2b921804..6d0ab8ebe1a4 100644
> --- a/env/env.c
> +++ b/env/env.c
> @@ -79,7 +79,25 @@ static void env_set_inited(enum env_location location)
>
>  static enum env_location env_load_location;
>
> -static enum env_location env_get_location(enum env_operation op, int prio)
> +/**
> + * 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. 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
> + * 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
> + */
> +__weak enum env_location env_get_location(enum env_operation op, int prio)
>  {
> switch (op) {
> case ENVOP_GET_CHAR:
> --
> git-series 0.9.1

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


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

2018-01-17 Thread Simon Glass
On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> 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.
>
> Signed-off-by: Maxime Ripard 
> ---
>  env/env.c | 36 +---
>  include/asm-generic/global_data.h |  1 +-
>  2 files changed, 30 insertions(+), 7 deletions(-)

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


Re: [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices

2018-01-17 Thread Alexander Graf


On 17.01.18 20:40, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>> The serial devices on the raspberry pi are based on clocks we can't easily
>> read and influence in U-Boot. However, the serial devices are always already
>> properly set up when coming up, so all we need to do is leave them alone.
>>
>> The way to do that is to specify "skip-init" in device tree usually, but
>> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
>> that does not have skip-init properly set.
>>
>> So instead we just force it in board specific code. That way serial devices
>> also work fine when skip-init is not passed explicitly in DT.
>>
>> Signed-off-by: Alexander Graf 
>> ---
>>  board/raspberrypi/rpi/rpi.c| 7 +++
>>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>>  drivers/serial/serial_pl01x.c  | 2 +-
>>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> Would you mind converting these drivers to livetree before adding these 
> patches?

Uh, why? I don't quite see how it's related - and I'm not sure I'll make
the rc1 cut-off even with just the pile I have right now :)


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


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

2018-01-17 Thread Simon Glass
On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> 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 
> Signed-off-by: Maxime Ripard 
> ---
>  env/mmc.c | 1 -
>  1 file changed, 1 deletion(-)

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


Re: [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active

2018-01-17 Thread Alexander Graf


On 17.01.18 20:46, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>> Now that we have all infrastructure in place to dynamically determine whether
>> a serial device is actually usable (read: routed to user accessible pins), we
>> can wire it up to the board.
>>
>> This patch adds support to determine whether the pl011 or mini-uart or no 
>> serial
>> is routed to the UART RX/TX pins on the Raspberry Pi family of boards.
>>
>> Signed-off-by: Alexander Graf 
>> ---
>>  board/raspberrypi/rpi/rpi.c | 69 
>> +
>>  1 file changed, 69 insertions(+)
>>
>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>> index a96d5d8952..b0cdad70f7 100644
>> --- a/board/raspberrypi/rpi/rpi.c
>> +++ b/board/raspberrypi/rpi/rpi.c
>> @@ -24,9 +24,16 @@
>>  #include 
>>  #endif
>>  #include 
>> +#include 
>>
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>> +/*
>> + * This is the GPIO pin that the user facing UART RX line is attached to.
>> + * We use this pin to determine which serial device is available.
>> + */
>> +#define BCM2835_GPIO_RX15
>> +
>>  /* From lowlevel_init.S */
>>  extern unsigned long fw_dtb_pointer;
>>
>> @@ -419,6 +426,68 @@ static void get_board_rev(void)
>> printf("RPI %s (0x%x)\n", model->name, revision);
>>  }
>>
>> +/*
>> + * We may get called before the device model is initialized, so we can not
>> + * rely on the GPIO driver.
>> + */
>> +int get_func_id(unsigned gpio)
>> +{
>> +   u32 val;
>> +   u32 node;
>> +   u32 *gpfsel;
>> +   fdt_addr_t addr;
>> +   fdt_size_t size;
>> +
>> +   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, 
>> "brcm,bcm2835-gpio");
>> +   if (node < 0)
>> +   return -EINVAL;
>> +
>> +   addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg",
>> + 0, , true);
>> +   gpfsel = (void*)addr;
>> +
>> +   val = readl([BCM2835_GPIO_FSEL_BANK(gpio)]);
>> +
>> +   return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & 
>> BCM2835_GPIO_FSEL_MASK);
>> +}
> 
> Ick, this should be done in the GPIO driver and use gpio_get_function().

Yes, but what if users specify the serial device to be pre-reloc and
don't do that for the GPIO (or really pinctrl) one? Then we'd not have
the driver around to determine whether serial is active, right?


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


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

2018-01-17 Thread Simon Glass
Hi Maxime,

On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> 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 | 135 +++
>  include/environment.h |   8 +++-
>  2 files changed, 94 insertions(+), 49 deletions(-)
>
> diff --git a/env/env.c b/env/env.c
> index 97ada5b5a6fd..4dc39b384c1e 100644
> --- a/env/env.c
> +++ b/env/env.c
> @@ -26,8 +26,11 @@ static struct env_driver *_env_driver_lookup(enum 
> env_location loc)
> return NULL;
>  }
>
> -static enum env_location env_get_location(void)
> +static enum env_location env_get_location(enum env_operation op, int prio)

Please add a function comment, including why @op is needed.

>  {
> +   if (prio >= 1)
> +   return ENVL_UNKNOWN;

What is this for? Can you please add a comment?

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


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

2018-01-17 Thread Simon Glass
Hi Maxime,

On 16 January 2018 at 01:16, Maxime Ripard
 wrote:
> 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(-)

Do you have a change log for this patch?

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


Re: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable

2018-01-17 Thread Alexander Graf


On 17.01.18 20:39, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>> On some boards, serial devices may or may not be muxed properly to actual
>> pins, depending on firmware configuration. To determine whether we should
>> use a serial device for U-Boot in-/output, we need to check whether it
>> is muxed properly.
>>
>> This is something only the board file can do, so let's expose a weak
>> function that a board can override to explicitly allow or disallow
>> usage of certain serial devices.
>>
>> Signed-off-by: Alexander Graf 
>> ---
>>  drivers/serial/serial-uclass.c | 11 +++
>>  include/serial.h   | 11 +++
>>  2 files changed, 22 insertions(+)
>>
> 
> Can we please figure out how handle this in the serial driver / driver
> model itself? I want to avoid weak functions with driver model.

I'm very happy to see suggestions :). The reason I went with the weak
function is really because I couldn't think of anything better.


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


Re: [U-Boot] [PATCH v2 1/7] serial: Use next serial device if probing fails

2018-01-17 Thread Alexander Graf


On 17.01.18 20:34, Simon Glass wrote:
> On 17 January 2018 at 00:54, Alexander Graf  wrote:
>> Currently our serial device search chokes on the fact that the serial
>> probe function could fail. If it does, instead of searching for the next
>> usable serial device, it just quits.
>>
>> This patch changes the fallback logic so that even when a serial device
>> was not probed correctly, we just try the next ones until we find one that
>> works.
>>
>> Signed-off-by: Alexander Graf 
>>
>> ---
>>
>> v1 -> v2:
>>
>>   - Make search logic easier to follow
>> ---
>>  drivers/serial/serial-uclass.c | 25 +++--
>>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> Reviewed-by: Simon Glass 
> 
> The fallback logic is getting more complicated. How come the DT does
> not specify the correct console?

By default the DT on the RPi does not specify any serial console.
However, users have grown accustomed to the fact that there is indeed
one :).

I guess it all boils down to the fact that Linux is terrible when it
comes to console selection. 99.9% of users that want a serial console
and have a graphical screen want to have *both* available as first class
citizen consoles. But Linux just can't do that, so we have a lot of
crude hacks all over the place.


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


Re: [U-Boot] [PATCH] ubi: Fix filesystem corruption on detach when fastmap enabled

2018-01-17 Thread Martin Townsend
Hi,


On Wed, Jan 17, 2018 at 3:47 PM, Richard Weinberger
 wrote:
> Martin,
>
> Am Dienstag, 16. Januar 2018, 15:13:04 CET schrieb Martin Townsend:
>> > Martin, can you please explain what corruption you see?
>> > From reading the code I'd assume that you miss volumes but a full scan
>> > would recover everything.
>>
>> I didn't do much analysis of the corruption I'm afraid.  When I tried
>> to reattach the the c->empty flag was set to true and indeed all the
>> EBA tables were reporting an empty filesystem even after a reboot.
>
> Sounds like what I'd expect.
>
>> Not sure if this was recoverable, how do you trigger a full scan?
>
> Booting a kernel without Fastmap support. B-)
>
>> > For Linux I suggest this fix:
>> >
>> > From 48287459cf8717cffac5aed423937cd7ba4360ab Mon Sep 17 00:00:00 2001
>> > From: Richard Weinberger 
>> > Date: Tue, 16 Jan 2018 14:12:46 +0100
>> > Subject: [PATCH] ubi: fastmap: Don't flush fastmap work on detach
>> >
>> > At this point UBI volumes have already been free()'ed and fastmap can no
>> > longer access these data structures.
>> >
>> > Fixes: 74cdaf24004a ("UBI: Fastmap: Fix memory leaks while closing the WL
>> > sub- system")
>> > Signed-off-by: Richard Weinberger 
>> > Cc: sta...@vger.kernel.org
>> > ---
>> >
>> >  drivers/mtd/ubi/fastmap-wl.c | 1 -
>> >  1 file changed, 1 deletion(-)
>> >
>> > diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
>> > index 4f0bd6b4422a..69dd21679a30 100644
>> > --- a/drivers/mtd/ubi/fastmap-wl.c
>> > +++ b/drivers/mtd/ubi/fastmap-wl.c
>> > @@ -362,7 +362,6 @@ static void ubi_fastmap_close(struct ubi_device *ubi)
>> >
>> >  {
>> >
>> > int i;
>> >
>> > -   flush_work(>fm_work);
>> >
>> > return_unused_pool_pebs(ubi, >fm_pool);
>> > return_unused_pool_pebs(ubi, >fm_wl_pool);
>> >
>> > --
>> > 2.13.6
>> >
>> > In U-Boot you can do the same.
>>
>> Richard: This will work but just want to check that ubi_wl_close is
>> supposed to never write out to the filesystem or will never do so in
>> future, if so maybe a something in the comments above ubi_wl_close to
>> ensure this?
>
> Hmm, not sure if I got this question.
> The filesystem sits above UBI. If we reach ubi_wl_close() all users ontop of
> UBI are gone. There is no UBIFS mounted anymore.
>

Thanks for clarifying, I'll submit a version 2 patch that replicates
this for U-Boot.

> Thanks,
> //richard
>
> --
> sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
> ATU66964118 - FN 374287y
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] bcm2835_gpio: Add support for pinmux

2018-01-17 Thread Alexander Graf


On 17.01.18 10:26, Amit Tomer wrote:
> Hi,
> 
>> +   val = readl(>reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
>> +   val &= ~(BCM2835_GPIO_FSEL_MASK << BCM2835_GPIO_FSEL_SHIFT(gpio));
>> +   val |= (func << BCM2835_GPIO_FSEL_SHIFT(gpio));
>> +   writel(val, >reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
> 
> Can clrsetbits_le32 be used here ?

Yeah, thanks for the suggestion!

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


Re: [U-Boot] [PATCH 3/3] mmc: bcm2835_sdhci: Add pinmux support

2018-01-17 Thread Alexander Graf


On 17.01.18 21:06, Simon Glass wrote:
> Hi Alex,
> 
> On 16 January 2018 at 05:46, Alexander Graf  wrote:
>> The bcm2835 firmware provided device trees expect device tree users
>> to support pin muxing for the SD devices to work properly.
>>
>> This patch adds pin muxing support to the sdhci based SD controller
>> on said family of SoCs, so that its pins are getting configured
>> correctly on boot.
>>
>> Signed-off-by: Alexander Graf 
>> ---
>>  drivers/mmc/bcm2835_sdhci.c | 11 +++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
>> index 3157354d2a..62ad109361 100644
>> --- a/drivers/mmc/bcm2835_sdhci.c
>> +++ b/drivers/mmc/bcm2835_sdhci.c
>> @@ -45,6 +45,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  /* 400KHz is max freq for card ID etc. Use that as min */
>>  #define MIN_FREQ 40
>> @@ -178,6 +179,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
>> fdt_addr_t base;
>> int emmc_freq;
>> int ret;
>> +   int pinctrl_handle;
>>
>> base = devfdt_get_addr(dev);
>> if (base == FDT_ADDR_T_NONE)
>> @@ -190,6 +192,15 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
>> }
>> emmc_freq = ret;
>>
>> +   pinctrl_handle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), 
>> "pinctrl-0", -1);
> 
> You can't do this sort of thing :-)
> 
> This should go in a pinctrl driver. The clue is that you are having to
> look up things manually here. You can create a basic driver very
> easily.

Yup, that's basically what I've spent today on :). Unfortunately my RPi
seems to corrupt its U-Boot binary on boot every so often, so some times
I end up with an unbootable system and I've been unable to actually
trace it down for real yet. For example some times I get weird
corruptions in the .dyn.rel section.

Either way, I've switched to network boot now, let's hope that makes
life easier. If things work out I'll send a new version tomorrow with an
actual pinmux driver that then instantiates the existing GPIO one as a
child (so that the pinmux one gets autoloaded).


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


Re: [U-Boot] X86 Broadwell-DE override FSP configuration

2018-01-17 Thread vnktux
Thank you Bin,

I managed to fully boot Broadwell-DE on platform with memory down enabled :)

Now before submitting the patch I have to solve a small problem.
In either case memory down is enable or not the booting process takes 1 hour 
and 20 minutes. On the output there are no error at all. I tried to 
enable/disable fastboot and  MRC but this didn't solve the problem.

Sent with [ProtonMail](https://protonmail.com) Secure Email.

 Original Message 
On 16 January 2018 2:01 PM, Bin Meng  wrote:

> +ML
>
> Hi Vincenzo,
>
> On Tue, Jan 16, 2018 at 8:21 PM, vnktux vnk...@protonmail.com wrote:
>
>> Hi all,
>> I managed to fully boot a bare metal U-Boot on the Intel Camelback Mountain
>> CRB (Broadwell-DE).
>
> This is great!
>
>> However I have a small problem, basically U-Boot does not override the FSP
>> UPD data when the platform boot.
>
> U-Boot can override the FSP UPD data.
>
>> For prototyping I am using a patched FSP binary I got in the company where I
>> work. Now that it boot on the camelback mountain I need it to run on another
>> platform (also broadwell-de) that has memory down installed on the
>> motherboard. That should be easy, all I have to do is to enable memory down
>> in the fsp_config.c file and provide the address of the SPD binary file. I
>> have done that, but for some reason it doesn't work. During the booting
>> process the platform give an error about the Dimm module not being
>> supported. That make sense since the pached FSP binary I am using has memory
>> down disabled. The part I don't understand is why U-Boot doesnt override the
>> UPD settings specified in my fsp_config.c file.
>> Below you will find my implementation, can somebody explain me what am I
>> doing wrong?
>> https://raw.githubusercontent.com/WarOfDevil/u-boot.x86_64-broadwell-de/master/arch/x86/cpu/broadwell-de/fsp_configs.c
>> https://raw.githubusercontent.com/WarOfDevil/u-boot.x86_64-broadwell-de/master/arch/x86/dts/poseidon.dts
>
> It looks you have commented out the FSP node in the device tree, then
> your fsp_configs.c won't do the UPD override.
>
>> Once I manage to make this work, I can create a patch for U-Boot.
>
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] clk: clk_stm32f: Remove STMMAC clock setup

2018-01-17 Thread Vikas Manocha
Hi,

On 01/17/2018 12:46 AM, patrice.chot...@st.com wrote:
> From: Patrice Chotard 
> 
> Thanks to 'commit ba1f96672522 ("net: designware: add clock support")'
> we don't need anymore to setup the STMMAC clock in board.
> 
> Signed-off-by: Patrice Chotard 

Reviewed-by: Vikas Manocha 

Cheers,
Vikas

> ---
>  arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 -
>  board/st/stm32f746-disco/stm32f746-disco.c   | 1 -
>  drivers/clk/clk_stm32f.c | 6 --
>  3 files changed, 8 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h 
> b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> index ae0faef..13f9c9b 100644
> --- a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> +++ b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> @@ -23,7 +23,6 @@ enum periph_id {
>  enum periph_clock {
>   SYSCFG_CLOCK_CFG,
>   TIMER2_CLOCK_CFG,
> - STMMAC_CLOCK_CFG,
>  };
>  
>  #endif /* __ASM_ARM_ARCH_PERIPH_H */
> diff --git a/board/st/stm32f746-disco/stm32f746-disco.c 
> b/board/st/stm32f746-disco/stm32f746-disco.c
> index 2e8aa86..58a5ef0 100644
> --- a/board/st/stm32f746-disco/stm32f746-disco.c
> +++ b/board/st/stm32f746-disco/stm32f746-disco.c
> @@ -75,7 +75,6 @@ static int stmmac_setup(void)
>   clock_setup(SYSCFG_CLOCK_CFG);
>   /* Set >RMII mode */
>   STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
> - clock_setup(STMMAC_CLOCK_CFG);
>  
>   return 0;
>  }
> diff --git a/drivers/clk/clk_stm32f.c b/drivers/clk/clk_stm32f.c
> index 63116e0..d0c7a90 100644
> --- a/drivers/clk/clk_stm32f.c
> +++ b/drivers/clk/clk_stm32f.c
> @@ -90,7 +90,6 @@
>  enum periph_clock {
>   SYSCFG_CLOCK_CFG,
>   TIMER2_CLOCK_CFG,
> - STMMAC_CLOCK_CFG,
>  };
>  
>  struct stm32_clk_info stm32f4_clk_info = {
> @@ -359,11 +358,6 @@ void clock_setup(int peripheral)
>   case TIMER2_CLOCK_CFG:
>   setbits_le32(_RCC->apb1enr, RCC_APB1ENR_TIM2EN);
>   break;
> - case STMMAC_CLOCK_CFG:
> - setbits_le32(_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_EN);
> - setbits_le32(_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_RX_EN);
> - setbits_le32(_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_TX_EN);
> - break;
>   default:
>   break;
>   }
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()

2018-01-17 Thread Vikas Manocha
Hi Patrice,

On 01/17/2018 12:46 AM, patrice.chot...@st.com wrote:
> From: Patrice Chotard 
> 
> Move SYSCFG clock setup into configure_clocks() instead of calling
> clock_setup() from drivers.

It is in board configuration.

> Move the RMII setup from board_early_init_f() to board_init()
> to insure that RMII bit is set only when clock driver is initialized.
> 
> Signed-off-by: Patrice Chotard 
> ---
>  arch/arm/include/asm/arch-stm32f7/stm32_periph.h |  1 -
>  board/st/stm32f746-disco/stm32f746-disco.c   | 19 ++-
>  drivers/clk/clk_stm32f.c | 10 --
>  3 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h 
> b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> index 13f9c9b..7b8f66a 100644
> --- a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> +++ b/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
> @@ -21,7 +21,6 @@ enum periph_id {
>  };
>  
>  enum periph_clock {
> - SYSCFG_CLOCK_CFG,
>   TIMER2_CLOCK_CFG,
>  };
>  
> diff --git a/board/st/stm32f746-disco/stm32f746-disco.c 
> b/board/st/stm32f746-disco/stm32f746-disco.c
> index 58a5ef0..8da7028 100644
> --- a/board/st/stm32f746-disco/stm32f746-disco.c
> +++ b/board/st/stm32f746-disco/stm32f746-disco.c
> @@ -69,23 +69,10 @@ int dram_init_banksize(void)
>   return 0;
>  }
>  
> -#ifdef CONFIG_ETH_DESIGNWARE
> -static int stmmac_setup(void)
> -{
> - clock_setup(SYSCFG_CLOCK_CFG);
> - /* Set >RMII mode */
> - STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
> -
> - return 0;
> -}
> -
>  int board_early_init_f(void)
>  {
> - stmmac_setup();
> -
>   return 0;
>  }
> -#endif
>  
>  #ifdef CONFIG_SPL_BUILD
>  #ifdef CONFIG_SPL_OS_BOOT
> @@ -162,5 +149,11 @@ int board_late_init(void)
>  int board_init(void)
>  {
>   gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
> +
> +#ifdef CONFIG_ETH_DESIGNWARE
> + /* Set >RMII mode */
> + STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
> +#endif
> +
>   return 0;
>  }
> diff --git a/drivers/clk/clk_stm32f.c b/drivers/clk/clk_stm32f.c
> index d0c7a90..1ae5b70 100644
> --- a/drivers/clk/clk_stm32f.c
> +++ b/drivers/clk/clk_stm32f.c
> @@ -67,8 +67,6 @@
>  #define RCC_DCKCFGRX_SDMMC1SEL   BIT(28)
>  #define RCC_DCKCFGR2_SDMMC2SEL   BIT(29)
>  
> -#define RCC_APB2ENR_SAI1EN   BIT(22)
> -
>  /*
>   * RCC AHB1ENR specific definitions
>   */
> @@ -86,9 +84,9 @@
>   * RCC APB2ENR specific definitions
>   */
>  #define RCC_APB2ENR_SYSCFGEN BIT(14)
> +#define RCC_APB2ENR_SAI1EN   BIT(22)
>  
>  enum periph_clock {
> - SYSCFG_CLOCK_CFG,
>   TIMER2_CLOCK_CFG,
>  };
>  
> @@ -227,6 +225,9 @@ static int configure_clocks(struct udevice *dev)
>   /* gate the SAI clock, needed for MMC 1&2 clocks */
>   setbits_le32(>apb2enr, RCC_APB2ENR_SAI1EN);
>  
> + /* gate the SYSCFG clock, needed to set RMII ethernet interface */

RMII interface only required for f746 disco board.

> + setbits_le32(>apb2enr, RCC_APB2ENR_SYSCFGEN);

RMII & Syscfg is board specific requirement, here it will configure it for all 
stm32f devices.

Cheers,
Vikas

> +
>   return 0;
>  }
>  
> @@ -352,9 +353,6 @@ static int stm32_clk_enable(struct clk *clk)
>  void clock_setup(int peripheral)
>  {
>   switch (peripheral) {
> - case SYSCFG_CLOCK_CFG:
> - setbits_le32(_RCC->apb2enr, RCC_APB2ENR_SYSCFGEN);
> - break;
>   case TIMER2_CLOCK_CFG:
>   setbits_le32(_RCC->apb1enr, RCC_APB1ENR_TIM2EN);
>   break;
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] bcm2835_gpio: Add support for pinmux

2018-01-17 Thread Simon Glass
Hi Alex,

On 16 January 2018 at 05:46, Alexander Graf  wrote:
> On the bcm2835 the GPIO IP block is responsible to control pin muxing
> of the configurable pins on the chip.
>
> This adds a simple helper function that allows a device driver to set
> pin muxing according to device tree configuration on those devices.
>
> Signed-off-by: Alexander Graf 
> ---
>  arch/arm/mach-bcm283x/include/mach/gpio.h |  1 +
>  drivers/gpio/bcm2835_gpio.c   | 40 
> +++
>  2 files changed, 41 insertions(+)
>
> diff --git a/arch/arm/mach-bcm283x/include/mach/gpio.h 
> b/arch/arm/mach-bcm283x/include/mach/gpio.h
> index daaee52f81..751594d09f 100644
> --- a/arch/arm/mach-bcm283x/include/mach/gpio.h
> +++ b/arch/arm/mach-bcm283x/include/mach/gpio.h
> @@ -62,5 +62,6 @@ struct bcm2835_gpio_platdata {
>  };
>
>  int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio);
> +void bcm2835_gpio_set_pinmux(struct udevice *dev, int handle);
>
>  #endif /* _BCM2835_GPIO_H_ */
> diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c
> index beaa21853a..209cbed9e6 100644
> --- a/drivers/gpio/bcm2835_gpio.c
> +++ b/drivers/gpio/bcm2835_gpio.c
> @@ -83,6 +83,46 @@ int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned 
> gpio)
> return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & 
> BCM2835_GPIO_FSEL_MASK);
>  }
>
> +static void bcm2835_gpio_set_func_id(struct udevice *dev, unsigned gpio, int 
> func)
> +{
> +   struct bcm2835_gpios *gpios = dev_get_priv(dev);
> +   u32 val;
> +
> +   val = readl(>reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
> +   val &= ~(BCM2835_GPIO_FSEL_MASK << BCM2835_GPIO_FSEL_SHIFT(gpio));
> +   val |= (func << BCM2835_GPIO_FSEL_SHIFT(gpio));
> +   writel(val, >reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
> +}
> +
> +void bcm2835_gpio_set_pinmux(struct udevice *dev, int handle)
> +{
> +   int node = fdt_node_offset_by_phandle(gd->fdt_blob, handle);
> +   u32 pins[16];
> +   int len;
> +   u32 func;
> +   int i;
> +
> +   if (!node)
> +   goto err;
> +
> +   func = fdtdec_get_int(gd->fdt_blob, node, "brcm,function", -1);
> +   if (func <= 0)
> +   goto err;
> +
> +   len = fdtdec_get_int_array_count(gd->fdt_blob, node, "brcm,pins", 
> pins,
> +ARRAY_SIZE(pins));
> +   if (len <= 0)
> +   goto err;
> +
> +   for (i = 0; i < len; i++)
> +   bcm2835_gpio_set_func_id(dev, pins[i], func);
> +
> +   return;
> +err:
> +   printf("Failed to pinmux phandle 0x%x\n", handle);
> +   return;
> +}

This should use livetree functions and I'm pretty sure it should go in
a pinctrl driver, not GPIO.

> +
>  static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
>  {
> int funcid = bcm2835_gpio_get_func_id(dev, offset);
> --
> 2.12.3
>

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


Re: [U-Boot] [PATCH 3/3] mmc: bcm2835_sdhci: Add pinmux support

2018-01-17 Thread Simon Glass
Hi Alex,

On 16 January 2018 at 05:46, Alexander Graf  wrote:
> The bcm2835 firmware provided device trees expect device tree users
> to support pin muxing for the SD devices to work properly.
>
> This patch adds pin muxing support to the sdhci based SD controller
> on said family of SoCs, so that its pins are getting configured
> correctly on boot.
>
> Signed-off-by: Alexander Graf 
> ---
>  drivers/mmc/bcm2835_sdhci.c | 11 +++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
> index 3157354d2a..62ad109361 100644
> --- a/drivers/mmc/bcm2835_sdhci.c
> +++ b/drivers/mmc/bcm2835_sdhci.c
> @@ -45,6 +45,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /* 400KHz is max freq for card ID etc. Use that as min */
>  #define MIN_FREQ 40
> @@ -178,6 +179,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
> fdt_addr_t base;
> int emmc_freq;
> int ret;
> +   int pinctrl_handle;
>
> base = devfdt_get_addr(dev);
> if (base == FDT_ADDR_T_NONE)
> @@ -190,6 +192,15 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
> }
> emmc_freq = ret;
>
> +   pinctrl_handle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), 
> "pinctrl-0", -1);

You can't do this sort of thing :-)

This should go in a pinctrl driver. The clue is that you are having to
look up things manually here. You can create a basic driver very
easily.

> +   if (pinctrl_handle != -1) {
> +   struct udevice *dev;
> +
> +   /* Need to set up pinmuxing */
> +   if (!uclass_first_device(UCLASS_GPIO, ) && dev)
> +   bcm2835_gpio_set_pinmux(dev, pinctrl_handle);
> +   }
> +
> /*
>  * See the comments in bcm2835_sdhci_raw_writel().
>  *
> --
> 2.12.3
>

Regards,
Simon
___
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-17 Thread Simon Glass
On 15 January 2018 at 22:33, 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(+)

Reviewed-by: Simon Glass 
___
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-17 Thread Simon Glass
On 15 January 2018 at 22:33, 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(+)

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


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

2018-01-17 Thread Simon Glass
On 15 January 2018 at 22:33, 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

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


Re: [U-Boot] [PATCH 1/3] ARM: dts: stm32: Add STMMAC clocks for stm32f746

2018-01-17 Thread Vikas Manocha
Hi,

On 01/17/2018 12:46 AM, patrice.chot...@st.com wrote:
> From: Patrice Chotard 
> 
> Add ETHMAC, ETHMACRX and ETHMACTX clocks for STMMAC.
> 
> Signed-off-by: Patrice Chotard 

Reviewed-by: Vikas Manocha 

Cheers,
Vikas

> ---
>  arch/arm/dts/stm32f746.dtsi | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/dts/stm32f746.dtsi b/arch/arm/dts/stm32f746.dtsi
> index 929bf82..46d148e 100644
> --- a/arch/arm/dts/stm32f746.dtsi
> +++ b/arch/arm/dts/stm32f746.dtsi
> @@ -65,6 +65,9 @@
>   compatible = "st,stm32-dwmac";
>   reg = <0x40028000 0x8000>;
>   reg-names = "stmmaceth";
> + clocks = < 0 STM32F7_AHB1_CLOCK(ETHMAC)>,
> +  < 0 STM32F7_AHB1_CLOCK(ETHMACTX)>,
> +  < 0 STM32F7_AHB1_CLOCK(ETHMACRX)>;
>   interrupts = <61>, <62>;
>   interrupt-names = "macirq", "eth_wake_irq";
>   snps,pbl = <8>;
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 00:54, Alexander Graf  wrote:
> Now that we have all infrastructure in place to dynamically determine whether
> a serial device is actually usable (read: routed to user accessible pins), we
> can wire it up to the board.
>
> This patch adds support to determine whether the pl011 or mini-uart or no 
> serial
> is routed to the UART RX/TX pins on the Raspberry Pi family of boards.
>
> Signed-off-by: Alexander Graf 
> ---
>  board/raspberrypi/rpi/rpi.c | 69 
> +
>  1 file changed, 69 insertions(+)
>
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index a96d5d8952..b0cdad70f7 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -24,9 +24,16 @@
>  #include 
>  #endif
>  #include 
> +#include 
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> +/*
> + * This is the GPIO pin that the user facing UART RX line is attached to.
> + * We use this pin to determine which serial device is available.
> + */
> +#define BCM2835_GPIO_RX15
> +
>  /* From lowlevel_init.S */
>  extern unsigned long fw_dtb_pointer;
>
> @@ -419,6 +426,68 @@ static void get_board_rev(void)
> printf("RPI %s (0x%x)\n", model->name, revision);
>  }
>
> +/*
> + * We may get called before the device model is initialized, so we can not
> + * rely on the GPIO driver.
> + */
> +int get_func_id(unsigned gpio)
> +{
> +   u32 val;
> +   u32 node;
> +   u32 *gpfsel;
> +   fdt_addr_t addr;
> +   fdt_size_t size;
> +
> +   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, 
> "brcm,bcm2835-gpio");
> +   if (node < 0)
> +   return -EINVAL;
> +
> +   addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg",
> + 0, , true);
> +   gpfsel = (void*)addr;
> +
> +   val = readl([BCM2835_GPIO_FSEL_BANK(gpio)]);
> +
> +   return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & 
> BCM2835_GPIO_FSEL_MASK);
> +}

Ick, this should be done in the GPIO driver and use gpio_get_function().

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


Re: [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 00:54, Alexander Graf  wrote:
> The serial devices on the raspberry pi are based on clocks we can't easily
> read and influence in U-Boot. However, the serial devices are always already
> properly set up when coming up, so all we need to do is leave them alone.
>
> The way to do that is to specify "skip-init" in device tree usually, but
> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
> that does not have skip-init properly set.
>
> So instead we just force it in board specific code. That way serial devices
> also work fine when skip-init is not passed explicitly in DT.
>
> Signed-off-by: Alexander Graf 
> ---
>  board/raspberrypi/rpi/rpi.c| 7 +++
>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>  drivers/serial/serial_pl01x.c  | 2 +-
>  3 files changed, 9 insertions(+), 2 deletions(-)

Would you mind converting these drivers to livetree before adding these patches?

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


Re: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable

2018-01-17 Thread Simon Glass
Hi Alex,

On 17 January 2018 at 00:54, Alexander Graf  wrote:
> On some boards, serial devices may or may not be muxed properly to actual
> pins, depending on firmware configuration. To determine whether we should
> use a serial device for U-Boot in-/output, we need to check whether it
> is muxed properly.
>
> This is something only the board file can do, so let's expose a weak
> function that a board can override to explicitly allow or disallow
> usage of certain serial devices.
>
> Signed-off-by: Alexander Graf 
> ---
>  drivers/serial/serial-uclass.c | 11 +++
>  include/serial.h   | 11 +++
>  2 files changed, 22 insertions(+)
>

Can we please figure out how handle this in the serial driver / driver
model itself? I want to avoid weak functions with driver model.

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


Re: [U-Boot] [PATCH v2 1/7] serial: Use next serial device if probing fails

2018-01-17 Thread Simon Glass
On 17 January 2018 at 00:54, Alexander Graf  wrote:
> Currently our serial device search chokes on the fact that the serial
> probe function could fail. If it does, instead of searching for the next
> usable serial device, it just quits.
>
> This patch changes the fallback logic so that even when a serial device
> was not probed correctly, we just try the next ones until we find one that
> works.
>
> Signed-off-by: Alexander Graf 
>
> ---
>
> v1 -> v2:
>
>   - Make search logic easier to follow
> ---
>  drivers/serial/serial-uclass.c | 25 +++--
>  1 file changed, 19 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass 

The fallback logic is getting more complicated. How come the DT does
not specify the correct console?

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


[U-Boot] [PATCH v2 15/18] tools: provide a tool to convert a binary file to an include

2018-01-17 Thread Heinrich Schuchardt
For testing EFI disk management we need an in-memory image of
a disk.

The tool file2include converts a file to a C include. The file
is separated into strings of 8 bytes. Only the non-zero strings
are written to the include. The output format has been designed
to maintain readability.

 #define EFI_ST_DISK_IMG { 0x0001, { \
  {0x01b8, "\x94\x37\x69\xfc\x00\x00\x00\x00"}, /* .7i. */ \
  {0x01c0, "\x02\x00\x83\x02\x02\x00\x01\x00"}, /*  */ \
  {0x01c8, "\x00\x00\x7f\x00\x00\x00\x00\x00"}, /*  */ \
  {0x01f8, "\x00\x00\x00\x00\x00\x00\x55\xaa"}, /* ..U. */ \
 ...
  {0x6000, "\x48\x65\x6c\x6c\x6f\x20\x77\x6f"}, /* Hello wo */ \
  {0x6008, "\x72\x6c\x64\x21\x0a\x00\x00\x00"}, /* rld! */ \
  {0, NULL} } }

As the disk image needed for testing contains mostly zeroes a high
compression ratio can be attained.

Signed-off-by: Heinrich Schuchardt 
---
v2
Add .gitignore entry for tools/file2include
---
 MAINTAINERS  |   1 +
 tools/.gitignore |   1 +
 tools/Makefile   |   3 ++
 tools/file2include.c | 106 +++
 4 files changed, 111 insertions(+)
 create mode 100644 tools/file2include.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e399008e23..d459153503 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -290,6 +290,7 @@ F:  include/efi*
 F: lib/efi*/
 F: test/py/tests/test_efi*
 F: cmd/bootefi.c
+F: tools/file2include.c
 
 FLATTENED DEVICE TREE
 M: Simon Glass 
diff --git a/tools/.gitignore b/tools/.gitignore
index 6a487d2202..c8cdaef90c 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -6,6 +6,7 @@
 /easylogo/easylogo
 /envcrc
 /fdtgrep
+/file2include
 /fit_check_sign
 /fit_info
 /gdb/gdbcont
diff --git a/tools/Makefile b/tools/Makefile
index 571f571ec9..b7d7d418ee 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -57,6 +57,8 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
 hostprogs-y += dumpimage mkimage
 hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign
 
+hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include
+
 FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o
 
 # The following files are synced with upstream DTC.
@@ -118,6 +120,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
 mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
 fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
 fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
+file2include-objs := file2include.o
 
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
diff --git a/tools/file2include.c b/tools/file2include.c
new file mode 100644
index 00..9145f0845a
--- /dev/null
+++ b/tools/file2include.c
@@ -0,0 +1,106 @@
+/*
+ * Convert a file image to a C define
+ *
+ * Copyright (c) 2017 Heinrich Schuchardt 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * For testing EFI disk management we need an in memory image of
+ * a disk.
+ *
+ * The tool file2include converts a file to a C include. The file
+ * is separated into strings of 8 bytes. Only the non-zero strings
+ * are written to the include. The output format has been designed
+ * to maintain readability.
+ *
+ * As the disk image needed for testing contains mostly zeroes a high
+ * compression ratio can be attained.
+ */
+#include 
+#include 
+#include 
+#include 
+
+/* Size of the blocks written to the compressed file */
+#define BLOCK_SIZE 8
+
+int main(int argc, char *argv[])
+{
+   FILE *file;
+   int ret;
+   unsigned char *buf;
+   size_t count, i, j;
+
+   /* Provide usage help */
+   if (argc != 2) {
+   printf("Usage:\n%s FILENAME\n", argv[0]);
+   return EXIT_FAILURE;
+   }
+   /* Open file */
+   file = fopen(argv[1], "r");
+   if (!file) {
+   perror("fopen");
+   return EXIT_FAILURE;
+   }
+   /* Get file length */
+   ret = fseek(file, 0, SEEK_END);
+   if (ret < 0) {
+   perror("fseek");
+   return EXIT_FAILURE;
+   }
+   count = ftell(file);
+   if (!count) {
+   fprintf(stderr, "File %s has length 0\n", argv[1]);
+   return EXIT_FAILURE;
+   }
+   rewind(file);
+   /* Read file */
+   buf = malloc(count);
+   if (!buf) {
+   perror("calloc");
+   return EXIT_FAILURE;
+   }
+   count = fread(buf, 1, count, file);
+
+   /* Generate output */
+   printf("/*\n");
+   printf(" *  Non-zero %u byte strings of a disk image\n", BLOCK_SIZE);
+   printf(" *\n");
+   printf(" *  Generated with tools/file2include\n");
+   printf(" *\n");
+   printf(" *  SPDX-License-Identifier:GPL-2.0+\n");
+   printf(" */\n\n");
+   printf("#define EFI_ST_DISK_IMG { 0x%08zx, { \\\n", count);
+
+   for (i = 0; 

[U-Boot] [PATCH v2 12/18] efi_loader: correct EFI_BLOCK_IO_PROTOCOL definitions

2018-01-17 Thread Heinrich Schuchardt
Add the revision constants.
Depending on the revision additional fields are needed in the
media descriptor.
Use efi_uintn_t for number of bytes to read or write.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_api.h | 10 --
 lib/efi_loader/efi_disk.c |  8 
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 502fffed20..0bc24d 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -424,18 +424,24 @@ struct efi_block_io_media
u32 io_align;
u8 pad2[4];
u64 last_block;
+   u64 lowest_aligned_lba;
+   u32 logical_blocks_per_physical_block;
+   u32 optimal_transfer_length_granualarity;
 };
 
+#define EFI_BLOCK_IO_PROTOCOL_REVISION20x00020001
+#define EFI_BLOCK_IO_PROTOCOL_REVISION30x0002001f
+
 struct efi_block_io {
u64 revision;
struct efi_block_io_media *media;
efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
char extended_verification);
efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
-   u32 media_id, u64 lba, unsigned long buffer_size,
+   u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer);
efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
-   u32 media_id, u64 lba, unsigned long buffer_size,
+   u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer);
efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
 };
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 92c3f45ca5..8f84e7788e 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -91,7 +91,7 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io 
*this,
 }
 
 static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this,
-   u32 media_id, u64 lba, unsigned long buffer_size,
+   u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer)
 {
void *real_buffer = buffer;
@@ -112,7 +112,7 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct 
efi_block_io *this,
real_buffer = efi_bounce_buffer;
 #endif
 
-   EFI_ENTRY("%p, %x, %"PRIx64", %lx, %p", this, media_id, lba,
+   EFI_ENTRY("%p, %x, %" PRIx64 ", %zx, %p", this, media_id, lba,
  buffer_size, buffer);
 
r = efi_disk_rw_blocks(this, media_id, lba, buffer_size, real_buffer,
@@ -126,7 +126,7 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct 
efi_block_io *this,
 }
 
 static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this,
-   u32 media_id, u64 lba, unsigned long buffer_size,
+   u32 media_id, u64 lba, efi_uintn_t buffer_size,
void *buffer)
 {
void *real_buffer = buffer;
@@ -147,7 +147,7 @@ static efi_status_t EFIAPI efi_disk_write_blocks(struct 
efi_block_io *this,
real_buffer = efi_bounce_buffer;
 #endif
 
-   EFI_ENTRY("%p, %x, %"PRIx64", %lx, %p", this, media_id, lba,
+   EFI_ENTRY("%p, %x, %" PRIx64 ", %zx, %p", this, media_id, lba,
  buffer_size, buffer);
 
/* Populate bounce buffer if necessary */
-- 
2.14.2

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


[U-Boot] [PATCH v2 09/18] efi_loader: make efi_block_io_guid a global symbol

2018-01-17 Thread Heinrich Schuchardt
The GUID of the EFI_BLOCK_IO_PROTOCOL is needed in different code
parts. To avoid duplication make efi_block_io_guid a global symbol.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_loader.h  | 2 ++
 lib/efi_loader/efi_disk.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 6b623d8327..6d04feb0a7 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -86,6 +86,8 @@ extern const struct efi_device_path_to_text_protocol 
efi_device_path_to_text;
 
 uint16_t *efi_dp_str(struct efi_device_path *dp);
 
+/* GUID of the EFI_BLOCK_IO_PROTOCOL */
+extern const efi_guid_t efi_block_io_guid;
 extern const efi_guid_t efi_global_variable_guid;
 extern const efi_guid_t efi_guid_console_control;
 extern const efi_guid_t efi_guid_device_path;
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index da92729779..cccfc6dac5 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -14,7 +14,7 @@
 #include 
 #include 
 
-static const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
+const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
 
 struct efi_disk_obj {
/* Generic EFI object parent class data */
-- 
2.14.2

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


[U-Boot] [PATCH v2 10/18] efi_loader: provide a function to create a partition node

2018-01-17 Thread Heinrich Schuchardt
Provide new function efi_dp_part_node() to create a device
node for a partition.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_loader.h |   2 +
 lib/efi_loader/efi_device_path.c | 106 ++-
 2 files changed, 72 insertions(+), 36 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 6d04feb0a7..456763e83a 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -300,6 +300,8 @@ struct efi_device_path *efi_dp_append_node(const struct 
efi_device_path *dp,
 
 struct efi_device_path *efi_dp_from_dev(struct udevice *dev);
 struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part);
+/* Create a device node for a block device partition. */
+struct efi_device_path *efi_dp_part_node(struct blk_desc *desc, int part);
 struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part,
 const char *path);
 struct efi_device_path *efi_dp_from_eth(void);
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index c1ba54e6bd..f00a0ce645 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -484,50 +484,16 @@ static unsigned dp_part_size(struct blk_desc *desc, int 
part)
 }
 
 /*
- * Create a device path for a block device or one of its partitions.
+ * Create a device node for a block device partition.
  *
  * @bufbuffer to which the device path is wirtten
  * @desc   block device descriptor
  * @part   partition number, 0 identifies a block device
  */
-static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
+static void *dp_part_node(void *buf, struct blk_desc *desc, int part)
 {
disk_partition_t info;
 
-#ifdef CONFIG_BLK
-   {
-   struct udevice *dev;
-   int ret = blk_find_device(desc->if_type, desc->devnum, );
-
-   if (ret)
-   dev = desc->bdev->parent;
-   buf = dp_fill(buf, dev);
-   }
-#else
-   /*
-* We *could* make a more accurate path, by looking at if_type
-* and handling all the different cases like we do for non-
-* legacy (ie CONFIG_BLK=y) case.  But most important thing
-* is just to have a unique device-path for if_type+devnum.
-* So map things to a fictitious USB device.
-*/
-   struct efi_device_path_usb *udp;
-
-   memcpy(buf, , sizeof(ROOT));
-   buf += sizeof(ROOT);
-
-   udp = buf;
-   udp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
-   udp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_USB;
-   udp->dp.length = sizeof(*udp);
-   udp->parent_port_number = desc->if_type;
-   udp->usb_interface = desc->devnum;
-   buf = [1];
-#endif
-
-   if (part == 0) /* the actual disk, not a partition */
-   return buf;
-
part_get_info(desc, part, );
 
if (desc->part_type == PART_TYPE_ISO) {
@@ -582,6 +548,51 @@ static void *dp_part_fill(void *buf, struct blk_desc 
*desc, int part)
return buf;
 }
 
+/*
+ * Create a device path for a block device or one of its partitions.
+ *
+ * @bufbuffer to which the device path is wirtten
+ * @desc   block device descriptor
+ * @part   partition number, 0 identifies a block device
+ */
+static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
+{
+#ifdef CONFIG_BLK
+   {
+   struct udevice *dev;
+   int ret = blk_find_device(desc->if_type, desc->devnum, );
+
+   if (ret)
+   dev = desc->bdev->parent;
+   buf = dp_fill(buf, dev);
+   }
+#else
+   /*
+* We *could* make a more accurate path, by looking at if_type
+* and handling all the different cases like we do for non-
+* legacy (ie CONFIG_BLK=y) case.  But most important thing
+* is just to have a unique device-path for if_type+devnum.
+* So map things to a fictitious USB device.
+*/
+   struct efi_device_path_usb *udp;
+
+   memcpy(buf, , sizeof(ROOT));
+   buf += sizeof(ROOT);
+
+   udp = buf;
+   udp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
+   udp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_USB;
+   udp->dp.length = sizeof(*udp);
+   udp->parent_port_number = desc->if_type;
+   udp->usb_interface = desc->devnum;
+   buf = [1];
+#endif
+
+   if (part == 0) /* the actual disk, not a partition */
+   return buf;
+
+   return dp_part_node(buf, desc, part);
+}
 
 /* Construct a device-path from a partition on a blk device: */
 struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part)
@@ -599,6 +610,29 @@ struct efi_device_path *efi_dp_from_part(struct blk_desc 
*desc, int part)
return start;
 }
 
+/*
+ * Create a device node for a block device partition.
+ *
+ * @bufbuffer 

[U-Boot] [PATCH v2 16/18] efi_driver: EFI block driver

2018-01-17 Thread Heinrich Schuchardt
This patch provides
* a uclass for EFI drivers
* a EFI driver for block devices

For each EFI driver the uclass
* creates a handle
* adds the driver binding protocol

The uclass provides the bind, start, and stop entry points for the driver
binding protocol.

In bind() and stop() it checks if the controller implements the protocol
supported by the EFI driver. In the start() function it calls the bind()
function of the EFI driver. In the stop() function it destroys the child
controllers.

The EFI block driver binds to controllers implementing the block io
protocol.

When the bind function of the EFI block driver is called it creates a
new U-Boot block device. It installs child handles for all partitions and
installs the simple file protocol on these.

The read and write functions of the EFI block driver delegate calls to the
controller that it is bound to.

A usage example is as following:

U-Boot loads the iPXE snp.efi executable. iPXE connects an iSCSI drive and
exposes a handle with the block IO protocol. It calls ConnectController.

Now the EFI block driver installs the partions with the simple file
protocol.

iPXE uses the simple file protocol to load Grub or the Linux Kernel.

Signed-off-by: Heinrich Schuchardt 
---
v2
Print to console only in debug mode.
Provide more comments.
Add commit message.
---
 common/board_r.c  |   3 +
 drivers/block/blk-uclass.c|   4 +-
 include/blk.h |   1 +
 include/config_fallbacks.h|   1 +
 include/dm/uclass-id.h|   1 +
 include/efi_driver.h  |  30 
 include/efi_loader.h  |   2 +
 lib/Makefile  |   1 +
 lib/efi_driver/Makefile   |  13 ++
 lib/efi_driver/efi_block_device.c | 175 
 lib/efi_driver/efi_uclass.c   | 330 ++
 11 files changed, 560 insertions(+), 1 deletion(-)
 create mode 100644 include/efi_driver.h
 create mode 100644 lib/efi_driver/Makefile
 create mode 100644 lib/efi_driver/efi_block_device.c
 create mode 100644 lib/efi_driver/efi_uclass.c

diff --git a/common/board_r.c b/common/board_r.c
index 2baa47f3a0..4ad37ee31a 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -715,7 +715,10 @@ static init_fnc_t init_sequence_r[] = {
set_cpu_clk_info, /* Setup clock information */
 #endif
 #ifdef CONFIG_EFI_LOADER
+   /* Setup EFI memory before any other EFI related code */
efi_memory_init,
+   /* Install EFI drivers */
+   efi_driver_init,
 #endif
stdio_init_tables,
initr_serial,
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 010ed32d3a..bfda2211f0 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -24,6 +24,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_HOST]  = "host",
[IF_TYPE_SYSTEMACE] = "ace",
[IF_TYPE_NVME]  = "nvme",
+   [IF_TYPE_EFI]   = "efi",
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
@@ -36,8 +37,9 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_SD]= UCLASS_INVALID,
[IF_TYPE_SATA]  = UCLASS_AHCI,
[IF_TYPE_HOST]  = UCLASS_ROOT,
-   [IF_TYPE_NVME]  = UCLASS_NVME,
[IF_TYPE_SYSTEMACE] = UCLASS_INVALID,
+   [IF_TYPE_NVME]  = UCLASS_NVME,
+   [IF_TYPE_EFI]   = UCLASS_EFI,
 };
 
 static enum if_type if_typename_to_iftype(const char *if_typename)
diff --git a/include/blk.h b/include/blk.h
index 41b4d7efa8..69b5a98e56 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -34,6 +34,7 @@ enum if_type {
IF_TYPE_HOST,
IF_TYPE_SYSTEMACE,
IF_TYPE_NVME,
+   IF_TYPE_EFI,
 
IF_TYPE_COUNT,  /* Number of interface types */
 };
diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
index 2c4d43d672..524313d5aa 100644
--- a/include/config_fallbacks.h
+++ b/include/config_fallbacks.h
@@ -52,6 +52,7 @@
defined(CONFIG_MMC) || \
defined(CONFIG_NVME) || \
defined(CONFIG_SYSTEMACE) || \
+   (defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)) || \
defined(CONFIG_SANDBOX)
 #define HAVE_BLOCK_DEVICE
 #endif
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 3fc20834ae..07fabc3ce6 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -34,6 +34,7 @@ enum uclass_id {
UCLASS_CROS_EC, /* Chrome OS EC */
UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */
UCLASS_DMA, /* Direct Memory Access */
+   UCLASS_EFI, /* EFI managed devices */
UCLASS_ETH, /* Ethernet device */
UCLASS_GPIO,/* Bank of general-purpose I/O pins */
UCLASS_FIRMWARE,/* Firmware */
diff --git a/include/efi_driver.h 

[U-Boot] [PATCH v2 18/18] efi_loader: fix ExitBootServices

2018-01-17 Thread Heinrich Schuchardt
This patch lets the implementation of ExitBootServices conform to
the UEFI standard.

The timer events must be disabled before calling the notification
functions of the exit boot services events.

The boot services must be disabled in the system table.

The handles in the system table should be defined as efi_handle_t.

Signed-off-by: Heinrich Schuchardt 
---
v2
new patch
---
 include/efi_api.h |  6 +++---
 lib/efi_loader/efi_boottime.c | 36 +++-
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 0bc24d..4252d11398 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -247,11 +247,11 @@ struct efi_system_table {
struct efi_table_hdr hdr;
unsigned long fw_vendor;   /* physical addr of wchar_t vendor string */
u32 fw_revision;
-   unsigned long con_in_handle;
+   efi_handle_t con_in_handle;
struct efi_simple_input_interface *con_in;
-   unsigned long con_out_handle;
+   efi_handle_t con_out_handle;
struct efi_simple_text_output_protocol *con_out;
-   unsigned long stderr_handle;
+   efi_handle_t stderr_handle;
struct efi_simple_text_output_protocol *std_err;
struct efi_runtime_services *runtime;
struct efi_boot_services *boottime;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 4b3b63e39a..2c5499e0c8 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1645,12 +1645,16 @@ static void efi_exit_caches(void)
 }
 
 /*
- * Stop boot services.
+ * Stop all boot services.
  *
  * This function implements the ExitBootServices service.
  * See the Unified Extensible Firmware Interface (UEFI) specification
  * for details.
  *
+ * All timer events are disabled.
+ * For exit boot services events the notification function is called.
+ * The boot services are disabled in the system table.
+ *
  * @image_handle   handle of the loaded image
  * @map_keykey of the memory map
  * @return status code
@@ -1662,16 +1666,24 @@ static efi_status_t EFIAPI 
efi_exit_boot_services(efi_handle_t image_handle,
 
EFI_ENTRY("%p, %ld", image_handle, map_key);
 
+   /* Make sure that notification functions are not called anymore */
+   efi_tpl = TPL_HIGH_LEVEL;
+
+   /* Check if ExitBootServices has already been called */
+   if (!systab.boottime)
+   return EFI_EXIT(EFI_SUCCESS);
+
/* Notify that ExitBootServices is invoked. */
for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
if (efi_events[i].type != EVT_SIGNAL_EXIT_BOOT_SERVICES)
continue;
-   efi_signal_event(_events[i]);
+   if (!efi_events[i].notify_function)
+   continue;
+   EFI_CALL_VOID(efi_events[i].notify_function(
+   _events[i], efi_events[i].notify_context));
}
-   /* Make sure that notification functions are not called anymore */
-   efi_tpl = TPL_HIGH_LEVEL;
 
-   /* XXX Should persist EFI variables here */
+   /* TODO Should persist EFI variables here */
 
board_quiesce_devices();
 
@@ -1681,6 +1693,20 @@ static efi_status_t EFIAPI 
efi_exit_boot_services(efi_handle_t image_handle,
/* This stops all lingering devices */
bootm_disable_interrupts();
 
+   /* Disable boottime services */
+   systab.con_in_handle = NULL;
+   systab.con_in = NULL;
+   systab.con_out_handle = NULL;
+   systab.con_out = NULL;
+   systab.stderr_handle = NULL;
+   systab.std_err = NULL;
+   systab.boottime = NULL;
+
+   /* Recalculate CRC32 */
+   systab.hdr.crc32 = 0;
+   systab.hdr.crc32 = crc32(0, (const unsigned char *),
+sizeof(struct efi_system_table));
+
/* Give the payload some time to boot */
efi_set_watchdog(0);
WATCHDOG_RESET();
-- 
2.14.2

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


[U-Boot] [PATCH v2 17/18] efi_selftest: provide a test for block io

2018-01-17 Thread Heinrich Schuchardt
Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_selftest/Makefile|   4 +
 lib/efi_selftest/efi_selftest_block_device.c | 395 +++
 lib/efi_selftest/efi_selftest_disk_image.h   |  69 +
 3 files changed, 468 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_block_device.c
 create mode 100644 lib/efi_selftest/efi_selftest_disk_image.h

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index e549553c82..20f614d6ba 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -21,3 +21,7 @@ efi_selftest_textoutput.o \
 efi_selftest_tpl.o \
 efi_selftest_util.o \
 efi_selftest_watchdog.o
+
+ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
+obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += efi_selftest_block_device.o
+endif
diff --git a/lib/efi_selftest/efi_selftest_block_device.c 
b/lib/efi_selftest/efi_selftest_block_device.c
new file mode 100644
index 00..9e4b93d9a6
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_block_device.c
@@ -0,0 +1,395 @@
+/*
+ * efi_selftest_block
+ *
+ * Copyright (c) 2017 Heinrich Schuchardt 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This test checks the driver for block IO devices.
+ * A disk image is created in memory.
+ * A handle is created for the new block IO device.
+ * The block I/O protocol is installed on the handle.
+ * ConnectController is used to setup partitions and to install the simple
+ * file protocol.
+ * A known file is read from the file system and verified.
+ */
+
+#include 
+#include "efi_selftest_disk_image.h"
+
+/* Block size of compressed disk image */
+#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8
+
+/* Binary logarithm of the block size */
+#define LB_BLOCK_SIZE 9
+
+static struct efi_boot_services *boottime;
+
+static const efi_guid_t block_io_protocol_guid = BLOCK_IO_GUID;
+static const efi_guid_t guid_device_path = DEVICE_PATH_GUID;
+static const efi_guid_t guid_simple_file_system_protocol =
+   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
+static efi_guid_t guid_vendor =
+   EFI_GUID(0xdbca4c98, 0x6cb0, 0x694d,
+0x08, 0x72, 0x81, 0x9c, 0x65, 0x0c, 0xb7, 0xb8);
+
+static struct efi_device_path *dp;
+
+/* One 8 byte block of the compressed disk image */
+struct line {
+   size_t addr;
+   char *line;
+};
+
+/* Compressed disk image */
+struct compressed_disk_image {
+   size_t length;
+   struct line lines[];
+};
+
+static const struct compressed_disk_image img = EFI_ST_DISK_IMG;
+
+/* Decompressed disk image */
+static u8 *image;
+
+/*
+ * Reset service of the block IO protocol.
+ *
+ * @this   block IO protocol
+ * @return status code
+ */
+static efi_status_t EFIAPI reset(
+   struct efi_block_io *this,
+   char extended_verification)
+{
+   return EFI_SUCCESS;
+}
+
+/*
+ * Read service of the block IO protocol.
+ *
+ * @this   block IO protocol
+ * @media_id   media id
+ * @lbastart of the read in logical blocks
+ * @buffer_sizenumber of bytes to read
+ * @buffer target buffer
+ * @return status code
+ */
+static efi_status_t EFIAPI read_blocks(
+   struct efi_block_io *this, u32 media_id, u64 lba,
+   efi_uintn_t buffer_size, void *buffer)
+{
+   u8 *start;
+
+   if ((lba << LB_BLOCK_SIZE) + buffer_size > img.length)
+   return EFI_INVALID_PARAMETER;
+   start = image + (lba << LB_BLOCK_SIZE);
+
+   boottime->copy_mem(buffer, start, buffer_size);
+
+   return EFI_SUCCESS;
+}
+
+/*
+ * Write service of the block IO protocol.
+ *
+ * @this   block IO protocol
+ * @media_id   media id
+ * @lbastart of the write in logical blocks
+ * @buffer_sizenumber of bytes to read
+ * @buffer source buffer
+ * @return status code
+ */
+static efi_status_t EFIAPI write_blocks(
+   struct efi_block_io *this, u32 media_id, u64 lba,
+   efi_uintn_t buffer_size, void *buffer)
+{
+   u8 *start;
+
+   if ((lba << LB_BLOCK_SIZE) + buffer_size > img.length)
+   return EFI_INVALID_PARAMETER;
+   start = image + (lba << LB_BLOCK_SIZE);
+
+   boottime->copy_mem(start, buffer, buffer_size);
+
+   return EFI_SUCCESS;
+}
+
+/*
+ * Flush service of the block IO protocol.
+ *
+ * @this   block IO protocol
+ * @return status code
+ */
+static efi_status_t EFIAPI flush_blocks(struct efi_block_io *this)
+{
+   return EFI_SUCCESS;
+}
+
+/*
+ * Decompress the disk image.
+ *
+ * @image  decompressed disk image
+ * @return status code
+ */
+static efi_status_t decompress(u8 **image)
+{
+   u8 *buf;
+   size_t i;
+   size_t addr;
+   size_t len;
+   efi_status_t ret;
+
+   ret = boottime->allocate_pool(EFI_LOADER_DATA, img.length,
+

[U-Boot] [PATCH v2 14/18] efi_loader: provide links between devices EFI handles

2018-01-17 Thread Heinrich Schuchardt
U-Boot devices and EFI handles can be related, e.g. an
IDE disk relates to a handle with the EFI_BLOCK_IO_PROTOCOL.
Provide pointers to store these links.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/dm/device.h   | 4 
 include/efi_loader.h  | 2 ++
 lib/efi_loader/efi_boottime.c | 1 +
 3 files changed, 7 insertions(+)

diff --git a/include/dm/device.h b/include/dm/device.h
index 813e49f330..e5c54fe7b6 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -11,6 +11,7 @@
 #ifndef _DM_DEVICE_H
 #define _DM_DEVICE_H
 
+#include 
 #include 
 #include 
 #include 
@@ -144,6 +145,9 @@ struct udevice {
uint32_t flags;
int req_seq;
int seq;
+#ifdef EFI_LOADER
+   efi_handle_t handle;
+#endif
 #ifdef CONFIG_DEVRES
struct list_head devres_head;
 #endif
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 4060348695..711c901eda 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -139,6 +139,8 @@ struct efi_object {
struct list_head protocols;
/* The object spawner can either use this for data or as identifier */
void *handle;
+   /* Device */
+   struct udevice *dev;
 };
 
 /**
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 5a3349ecb2..4b3b63e39a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -362,6 +362,7 @@ efi_status_t efi_create_handle(efi_handle_t *handle)
  (void **));
if (r != EFI_SUCCESS)
return r;
+   obj->dev = NULL;
efi_add_handle(obj);
*handle = obj->handle;
return r;
-- 
2.14.2

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


[U-Boot] [PATCH v2 06/18] efi_loader: check tables in helloworld.efi

2018-01-17 Thread Heinrich Schuchardt
Check if the device tree and the SMBIOS table are available.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/helloworld.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index b8c147d7f2..1ec0179226 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -14,6 +14,22 @@
 #include 
 
 static const efi_guid_t loaded_image_guid = LOADED_IMAGE_GUID;
+static const efi_guid_t fdt_guid = EFI_FDT_GUID;
+static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
+
+static int hw_memcmp(const void *buf1, const void *buf2, size_t length)
+{
+   const u8 *pos1 = buf1;
+   const u8 *pos2 = buf2;
+
+   for (; length; --length) {
+   if (*pos1 != *pos2)
+   return *pos1 - *pos2;
+   ++pos1;
+   ++pos2;
+   }
+   return 0;
+}
 
 /*
  * Entry point of the EFI application.
@@ -29,6 +45,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_boot_services *boottime = systable->boottime;
struct efi_loaded_image *loaded_image;
efi_status_t ret;
+   efi_uintn_t i;
 
con_out->output_string(con_out, L"Hello, world!\n");
 
@@ -40,6 +57,15 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
   L"Cannot open loaded image protocol\n");
goto out;
}
+   /* Find configuration tables */
+   for (i = 0; i < systable->nr_tables; ++i) {
+   if (!hw_memcmp(>tables[i].guid, _guid,
+  sizeof(efi_guid_t)))
+   con_out->output_string(con_out, L"Have device tree\n");
+   if (!hw_memcmp(>tables[i].guid, _guid,
+  sizeof(efi_guid_t)))
+   con_out->output_string(con_out, L"Have SMBIOS table\n");
+   }
/* Output the load options */
con_out->output_string(con_out, L"Load options: ");
if (loaded_image->load_options_size && loaded_image->load_options)
-- 
2.14.2

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


[U-Boot] [PATCH v2 08/18] efi_loader: efi_disk_register: correctly determine if_type_name

2018-01-17 Thread Heinrich Schuchardt
The interface type name can be used to look up the interface type.
Don't confound it with the driver name which may be different.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/efi_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 8771e880f6..da92729779 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -330,7 +330,7 @@ int efi_disk_register(void)
 dev;
 uclass_next_device_check()) {
struct blk_desc *desc = dev_get_uclass_platdata(dev);
-   const char *if_typename = dev->driver->name;
+   const char *if_typename = blk_get_if_type_name(desc->if_type);
 
printf("Scanning disk %s...\n", dev->name);
 
-- 
2.14.2

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


[U-Boot] [PATCH v2 07/18] efi_loader: fix StartImage bootservice

2018-01-17 Thread Heinrich Schuchardt
The calling convention for the entry point of an EFI image
is always 'asmlinkage'.

Signed-off-by: Heinrich Schuchardt 
---
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 e046a7be9d..5a3349ecb2 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1533,7 +1533,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);
struct efi_loaded_image *info = image_handle;
 
EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
-- 
2.14.2

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


[U-Boot] [PATCH v2 11/18] efi_loader: make efi_disk_create_partitions a global symbol

2018-01-17 Thread Heinrich Schuchardt
Up to now we have been using efi_disk_create_partitions() to create
partions for block device that existed before starting an EFI
application.

We need to to call it for for block devices created by EFI
applications at run time. The EFI application will define the
handle for the block device and install a device path protocol
on it. We have to use this device path as stem for the partition
device paths.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_loader.h  |  4 +++
 lib/efi_loader/efi_disk.c | 84 +--
 2 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 456763e83a..0ba7badb15 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -174,6 +174,10 @@ extern struct list_head efi_obj_list;
 int efi_console_register(void);
 /* Called by bootefi to make all disk storage accessible as EFI objects */
 int efi_disk_register(void);
+/* Create handles and protocols for the partions of a block device */
+int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
+  const char *if_typename, int diskid,
+  const char *pdevname);
 /* Called by bootefi to make GOP (graphical) interface available */
 int efi_gop_register(void);
 /* Called by bootefi to make the network interface available */
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index cccfc6dac5..92c3f45ca5 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -216,27 +216,31 @@ efi_fs_from_path(struct efi_device_path *full_path)
 }
 
 /*
- * Create a device for a disk
+ * Create a handle for a partition or disk
  *
- * @name   not used
+ * @parent parent handle
+ * @dp_parent  parent device path
  * @if_typename interface name for block device
  * @desc   internal block device
  * @dev_index   device index for block device
  * @offset offset into disk for simple partitions
+ * @return disk object
  */
-static void efi_disk_add_dev(const char *name,
-const char *if_typename,
-struct blk_desc *desc,
-int dev_index,
-lbaint_t offset,
-unsigned int part)
+static struct efi_disk_obj *efi_disk_add_dev(
+   efi_handle_t parent,
+   struct efi_device_path *dp_parent,
+   const char *if_typename,
+   struct blk_desc *desc,
+   int dev_index,
+   lbaint_t offset,
+   unsigned int part)
 {
struct efi_disk_obj *diskobj;
efi_status_t ret;
 
/* Don't add empty devices */
if (!desc->lba)
-   return;
+   return NULL;
 
diskobj = calloc(1, sizeof(*diskobj));
if (!diskobj)
@@ -246,7 +250,14 @@ static void efi_disk_add_dev(const char *name,
efi_add_handle(>parent);
 
/* Fill in object data */
-   diskobj->dp = efi_dp_from_part(desc, part);
+   if (part) {
+   struct efi_device_path *node = efi_dp_part_node(desc, part);
+
+   diskobj->dp = efi_dp_append_node(dp_parent, node);
+   efi_free_pool(node);
+   } else {
+   diskobj->dp = efi_dp_from_part(desc, part);
+   }
diskobj->part = part;
ret = efi_add_protocol(diskobj->parent.handle, _block_io_guid,
   >ops);
@@ -280,20 +291,38 @@ static void efi_disk_add_dev(const char *name,
if (part != 0)
diskobj->media.logical_partition = 1;
diskobj->ops.media = >media;
-   return;
+   return diskobj;
 out_of_memory:
printf("ERROR: Out of memory\n");
+   return NULL;
 }
 
-static int efi_disk_create_partitions(struct blk_desc *desc,
- const char *if_typename,
- int diskid,
- const char *pdevname)
+/*
+ * Create handles and protocols for the partions of a block device
+ *
+ * @parent handle of the parent disk
+ * @blk_desc   block device
+ * @if_typenameinterface type
+ * @diskid device number
+ * @pdevname   device name
+ * @return number of partions created
+ */
+int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
+  const char *if_typename, int diskid,
+  const char *pdevname)
 {
int disks = 0;
char devname[32] = { 0 }; /* dp->str is u16[32] long */
disk_partition_t info;
int part;
+   struct efi_device_path *dp = NULL;
+   efi_status_t ret;
+   struct efi_handler *handler;
+
+ 

[U-Boot] [PATCH v2 04/18] efi_loader: print device path when entering efi_load_image

2018-01-17 Thread Heinrich Schuchardt
Use %pD to print the device path instead of its address when
entering efi_load_image.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/efi_boottime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 42cf197af9..e046a7be9d 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1474,7 +1474,7 @@ static efi_status_t EFIAPI efi_load_image(bool 
boot_policy,
struct efi_object *obj;
efi_status_t ret;
 
-   EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image,
+   EFI_ENTRY("%d, %p, %pD, %p, %ld, %p", boot_policy, parent_image,
  file_path, source_buffer, source_size, image_handle);
 
info = calloc(1, sizeof(*info));
-- 
2.14.2

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


[U-Boot] [PATCH v2 03/18] efi_loader: correct find simple file system protocol

2018-01-17 Thread Heinrich Schuchardt
In contrast to the description the code did not split the device
path into device part and file part.

The code should use the installed protocol and not refer to the
internal structure of the the disk object.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/efi_disk.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 85b4a147e2..8771e880f6 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -175,25 +175,44 @@ static const struct efi_block_io block_io_disk_template = 
{
 };
 
 /*
- * Find filesystem from a device-path.  The passed in path 'p' probably
- * contains one or more /File(name) nodes, so the comparison stops at
- * the first /File() node, and returns the pointer to that via 'rp'.
- * This is mostly intended to be a helper to map a device-path to an
- * efi_file_handle object.
+ * Get the simple file system protocol for a file device path.
+ *
+ * The full path provided is split into device part and into a file
+ * part. The device part is used to find the handle on which the
+ * simple file system protocol is installed.
+ *
+ * @full_path  device path including device and file
+ * @return simple file system protocol
  */
 struct efi_simple_file_system_protocol *
-efi_fs_from_path(struct efi_device_path *fp)
+efi_fs_from_path(struct efi_device_path *full_path)
 {
struct efi_object *efiobj;
-   struct efi_disk_obj *diskobj;
+   struct efi_handler *handler;
+   struct efi_device_path *device_path;
+   struct efi_device_path *file_path;
+   efi_status_t ret;
 
-   efiobj = efi_dp_find_obj(fp, NULL);
+   /* Split the path into a device part and a file part */
+   ret = efi_dp_split_file_path(full_path, _path, _path);
+   if (ret != EFI_SUCCESS)
+   return NULL;
+   efi_free_pool(file_path);
+
+   /* Get the EFI object for the partition */
+   efiobj = efi_dp_find_obj(device_path, NULL);
+   efi_free_pool(device_path);
if (!efiobj)
return NULL;
 
-   diskobj = container_of(efiobj, struct efi_disk_obj, parent);
+   /* Find the simple file system protocol */
+   ret = efi_search_protocol(efiobj, _simple_file_system_protocol_guid,
+ );
+   if (ret != EFI_SUCCESS)
+   return NULL;
 
-   return diskobj->volume;
+   /* Return the simple file system protocol for the partition */
+   return handler->protocol_interface;
 }
 
 /*
-- 
2.14.2

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


[U-Boot] [PATCH v2 05/18] efi_loader: allocate correct memory type for EFI image

2018-01-17 Thread Heinrich Schuchardt
The category of memory allocated for an EFI image should depend on
its type (application, bootime service driver, runtime service driver).

Our helloworld.efi built on arm64 has an illegal image type. Treat it
like an EFI application.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/efi_image_loader.c | 64 ---
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/lib/efi_loader/efi_image_loader.c 
b/lib/efi_loader/efi_image_loader.c
index 849d7ce377..9d2214b481 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -73,6 +73,40 @@ void __weak invalidate_icache_all(void)
/* If the system doesn't support icache_all flush, cross our fingers */
 }
 
+/*
+ * Determine the memory types to be used for code and data.
+ *
+ * @loaded_image_info  image descriptor
+ * @image_type field Subsystem of the optional header for
+ * Windows specific field
+ */
+static void efi_set_code_and_data_type(
+   struct efi_loaded_image *loaded_image_info,
+   uint16_t image_type)
+{
+   switch (image_type) {
+   case IMAGE_SUBSYSTEM_EFI_APPLICATION:
+   loaded_image_info->image_code_type = EFI_LOADER_CODE;
+   loaded_image_info->image_data_type = EFI_LOADER_DATA;
+   break;
+   case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
+   loaded_image_info->image_code_type = EFI_BOOT_SERVICES_CODE;
+   loaded_image_info->image_data_type = EFI_BOOT_SERVICES_DATA;
+   break;
+   case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
+   case IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:
+   loaded_image_info->image_code_type = EFI_RUNTIME_SERVICES_CODE;
+   loaded_image_info->image_data_type = EFI_RUNTIME_SERVICES_DATA;
+   break;
+   default:
+   printf("%s: invalid image type: %u\n", __func__, image_type);
+   /* Let's assume it is an application */
+   loaded_image_info->image_code_type = EFI_LOADER_CODE;
+   loaded_image_info->image_data_type = EFI_LOADER_DATA;
+   break;
+   }
+}
+
 /*
  * This function loads all sections from a PE binary into a newly reserved
  * piece of memory. On successful load it then returns the entry point for
@@ -94,7 +128,6 @@ void *efi_load_pe(void *efi, struct efi_loaded_image 
*loaded_image_info)
unsigned long virt_size = 0;
bool can_run_nt64 = true;
bool can_run_nt32 = true;
-   uint16_t image_type;
 
 #if defined(CONFIG_ARM64)
can_run_nt32 = false;
@@ -131,7 +164,9 @@ void *efi_load_pe(void *efi, struct efi_loaded_image 
*loaded_image_info)
IMAGE_NT_HEADERS64 *nt64 = (void *)nt;
IMAGE_OPTIONAL_HEADER64 *opt = >OptionalHeader;
image_size = opt->SizeOfImage;
-   efi_reloc = efi_alloc(virt_size, EFI_LOADER_DATA);
+   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
+   efi_reloc = efi_alloc(virt_size,
+ loaded_image_info->image_code_type);
if (!efi_reloc) {
printf("%s: Could not allocate %lu bytes\n",
   __func__, virt_size);
@@ -140,12 +175,13 @@ void *efi_load_pe(void *efi, struct efi_loaded_image 
*loaded_image_info)
entry = efi_reloc + opt->AddressOfEntryPoint;
rel_size = opt->DataDirectory[rel_idx].Size;
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
-   image_type = opt->Subsystem;
} else if (can_run_nt32 &&
   (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)) 
{
IMAGE_OPTIONAL_HEADER32 *opt = >OptionalHeader;
image_size = opt->SizeOfImage;
-   efi_reloc = efi_alloc(virt_size, EFI_LOADER_DATA);
+   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
+   efi_reloc = efi_alloc(virt_size,
+ loaded_image_info->image_code_type);
if (!efi_reloc) {
printf("%s: Could not allocate %lu bytes\n",
   __func__, virt_size);
@@ -154,32 +190,12 @@ void *efi_load_pe(void *efi, struct efi_loaded_image 
*loaded_image_info)
entry = efi_reloc + opt->AddressOfEntryPoint;
rel_size = opt->DataDirectory[rel_idx].Size;
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
-   image_type = opt->Subsystem;
} else {
printf("%s: Invalid optional header magic %x\n", __func__,
   nt->OptionalHeader.Magic);
return NULL;
}
 
-   switch (image_type) {
-   case IMAGE_SUBSYSTEM_EFI_APPLICATION:
- 

[U-Boot] [PATCH v2 13/18] efi_loader: provide function to get last node of a device path

2018-01-17 Thread Heinrich Schuchardt
On a block device and its partions the same protocols can be
installed. To tell the apart we can use the type of the last
node of the device path which is not the end node.

The patch provides a utility function to find this last node.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_loader.h |  3 +++
 lib/efi_loader/efi_device_path.c | 20 
 2 files changed, 23 insertions(+)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 0ba7badb15..4060348695 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -312,6 +312,9 @@ struct efi_device_path *efi_dp_from_eth(void);
 struct efi_device_path *efi_dp_from_mem(uint32_t mem_type,
uint64_t start_address,
uint64_t end_address);
+/* Determine the last device path node that is not the end node. */
+const struct efi_device_path *efi_dp_last_node(
+   const struct efi_device_path *dp);
 efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
struct efi_device_path **device_path,
struct efi_device_path **file_path);
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index f00a0ce645..c941ea7717 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -208,6 +208,26 @@ struct efi_object *efi_dp_find_obj(struct efi_device_path 
*dp,
return efiobj;
 }
 
+/*
+ * Determine the last device path node that is not the end node.
+ *
+ * @dp device path
+ * @return last node before the end node if it exists
+ * otherwise NULL
+ */
+const struct efi_device_path *efi_dp_last_node(const struct efi_device_path 
*dp)
+{
+   struct efi_device_path *ret;
+
+   if (!dp || dp->type == DEVICE_PATH_TYPE_END)
+   return NULL;
+   while (dp) {
+   ret = (struct efi_device_path *)dp;
+   dp = efi_dp_next(dp);
+   }
+   return ret;
+}
+
 /* return size not including End node: */
 unsigned efi_dp_size(const struct efi_device_path *dp)
 {
-- 
2.14.2

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


[U-Boot] [PATCH v2 02/18] efi_loader: address of the simple file system protocol

2018-01-17 Thread Heinrich Schuchardt
When installing the the simple file system protocol we have to path
the address of the structure and not the address of a pointer ot the
structure.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 lib/efi_loader/efi_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index d299fc8dea..85b4a147e2 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -242,7 +242,7 @@ static void efi_disk_add_dev(const char *name,
 diskobj->dp);
ret = efi_add_protocol(diskobj->parent.handle,
   _simple_file_system_protocol_guid,
-  >volume);
+  diskobj->volume);
if (ret != EFI_SUCCESS)
goto out_of_memory;
}
-- 
2.14.2

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


[U-Boot] [PATCH v2 00/18] efi_loader: enable EFI driver provided block device

2018-01-17 Thread Heinrich Schuchardt
With this patch series an EFI application or driver can supply
a block device which in turn can be used to download an image.

E.g. we can load iPXE, connect iSCSI drives, download grub from the
SAN and afterwards with grub download and run an EFI application.
Booting Linux from an iSCSI drive was successful on arm64.

v2:
Add an additional patch to fix ExitBootServices.
Provide comments for EFI block driver.
Avoid printing when not in debug mode
Add product tools/file2include to .gitignore.
Put the patch with the test for block io after the patch for the
driver.

Heinrich Schuchardt (18):
  efi_loader: return NULL from device path functions
  efi_loader: address of the simple file system protocol
  efi_loader: correct find simple file system protocol
  efi_loader: print device path when entering efi_load_image
  efi_loader: allocate correct memory type for EFI image
  efi_loader: check tables in helloworld.efi
  efi_loader: fix StartImage bootservice
  efi_loader: efi_disk_register: correctly determine if_type_name
  efi_loader: make efi_block_io_guid a global symbol
  efi_loader: provide a function to create a partition node
  efi_loader: make efi_disk_create_partitions a global symbol
  efi_loader: correct EFI_BLOCK_IO_PROTOCOL definitions
  efi_loader: provide function to get last node of a device path
  efi_loader: provide links between devices EFI handles
  tools: provide a tool to convert a binary file to an include
  efi_driver: EFI block driver
  efi_selftest: provide a test for block io
  efi_loader: fix ExitBootServices

 MAINTAINERS  |   1 +
 common/board_r.c |   3 +
 drivers/block/blk-uclass.c   |   4 +-
 include/blk.h|   1 +
 include/config_fallbacks.h   |   1 +
 include/dm/device.h  |   4 +
 include/dm/uclass-id.h   |   1 +
 include/efi_api.h|  16 +-
 include/efi_driver.h |  30 ++
 include/efi_loader.h |  21 +-
 lib/Makefile |   1 +
 lib/efi_driver/Makefile  |  13 +
 lib/efi_driver/efi_block_device.c| 175 
 lib/efi_driver/efi_uclass.c  | 330 ++
 lib/efi_loader/efi_boottime.c|  42 ++-
 lib/efi_loader/efi_device_path.c | 168 +---
 lib/efi_loader/efi_disk.c| 137 +++---
 lib/efi_loader/efi_image_loader.c|  64 +++--
 lib/efi_loader/helloworld.c  |  26 ++
 lib/efi_selftest/Makefile|   4 +
 lib/efi_selftest/efi_selftest_block_device.c | 395 +++
 lib/efi_selftest/efi_selftest_disk_image.h   |  69 +
 tools/.gitignore |   1 +
 tools/Makefile   |   3 +
 tools/file2include.c | 106 +++
 25 files changed, 1493 insertions(+), 123 deletions(-)
 create mode 100644 include/efi_driver.h
 create mode 100644 lib/efi_driver/Makefile
 create mode 100644 lib/efi_driver/efi_block_device.c
 create mode 100644 lib/efi_driver/efi_uclass.c
 create mode 100644 lib/efi_selftest/efi_selftest_block_device.c
 create mode 100644 lib/efi_selftest/efi_selftest_disk_image.h
 create mode 100644 tools/file2include.c

-- 
2.14.2

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


[U-Boot] [PATCH v2 01/18] efi_loader: return NULL from device path functions

2018-01-17 Thread Heinrich Schuchardt
For the construction of device paths we need to call the
AllocatePool service. We should not ignore if it fails due to an
out of memory situation.

This patch changes the device path functions to return NULL if
the memory allocation fails.

Additional patches will be needed to fix the callers.

Signed-off-by: Heinrich Schuchardt 
---
v2
No change
---
 include/efi_loader.h |  6 +++---
 lib/efi_loader/efi_device_path.c | 42 ++--
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 37389c33cc..6b623d8327 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -304,9 +304,9 @@ struct efi_device_path *efi_dp_from_eth(void);
 struct efi_device_path *efi_dp_from_mem(uint32_t mem_type,
uint64_t start_address,
uint64_t end_address);
-void efi_dp_split_file_path(struct efi_device_path *full_path,
-   struct efi_device_path **device_path,
-   struct efi_device_path **file_path);
+efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
+   struct efi_device_path **device_path,
+   struct efi_device_path **file_path);
 
 #define EFI_DP_TYPE(_dp, _type, _subtype) \
(((_dp)->type == DEVICE_PATH_TYPE_##_type) && \
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 2a8efea6e7..c1ba54e6bd 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -58,8 +58,11 @@ static void *dp_alloc(size_t sz)
 {
void *buf;
 
-   if (efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, sz, ) != EFI_SUCCESS)
+   if (efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, sz, ) !=
+   EFI_SUCCESS) {
+   debug("EFI: ERROR: out of memory in %s\n", __func__);
return NULL;
+   }
 
return buf;
 }
@@ -227,6 +230,8 @@ struct efi_device_path *efi_dp_dup(const struct 
efi_device_path *dp)
return NULL;
 
ndp = dp_alloc(sz);
+   if (!ndp)
+   return NULL;
memcpy(ndp, dp, sz);
 
return ndp;
@@ -246,6 +251,8 @@ struct efi_device_path *efi_dp_append(const struct 
efi_device_path *dp1,
unsigned sz1 = efi_dp_size(dp1);
unsigned sz2 = efi_dp_size(dp2);
void *p = dp_alloc(sz1 + sz2 + sizeof(END));
+   if (!p)
+   return NULL;
memcpy(p, dp1, sz1);
memcpy(p + sz1, dp2, sz2);
memcpy(p + sz1 + sz2, , sizeof(END));
@@ -267,6 +274,8 @@ struct efi_device_path *efi_dp_append_node(const struct 
efi_device_path *dp,
} else if (!dp) {
unsigned sz = node->length;
void *p = dp_alloc(sz + sizeof(END));
+   if (!p)
+   return NULL;
memcpy(p, node, sz);
memcpy(p + sz, , sizeof(END));
ret = p;
@@ -274,6 +283,8 @@ struct efi_device_path *efi_dp_append_node(const struct 
efi_device_path *dp,
/* both dp and node are non-null */
unsigned sz = efi_dp_size(dp);
void *p = dp_alloc(sz + node->length + sizeof(END));
+   if (!p)
+   return NULL;
memcpy(p, dp, sz);
memcpy(p + sz, node, node->length);
memcpy(p + sz + node->length, , sizeof(END));
@@ -435,6 +446,8 @@ struct efi_device_path *efi_dp_from_dev(struct udevice *dev)
void *buf, *start;
 
start = buf = dp_alloc(dp_size(dev) + sizeof(END));
+   if (!buf)
+   return NULL;
buf = dp_fill(buf, dev);
*((struct efi_device_path *)buf) = END;
 
@@ -576,6 +589,8 @@ struct efi_device_path *efi_dp_from_part(struct blk_desc 
*desc, int part)
void *buf, *start;
 
start = buf = dp_alloc(dp_part_size(desc, part) + sizeof(END));
+   if (!buf)
+   return NULL;
 
buf = dp_part_fill(buf, desc, part);
 
@@ -614,6 +629,8 @@ struct efi_device_path *efi_dp_from_file(struct blk_desc 
*desc, int part,
dpsize += fpsize;
 
start = buf = dp_alloc(dpsize + sizeof(END));
+   if (!buf)
+   return NULL;
 
if (desc)
buf = dp_part_fill(buf, desc, part);
@@ -648,6 +665,8 @@ struct efi_device_path *efi_dp_from_eth(void)
dpsize += sizeof(*ndp);
 
start = buf = dp_alloc(dpsize + sizeof(END));
+   if (!buf)
+   return NULL;
 
 #ifdef CONFIG_DM_ETH
buf = dp_fill(buf, eth_get_dev());
@@ -678,6 +697,8 @@ struct efi_device_path *efi_dp_from_mem(uint32_t 
memory_type,
void *buf, *start;
 
start = buf = dp_alloc(sizeof(*mdp) + sizeof(END));
+   if (!buf)
+   return NULL;
 

Re: [U-Boot] Pull request: u-boot-net.git master

2018-01-17 Thread Joe Hershberger
Hi Tom,

On Mon, Jan 15, 2018 at 8:25 PM, Tom Rini  wrote:
> On Mon, Jan 15, 2018 at 12:06:17PM -0600, Joe Hershberger wrote:
>
>> Hi Tom,
>>
>> The following changes since commit 3dde8f20377c3a051dda64497bdf0cdb23e03a2d:
>>
>>   Merge git://git.denx.de/u-boot-mmc (2018-01-14 22:26:38 -0500)
>>
>> are available in the git repository at:
>>
>>
>>   git://git.denx.de/u-boot-net.git master
>>
>> for you to fetch changes up to 1e2d2597a667e16adfe0a8a9be22e904cee84727:
>>
>>   phy: atheros: set auto-negotiation for AR8021 (2018-01-15 12:05:27 -0600)
>>
>
> Applied to u-boot/master, thanks!
>
> But please note from ceheckpatch.pl (which is actually pretty good):

Sorry, I should have noted this in the PR. These remaining checkpatch
spew are deliberate. I reviewed each of them to be acceptable.

Cheers,
-Joe

>
> WARNING: please write a paragraph that describes the config symbol fully
> #37: FILE: drivers/net/Kconfig:188:
> +config MACB_ZYNQ
>
> total: 0 errors, 1 warnings, 0 checks, 213 lines checked
> ERROR: Unrecognized email address: 'Coverity (CID: 144423)'
> #8:
> Reported-by: Coverity (CID: 144423)
>
> total: 1 errors, 0 warnings, 0 checks, 19 lines checked
> WARNING: please write a paragraph that describes the config symbol fully
> #34: FILE: drivers/net/phy/Kconfig:15:
> +config B53_SWITCH
>
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #67:
> new file mode 100644
>
> CHECK: Prefer using the BIT macro
> #134: FILE: drivers/net/phy/b53.c:63:
> +#define   PORT_OVERRIDE_SPEED_100M (1 << PORT_OVERRIDE_SPEED_S)
>
> total: 0 errors, 2 warnings, 1 checks, 675 lines checked
> CHECK: Unbalanced braces around else statement
> #38: FILE: net/bootp.c:396:
> +   } else
>
> total: 0 errors, 0 warnings, 1 checks, 24 lines checked
> WARNING: A patch subject line should describe the change not the tool that 
> found it
> #4:
> Subject: [PATCH] net: sh-eth: Fix coding style checked by checkpatch.pl
>
> WARNING: 'alligned' may be misspelled - perhaps 'aligned'?
> #10:
> Change from alligned to aligned.
>
> total: 0 errors, 2 warnings, 0 checks, 92 lines checked
> WARNING: please write a paragraph that describes the config symbol fully
> #277: FILE: drivers/net/Kconfig:279:
> +config SH_ETHER
>
> total: 0 errors, 1 warnings, 0 checks, 273 lines checked
>
> --
> Tom
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-01-17 Thread York Sun
Tom,

The following changes since commit 3dde8f20377c3a051dda64497bdf0cdb23e03a2d:

  Merge git://git.denx.de/u-boot-mmc (2018-01-14 22:26:38 -0500)

are available in the git repository at:

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

for you to fetch changes up to 2eb2dbd4577898bf289e911b2286df3f2363af6e:

  armv8: ls1088ardb: Add environment variable address location for
QSPI-NOR (2018-01-17 10:30:54 -0800)


Ashish Kumar (3):
  armv8: ls1088: Add USB and PCI configs in SD-BOOT defconfig
  env: sf: Add support for env init for QSPI-NOR
  armv8: ls1088ardb: Add environment variable address location for
QSPI-NOR

Bhaskar Upadhaya (2):
  armv8/kconfig: Align boards of same family at one place
  board: ls1012a: LS1012A-2G5RDB board support

Priyanka Jain (2):
  board/ls2081ardb: Update board related prints
  board/ls2081ard: Correct code to get QMAP value in checkboard

Sriram Dash (1):
  serial: lpuart: Proper device identification

Sumit Garg (1):
  configs: SECURE_BOOT: Enable CONFIG_CMD_EXT4_WRITE

Tom Rini (3):
  powerpc: P1010RDB: Rework local command to not be included in SPL
  arm: ls1021atwr: Rework local commands to not be included in SPL
  freescale: Ensure common commands are not included in SPL binary

Yuantian Tang (2):
  arm64: ls1046a: Add sata distro boot support
  arm64: ls1012a: Add sata distro boot support

Zhang Ying-22455 (1):
  armv8/ls1088a: configure PMU's PCTBENR to enable WDT

 arch/arm/Kconfig   |  12 +++
 arch/arm/cpu/armv8/Kconfig |   5 +-
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c|   4 +-
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/fsl-ls1012a-2g5rdb.dts|  43 ++
 board/freescale/common/Kconfig |   2 +
 board/freescale/common/cmd_esbc_validate.c |   2 +
 board/freescale/common/qixis.c |  14 ++--
 board/freescale/ls1012ardb/Kconfig |  18 +
 board/freescale/ls1012ardb/MAINTAINERS |   7 ++
 board/freescale/ls1012ardb/README  |  43 ++
 board/freescale/ls1012ardb/ls1012ardb.c|   7 +-
 board/freescale/ls1021atwr/ls1021atwr.c|  91 +++--
 board/freescale/ls2080ardb/ls2080ardb.c|   4 +-
 board/freescale/p1010rdb/p1010rdb.c|   2 +
 configs/ls1012a2g5rdb_qspi_defconfig   |  40 ++
 configs/ls1088aqds_sdcard_qspi_defconfig   |  12 +++
 configs/ls1088ardb_sdcard_qspi_defconfig   |  12 +++
 drivers/serial/serial_lpuart.c |  18 ++---
 env/sf.c   |  21 +
 include/configs/ls1012a2g5rdb.h| 122
+
 include/configs/ls1012a_common.h   |  11 +++
 include/configs/ls1012aqds.h   |  10 ---
 include/configs/ls1012ardb.h   |   9 ---
 include/configs/ls1046a_common.h   |  13 +++
 include/configs/ls1046aqds.h   |  10 ---
 include/configs/ls1046ardb.h   |  12 ---
 include/configs/ls1088a_common.h   |   6 ++
 include/configs/ls1088aqds.h   |   1 -
 include/configs/ls1088ardb.h   |   1 -
 30 files changed, 439 insertions(+), 114 deletions(-)
 create mode 100644 arch/arm/dts/fsl-ls1012a-2g5rdb.dts
 create mode 100644 configs/ls1012a2g5rdb_qspi_defconfig
 create mode 100644 include/configs/ls1012a2g5rdb.h

Thanks.

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


[U-Boot] [BUG] x86: Could not get phandle node for /gpios@0:num-gpios(cell 0)

2018-01-17 Thread Heinrich Schuchardt
When running the Travis test suite for master I see warnings

arch/sandbox/dts/sandbox.dtb: Warning (gpios_property): Could not get
phandle node for /gpios@0:num-gpios(cell 0)
(https://travis-ci.org/xypron2/u-boot/jobs/329755777)

The warning is created by check_gpios_property() in scripts/dtc/checks.c.

This seems to be cause by the following patch:
999a78d5cf00dfb8cd8342454933ea492e955377
("scripts/dtc: Update to upstream version v1.4.5-3-gb1a60033c110")

I guess that the dts is ok and the test is incorrect. Could you, please,
have look.

Best regards

Heinrich

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


Re: [U-Boot] [U-Boot, v4, 07/11] spl: add support to booting with OP-TEE

2018-01-17 Thread Bryan O'Donoghue



On 15/01/18 04:48, Peng Fan wrote:

On Mon, Jan 15, 2018 at 11:25:00AM +0800, Kever Yang wrote:

Bryan,


On 01/12/2018 11:10 PM, Bryan O'Donoghue wrote:



On 12/01/18 11:27, Philipp Tomsich wrote:

OP-TEE is an open source trusted OS, in armv7, its loading and
running are like this:
loading:
- SPL load both OP-TEE and U-Boot
running:
- SPL run into OP-TEE in secure mode;
- OP-TEE run into U-Boot in non-secure mode;

More detail:
https://github.com/OP-TEE/optee_os
and search for 'boot arguments' for detail entry parameter in:
core/arch/arm/kernel/generic_entry_a32.S

Signed-off-by: Kever Yang 
---

Changes in v4:
- use NULL instead of '0'
- add fdt_addr as arg2 of entry

Changes in v3: None
Changes in v2:
- Using new image type for op-tee

  common/spl/Kconfig |  7 +++
  common/spl/Makefile|  1 +
  common/spl/spl.c   |  9 +
  common/spl/spl_optee.S | 13 +
  include/spl.h  | 13 +
  5 files changed, 43 insertions(+)
  create mode 100644 common/spl/spl_optee.S



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



Kever, Philipp

I have patches that define a IH_TYPE_OPTEE as a bootable OPTEE
image (one that never returns to u-boot).


I don't understand how you use OP-TEE in your project.
You are using U-Boot 'bootm' cmd to run into OP-TEE and 'PC' never
get out of the OP-TEE os?
The upstream OP-TEE will always be back to the pointer in 'lr'.

We are using boot flow like ARMv8 for OP-TEE in armv7, could you
introduce your flow?


The flow is ROM->U-Boot->OP-TEE->Linux.


Hi Kever, this got buried in my mailbox...

Which I believe is the preferred flow for armv7

That said - if you look at the TI commits for IH_TYPE_TEE I believe 
*that* is the appropriate type for what you are doing with SPL.


As I read the TI code the TEE is installed into memory - jumped into and 
returned out of, which is the model you are using with SPL here.


Basically that's what 
arch/arm/mach-omap2/sec-common.c::secure_tee_install() does.


So, I think the SPL solution you have can co-exist quite easily with the 
model we have described above for imx7.


My only suggestion here is that you probably don't need to define a new 
image type for SPL - you can reuse IH_TYPE_TEE for SPL as below.


Other than that I think the SPL/bootm or indeed the TI method of 
installing a TEE are entirely able to (and should) live side-by-side.



+#if CONFIG_IS_ENABLED(OPTEE)
+case IH_TYPE_TEE:
+debug("Jumping to U-Boot via OP-TEE\n");
+spl_optee_entry(NULL, NULL, spl_image->fdt_addr,
+(void *)spl_image.entry_point);
+break;
+#endif

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


Re: [U-Boot] [PATCH] ubi: Fix filesystem corruption on detach when fastmap enabled

2018-01-17 Thread Richard Weinberger
Martin,

Am Dienstag, 16. Januar 2018, 15:13:04 CET schrieb Martin Townsend:
> > Martin, can you please explain what corruption you see?
> > From reading the code I'd assume that you miss volumes but a full scan
> > would recover everything.
> 
> I didn't do much analysis of the corruption I'm afraid.  When I tried
> to reattach the the c->empty flag was set to true and indeed all the
> EBA tables were reporting an empty filesystem even after a reboot.

Sounds like what I'd expect.

> Not sure if this was recoverable, how do you trigger a full scan?

Booting a kernel without Fastmap support. B-)

> > For Linux I suggest this fix:
> > 
> > From 48287459cf8717cffac5aed423937cd7ba4360ab Mon Sep 17 00:00:00 2001
> > From: Richard Weinberger 
> > Date: Tue, 16 Jan 2018 14:12:46 +0100
> > Subject: [PATCH] ubi: fastmap: Don't flush fastmap work on detach
> > 
> > At this point UBI volumes have already been free()'ed and fastmap can no
> > longer access these data structures.
> > 
> > Fixes: 74cdaf24004a ("UBI: Fastmap: Fix memory leaks while closing the WL
> > sub- system")
> > Signed-off-by: Richard Weinberger 
> > Cc: sta...@vger.kernel.org
> > ---
> > 
> >  drivers/mtd/ubi/fastmap-wl.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
> > index 4f0bd6b4422a..69dd21679a30 100644
> > --- a/drivers/mtd/ubi/fastmap-wl.c
> > +++ b/drivers/mtd/ubi/fastmap-wl.c
> > @@ -362,7 +362,6 @@ static void ubi_fastmap_close(struct ubi_device *ubi)
> > 
> >  {
> >  
> > int i;
> > 
> > -   flush_work(>fm_work);
> > 
> > return_unused_pool_pebs(ubi, >fm_pool);
> > return_unused_pool_pebs(ubi, >fm_wl_pool);
> > 
> > --
> > 2.13.6
> > 
> > In U-Boot you can do the same.
>
> Richard: This will work but just want to check that ubi_wl_close is
> supposed to never write out to the filesystem or will never do so in
> future, if so maybe a something in the comments above ubi_wl_close to
> ensure this?

Hmm, not sure if I got this question.
The filesystem sits above UBI. If we reach ubi_wl_close() all users ontop of 
UBI are gone. There is no UBIFS mounted anymore.

Thanks,
//richard

-- 
sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
ATU66964118 - FN 374287y
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 0/6] Support for the Turris Omnia router

2018-01-17 Thread Andreas Färber
Hi Marek and Stefan,

Am 09.06.2017 um 19:28 schrieb Marek Behún:
> This is the fourth version of patches for adding support for the
> Turris Omnia board, a router developed by the CZ.NIC.

I'm still facing trouble testing turris_omnia on latest v2018.01.

First, that made me notice there's no README for how to test and deploy.
I'm aware of temporary:
sendbeacon /dev/ttyUSBx
./tools/kwboot -t -B 115200 /dev/ttyUSBx -b u-boot-spl.kwb -p
# or without -p when s/BOOT_FROM spi/BOOT_FROM uart/
and permanent:
tftpboot 0x100 u-boot-spl.kwb
sf probe
sf update 0x100 0 $filesize

I used to have the original factory CZ.NIC U-Boot in SPI and booted test
versions only via sendbeacon+kwboot.

With mainline that appears to be broken - the CONFIG_ARMADA_38X code in
arch/arm/mach-mvebu/spl.c seems to run into !boot_device and instead of
UART tries to boot from SPI - nothing happens then and kwboot complains.
I can force it to continue booting from UART by commenting out the if.
So Stefan, it looks like your auto-detection is not working here and the
Kconfig option to force it was dropped prematurely.

When forcing UART, as soon as the progress surpasses 99%, it reboots
into SPI SPL without any error message.
Using the old U-Boot fork I've tried flashing u-boot-spl.kwb - similarly
it gets stuck in the SPL trying to boot on from SPI. After a while it
reboots, and so on in a loop.

So it seems that non-SPL U-Boot 2018.01 is broken, on my 2 GB model.

I also ran into a couple DDR3 training failures when booting via UART.
No such training problems observed booting from SPI.

Any hints appreciated.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-01-17 Thread Diego Dorta
Hi Peng,

2018-01-16 10:25 GMT-02:00 Peng Fan :
>
>
>> -Original Message-
>> From: Diego Dorta [mailto:diegohdo...@gmail.com]
>> Sent: Tuesday, January 16, 2018 8:15 PM
>> To: Peng Fan 
>> Cc: Peng Fan ; Fabio Estevam
>> ; U-Boot-Denx 
>> Subject: Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and
>> i.MX8MQ EVK
>>
>> Hi Peng,
>>
>> 2018-01-13 8:55 GMT-02:00 Peng Fan :
>> > Hi Diego,
>> > On Thu, Jan 11, 2018 at 10:36:02AM -0200, Diego Dorta wrote:
>> >>Hi Peng,
>> >>
>> >>2018-01-10 23:16 GMT-02:00 Peng Fan :
>> >>> Hi Diego,
>> >>>
>> >>> On Wed, Jan 10, 2018 at 11:08:54AM -0200, Diego Dorta wrote:
>> Hi Peng,
>> 
>> 2018-01-10 3:20 GMT-02:00 Peng Fan :
>> > This patchset is to add i.MX8M and i.MX8MQ-EVK support
>> >
>> > V5:
>> >  Drop wait_mask_set/clr_timeout and switch to use
>> > readl_poll_timeout in  the patchset.
>> >
>> > V4:
>> >  Regenerate patchset based on Tom's master tree.
>> >  In this patchset,
>> >
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2
>> >
>> Fpatchwork.ozlabs.org%2Fpatch%2F855027%2F=02%7C01%7Cpeng.fan%
>> >
>> 40nxp.com%7C7ff0a80d79454c1eb43608d55cdad59d%7C686ea1d3bc2b4c6fa92
>> >
>> cd99c5c301635%7C0%7C1%7C636517017329353990=ukU9u%2B99GtYbM
>> Pu
>> > 1F18ZK2FvUpwWJI5ge4Hb607OPMk%3D=0
>> >  "arm: imx: Rework i.MX specific commands to be excluded from SPL"
>> > from  Tom is included to avoid merge conflicts because the i.mx8m
>> > change  also has some modification to bootaux and arch/arm/mach-
>> imx/Makefile.
>> >  Because CONFIG_GPT_TIMER change, I did a small modification to
>> > apply  Tom's patch, no function change.
>> >
>> >  Include ATF link in README.
>> >
>> > V3:
>> >  This patchset based on
>> >
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2
>> >
>> Fpatchwork.ozlabs.org%2Fpatch%2F855027%2F=02%7C01%7Cpeng.fan%
>> >
>> 40nxp.com%7C7ff0a80d79454c1eb43608d55cdad59d%7C686ea1d3bc2b4c6fa92
>> >
>> cd99c5c301635%7C0%7C1%7C636517017329353990=ukU9u%2B99GtYbM
>> Pu
>> > 1F18ZK2FvUpwWJI5ge4Hb607OPMk%3D=0
>> >  "arm: imx: Rework i.MX specific commands to be excluded from SPL"
>> > from  Tom to avoid this patchset fail apply after Tom's patch merged.
>> >
>> >  Previously "power: pmic/regulator allow dm be omited by SPL"
>> > broke other  boards, in V3 patchset, only touch pfuze100 related 
>> > options.
>> >
>> >  Sharing code about get mac from fuse between mx7/mx8m  Sharing
>> > code about bootaux between mx6/7/mx8m  Sharing code about cpu
>> > speed grade between mx7/mx8m  Sharing code about get boot device
>> > between mx7/mx8m  Sharding code about mmc env between
>> mx7/mx8m
>> >
>> >  Introduce wait_mask_set/clr_timeout to avoid deadloop in clock
>> > pll configuration
>> >
>> >  Correct authorship of fix building warning on fec arm64, patch 27/31.
>> >
>> >  Switch to use structure for DDR Controller. For DDR PHY
>> > registers,  there are about more than 10 thousands registers, I
>> > could not convert  them with detailed register name, and the
>> > script is generated from IC team,  So I use regs[0x] arrays
>> > here fo easily converting between IC team  released script and uboot
>> ddr phy cod.
>> >
>> >  Improve REAMME file to include where to download firmware and
>> > imx-mkimage  and how to build
>> >
>> >  Add review tags on the V2 patchset.
>> >
>> >  Hope this patchset could catch up next release :)
>> >
>> > V2:
>> >
>> >  patch 02/23: convert to structure, drop is_boot_from_usb and
>> >   disconnect_from_usb
>> >  patch 04/23: conver to use structure for the clock driver, removed the
>> >   CCM_xxx macros. Add static for local functons.
>> >   Add init_usdhc_clk, init_uart_clk and etc to not enable
>> >   them all at default.
>> >  patch 05/23: Add more commit msg for the sip part.
>> >  patch 08/23: Merge the spl boot device with i.MX7  patch 12/23:
>> > Typo fix and return error fix from Heiko for the SoC related part
>> > patch 22/23: Use a weak function ddr_init. If patch 23/23 could not be
>> >   accepted at current stage, to make others still be could 
>> > be
>> >   compiled.
>> >
>> > The patchset depends on
>> >
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2
>> >
>> Fpatchwork.ozlabs.org%2Fpatch%2F841934%2F=02%7C01%7Cpeng.fan%
>> >
>> 40nxp.com%7C7ff0a80d79454c1eb43608d55cdad59d%7C686ea1d3bc2b4c6fa92
>> >
>> cd99c5c301635%7C0%7C1%7C636517017329353990=Il%2F%2Bkzq%2B0G
>> S
>> > 

Re: [U-Boot] [PATCH] mmc: fix the wrong dislabing clock

2018-01-17 Thread Jean-Jacques Hiblot



On 17/01/2018 11:56, Jaehoon Chung wrote:

Hi,

On 01/17/2018 07:36 PM, Jaehoon Chung wrote:

When power is off, clock is not disabling.
Because it's passed to 1, mmc->clock should be set to f_min value.
Some drivers can't initialize the eMMC/SD card with current status.

This patch is to fix the disabling clock value to 0.

Subject is typo..Will resend. but i want to get the opinion about this patch.


It looks good to me.

Reviewed-by: Jean-Jacques Hiblot 




Best Regards,
Jaehoon Chung


Fixes: 2e7410d76ad1 ("mmc: disable the mmc clock during power off")

Signed-off-by: Jaehoon Chung 
---
  drivers/mmc/mmc.c | 12 +++-
  1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 53c819187e..311f51f237 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1501,11 +1501,13 @@ static int mmc_set_ios(struct mmc *mmc)
  
  int mmc_set_clock(struct mmc *mmc, uint clock, bool disable)

  {
-   if (clock > mmc->cfg->f_max)
-   clock = mmc->cfg->f_max;
+   if (!disable && clock != 0) {
+   if (clock > mmc->cfg->f_max)
+   clock = mmc->cfg->f_max;
  
-	if (clock < mmc->cfg->f_min)

-   clock = mmc->cfg->f_min;
+   if (clock < mmc->cfg->f_min)
+   clock = mmc->cfg->f_min;
+   }
  
  	mmc->clock = clock;

mmc->clk_disable = disable;
@@ -2449,7 +2451,7 @@ static int mmc_power_on(struct mmc *mmc)
  
  static int mmc_power_off(struct mmc *mmc)

  {
-   mmc_set_clock(mmc, 1, true);
+   mmc_set_clock(mmc, 0, true);
  #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR)
if (mmc->vmmc_supply) {
int ret = regulator_set_enable(mmc->vmmc_supply, false);





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


[U-Boot] [PATCH 4/5] zynq: board: Remove checkboard

2018-01-17 Thread Ezequiel Garcia
Now that showing silicon version is part of the CPU
info display, let's remove checkboard().

Note that the generic show_board_info() will still
show the DT 'model' property. For instance:

  U-Boot 2018.01-00172-g5e296ab7317a (Jan 17 2018 - 09:57:36 -0300)

  CPU:   Zynq 7z010
  Silicon: v3.1
  Model: Bitmain Antminer S9 Board

Signed-off-by: Ezequiel Garcia 
---
 board/xilinx/zynq/board.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index f9e7bca4ee40..2374da68328f 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -11,7 +11,6 @@
 #include 
 #include 
 #include 
-#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -52,22 +51,6 @@ int board_late_init(void)
return 0;
 }
 
-#ifdef CONFIG_DISPLAY_BOARDINFO
-int checkboard(void)
-{
-   u32 version = zynq_get_silicon_version();
-
-   version <<= 1;
-   if (version > (PCW_SILICON_VERSION_3 << 1))
-   version += 1;
-
-   puts("Board: Xilinx Zynq\n");
-   printf("Silicon: v%d.%d\n", version >> 1, version & 1);
-
-   return 0;
-}
-#endif
-
 int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
 {
 #if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
-- 
2.15.1

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


[U-Boot] [PATCH 3/5] zynq: Support CPU info display

2018-01-17 Thread Ezequiel Garcia
This commit adds CPU and silicon version information
consuming the SLCR IDCODE and DEVCFG MCTRL registers,
respectively.

Signed-off-by: Ariel D'Alessandro 
Signed-off-by: Ezequiel Garcia 
---
 arch/arm/mach-zynq/cpu.c | 46 ++
 1 file changed, 46 insertions(+)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index 53a07b0059c2..602f483c162b 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -35,6 +35,25 @@ static const struct {
 };
 #endif
 
+#ifdef CONFIG_DISPLAY_CPUINFO
+static const struct {
+   u8 idcode;
+   const char *cpuinfo;
+} zynq_cpu_info[] = {
+   { .idcode = XILINX_ZYNQ_7007S,  .cpuinfo = XILINX_XC7Z007S_NAME },
+   { .idcode = XILINX_ZYNQ_7010,   .cpuinfo = XILINX_XC7Z010_NAME },
+   { .idcode = XILINX_ZYNQ_7012S,  .cpuinfo = XILINX_XC7Z012S_NAME },
+   { .idcode = XILINX_ZYNQ_7014S,  .cpuinfo = XILINX_XC7Z014S_NAME },
+   { .idcode = XILINX_ZYNQ_7015,   .cpuinfo = XILINX_XC7Z015_NAME },
+   { .idcode = XILINX_ZYNQ_7020,   .cpuinfo = XILINX_XC7Z020_NAME },
+   { .idcode = XILINX_ZYNQ_7030,   .cpuinfo = XILINX_XC7Z030_NAME },
+   { .idcode = XILINX_ZYNQ_7035,   .cpuinfo = XILINX_XC7Z035_NAME },
+   { .idcode = XILINX_ZYNQ_7045,   .cpuinfo = XILINX_XC7Z045_NAME },
+   { .idcode = XILINX_ZYNQ_7100,   .cpuinfo = XILINX_XC7Z100_NAME },
+   { /* Sentinel */ },
+};
+#endif
+
 int arch_cpu_init(void)
 {
zynq_slcr_unlock();
@@ -99,3 +118,30 @@ const xilinx_desc *zynq_fpga_desc(void)
return NULL;
 }
 #endif
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+int print_cpuinfo(void)
+{
+   u32 idcode, version;
+   bool found;
+   u8 i;
+
+   idcode = zynq_slcr_get_idcode();
+   found = false;
+   for (i = 0; zynq_cpu_info[i].idcode; i++) {
+   if (zynq_cpu_info[i].idcode == idcode) {
+   found = true;
+   break;
+   }
+   }
+
+   version = zynq_get_silicon_version() << 1;
+   if (version > (PCW_SILICON_VERSION_3 << 1))
+   version += 1;
+   if (found) {
+   printf("CPU:   Zynq %s\n", zynq_cpu_info[i].cpuinfo);
+   printf("Silicon: v%d.%d\n", version >> 1, version & 1);
+   }
+   return 0;
+}
+#endif
-- 
2.15.1

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


[U-Boot] [PATCH 5/5] configs: zynq: Enable DISPLAY_CPUINFO

2018-01-17 Thread Ezequiel Garcia
Now that silicon version has been moved from checkboard()
to print_cpuinfo(), we need to enable DISPLAY_CPUINFO option.

Signed-off-by: Ezequiel Garcia 
---
 configs/syzygy_hub_defconfig   | 1 -
 configs/topic_miami_defconfig  | 1 -
 configs/topic_miamilite_defconfig  | 1 -
 configs/topic_miamiplus_defconfig  | 1 -
 configs/zynq_cc108_defconfig   | 1 -
 configs/zynq_cse_qspi_defconfig| 1 -
 configs/zynq_microzed_defconfig| 1 -
 configs/zynq_picozed_defconfig | 1 -
 configs/zynq_z_turn_defconfig  | 1 -
 configs/zynq_zc702_defconfig   | 1 -
 configs/zynq_zc706_defconfig   | 1 -
 configs/zynq_zc770_xm010_defconfig | 1 -
 configs/zynq_zc770_xm011_defconfig | 1 -
 configs/zynq_zc770_xm012_defconfig | 1 -
 configs/zynq_zc770_xm013_defconfig | 1 -
 configs/zynq_zed_defconfig | 1 -
 configs/zynq_zybo_defconfig| 1 -
 17 files changed, 17 deletions(-)

diff --git a/configs/syzygy_hub_defconfig b/configs/syzygy_hub_defconfig
index 8bdc4be67d70..b4a41b484885 100644
--- a/configs/syzygy_hub_defconfig
+++ b/configs/syzygy_hub_defconfig
@@ -9,7 +9,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/topic_miami_defconfig b/configs/topic_miami_defconfig
index aabd705da0fb..866c91276d95 100644
--- a/configs/topic_miami_defconfig
+++ b/configs/topic_miami_defconfig
@@ -8,7 +8,6 @@ 
CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miami/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miami"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
diff --git a/configs/topic_miamilite_defconfig 
b/configs/topic_miamilite_defconfig
index 7228283b3c6b..1cae54c2da5e 100644
--- a/configs/topic_miamilite_defconfig
+++ b/configs/topic_miamilite_defconfig
@@ -8,7 +8,6 @@ 
CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miamilite/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miamilite"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
diff --git a/configs/topic_miamiplus_defconfig 
b/configs/topic_miamiplus_defconfig
index d511a942838b..13f69eb4b1ca 100644
--- a/configs/topic_miamiplus_defconfig
+++ b/configs/topic_miamiplus_defconfig
@@ -8,7 +8,6 @@ 
CONFIG_BOOT_INIT_FILE="board/topic/zynq/zynq-topic-miamiplus/ps7_regs.txt"
 CONFIG_DEFAULT_DEVICE_TREE="zynq-topic-miamiplus"
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=0
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
diff --git a/configs/zynq_cc108_defconfig b/configs/zynq_cc108_defconfig
index bdba0d1cc9ba..31d5dda12b06 100644
--- a/configs/zynq_cc108_defconfig
+++ b/configs/zynq_cc108_defconfig
@@ -7,7 +7,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_HUSH_PARSER=y
diff --git a/configs/zynq_cse_qspi_defconfig b/configs/zynq_cse_qspi_defconfig
index 9659faefbf33..f5201a72d6be 100644
--- a/configs/zynq_cse_qspi_defconfig
+++ b/configs/zynq_cse_qspi_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEFAULT_DEVICE_TREE="zynq-cse-qspi-single"
 CONFIG_DEBUG_UART=y
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_BOOTDELAY=-1
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_PROMPT="Zynq> "
diff --git a/configs/zynq_microzed_defconfig b/configs/zynq_microzed_defconfig
index fc21eb8f67a3..fbce9631f893 100644
--- a/configs/zynq_microzed_defconfig
+++ b/configs/zynq_microzed_defconfig
@@ -6,7 +6,6 @@ CONFIG_DEFAULT_DEVICE_TREE="zynq-microzed"
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/zynq_picozed_defconfig b/configs/zynq_picozed_defconfig
index f36e7bd849f4..e58b90b710ca 100644
--- a/configs/zynq_picozed_defconfig
+++ b/configs/zynq_picozed_defconfig
@@ -3,7 +3,6 @@ CONFIG_ARCH_ZYNQ=y
 CONFIG_SYS_TEXT_BASE=0x400
 CONFIG_SPL_STACK_R_ADDR=0x20
 CONFIG_DEFAULT_DEVICE_TREE="zynq-picozed"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/zynq_z_turn_defconfig b/configs/zynq_z_turn_defconfig
index c727b2acbf28..d4934c8d1673 100644
--- a/configs/zynq_z_turn_defconfig
+++ b/configs/zynq_z_turn_defconfig
@@ -7,7 +7,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/zynq_zc702_defconfig b/configs/zynq_zc702_defconfig
index 0d0efc223dd4..df0a1adf793d 100644
--- a/configs/zynq_zc702_defconfig
+++ b/configs/zynq_zc702_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART=y
 

[U-Boot] [PATCH 2/5] zynq: Rework FPGA initialization

2018-01-17 Thread Ezequiel Garcia
This commit moves the FPGA descriptor definition
to mach-zynq, where it makes more sense.

Also, the implementation is reworked to be cleaner
and a bit smaller.

add/remove: 2/11 grow/shrink: 0/1 up/down: 420/-608 (-188)
function old new   delta
zynq_fpga_descs- 352+352
zynq_fpga_desc -  68 +68
fpga100   28   - -28
fpga045   28   - -28
fpga035   28   - -28
fpga030   28   - -28
fpga020   28   - -28
fpga015   28   - -28
fpga014s  28   - -28
fpga012s  28   - -28
fpga010   28   - -28
fpga007s  28   - -28
fpga  28   - -28
board_init   332  32-300
Total: Before=574182, After=573994, chg -0.03%

Signed-off-by: Ariel D'Alessandro 
Signed-off-by: Ezequiel Garcia 
---
 arch/arm/mach-zynq/cpu.c| 41 +++-
 arch/arm/mach-zynq/include/mach/sys_proto.h |  3 ++
 board/xilinx/zynq/board.c   | 59 +
 3 files changed, 44 insertions(+), 59 deletions(-)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index ee1c1a943b66..53a07b0059c2 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -5,14 +5,36 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 
 #define ZYNQ_SILICON_VER_MASK  0xF000
 #define ZYNQ_SILICON_VER_SHIFT 28
 
+#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
+(defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
+static const struct {
+   u8 idcode;
+   xilinx_desc desc;
+} zynq_fpga_descs[] = {
+   { .idcode = XILINX_ZYNQ_7007S,  .desc = XILINX_XC7Z007S_DESC(0x07) },
+   { .idcode = XILINX_ZYNQ_7010,   .desc = XILINX_XC7Z010_DESC(0x10)  },
+   { .idcode = XILINX_ZYNQ_7012S,  .desc = XILINX_XC7Z012S_DESC(0x12) },
+   { .idcode = XILINX_ZYNQ_7014S,  .desc = XILINX_XC7Z014S_DESC(0x14) },
+   { .idcode = XILINX_ZYNQ_7015,   .desc = XILINX_XC7Z015_DESC(0x15)  },
+   { .idcode = XILINX_ZYNQ_7020,   .desc = XILINX_XC7Z020_DESC(0x20)  },
+   { .idcode = XILINX_ZYNQ_7030,   .desc = XILINX_XC7Z030_DESC(0x30)  },
+   { .idcode = XILINX_ZYNQ_7035,   .desc = XILINX_XC7Z035_DESC(0x35)  },
+   { .idcode = XILINX_ZYNQ_7045,   .desc = XILINX_XC7Z045_DESC(0x45)  },
+   { .idcode = XILINX_ZYNQ_7100,   .desc = XILINX_XC7Z100_DESC(0x100) },
+   { /* Sentinel */ },
+};
+#endif
+
 int arch_cpu_init(void)
 {
zynq_slcr_unlock();
@@ -60,3 +82,20 @@ void enable_caches(void)
dcache_enable();
 }
 #endif
+
+#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
+(defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
+const xilinx_desc *zynq_fpga_desc(void)
+{
+   u32 idcode;
+   u8 i;
+
+   idcode = zynq_slcr_get_idcode();
+   for (i = 0; zynq_fpga_descs[i].idcode; i++) {
+   if (zynq_fpga_descs[i].idcode == idcode) {
+   return _fpga_descs[i].desc;
+   }
+   }
+   return NULL;
+}
+#endif
diff --git a/arch/arm/mach-zynq/include/mach/sys_proto.h 
b/arch/arm/mach-zynq/include/mach/sys_proto.h
index af61352dd110..fd5744c4e85e 100644
--- a/arch/arm/mach-zynq/include/mach/sys_proto.h
+++ b/arch/arm/mach-zynq/include/mach/sys_proto.h
@@ -7,6 +7,8 @@
 #ifndef _SYS_PROTO_H_
 #define _SYS_PROTO_H_
 
+#include 
+
 extern void zynq_slcr_lock(void);
 extern void zynq_slcr_unlock(void);
 extern void zynq_slcr_cpu_reset(void);
@@ -16,6 +18,7 @@ extern u32 zynq_slcr_get_boot_mode(void);
 extern u32 zynq_slcr_get_idcode(void);
 extern int zynq_slcr_get_mio_pin_status(const char *periph);
 extern void zynq_ddrc_init(void);
+extern const xilinx_desc *zynq_fpga_desc(void);
 extern unsigned int zynq_get_silicon_version(void);
 
 int zynq_board_read_rom_ethaddr(unsigned char *ethaddr);
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index e59038106aa6..f9e7bca4ee40 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -15,69 +15,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
-(defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
-static xilinx_desc fpga;
-
-/* It can be done differently */
-static xilinx_desc fpga007s = XILINX_XC7Z007S_DESC(0x7);
-static xilinx_desc fpga010 = 

[U-Boot] [PATCH 1/5] zynq: Define macros for the device names

2018-01-17 Thread Ezequiel Garcia
This will allow to reuse the macros when showing
the CPU info.

Signed-off-by: Ezequiel Garcia 
---
 include/zynqpl.h | 32 ++--
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/include/zynqpl.h b/include/zynqpl.h
index 5a34a17daefe..e10a266643bd 100644
--- a/include/zynqpl.h
+++ b/include/zynqpl.h
@@ -42,45 +42,57 @@ extern struct xilinx_fpga_op zynq_op;
 #define XILINX_XC7Z045_SIZE106571232/8
 #define XILINX_XC7Z100_SIZE139330784/8
 
+/* Device Names */
+#define XILINX_XC7Z007S_NAME   "7z007s"
+#define XILINX_XC7Z010_NAME"7z010"
+#define XILINX_XC7Z012S_NAME   "7z012s"
+#define XILINX_XC7Z014S_NAME   "7z014s"
+#define XILINX_XC7Z015_NAME"7z015"
+#define XILINX_XC7Z020_NAME"7z020"
+#define XILINX_XC7Z030_NAME"7z030"
+#define XILINX_XC7Z035_NAME"7z035"
+#define XILINX_XC7Z045_NAME"7z045"
+#define XILINX_XC7Z100_NAME"7z100"
+
 /* Descriptor Macros */
 #define XILINX_XC7Z007S_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z007S_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z007s" }
+   XILINX_XC7Z007S_NAME }
 
 #define XILINX_XC7Z010_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z010_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z010" }
+   XILINX_XC7Z010_NAME }
 
 #define XILINX_XC7Z012S_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z012S_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z012s" }
+   XILINX_XC7Z012S_NAME }
 
 #define XILINX_XC7Z014S_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z014S_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z014s" }
+   XILINX_XC7Z014S_NAME }
 
 #define XILINX_XC7Z015_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z015_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z015" }
+   XILINX_XC7Z015_NAME }
 
 #define XILINX_XC7Z020_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z020_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z020" }
+   XILINX_XC7Z020_NAME }
 
 #define XILINX_XC7Z030_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z030_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z030" }
+   XILINX_XC7Z030_NAME }
 
 #define XILINX_XC7Z035_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z035_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z035" }
+   XILINX_XC7Z035_NAME }
 
 #define XILINX_XC7Z045_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z045_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z045" }
+   XILINX_XC7Z045_NAME }
 
 #define XILINX_XC7Z100_DESC(cookie) \
 { xilinx_zynq, devcfg, XILINX_XC7Z100_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
-   "7z100" }
+   XILINX_XC7Z100_NAME }
 
 #endif /* _ZYNQPL_H_ */
-- 
2.15.1

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


[U-Boot] [PATCH 0/5] zynq: Fun with board and CPU info display

2018-01-17 Thread Ezequiel Garcia
This series aims at adding support for CPU information display.
While here, following suggestions from Michal, the FPGA
initialization is cleaned up.

Ezequiel Garcia (5):
  zynq: Define macros for the device names
  zynq: Rework FPGA initialization
  zynq: Support CPU info display
  zynq: board: Remove checkboard
  configs: zynq: Enable DISPLAY_CPUINFO

 arch/arm/mach-zynq/cpu.c| 87 -
 arch/arm/mach-zynq/include/mach/sys_proto.h |  3 +
 board/xilinx/zynq/board.c   | 76 +
 configs/syzygy_hub_defconfig|  1 -
 configs/topic_miami_defconfig   |  1 -
 configs/topic_miamilite_defconfig   |  1 -
 configs/topic_miamiplus_defconfig   |  1 -
 configs/zynq_cc108_defconfig|  1 -
 configs/zynq_cse_qspi_defconfig |  1 -
 configs/zynq_microzed_defconfig |  1 -
 configs/zynq_picozed_defconfig  |  1 -
 configs/zynq_z_turn_defconfig   |  1 -
 configs/zynq_zc702_defconfig|  1 -
 configs/zynq_zc706_defconfig|  1 -
 configs/zynq_zc770_xm010_defconfig  |  1 -
 configs/zynq_zc770_xm011_defconfig  |  1 -
 configs/zynq_zc770_xm012_defconfig  |  1 -
 configs/zynq_zc770_xm013_defconfig  |  1 -
 configs/zynq_zed_defconfig  |  1 -
 configs/zynq_zybo_defconfig |  1 -
 include/zynqpl.h| 32 +++
 21 files changed, 112 insertions(+), 103 deletions(-)

-- 
2.15.1

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


Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread RB23
i checked, and if you mean these patches:
https://patchwork.ozlabs.org/patch/765992/
https://patchwork.ozlabs.org/patch/765996/
https://patchwork.ozlabs.org/patch/765997/
https://patchwork.ozlabs.org/patch/765998/

i already applied them, and they didn't work as well.

i also found these patches which i didn't try yet:
https://lists.denx.de/pipermail/u-boot/2017-May/292230.html

should i try those instead?

2018-01-17 15:09 GMT+02:00 Marek Vasut :

> On 01/17/2018 02:06 PM, Simon Goldschmidt wrote:
> > On 17.01.2018 14:01, RB23 wrote:
> >> hey, i downloaded the september and november versions and i applied
> >> the patches on both of them, re-compiled the u boot,
> >> and still, it gives me the same error when trying the command "sf probe"
> >> i'm not sure what to do, is it possible that i missed something? like
> >> a define or something in the make menuconfig?
> >> i did some debugging and it seems that the crash happens on this line:
> >> div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
> >> thanks.
> >>
> >
> > I don't know exactly which patches you are talking about, but the
> > divide-by-zero problem is still present with all patches I applied. To
> > fix it, you need to set up your device tree correctly so that the speed
> > is initialized.
> >
> > If I remember correctly, you need need to have a flash chip below the
> > qspi in the device tree. Check Jason's changes to the various socfpga
> > dts files.
> >
>
> Er, maybe a patch which checks this condition wouldn't hurt ?
>
> --
> Best regards,
> Marek Vasut
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread Marek Vasut
On 01/17/2018 02:06 PM, Simon Goldschmidt wrote:
> On 17.01.2018 14:01, RB23 wrote:
>> hey, i downloaded the september and november versions and i applied
>> the patches on both of them, re-compiled the u boot,
>> and still, it gives me the same error when trying the command "sf probe"
>> i'm not sure what to do, is it possible that i missed something? like
>> a define or something in the make menuconfig?
>> i did some debugging and it seems that the crash happens on this line:
>> div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
>> thanks.
>>
> 
> I don't know exactly which patches you are talking about, but the
> divide-by-zero problem is still present with all patches I applied. To
> fix it, you need to set up your device tree correctly so that the speed
> is initialized.
> 
> If I remember correctly, you need need to have a flash chip below the
> qspi in the device tree. Check Jason's changes to the various socfpga
> dts files.
> 

Er, maybe a patch which checks this condition wouldn't hurt ?

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


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

2018-01-17 Thread Maxime Ripard
On Wed, Jan 17, 2018 at 08:01:34AM -0500, Tom Rini wrote:
> On Wed, Jan 17, 2018 at 09:58:53AM +0100, Maxime Ripard wrote:
> > Hi,
> > 
> > On Tue, Jan 16, 2018 at 04:56:49PM -0500, Tom Rini wrote:
> > > On Tue, Jan 16, 2018 at 10:16:36AM +0100, Maxime Ripard wrote:
> > > > 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 one test seems to fail in one test:
> > > > https://travis-ci.org/mripard/u-boot/jobs/329229382
> > > > 
> > > > I really cannot really make any sense of why a change in the way the
> > > > environment loads could affect the operation of a DHCP client. Is there 
> > > > a
> > > > way to reproduce locally?
> > > 
> > > In this case, roughly, clone https://github.com/swarren/uboot-test-hooks
> > > and then:
> > > $ export PATH=${PATH}:/path/to/uboot-test-hooks/bin
> > > $ export PYTHONPATH=/path/to/uboot-test-hooks/py/travis-ci:${PYTHONPATH}
> > > $ export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/$1
> > > $ ./test/py/test.py --bd vexpress_ca15_tc2 --build-dir 
> > > "$UBOOT_TRAVIS_BUILD_DIR" -k 'net'
> > 
> > Thanks, I had to tweak it a bit to add --id qemu, and copy the
> > conf.vexpress_ca15_tc2_qemu file in a directory with my hostname in
> > the uboot-test-hooks repo.
> 
> Ah right, yes, oops.  I quickly grabbed bits out of my local wrapper
> script around it.

Don't worry, I was on a good enough path :)

> > And this is really getting weird, since the tests passes on my
> > machine:
> > http://code.bulix.org/rp6z29-258577
> 
> Does it repeatedly fail in travis (which, uh, stopped working for me
> yesterday, I haven't seen if it's un-wedged today)?  You can restart a
> specific sub-job rather than the whole.

It was repeatedly failing for that commit, but I reordered a few
commits since (and I tested the new branch on my machine). I triggered
a new build on travis that is currently running, but is taking a long
time to complete. I'll let you know the results.

Thanks!
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] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread Simon Goldschmidt

On 17.01.2018 14:01, RB23 wrote:
hey, i downloaded the september and november versions and i applied 
the patches on both of them, re-compiled the u boot,

and still, it gives me the same error when trying the command "sf probe"
i'm not sure what to do, is it possible that i missed something? like 
a define or something in the make menuconfig?

i did some debugging and it seems that the crash happens on this line:
div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
thanks.



I don't know exactly which patches you are talking about, but the 
divide-by-zero problem is still present with all patches I applied. To 
fix it, you need to set up your device tree correctly so that the speed 
is initialized.


If I remember correctly, you need need to have a flash chip below the 
qspi in the device tree. Check Jason's changes to the various socfpga 
dts files.


Regards,
Simon

2018-01-08 11:17 GMT+02:00 Goldschmidt Simon 
>:


On Mon, 08/012018 06:27, Vignesh R wrote:
> On Monday 08 January 2018 09:10 AM, Jason Rush wrote:
> [...]
> >>> 1. The indaddrtrig register was being programmed with an
incorrect
> >>> value for socfpga as the result of assuming it should be
programmed
> >>> with the same address as the ahbbase address.  This issue is
> >>> resolved by adopting the Linux DT bindings, which has an
independent
> >>> setting for the indaddrtrig register so the register can be
set correctly on all
> architectures.  Plus it aligns the DT between u-boot and Linux.
> >> That should be an easy patch, so this is the patchset
0/5..5/5 that
> >> you just submitted ?
> > Yes. I saw you Acked it, thank you.
> >>> 2. The cadence driver was modified at one point to use the
bouncebuf
> >>> functions to fix an issue on a TI architecture that
expected, where
> >>> if I recall correctly all reads except the last have to be
32-bit
> >>> reads.  However, since the bouncebuf was designed for DMA
transfers,
> >>> it invalidates the data cache after reading, but since the
cadence
> >>> is using cpu transfers the newly read data is thrown away
when the
> >>> cache is invalidated.  This issue is resolved by reverting
the commit that
> introduced using the bounce buffer for read operations, which
according to
> Vignesh don't cause any issues to the TI architecture.
> >> Hm, I wonder why you need bounce buffer at all here. The
CQSPI
> >> literally reads/writes a register space (or some FIFO in register
> >> space), there is no DMA involved at all. I also wonder why we
have to
> >> manipulate with cache at all here.
> >
> > I agree, I don't believe this needs a bounce buffer at all.  This
> > isn't a DMA, there is no need for cache manipulation.  Vignesh
> > understands the problem better than I do on the TI platform, but I
> > believe it was used since it was an easy way to ensure the
register read/writes
> were all 32-bits wide up until the last read/write.
>
> Yes, that was the intention. Unfortunately, I chose to use
common bounce buffer
> implementation which was doing cache manipulations.
>
> > I believe the bounce buffer should be removed from the CQSPI
driver
> > and a different solution should be implemented, but Vignesh should
> > weigh in on that since it effects his architecture.
> >
>
> CQSPI on TI K2G has problems with non 32 bit aligned write
operations.
> But read operations are unaffected. Therefore I have Ack'ed
Simon's patch
> reverting bouncebuf for read. For writes, I have patches to
revert common
> bouncebuf usage and use a local pagesize buffer for overcome
alignment issue. I
> am waiting for current patch backlogs to be merged so that its
easy for testing w/o
> specifying bunch of dependent patches.
>
> Or if Simon agrees, I can add his patch to my series post it to
mailing list (rebased
> on top of Jason's series)?

Well, it's not really "my" patch, anyway. It reverts a commit of
yours, so sure, as long as this does not stand in the way of getting
qspi running on 2018.03, go ahead and itegrate it in your patchset.

I'd be happy to have this sent now so I can test both patchsets on
top of 2018.01(-rc).

Thanks,
Simon




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


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

2018-01-17 Thread Tom Rini
On Wed, Jan 17, 2018 at 09:58:53AM +0100, Maxime Ripard wrote:
> Hi,
> 
> On Tue, Jan 16, 2018 at 04:56:49PM -0500, Tom Rini wrote:
> > On Tue, Jan 16, 2018 at 10:16:36AM +0100, Maxime Ripard wrote:
> > > 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 one test seems to fail in one test:
> > > https://travis-ci.org/mripard/u-boot/jobs/329229382
> > > 
> > > I really cannot really make any sense of why a change in the way the
> > > environment loads could affect the operation of a DHCP client. Is there a
> > > way to reproduce locally?
> > 
> > In this case, roughly, clone https://github.com/swarren/uboot-test-hooks
> > and then:
> > $ export PATH=${PATH}:/path/to/uboot-test-hooks/bin
> > $ export PYTHONPATH=/path/to/uboot-test-hooks/py/travis-ci:${PYTHONPATH}
> > $ export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/$1
> > $ ./test/py/test.py --bd vexpress_ca15_tc2 --build-dir 
> > "$UBOOT_TRAVIS_BUILD_DIR" -k 'net'
> 
> Thanks, I had to tweak it a bit to add --id qemu, and copy the
> conf.vexpress_ca15_tc2_qemu file in a directory with my hostname in
> the uboot-test-hooks repo.

Ah right, yes, oops.  I quickly grabbed bits out of my local wrapper
script around it.

> And this is really getting weird, since the tests passes on my
> machine:
> http://code.bulix.org/rp6z29-258577

Does it repeatedly fail in travis (which, uh, stopped working for me
yesterday, I haven't seen if it's un-wedged today)?  You can restart a
specific sub-job rather than the whole.

-- 
Tom


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


Re: [U-Boot] QSPI "sf probe ...", "sf read ..." on Altera SoC FPGA

2018-01-17 Thread RB23
hey, i downloaded the september and november versions and i applied the
patches on both of them, re-compiled the u boot,
and still, it gives me the same error when trying the command "sf probe"
i'm not sure what to do, is it possible that i missed something? like a
define or something in the make menuconfig?
i did some debugging and it seems that the crash happens on this line:
div = DIV_ROUND_UP(ref_clk_hz, sclk-hz * 2) -1;
thanks.

2018-01-08 11:17 GMT+02:00 Goldschmidt Simon <
sgoldschm...@de.pepperl-fuchs.com>:

> On Mon, 08/012018 06:27, Vignesh R wrote:
> > On Monday 08 January 2018 09:10 AM, Jason Rush wrote:
> > [...]
> > >>> 1. The indaddrtrig register was being programmed with an incorrect
> > >>> value for socfpga as the result of assuming it should be programmed
> > >>> with the same address as the ahbbase address.  This issue is
> > >>> resolved by adopting the Linux DT bindings, which has an independent
> > >>> setting for the indaddrtrig register so the register can be set
> correctly on all
> > architectures.  Plus it aligns the DT between u-boot and Linux.
> > >> That should be an easy patch, so this is the patchset 0/5..5/5 that
> > >> you just submitted ?
> > > Yes. I saw you Acked it, thank you.
> > >>> 2. The cadence driver was modified at one point to use the bouncebuf
> > >>> functions to fix an issue on a TI architecture that expected, where
> > >>> if I recall correctly all reads except the last have to be 32-bit
> > >>> reads.  However, since the bouncebuf was designed for DMA transfers,
> > >>> it invalidates the data cache after reading, but since the cadence
> > >>> is using cpu transfers the newly read data is thrown away when the
> > >>> cache is invalidated.  This issue is resolved by reverting the
> commit that
> > introduced using the bounce buffer for read operations, which according
> to
> > Vignesh don't cause any issues to the TI architecture.
> > >> Hm, I wonder why you need bounce buffer at all here. The CQSPI
> > >> literally reads/writes a register space (or some FIFO in register
> > >> space), there is no DMA involved at all. I also wonder why we have to
> > >> manipulate with cache at all here.
> > >
> > > I agree, I don't believe this needs a bounce buffer at all.  This
> > > isn't a DMA, there is no need for cache manipulation.  Vignesh
> > > understands the problem better than I do on the TI platform, but I
> > > believe it was used since it was an easy way to ensure the register
> read/writes
> > were all 32-bits wide up until the last read/write.
> >
> > Yes, that was the intention. Unfortunately, I chose to use common bounce
> buffer
> > implementation which was doing cache manipulations.
> >
> > > I believe the bounce buffer should be removed from the CQSPI driver
> > > and a different solution should be implemented, but Vignesh should
> > > weigh in on that since it effects his architecture.
> > >
> >
> > CQSPI on TI K2G has problems with non 32 bit aligned write operations.
> > But read operations are unaffected. Therefore I have Ack'ed Simon's patch
> > reverting bouncebuf for read. For writes, I have patches to revert common
> > bouncebuf usage and use a local pagesize buffer for overcome alignment
> issue. I
> > am waiting for current patch backlogs to be merged so that its easy for
> testing w/o
> > specifying bunch of dependent patches.
> >
> > Or if Simon agrees, I can add his patch to my series post it to mailing
> list (rebased
> > on top of Jason's series)?
>
> Well, it's not really "my" patch, anyway. It reverts a commit of
> yours, so sure, as long as this does not stand in the way of getting
> qspi running on 2018.03, go ahead and itegrate it in your patchset.
>
> I'd be happy to have this sent now so I can test both patchsets on
> top of 2018.01(-rc).
>
> Thanks,
> Simon
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] configs: keystone2: env: Fix burn_uboot_spi command

2018-01-17 Thread Tom Rini
On Wed, Jan 17, 2018 at 01:08:19PM +0530, Faiz Abbas wrote:
> Hi,
> 
> +Vignesh
> 
> On Tuesday 16 January 2018 08:55 PM, Tom Rini wrote:
> > On Tue, Jan 16, 2018 at 01:43:40PM +0530, Faiz Abbas wrote:
> >> Now the u-boot spi image is greater than 0x9, increase the same in
> >> env during spi erase.
> >>
> >> Signed-off-by: Faiz Abbas 
> >> ---
> >>  include/configs/ti_armv7_keystone2.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/configs/ti_armv7_keystone2.h 
> >> b/include/configs/ti_armv7_keystone2.h
> >> index 562bb65..7fb3aaf 100644
> >> --- a/include/configs/ti_armv7_keystone2.h
> >> +++ b/include/configs/ti_armv7_keystone2.h
> >> @@ -266,7 +266,7 @@
> >>"${bootdir}/${fit_bootfile}\0"  \
> >>"get_uboot_net=dhcp ${loadaddr} ${tftp_root}/${name_uboot}\0"   \
> >>"get_uboot_nfs=nfs ${loadaddr} ${nfs_root}/boot/${name_uboot}\0" \
> >> -  "burn_uboot_spi=sf probe; sf erase 0 0x9; " \
> >> +  "burn_uboot_spi=sf probe; sf erase 0 0x10; "\
> >>"sf write ${loadaddr} 0 ${filesize}\0"  \
> >>"burn_uboot_nand=nand erase 0 0x10; "   \
> >>"nand write ${loadaddr} 0 ${filesize}\0"\
> > 
> > Can we future proof this?  Where is the next bit of content located in
> > the SPI flash?  We should erase up to that instead I think.  Thanks!
> > 
> 
> Currently it is limited to 1M by the parameter we pass to kernel in
> include/environment/ti/spi.h
> 
> 
> #define KEYSTONE_SPI0_MTD_PARTS "spi0.0:1m(u-boot-spl)ro,-(misc);\0"
> #define KEYSTONE_SPI1_MTD_PARTS "spi1.0:1m(u-boot-spl)ro,-(misc);\0"
> 
> 
> This was added by 3f18ff0 ("ARM: keystone: Pass SPI MTD partition table
> via kernel command line")
> 
> So this is the maximum limit right now.

OK, thanks!

Reviewed-by: Tom Rini 

-- 
Tom


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 V5 29/31] power: pmic/regulator allow dm be omitted by SPL

2018-01-17 Thread Jaehoon Chung
On 01/10/2018 02:20 PM, Peng Fan wrote:
> Allow the dm driver be omitted by SPL.
> 
> Signed-off-by: Peng Fan 
> Reviewed-by: Simon Glass 
> Cc: Jaehoon Chung 
> Cc: Stefano Babic 

Sorry, i add the reviewed-by tag at previous version.

Reviewed-by: Jaehoon Chung 

> ---
>  drivers/power/pmic/Makefile  | 2 +-
>  drivers/power/regulator/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
> index 7d6c583d34..fc19fdc701 100644
> --- a/drivers/power/pmic/Makefile
> +++ b/drivers/power/pmic/Makefile
> @@ -8,7 +8,7 @@
>  obj-$(CONFIG_DM_PMIC) += pmic-uclass.o
>  obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
>  obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o
> -obj-$(CONFIG_DM_PMIC_PFUZE100) += pfuze100.o
> +obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
>  obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o
>  obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
>  obj-$(CONFIG_PMIC_ACT8846) += act8846.o
> diff --git a/drivers/power/regulator/Makefile 
> b/drivers/power/regulator/Makefile
> index 7a2e76dc82..353177d5f4 100644
> --- a/drivers/power/regulator/Makefile
> +++ b/drivers/power/regulator/Makefile
> @@ -9,7 +9,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o
>  obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
>  obj-$(CONFIG_REGULATOR_AS3722)   += as3722_regulator.o
>  obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
> -obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o
> +obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
>  obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
> 

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


  1   2   >