[U-Boot] [PATCH v2 1/2] efi_loader: adjust definitions of variable services

2018-05-16 Thread Heinrich Schuchardt
The definitons of the variable services are adjusted:
- use efi_uintn_t instead of unsigned long
- use u16 * instead of s16 * for Unicode strings
- correct definition of QueryVariableInfo
- rename efi_get_next_variable to efi_get_next_variable_name

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 include/efi_api.h | 24 
 include/efi_loader.h  | 18 +-
 lib/efi_loader/efi_bootmgr.c  | 10 +-
 lib/efi_loader/efi_runtime.c  | 10 +-
 lib/efi_loader/efi_variable.c | 24 
 5 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 64c27e494bc..094be6edf9b 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -214,15 +214,15 @@ struct efi_runtime_services {
uint32_t descriptor_version,
struct efi_mem_desc *virtmap);
efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
-   efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
-   efi_guid_t *vendor, u32 *attributes,
-   unsigned long *data_size, void *data);
-   efi_status_t (EFIAPI *get_next_variable)(
-   unsigned long *variable_name_size,
-   s16 *variable_name, efi_guid_t *vendor);
-   efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
-   efi_guid_t *vendor, u32 attributes,
-   unsigned long data_size, void *data);
+   efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
+   efi_guid_t *vendor, u32 *attributes,
+   efi_uintn_t *data_size, void *data);
+   efi_status_t (EFIAPI *get_next_variable_name)(
+   efi_uintn_t *variable_name_size,
+   u16 *variable_name, efi_guid_t *vendor);
+   efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
+   efi_guid_t *vendor, u32 attributes,
+   efi_uintn_t data_size, void *data);
efi_status_t (EFIAPI *get_next_high_mono_count)(
uint32_t *high_count);
void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
@@ -239,9 +239,9 @@ struct efi_runtime_services {
u32 reset_type);
efi_status_t (EFIAPI *query_variable_info)(
u32 attributes,
-   u64 maximum_variable_storage_size,
-   u64 remaining_variable_storage_size,
-   u64 maximum_variable_size);
+   u64 *maximum_variable_storage_size,
+   u64 *remaining_variable_storage_size,
+   u64 *maximum_variable_size);
 };
 
 /* EFI event group GUID definitions */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2868ca25abb..4e9e9d05c76 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -415,15 +415,15 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t 
image_handle,
 struct efi_system_table *systab);
 #endif
 
-efi_status_t EFIAPI efi_get_variable(s16 *variable_name,
-   efi_guid_t *vendor, u32 *attributes,
-   unsigned long *data_size, void *data);
-efi_status_t EFIAPI efi_get_next_variable(
-   unsigned long *variable_name_size,
-   s16 *variable_name, efi_guid_t *vendor);
-efi_status_t EFIAPI efi_set_variable(s16 *variable_name,
-   efi_guid_t *vendor, u32 attributes,
-   unsigned long data_size, void *data);
+efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
+u32 *attributes, efi_uintn_t *data_size,
+void *data);
+efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
+  u16 *variable_name,
+  efi_guid_t *vendor);
+efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
+u32 attributes, efi_uintn_t data_size,
+void *data);
 
 void *efi_bootmgr_load(struct efi_device_path **device_path,
   struct efi_device_path **file_path);
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 153e1737573..853358ab937 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -70,17 +70,17 @@ static void parse_load_option(struct load_option *lo, void 
*ptr)
 
 /* free() the result */
 static void *get_var(u16 *name, const efi_guid_t *vendor,
-unsigned long *size)
+efi_uintn_t *size)
 {
efi_guid_t *v = (efi_guid_t *)vendor;

[U-Boot] [PATCH v2 2/2] efi_selftest: unit test for variable services

2018-05-16 Thread Heinrich Schuchardt
Provide a unit test for variable services.

Signed-off-by: Heinrich Schuchardt 
---
v2
fix warning when building on 64bit architecture
---
 lib/efi_selftest/Makefile |   1 +
 lib/efi_selftest/efi_selftest_variables.c | 180 ++
 2 files changed, 181 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_variables.c

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 8c416178478..5dbe3363b30 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -28,6 +28,7 @@ efi_selftest_textinput.o \
 efi_selftest_textoutput.o \
 efi_selftest_tpl.o \
 efi_selftest_util.o \
+efi_selftest_variables.o \
 efi_selftest_watchdog.o
 
 ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
diff --git a/lib/efi_selftest/efi_selftest_variables.c 
b/lib/efi_selftest/efi_selftest_variables.c
new file mode 100644
index 000..f5e8eb6231c
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -0,0 +1,180 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_variables
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt 
+ *
+ * This unit test checks the following protocol services:
+ * ConnectController, DisconnectController,
+ * InstallProtocol, ReinstallProtocol, UninstallProtocol,
+ * OpenProtocol, CloseProtcol, OpenProtocolInformation
+ */
+
+#include 
+
+#define EFI_ST_MAX_DATA_SIZE 16
+#define EFI_ST_MAX_VARNAME_SIZE 40
+
+static struct efi_boot_services *boottime;
+static struct efi_runtime_services *runtime;
+static efi_guid_t guid_vendor0 =
+   EFI_GUID(0x67029eb5, 0x0af2, 0xf6b1,
+0xda, 0x53, 0xfc, 0xb5, 0x66, 0xdd, 0x1c, 0xe6);
+static efi_guid_t guid_vendor1 =
+   EFI_GUID(0xff629290, 0x1fc1, 0xd73f,
+0x8f, 0xb1, 0x32, 0xf9, 0x0c, 0xa0, 0x42, 0xea);
+
+/*
+ * Setup unit test.
+ *
+ * @handle handle of the loaded image
+ * @systable   system table
+ */
+static int setup(const efi_handle_t img_handle,
+const struct efi_system_table *systable)
+{
+   boottime = systable->boottime;
+   runtime = systable->runtime;
+
+   return EFI_ST_SUCCESS;
+}
+
+/*
+ * Execute unit test.
+ */
+static int execute(void)
+{
+   efi_status_t ret;
+   efi_uintn_t len;
+   u32 attr;
+   u8 v[16] = {0x5d, 0xd1, 0x5e, 0x51, 0x5a, 0x05, 0xc7, 0x0c,
+   0x35, 0x4a, 0xae, 0x87, 0xa5, 0xdf, 0x0f, 0x65,};
+   u8 *data[EFI_ST_MAX_DATA_SIZE];
+   u16 varname[EFI_ST_MAX_VARNAME_SIZE];
+   int flag;
+   efi_guid_t guid;
+   u64 max_storage, rem_storage, max_size;
+
+   ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS,
+  _storage, _storage,
+  _size);
+   if (ret != EFI_SUCCESS) {
+   efi_st_todo("QueryVariableInfo failed\n");
+   } else if (!max_storage || !rem_storage || !max_size) {
+   efi_st_error("QueryVariableInfo: wrong info\n");
+   return EFI_ST_FAILURE;
+   }
+   /* Set variable 0 */
+   ret = runtime->set_variable(L"efi_st_var0", _vendor0,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS,
+   3, v + 4);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("SetVariable failed\n");
+   return EFI_ST_FAILURE;
+   }
+   /* Set variable 1 */
+   ret = runtime->set_variable(L"efi_st_var1", _vendor1,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS,
+   8, v);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("SetVariable failed\n");
+   return EFI_ST_FAILURE;
+   }
+   len = EFI_ST_MAX_DATA_SIZE;
+   ret = runtime->get_variable(L"efi_st_var1", _vendor1,
+   , , data);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("GetVariable failed\n");
+   return EFI_ST_FAILURE;
+   }
+   if (len != 8) {
+   efi_st_error("GetVariable returned wrong length %u\n",
+(unsigned int)len);
+   return EFI_ST_FAILURE;
+   }
+   if (efi_st_memcmp(data, v, 8)) {
+   efi_st_error("GetVariable returned wrong value\n");
+   return EFI_ST_FAILURE;
+   }
+   /* Append variable 1 */
+   ret = runtime->set_variable(L"efi_st_var1", _vendor1,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS |
+   EFI_VARIABLE_APPEND_WRITE,
+   7, v + 8);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("SetVariable failed\n");
+   return EFI_ST_FAILURE;
+   }
+   len = EFI_ST_MAX_DATA_SIZE;
+   ret = runtime->get_variable(L"efi_st_var1", _vendor1,
+   , , data);
+   if (ret != EFI_SUCCESS) {
+   

[U-Boot] [PATCH v2 0/2] efi_loader: adjust definitions of variable services

2018-05-16 Thread Heinrich Schuchardt
The definitons of the variable services are adjusted:
- use efi_uintn_t instead of unsigned long
- use u16 * instead of s16 * for Unicode strings
- correct definition of QueryVariableInfo
- rename efi_get_next_variable to efi_get_next_variable_name

A unit test for the variable services is supplied.

v2:
fix warning when building on 64bit architecture

Heinrich Schuchardt (2):
  efi_loader: adjust definitions of variable services
  efi_selftest: unit test for variable services

 include/efi_api.h |  24 +--
 include/efi_loader.h  |  18 +--
 lib/efi_loader/efi_bootmgr.c  |  10 +-
 lib/efi_loader/efi_runtime.c  |  10 +-
 lib/efi_loader/efi_variable.c |  24 +--
 lib/efi_selftest/Makefile |   1 +
 lib/efi_selftest/efi_selftest_variables.c | 180 ++
 7 files changed, 224 insertions(+), 43 deletions(-)
 create mode 100644 lib/efi_selftest/efi_selftest_variables.c

-- 
2.17.0

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


Re: [U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 07:13 PM, Heinrich Schuchardt wrote:
> On 05/16/2018 05:42 PM, Simon Glass wrote:
>> A limitation of the EFI loader at present is that it does not build with
>> sandbox. This makes it hard to write tests, since sandbox is used for most
>> testing in U-Boot.
>>
>> This series enables the EFI loader feature. It allows sandbox to build and
>> run a trivial function which calls the EFI API to output a message.
>>
>> This series is at u-boot-dm/efi-working
> 
> I applied you patch series
> 
> make sandbox_defconfig
> CONFIG_CMD_BOOTEFI_SELFTEST=y
> make -j6
> 
> results in:
> 
> ld.bfd: read in flex scanner failed
> scripts/Makefile.lib:407: recipe for target
> 'lib/efi_selftest/efi_selftest_miniapp_exit_efi.so' failed
> make[2]: *** [lib/efi_selftest/efi_selftest_miniapp_exit_efi.so] Error 1
> rm lib/efi_selftest/efi_selftest_miniapp_exit.o
> lib/efi_selftest/efi_selftest_miniapp_return.o
> scripts/Makefile.build:423: recipe for target 'lib/efi_selftest' failed
> make[1]: *** [lib/efi_selftest] Error 2
> make[1]: *** Waiting for unfinished jobs
> 
> Please, change /lib/efi_selftest/Makefile
> -ifeq ($(CONFIG_X86_64),)
> +ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)

A better solution would be to define EFI_LDS, EFI_CRT0, and EFI_RELOC in
file arch/sandbox/config.mk in accordance with the host architecture.

Best regards

Heinrich

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


Re: [U-Boot] [PATCH 01/12] ARM: socfpga: Sync A10 clock manager binding parser

2018-05-16 Thread Chee, Tien Fong
On Sat, 2018-05-12 at 22:30 +0200, Marek Vasut wrote:
> The A10 clock manager parsed DT bindings generated by Quartus the
> bsp-editor to configure the A10 clocks. Sadly, those DT bindings
> changed at some point. The clock manager patch used the old ones,
> this patch replaces the bindings parser with one for the new set.
> 
> Signed-off-by: Marek Vasut 
> Cc: Chin Liang See 
> Cc: Dinh Nguyen 
> ---
>  arch/arm/mach-socfpga/clock_manager_arria10.c  | 158
> ++---
>  .../include/mach/clock_manager_arria10.h   |   2 +-
>  2 files changed, 111 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/clock_manager_arria10.c
> b/arch/arm/mach-socfpga/clock_manager_arria10.c
> index 4ee6a82b5f..defa2f6261 100644
> --- a/arch/arm/mach-socfpga/clock_manager_arria10.c
> +++ b/arch/arm/mach-socfpga/clock_manager_arria10.c
> @@ -9,6 +9,9 @@
>  #include 
>  #include 
>  
> +static const struct socfpga_clock_manager *clock_manager_base =
> + (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
> +
>  static u32 eosc1_hz;
>  static u32 cb_intosc_hz;
>  static u32 f2s_free_hz;
> @@ -64,89 +67,150 @@ struct perpll_cfg {
>   u32 cntr8clk_cnt;
>   u32 cntr8clk_src;
>   u32 cntr9clk_cnt;
> + u32 cntr9clk_src;
Why add this? I believe this is not exist.
>   u32 emacctl_emac0sel;
>   u32 emacctl_emac1sel;
>   u32 emacctl_emac2sel;
>   u32 gpiodiv_gpiodbclk;
>  };
>  
> -struct alteragrp_cfg {
> - u32 nocclk;
> - u32 mpuclk;
> +struct strtou32 {
> + const char *str;
> + const u32 val;
>  };
>  
> -static const struct socfpga_clock_manager *clock_manager_base =
> - (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
> +static const struct strtou32 mainpll_cfg_tab[] = {
> + { "vco0-psrc", offsetof(struct mainpll_cfg, vco0_psrc) },
> + { "vco1-denom", offsetof(struct mainpll_cfg, vco1_denom) },
> + { "vco1-numer", offsetof(struct mainpll_cfg, vco1_numer) },
> + { "mpuclk-cnt", offsetof(struct mainpll_cfg, mpuclk_cnt) },
> + { "mpuclk-src", offsetof(struct mainpll_cfg, mpuclk_src) },
> + { "nocclk-cnt", offsetof(struct mainpll_cfg, nocclk_cnt) },
> + { "nocclk-src", offsetof(struct mainpll_cfg, nocclk_src) },
> + { "cntr2clk-cnt", offsetof(struct mainpll_cfg, cntr2clk_cnt)
> },
> + { "cntr3clk-cnt", offsetof(struct mainpll_cfg, cntr3clk_cnt)
> },
> + { "cntr4clk-cnt", offsetof(struct mainpll_cfg, cntr4clk_cnt)
> },
> + { "cntr5clk-cnt", offsetof(struct mainpll_cfg, cntr5clk_cnt)
> },
> + { "cntr6clk-cnt", offsetof(struct mainpll_cfg, cntr6clk_cnt)
> },
> + { "cntr7clk-cnt", offsetof(struct mainpll_cfg, cntr7clk_cnt)
> },
> + { "cntr7clk-src", offsetof(struct mainpll_cfg, cntr7clk_src)
> },
> + { "cntr8clk-cnt", offsetof(struct mainpll_cfg, cntr8clk_cnt)
> },
> + { "cntr9clk-cnt", offsetof(struct mainpll_cfg, cntr9clk_cnt)
> },
> + { "cntr9clk-src", offsetof(struct mainpll_cfg, cntr9clk_src)
> },
> + { "cntr15clk-cnt", offsetof(struct mainpll_cfg,
> cntr15clk_cnt) },
> + { "nocdiv-l4mainclk", offsetof(struct mainpll_cfg,
> nocdiv_l4mainclk) },
> + { "nocdiv-l4mpclk", offsetof(struct mainpll_cfg,
> nocdiv_l4mpclk) },
> + { "nocdiv-l4spclk", offsetof(struct mainpll_cfg,
> nocdiv_l4spclk) },
> + { "nocdiv-csatclk", offsetof(struct mainpll_cfg,
> nocdiv_csatclk) },
> + { "nocdiv-cstraceclk", offsetof(struct mainpll_cfg,
> nocdiv_cstraceclk) },
> + { "nocdiv-cspdbgclk", offsetof(struct mainpll_cfg,
> nocdiv_cspdbclk) },
> +};
> +
> +static const struct strtou32 perpll_cfg_tab[] = {
> + { "vco0-psrc", offsetof(struct perpll_cfg, vco0_psrc) },
> + { "vco1-denom", offsetof(struct perpll_cfg, vco1_denom) },
> + { "vco1-numer", offsetof(struct perpll_cfg, vco1_numer) },
> + { "cntr2clk-cnt", offsetof(struct perpll_cfg, cntr2clk_cnt)
> },
> + { "cntr2clk-src", offsetof(struct perpll_cfg, cntr2clk_src)
> },
> + { "cntr3clk-cnt", offsetof(struct perpll_cfg, cntr3clk_cnt)
> },
> + { "cntr3clk-src", offsetof(struct perpll_cfg, cntr3clk_src)
> },
> + { "cntr4clk-cnt", offsetof(struct perpll_cfg, cntr4clk_cnt)
> },
> + { "cntr4clk-src", offsetof(struct perpll_cfg, cntr4clk_src)
> },
> + { "cntr5clk-cnt", offsetof(struct perpll_cfg, cntr5clk_cnt)
> },
> + { "cntr5clk-src", offsetof(struct perpll_cfg, cntr5clk_src)
> },
> + { "cntr6clk-cnt", offsetof(struct perpll_cfg, cntr6clk_cnt)
> },
> + { "cntr6clk-src", offsetof(struct perpll_cfg, cntr6clk_src)
> },
> + { "cntr7clk-cnt", offsetof(struct perpll_cfg, cntr7clk_cnt)
> },
> + { "cntr8clk-cnt", offsetof(struct perpll_cfg, cntr8clk_cnt)
> },
> + { "cntr8clk-src", offsetof(struct perpll_cfg, cntr8clk_src)
> },
> + { "cntr9clk-cnt", offsetof(struct perpll_cfg, cntr9clk_cnt)
> },
> + { "emacctl-emac0sel", offsetof(struct perpll_cfg,
> emacctl_emac0sel) },
> + { 

Re: [U-Boot] [PATCH 1/3] doc: Add new doc for file system firmware loader driver model

2018-05-16 Thread Chee, Tien Fong
On Wed, 2018-05-16 at 08:48 -0400, Tom Rini wrote:
> On Wed, May 16, 2018 at 05:21:39PM +0800, tien.fong.c...@intel.com
> wrote:
> 
> > 
> > From: Tien Fong Chee 
> > 
> > Provide information about
> > 
> > - overview of file system firmware loader driver model
> > - describe default storage device in device tree source
> > - describe fie system firmware loader API
> > 
> > Signed-off-by: Tien Fong Chee 
> > ---
> >  doc/driver-model/fs_firmware_loader.txt |  100
> > +++
> >  1 files changed, 100 insertions(+), 0 deletions(-)
> >  create mode 100644 doc/driver-model/fs_firmware_loader.txt
> > 
> > diff --git a/doc/driver-model/fs_firmware_loader.txt b/doc/driver-
> > model/fs_firmware_loader.txt
> > new file mode 100644
> > index 000..167660a
> > --- /dev/null
> > +++ b/doc/driver-model/fs_firmware_loader.txt
> > @@ -0,0 +1,100 @@
> > +/*
> > + * Copyright (C) 2018 Intel Corporation 
> > + *
> > + * SPDX-License-Identifier:GPL-2.0
> > + */
> As this isn't code please don't put a code header up for the first
> comment block.  Frankly I'd rather see an rST comment block up front
> even with the rest being plain text as long term I imagine we'll move
> to
> rST.
> 
Okay, i will remove the license and changing it to rST format.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] common: image-fit: add FIT data-position & data-offset property support

2018-05-16 Thread Kelvin Cheung
Hi Simon,
You are right.
I will update the patch soon.
Thanks very much!

2018-05-16 23:40 GMT+08:00 Simon Glass :

> Hi Kevin,
>
> On 16 May 2018 at 15:35, Kelvin Cheung  wrote:
> > Add FIT data-position & data-offset property support for bootm,
> > which are already supported in SPL.
> >
> > Signed-off-by: Kelvin Cheung 
> > ---
> >
> >  common/image-fit.c | 82 ++
> +---
> >  1 file changed, 78 insertions(+), 4 deletions(-)
> >
> > diff --git a/common/image-fit.c b/common/image-fit.c
> > index 5b93dce..f21db4b 100644
> > --- a/common/image-fit.c
> > +++ b/common/image-fit.c
> > @@ -359,11 +359,14 @@ void fit_image_print(const void *fit, int
> image_noffset, const char *p)
> >  {
> > char *desc;
> > uint8_t type, arch, os, comp;
> > -   size_t size;
> > +   size_t size = 0;
> > ulong load, entry;
> > const void *data;
> > int noffset;
> > int ndepth;
> > +   bool external_data = false;
> > +   int offset;
> > +   int len;
> > int ret;
> >
> > /* Mandatory properties */
> > @@ -391,7 +394,27 @@ void fit_image_print(const void *fit, int
> image_noffset, const char *p)
> > fit_image_get_comp(fit, image_noffset, );
> > printf("%s  Compression:  %s\n", p, genimg_get_comp_name(comp));
> >
> > -   ret = fit_image_get_data(fit, image_noffset, , );
> > +   if (!fit_image_get_data_position(fit, image_noffset, )) {
> > +   external_data = true;
> > +   } else if (!fit_image_get_data_offset(fit, image_noffset,
> )) {
> > +   external_data = true;
> > +   /*
> > +* For FIT with external data, figure out where
> > +* the external images start. This is the base
> > +* for the data-offset properties in each image.
> > +*/
> > +   size = (fdt_totalsize(fit) + 3) & ~3;
> > +   offset += size;
> > +   }
> > +
> > +   if (external_data) {
> > +   printf("%s  External Data\n", p);
> > +   ret = fit_image_get_data_size(fit, image_noffset, );
> > +   data = fit + offset;
> > +   size = len;
> > +   } else {
> > +   ret = fit_image_get_data(fit, image_noffset, ,
> );
> > +   }
>
> It looks like you should create which does all of the above, that can
> be called in the three places where you repeat this code.
>
> Perhaps fit_image_get_data_buf_size()?
>
> >
> >  #ifndef USE_HOSTCC
> > printf("%s  Data Start:   ", p);
> > @@ -1151,9 +1174,35 @@ int fit_image_verify(const void *fit, int
> image_noffset)
> > size_t  size;
> > int noffset = 0;
> > char*err_msg = "";
> > +   bool external_data = false;
> > +   int offset;
> > +   int len;
> > +   int ret;
> >
> > /* Get image data and data length */
> > -   if (fit_image_get_data(fit, image_noffset, , )) {
> > +   if (!fit_image_get_data_position(fit, image_noffset, )) {
> > +   external_data = true;
> > +   } else if (!fit_image_get_data_offset(fit, image_noffset,
> )) {
> > +   external_data = true;
> > +   /*
> > +* For FIT with external data, figure out where
> > +* the external images start. This is the base
> > +* for the data-offset properties in each image.
> > +*/
> > +   size = (fdt_totalsize(fit) + 3) & ~3;
> > +   offset += size;
> > +   }
> > +
> > +   if (external_data) {
> > +   debug("External Data\n");
> > +   ret = fit_image_get_data_size(fit, image_noffset, );
> > +   data = fit + offset;
> > +   size = len;
> > +   } else {
> > +   ret = fit_image_get_data(fit, image_noffset, ,
> );
> > +   }
> > +
> > +   if (ret) {
> > err_msg = "Can't get image data/size";
> > printf("error!\n%s for '%s' hash node in '%s' image
> node\n",
> >err_msg, fit_get_name(fit, noffset, NULL),
> > @@ -1750,6 +1799,9 @@ int fit_image_load(bootm_headers_t *images, ulong
> addr,
> > uint8_t os_arch;
> >  #endif
> > const char *prop_name;
> > +   bool external_data = false;
> > +   int offset;
> > +   int data_len;
> > int ret;
> >
> > fit = map_sysmem(addr, 0);
> > @@ -1875,7 +1927,29 @@ int fit_image_load(bootm_headers_t *images, ulong
> addr,
> > bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK);
> >
> > /* get image data address and length */
> > -   if (fit_image_get_data(fit, noffset, , )) {
> > +   if (!fit_image_get_data_position(fit, noffset, )) {
> > +   external_data = true;
> > +   } else if 

Re: [U-Boot] [PATCH] spi: cadence_qspi: Change to use devfdt_get_addr_index()

2018-05-16 Thread Ley Foon Tan
On Wed, May 16, 2018 at 9:33 PM, Jagan Teki  wrote:
> On Mon, May 7, 2018 at 3:12 PM, Ley Foon Tan  wrote:
>> Change to use devfdt_get_addr_index() function to get fdt address.
>>
>> Original code has compilation warning below:
>>
>> drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
>> drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of 
>> different size [-Wint-to-pointer-cast]
>>   plat->regbase = (void *)data[0];
>>   ^
>> drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of 
>> different size [-Wint-to-pointer-cast]
>>   plat->ahbbase = (void *)data[2];
>
> was this a coverage-tool check, I didn't see any warning with arm
> compiler? make socfpga_arria5_defconfig && make

This error came up if compile with ARM 64bit (aarch64-linux-gnu-).

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


Re: [U-Boot] help on DM

2018-05-16 Thread Andy Tang
Thanks Simon. We convert the driver to ahci uclass. Problem solved.

Regards,
Andy

-Original Message-
From: s...@google.com [mailto:s...@google.com] On Behalf Of Simon Glass
Sent: 2018年5月16日 23:40
To: Andy Tang 
Cc: u-boot@lists.denx.de
Subject: Re: help on DM

Hi Andy,

On 8 May 2018 at 19:48, Andy Tang  wrote:
> Hi Simon,
>
>
>
> I am working on enabling DM for sata driver. Previously sata was 
> initialized by calling
>
> the functions ahci_init() and scsi_scan(). Now I plan to use 
> driver/ata/sata_ceva.c as our sata driver.
>
> In board config file I enabled the following configs (dts was added
> properly):
>
>
>
> +CONFIG_DM_SCSI=y
>
> +CONFIG_SATA_CEVA=y
>
> +CONFIG_AHCI=y
>
> +CONFIG_BLK=y
>
> +CONFIG_SCSI_AHCI=y
>
> +CONFIG_SCSI=y
>
>
>
> But I always got the "Synchronous Abort" error. I tracked the code and 
> found
>
> dev->uclass_priv was not allocated properly because
> dev->uclass->uc_drv->per_device_auto_alloc_size is 0.
>
> But I didn’t find where I can set per_device_auto_alloc_size or attach 
> a uclass_priv structure to the device.
>
>
>
> I am new to DM. Could you please give me some suggestions here?

So you are expecting that the SCSI uclass should have some per-device uclass 
data? I don't think this is the case at present.

Which code is actually crashing here?

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


Re: [U-Boot] [PATCH] drivers/net/vsc9953: Initialize action RAM in VCAP complex

2018-05-16 Thread Joe Hershberger
On Wed, May 9, 2018 at 9:22 AM,   wrote:
> From: Radu Bulie 
>
> VCAP tables must be initialized even if no advanced classification
> is used. If no initialization is performed, then ECC error will
> be observed by the user when the first packet enters the l2switch.
> The error is marked in MPIC_EISR0 -bit 29 which means - Internal RAM
> multi-bit ECC error.
> This patch fixes the aforementioned ECC error by performing the
> initialization of VCAP tables.
>
> Signed-off-by: Radu Bulie 
> ---
>  drivers/net/vsc9953.c | 134 
> ++
>  include/vsc9953.h |  58 ++
>  2 files changed, 192 insertions(+)
>
> diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
> index 2388438..f90181d 100644
> --- a/drivers/net/vsc9953.c
> +++ b/drivers/net/vsc9953.c
> @@ -2469,6 +2469,139 @@ void vsc9953_default_configuration(void)
> debug("VSC9953: failed to set default aggregation code 
> mode\n");
>  }
>
> +static void vcap_entry2cache_init(u32 target, u32 entry_words)
> +{
> +   int i;
> +
> +   for (i = 0; i < entry_words; i++) {
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> +   VSC9953_VCAP_CACHE_ENTRY_DAT(target, i)), 
> 0x00);
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> +   VSC9953_VCAP_CACHE_MASK_DAT(target, i)), 
> 0xFF);
> +   }
> +
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> +   VSC9953_VCAP_CACHE_TG_DAT(target)), 0x00);
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> + VSC9953_VCAP_CFG_MV_CFG(target)),
> +VSC9953_VCAP_CFG_MV_CFG_SIZE(entry_words));
> +}
> +
> +static void vcap_action2cache_init(u32 target, u32 action_words,
> +  u32 counter_words)
> +{
> +   int i;
> +
> +   for (i = 0; i < action_words; i++)
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> +  VSC9953_VCAP_CACHE_ACTION_DAT(target, i)), 
> 0x00);
> +
> +   for (i = 0; i < counter_words; i++)
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> + VSC9953_VCAP_CACHE_CNT_DAT(target, i)), 
> 0x00);
> +}
> +
> +static int vcap_cmd(u32 target, u16 ix, int cmd, int sel, int entry_count)
> +{
> +   u32 tgt = target;
> +   u32 value = (VSC9953_VCAP_UPDATE_CTRL_UPDATE_CMD(cmd) |
> +VSC9953_VCAP_UPDATE_CTRL_UPDATE_ADDR(ix) |
> +VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
> +
> +   if ((sel & TCAM_SEL_ENTRY) && ix >= entry_count)
> +   return CMD_RET_FAILURE;
> +
> +   if (!(sel & TCAM_SEL_ENTRY))
> +   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ENTRY_DIS;
> +
> +   if (!(sel & TCAM_SEL_ACTION))
> +   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ACTION_DIS;
> +
> +   if (!(sel & TCAM_SEL_COUNTER))
> +   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_CNT_DIS;
> +
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> +   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)), value);
> +
> +   do {
> +   value = in_le32((unsigned int *)(VSC9953_OFFSET +
> +   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)));
> +
> +   } while (value & VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
> +
> +   return CMD_RET_SUCCESS;
> +}
> +
> +static void vsc9953_vcap_init(void)
> +{
> +   u32 tgt = VSC9953_ES0;
> +   int cmd_ret;
> +
> +   /* write entries */
> +   vcap_entry2cache_init(tgt, ENTRY_WORDS_ES0);
> +   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
> +  ENTRY_WORDS_ES0);
> +   if (cmd_ret != CMD_RET_SUCCESS)
> +   debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n",
> + __LINE__);
> +
> +   /* write actions and counters */
> +   vcap_action2cache_init(tgt, BITS_TO_DWORD(91), BITS_TO_DWORD(1));
> +   out_le32((unsigned int *)(VSC9953_OFFSET +
> + VSC9953_VCAP_CFG_MV_CFG(tgt)),
> +VSC9953_VCAP_CFG_MV_CFG_SIZE(VSC9953_ES0_CNT + 
> VSC9953_PORTS));
> +   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE,
> +  TCAM_SEL_ACTION | TCAM_SEL_COUNTER, 
> ENTRY_WORDS_ES0);
> +   if (cmd_ret != CMD_RET_SUCCESS)
> +   debug("VSC9953:%d invalid TCAM_SEL_ACTION | 
> TCAM_SEL_COUNTER\n",
> + __LINE__);
> +
> +   tgt = VSC9953_IS1;
> +
> +   /* write entries */
> +   vcap_entry2cache_init(tgt, ENTRY_WORDS_IS1);
> +   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
> +  ENTRY_WORDS_IS1);
> +   if (cmd_ret != CMD_RET_SUCCESS)
> +   debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n",
> +   

Re: [U-Boot] [PATCH] net: nfs: don't fail when nfs_read_reply returns -NFS_RPC_DROP

2018-05-16 Thread Joe Hershberger
On Mon, May 14, 2018 at 10:34 AM, Vasily Khoruzhick  wrote:
> That can happen if duplicate UDP packet arrived, and that's not uncommon.
> Anyway, we ignore packets with rpc_id lower than last we sent for other
> requests, so it makes sense to do that for read request as well.
>
> Signed-off-by: Vasily Khoruzhick 

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


Re: [U-Boot] [PATCH 4/4] board: turris_mox: Add gpio command to defconfig

2018-05-16 Thread Ladislav Michl
On Wed, May 16, 2018 at 04:39:42PM +0200, Marek Behún wrote:
> This can be used to detect whether the button is pressed or light the
> LED diode.

Well, I know it is annoying, but as patch is oneliner anyway, let's get
at least commit log right.

LED stands for Light-Emitting Diode, so Light-Emitting Diode diode
does not look very nice.

(Yes, I know "LED dióda" is commonly used idiom, but this does not
make it any more right)

Thanks,
ladis

> Signed-off-by: Marek Behun 
> 
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 7dea7157dc..9538903bd3 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_ARCH_EARLY_INIT_R=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_CLK=y
> +CONFIG_CMD_GPIO=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
>  CONFIG_CMD_SF=y
> -- 
> 2.16.1
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] test: Fix test_vboot to call openssl without redirection

2018-05-16 Thread Simon Glass
Hi Stephen,

On 16 May 2018 at 09:55, Stephen Warren  wrote:
> On 05/16/2018 01:10 AM, Simon Glass wrote:
>>
>> The redirection seems to cause this test to fail now. It isn't needed, so
>> drop it.
>
>
> I guess I have no particular objection to this, but I will point out that
> the test is working just fine as-is right now, so it might be worth
> investigating more re: what the error is and why it's happening... It'd be
> good to describe the details of the failure in the commit description too.

So the test works OK for you? For me it fails. I'll update the commit message.

# Store the output so it can be accessed if we raise an exception.
self.output = output
self.exit_status = exit_status
if exception:
>   raise exception
E   Exception: Exit code: 1

test/py/multiplexed_log.py:173: Exception
--- Captured stdout call
---
+openssl genpkey -algorithm RSA -out
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/build-sandbox/dev.key
-pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537
2>/dev/null
genpkey: Use -help for summary.
Exit code: 1

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


[U-Boot] Please pull u-boot-dm

2018-05-16 Thread Simon Glass
Hi Tom,

The following changes since commit 0315d6959fdd9d2a4d89016c311e9c8c8d239a10:

  ARM: mvebu: a38x: Add missing SPDX license identfier (2018-05-15
09:08:00 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git

for you to fetch changes up to f717b4c8e7fc871573755a05be96c8ef857eabce:

  pinctrl: do not set_state for device without valid ofnode
(2018-05-16 00:25:19 -0600)


Kever Yang (1):
  pinctrl: do not set_state for device without valid ofnode

Lothar Waßmann (1):
  tools: buildman: Don't use the working dir as build dir

 drivers/pinctrl/pinctrl-uclass.c |  6 ++
 tools/buildman/builderthread.py  |  4 
 tools/buildman/control.py| 28 +---
 tools/buildman/func_test.py  |  9 +
 4 files changed, 44 insertions(+), 3 deletions(-)

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


Re: [U-Boot] [PATCH 1/1] efi_loader: avoid using unitialized values as console size

2018-05-16 Thread Simon Glass
On 16 May 2018 at 10:17, Heinrich Schuchardt  wrote:
> If a request for the console size would be answered with a response
> with less then three values, uninitialized stack memory would be
> copied to the number of rows and columns of the terminal.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/efi_loader/efi_console.c | 14 --
>  1 file changed, 12 insertions(+), 2 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 3/7] serial: serial_msm: initialize uart only before relocation

2018-05-16 Thread Simon Glass
On 16 May 2018 at 03:13, Ramon Fried  wrote:
> The uart is already initialized prior to relocation,
> reinitialization after relocation is unnecessary.
>
> Signed-off-by: Ramon Fried 
> ---
> v2: removed extra parenthesis
>
>  drivers/serial/serial_msm.c | 4 
>  1 file changed, 4 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 v2 1/7] db820c: set clk node to be probed before relocation

2018-05-16 Thread Simon Glass
On 16 May 2018 at 03:13, Ramon Fried  wrote:
> The clock and serial nodes are needed before relocation.
> This patch ensures that the msm-serial driver will probe
> and provide uart output before relocation.
>
> Signed-off-by: Ramon Fried 
> ---
> v2: fixed alignment
>  arch/arm/dts/dragonboard820c-uboot.dtsi | 14 ++
>  1 file changed, 14 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 6/6] usb: xhci: zynqmp: Remove support for !DM_USB

2018-05-16 Thread Simon Glass
On 16 May 2018 at 08:26, Michal Simek  wrote:
> Switch to DM_USB was done and there is no need to keep !DM_USB code in
> tree.
>
> Signed-off-by: Michal Simek 
> ---
>
>  drivers/usb/host/Kconfig   |  1 +
>  drivers/usb/host/xhci-zynqmp.c | 46 --
>  scripts/config_whitelist.txt   |  1 -
>  3 files changed, 1 insertion(+), 47 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 2/6] usb: common: add support to get maximum speed from dt

2018-05-16 Thread Simon Glass
On 16 May 2018 at 08:26, Michal Simek  wrote:
> From: Mugunthan V N 
>
> Add support to get maximum speed from dt so that usb drivers
> makes use of it for DT parsing.
>
> Signed-off-by: Mugunthan V N 
> Signed-off-by: Michal Simek 
> (rebase and fix errors)
> ---
>
>  drivers/usb/common/common.c | 29 +
>  include/linux/usb/otg.h |  9 +
>  2 files changed, 38 insertions(+)

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


[U-Boot] [PATCH] board: turris_mox: Add fixed regulator support to defconfig

2018-05-16 Thread Marek Behún
Without this USB3 won't work in U-Boot.

Signed-off-by: Marek Behun 
---
 configs/turris_mox_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 9538903bd3..45c1399687 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -63,6 +63,8 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_MVEBU_A3700_UART=y
 CONFIG_MVEBU_A3700_SPI=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
-- 
2.16.1

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


Re: [U-Boot] [PATCH v4 14/14] net: fastboot: Merge AOSP UDP fastboot

2018-05-16 Thread Alex Kiernan
On Wed, May 16, 2018 at 8:15 PM Joe Hershberger 
wrote:

> On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan 
wrote:
> > Merge UDP fastboot support from AOSP:
> >
> >
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
> >
> > Signed-off-by: Alex Kiernan 
> > Signed-off-by: Alex Deymo 
> > Signed-off-by: Jocelyn Bohr 
> > Reviewed-by: Simon Glass 
> > ---
> >
> > Changes in v4:
> > - guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
> > - add docbook comments
> > - remove parameter from fastboot_boot() since we always want
> >   fastboot_buf_addr (and if we're using fastboot_bootcmd then it's
> >   ignored)
> >
> > Changes in v3:
> > - use FASTBOOT as our guard in Kconfig not a list of USB || UDP
> > - correct mis-translation from AOSP introduced when cleaning up for
> >   checkpatch - we should write when buffer is not NULL, rather than
> >   erasing, and erase when buffer is NULL
> > - use CMD_RET_USAGE from do_fastboot
> > - remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
> > - rename timed_send_info to fastboot_send_info, rename
fastboot_send_info to
> >   fastboot_udp_send_info
> > - replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
> > - move start time into timed_send_info() rather than passing it in
> > - make calls to fastboot_udp_send_info a runtime dependency, not a
compile
> >   time one
> > - set ${filesize} to size of downloaded image
> > - add progress meter from USB path during download
> > - add support for 'oem format' command from the USB path
> > - rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is
the
> >   fastboot boot command
> > - make getvar implementation table driven
> > - add fastboot_buf_addr, fastboot_buf_size to override buffer address
and
> >   size
> > - return correct filesystem type in getvar partition-type on MMC
> > - process "fastboot." prefixed env variables in getvar first so you
> >   can override the normal values (this also lets you set a fs type for
> >   NAND devices)
> > - make global variables static and add accessors for the things which
> >   the transport layers need
> > - squash subsequent patches which change this code into this one:
> >   - If the fastboot flash/erase commands are disabled, remove that
support
> > so we still build correctly.
> >   - Add NAND support to fastboot UDP flash/erase commands
> >   - If we don't have a partition name passed, report it as not found.
> >   - Change the behaviour of the fastboot net code such that
> > "reboot-bootloader" is no longer written to
CONFIG_FASTBOOT_BUF_ADDR for
> > use as a marker on reboot (the AOSP code in
common/android-bootloader.c
> > uses this marker - this code could be reinstated there if that gets
> > merged).
> >   - Merge USB and UDP boot code. The USB implementation stays the same,
but
> > UDP no longer passes an fdt. We introduce a new environment variable
> > 'fastboot_bootcmd' which if set overrides the hardcoded boot
command,
> > setting this then allows the UDP implementation to remain the same.
If
> > after running 'fastboot_bootcmd' the board has not booted, control
is
> > returned to U-Boot and the fastboot process ends.
> >   - Separate the fastboot protocol handling from the fastboot UDP code
in
> > preparation for reusing it in the USB code.
> >
> > Changes in v2:
> > - ensure fastboot syntax is backward compatible - 'fastboot 0' means
> >   'fastboot usb 0'
> >
> >  cmd/fastboot.c|  91 +++-
> >  drivers/fastboot/Kconfig  |  15 ++
> >  drivers/fastboot/Makefile |   3 +-
> >  drivers/fastboot/fb_command.c | 327
++
> >  drivers/fastboot/fb_common.c  | 113 +++
> >  drivers/fastboot/fb_getvar.c  | 229 +
> >  drivers/fastboot/fb_mmc.c |  76 +-
> >  drivers/fastboot/fb_nand.c|  12 +-
> >  include/fastboot.h| 157 
> >  include/fb_mmc.h  |   8 +-
> >  include/fb_nand.h |  10 +-
> >  include/net.h |   2 +-
> >  include/net/fastboot.h|  21 +++
> >  net/Makefile  |   1 +
> >  net/fastboot.c| 312

> >  net/net.c |   7 +
> >  16 files changed, 1367 insertions(+), 17 deletions(-)
> >  create mode 100644 drivers/fastboot/fb_command.c
> >  create mode 100644 drivers/fastboot/fb_getvar.c
> >  create mode 100644 include/net/fastboot.h
> >  create mode 100644 net/fastboot.c
> >
> > diff --git a/cmd/fastboot.c b/cmd/fastboot.c
> > index a5ec5f4..557257a 100644
> > --- a/cmd/fastboot.c
> > +++ b/cmd/fastboot.c
> > @@ -10,10 +10,32 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >  #include 
> >
> > -static 

[U-Boot] Which carrier card is targeted by the zynq picozed implementation?

2018-05-16 Thread Ed Jubenville
I may have missed it, but I cannot determine which carrier card is targeted by 
"configs/zynq_picozed_defconfig" and "arch/arm/dts/zynq-picozed.dtb".


Most of a picozed's multiplexed I/O (MIO) depends on its carrier card design, 
so any picozed-related files that are independent of a carrier card don't make 
sense.


For example, a config name such as "zynq_picozed_carrierv2_defconfig" would 
make a lot more sense.


1) Which carrier card is targeted by the existing "picozed" configuration files?

2) What is the recommended procedure to adapt the picozed configuration to a 
custom carrier card.


Ed


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


[U-Boot] [PATCH] rockchip: make_fit_atf: use elf entry point

2018-05-16 Thread Mian Yousaf Kaukab
make_fit_atf.py uses physical address of first segment as the
entry point to bl31. It is incorrect and causes following abort
when bl31_entry() is called:

U-Boot SPL board initTrying to boot from MMC1
"Synchronous Abort" handler, esr 0x0200
elr:  lr : ff8c7e8c
x 0: ff8e x 1: 
x 2:  x 3: ff8e0180
x 4:  x 5: 
x 6: 0030 x 7: ff8e0188
x 8: 01e0 x 9: 
x10: 0007fcdc x11: 002881b8
x12: 01a2 x13: 0198
x14: 0007fdcc x15: 002881b8
x16: 003c0724 x17: 003c0718
x18: 0007fe80 x19: ff8e
x20: 0020 x21: ff8e
x22:  x23: 0007fe30
x24: ff8d1c3c x25: ff8d5000
x26: deadbeef x27: 04a0
x28: 009c x29: 0007fd90

Fix it by using the entry point from the elf header.

Signed-off-by: Mian Yousaf Kaukab 
---
 arch/arm/mach-rockchip/make_fit_atf.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-rockchip/make_fit_atf.py 
b/arch/arm/mach-rockchip/make_fit_atf.py
index 6b3d9201c9..b88a5e1f16 100755
--- a/arch/arm/mach-rockchip/make_fit_atf.py
+++ b/arch/arm/mach-rockchip/make_fit_atf.py
@@ -53,7 +53,7 @@ DT_END="""
 };
 """
 
-def append_atf_node(file, atf_index, phy_addr):
+def append_atf_node(file, atf_index, phy_addr, elf_entry):
 """
 Append ATF DT node to input FIT dts file.
 """
@@ -67,7 +67,7 @@ def append_atf_node(file, atf_index, phy_addr):
 print >> file, '\t\t\tcompression = "none";'
 print >> file, '\t\t\tload = <0x%08x>;' % phy_addr
 if atf_index == 1:
-print >> file, '\t\t\tentry = <0x%08x>;' % phy_addr
+print >> file, '\t\t\tentry = <0x%08x>;' % elf_entry
 print >> file, '\t\t};'
 print >> file, ''
 
@@ -141,12 +141,13 @@ def generate_atf_fit_dts(fit_file_name, bl31_file_name, 
uboot_file_name, dtbs_fi
 
 with open(bl31_file_name) as bl31_file:
 bl31 = ELFFile(bl31_file)
+elf_entry = bl31.header['e_entry']
 for i in range(bl31.num_segments()):
 seg = bl31.get_segment(i)
 if ('PT_LOAD' == seg.__getitem__(ELF_SEG_P_TYPE)):
 paddr = seg.__getitem__(ELF_SEG_P_PADDR)
 p= seg.__getitem__(ELF_SEG_P_PADDR)
-append_atf_node(fit_file, i+1, paddr)
+append_atf_node(fit_file, i+1, paddr, elf_entry)
 atf_cnt = i+1
 append_fdt_node(fit_file, dtbs_file_name)
 print >> fit_file, '%s' % DT_IMAGES_NODE_END
-- 
2.11.0

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


Re: [U-Boot] [PATCH] net: cpsw: ti: Reap completed packets before stopping interface

2018-05-16 Thread Joe Hershberger
On Sat, May 12, 2018 at 2:30 AM, Alex Kiernan  wrote:
> If you send a final packet just before stopping the interface (e.g. a final
> ACK as part of the UDP fastboot protocol), then that packet isn't reliably
> delivered onto the wire.
>
> Reap packets prior to stopping the interface to ensure any which are
> in-flight make it out. Also remove buffer and len from the call to
> cpdma_process() as we weren't using them on their return.
>
> Signed-off-by: Alex Kiernan 

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


Re: [U-Boot] [PATCH v4 14/14] net: fastboot: Merge AOSP UDP fastboot

2018-05-16 Thread Joe Hershberger
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan  wrote:
> Merge UDP fastboot support from AOSP:
>
>   
> https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
>
> Signed-off-by: Alex Kiernan 
> Signed-off-by: Alex Deymo 
> Signed-off-by: Jocelyn Bohr 
> Reviewed-by: Simon Glass 
> ---
>
> Changes in v4:
> - guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
> - add docbook comments
> - remove parameter from fastboot_boot() since we always want
>   fastboot_buf_addr (and if we're using fastboot_bootcmd then it's
>   ignored)
>
> Changes in v3:
> - use FASTBOOT as our guard in Kconfig not a list of USB || UDP
> - correct mis-translation from AOSP introduced when cleaning up for
>   checkpatch - we should write when buffer is not NULL, rather than
>   erasing, and erase when buffer is NULL
> - use CMD_RET_USAGE from do_fastboot
> - remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
> - rename timed_send_info to fastboot_send_info, rename fastboot_send_info to
>   fastboot_udp_send_info
> - replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
> - move start time into timed_send_info() rather than passing it in
> - make calls to fastboot_udp_send_info a runtime dependency, not a compile
>   time one
> - set ${filesize} to size of downloaded image
> - add progress meter from USB path during download
> - add support for 'oem format' command from the USB path
> - rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the
>   fastboot boot command
> - make getvar implementation table driven
> - add fastboot_buf_addr, fastboot_buf_size to override buffer address and
>   size
> - return correct filesystem type in getvar partition-type on MMC
> - process "fastboot." prefixed env variables in getvar first so you
>   can override the normal values (this also lets you set a fs type for
>   NAND devices)
> - make global variables static and add accessors for the things which
>   the transport layers need
> - squash subsequent patches which change this code into this one:
>   - If the fastboot flash/erase commands are disabled, remove that support
> so we still build correctly.
>   - Add NAND support to fastboot UDP flash/erase commands
>   - If we don't have a partition name passed, report it as not found.
>   - Change the behaviour of the fastboot net code such that
> "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for
> use as a marker on reboot (the AOSP code in common/android-bootloader.c
> uses this marker - this code could be reinstated there if that gets
> merged).
>   - Merge USB and UDP boot code. The USB implementation stays the same, but
> UDP no longer passes an fdt. We introduce a new environment variable
> 'fastboot_bootcmd' which if set overrides the hardcoded boot command,
> setting this then allows the UDP implementation to remain the same. If
> after running 'fastboot_bootcmd' the board has not booted, control is
> returned to U-Boot and the fastboot process ends.
>   - Separate the fastboot protocol handling from the fastboot UDP code in
> preparation for reusing it in the USB code.
>
> Changes in v2:
> - ensure fastboot syntax is backward compatible - 'fastboot 0' means
>   'fastboot usb 0'
>
>  cmd/fastboot.c|  91 +++-
>  drivers/fastboot/Kconfig  |  15 ++
>  drivers/fastboot/Makefile |   3 +-
>  drivers/fastboot/fb_command.c | 327 
> ++
>  drivers/fastboot/fb_common.c  | 113 +++
>  drivers/fastboot/fb_getvar.c  | 229 +
>  drivers/fastboot/fb_mmc.c |  76 +-
>  drivers/fastboot/fb_nand.c|  12 +-
>  include/fastboot.h| 157 
>  include/fb_mmc.h  |   8 +-
>  include/fb_nand.h |  10 +-
>  include/net.h |   2 +-
>  include/net/fastboot.h|  21 +++
>  net/Makefile  |   1 +
>  net/fastboot.c| 312 
>  net/net.c |   7 +
>  16 files changed, 1367 insertions(+), 17 deletions(-)
>  create mode 100644 drivers/fastboot/fb_command.c
>  create mode 100644 drivers/fastboot/fb_getvar.c
>  create mode 100644 include/net/fastboot.h
>  create mode 100644 net/fastboot.c
>
> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
> index a5ec5f4..557257a 100644
> --- a/cmd/fastboot.c
> +++ b/cmd/fastboot.c
> @@ -10,10 +10,32 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>
> -static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
> argv[])
> +static int do_fastboot_udp(int argc, char *const argv[],
> +  uintptr_t buf_addr, size_t buf_size)
>  {
> +#if CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)
> +   int err = 

Re: [U-Boot] [PATCH v4 13/14] mmc: Separate "mmc swrite" from fastboot

2018-05-16 Thread Joe Hershberger
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan  wrote:
> Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> swrite" command is separated from the fastboot code.
>
> Move image-sparse from common to lib so it's clear it's library code.
>
> Signed-off-by: Alex Kiernan 

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


Re: [U-Boot] spi(u-boot)+MMC(Kernel)

2018-05-16 Thread Fabio Estevam
Hi Mehmet,

On Wed, May 16, 2018 at 5:10 AM, Mehmet Ali İPİN
 wrote:

> I had our mx6dl board boot from SPI flash. Now I wish to boot kernel from
> eMMC flash.  I am studying warp board’s config parameters.

You need to simply load the zImage and dtb from eMMC and put it to RAM.

Take a look at loadimage and loadfdt scripts at
include/configs/mx6sabre_common.h, for example.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 03/16] efi: sandbox: Adjust memory usage for sandbox

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> With sandbox the U-Boot code is not mapped into the sandbox memory range
> so does not need to be excluded when allocating EFI memory. Update the EFI
> memory init code to take account of that.
> 
> Also use mapmem instead of a cast to convert a memory address to a
> pointer.
> 
> Signed-off-by: Simon Glass 

running ./u-boot

bootefi selftest
Found 0 disks
WARNING: booting without device tree

Testing EFI API implementation

Number of tests to execute: 17

Setting up 'block device'
Setting up 'block device' succeeded

Executing 'block device'
lib/efi_selftest/efi_selftest_block_device.c(378):
TODO: Wrong volume label 'xxa1', expected 'U-BOOT TEST'
FAT: Misaligned buffer address (7ff70aafe658)
Segmentation fault

Please, fix the alignment fault. You have to ensure that the memory that
Sandbox has retrieved via malloc is reduced to 4k aligned pages before
being published to the EFI implementation in lib/efi_loader/efi_memory.c

Best regards

Heinrich

> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Update to use mapmem instead of a cast
> 
>  lib/efi_loader/efi_memory.c | 31 ++-
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 664c651db56..3fbed63728b 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -388,7 +389,7 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t 
> size, void **buffer)
>   r = efi_allocate_pages(0, pool_type, num_pages, );
>  
>   if (r == EFI_SUCCESS) {
> - struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
> + struct efi_pool_allocation *alloc = map_sysmem(t, size);
>   alloc->num_pages = num_pages;
>   *buffer = alloc->data;
>   }
> @@ -499,18 +500,22 @@ int efi_memory_init(void)
>  
>   efi_add_known_memory();
>  
> - /* Add U-Boot */
> - uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK;
> - uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
> - efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
> -
> - /* Add Runtime Services */
> - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> - runtime_end = (ulong)&__efi_runtime_stop;
> - runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> - runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
> - efi_add_memory_map(runtime_start, runtime_pages,
> -EFI_RUNTIME_SERVICES_CODE, false);
> + if (!IS_ENABLED(CONFIG_SANDBOX)) {
> + /* Add U-Boot */
> + uboot_start = (gd->start_addr_sp - uboot_stack_size) &
> + ~EFI_PAGE_MASK;
> + uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
> + efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA,
> +false);
> +
> + /* Add Runtime Services */
> + runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> + runtime_end = (ulong)&__efi_runtime_stop;
> + runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> + runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
> + efi_add_memory_map(runtime_start, runtime_pages,
> +EFI_RUNTIME_SERVICES_CODE, false);
> + }
>  
>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
>   /* Request a 32bit 64MB bounce buffer region */
> 

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


Re: [U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> A limitation of the EFI loader at present is that it does not build with
> sandbox. This makes it hard to write tests, since sandbox is used for most
> testing in U-Boot.
> 
> This series enables the EFI loader feature. It allows sandbox to build and
> run a trivial function which calls the EFI API to output a message.
> 
> This series is at u-boot-dm/efi-working

I applied you patch series

make sandbox_defconfig
CONFIG_CMD_BOOTEFI_SELFTEST=y
make -j6

results in:

ld.bfd: read in flex scanner failed
scripts/Makefile.lib:407: recipe for target
'lib/efi_selftest/efi_selftest_miniapp_exit_efi.so' failed
make[2]: *** [lib/efi_selftest/efi_selftest_miniapp_exit_efi.so] Error 1
rm lib/efi_selftest/efi_selftest_miniapp_exit.o
lib/efi_selftest/efi_selftest_miniapp_return.o
scripts/Makefile.build:423: recipe for target 'lib/efi_selftest' failed
make[1]: *** [lib/efi_selftest] Error 2
make[1]: *** Waiting for unfinished jobs

Please, change /lib/efi_selftest/Makefile
-ifeq ($(CONFIG_X86_64),)
+ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)

Now running ./u-boot

bootefi selftest
Found 0 disks
WARNING: booting without device tree

Testing EFI API implementation

Number of tests to execute: 17

Setting up 'block device'
Setting up 'block device' succeeded

Executing 'block device'
lib/efi_selftest/efi_selftest_block_device.c(378):
TODO: Wrong volume label 'xxa1', expected 'U-BOOT TEST'
FAT: Misaligned buffer address (7ff70aafe658)
Segmentation fault

Please, fix the alignment fault. You have to ensure that the memory that
Sandbox has retrieved via malloc is reduced to 4k aligned pages before
being published to the EFI implementation in lib/efi_loader/efi_memory.c

Best regards

Heinrich



> 
> Changes in v4:
> - Fix up the sizeof() operations on jmp_buf
> - Move the fix to query_console_serial()
> - Rebase to master
> - Remove code already applied
> - Update SPDX tags
> - Update subject
> 
> Changes in v3:
> - Add comments on aligment
> - Add new patch to init the 'rows' and 'cols' variables
> - Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
> - Add new patch to split out test init/uninit into functions
> - Add patch to create a function to set up for running EFI code
> - Drop incorrect map_sysmem() in write_smbios_table()
> - Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)
> - Rebase to master
> - Return error value of efi_allocate_pages()
> - Update function comment for write_smbios_table()
> 
> Changes in v2:
> - Rebase to master
> - Update return type of efi_smbios_register() to efi_status_t
> - Update to use mapmem instead of a cast
> - Use return value of efi_install_configuration_table
> 
> Simon Glass (16):
>   efi: Init the 'rows' and 'cols' variables
>   efi: Update some comments related to smbios tables
>   efi: sandbox: Adjust memory usage for sandbox
>   sandbox: smbios: Update to support sandbox
>   sandbox: Add a setjmp() implementation
>   efi: sandbox: Add required linker sections
>   efi: sandbox: Add distroboot support
>   Define board_quiesce_devices() in a shared location
>   Add a comment for board_quiesce_devices()
>   efi: sandbox: Add relocation constants
>   efi: Add a comment about duplicated ELF constants
>   efi: sandbox: Enable EFI loader builder for sandbox
>   efi: Split out test init/uninit into functions
>   efi: sandbox: Add a simple 'bootefi test' command
>   efi: Create a function to set up for running EFI code
>   efi: Rename bootefi_test_finish() to bootefi_run_finish()
> 
>  arch/arm/include/asm/u-boot-arm.h |   1 -
>  arch/sandbox/cpu/cpu.c|  13 +++
>  arch/sandbox/cpu/os.c |  23 +
>  arch/sandbox/cpu/u-boot.lds   |  29 ++
>  arch/sandbox/include/asm/setjmp.h |  30 ++
>  arch/sandbox/lib/Makefile |   2 +-
>  arch/sandbox/lib/sections.c   |  12 +++
>  arch/x86/include/asm/u-boot-x86.h |   1 -
>  arch/x86/lib/bootm.c  |   4 -
>  cmd/bootefi.c | 158 +-
>  common/bootm.c|   4 +
>  include/bootm.h   |   8 ++
>  include/config_distro_bootcmd.h   |   2 +-
>  include/efi_loader.h  |  10 ++
>  include/os.h  |  21 
>  include/smbios.h  |   5 +-
>  lib/efi_loader/Kconfig|  12 ++-
>  lib/efi_loader/Makefile   |   1 +
>  lib/efi_loader/efi_console.c  |   5 +-
>  lib/efi_loader/efi_memory.c   |  31 +++---
>  lib/efi_loader/efi_runtime.c  |   7 ++
>  lib/efi_loader/efi_smbios.c   |   7 +-
>  lib/efi_loader/efi_test.c |  16 +++
>  lib/smbios.c  |  32 --
>  24 files changed, 351 insertions(+), 83 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/setjmp.h
>  create mode 100644 arch/sandbox/lib/sections.c
>  create mode 100644 lib/efi_loader/efi_test.c
> 

___
U-Boot mailing list

Re: [U-Boot] [PATCH v4 03/16] efi: sandbox: Adjust memory usage for sandbox

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> With sandbox the U-Boot code is not mapped into the sandbox memory range
> so does not need to be excluded when allocating EFI memory. Update the EFI
> memory init code to take account of that.
> 
> Also use mapmem instead of a cast to convert a memory address to a
> pointer.
> 
> Signed-off-by: Simon Glass 

This patch does not apply to Alex's efi-next repository due to
https://github.com/agraf/u-boot/commit/e62d2cd60480a867dd21a102238f5387b82140d7

Please, rebase.

Best regards

Heinrich

> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Update to use mapmem instead of a cast
> 
>  lib/efi_loader/efi_memory.c | 31 ++-
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 664c651db56..3fbed63728b 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -388,7 +389,7 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t 
> size, void **buffer)
>   r = efi_allocate_pages(0, pool_type, num_pages, );
>  
>   if (r == EFI_SUCCESS) {
> - struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
> + struct efi_pool_allocation *alloc = map_sysmem(t, size);
>   alloc->num_pages = num_pages;
>   *buffer = alloc->data;
>   }
> @@ -499,18 +500,22 @@ int efi_memory_init(void)
>  
>   efi_add_known_memory();
>  
> - /* Add U-Boot */
> - uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK;
> - uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
> - efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
> -
> - /* Add Runtime Services */
> - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> - runtime_end = (ulong)&__efi_runtime_stop;
> - runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> - runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
> - efi_add_memory_map(runtime_start, runtime_pages,
> -EFI_RUNTIME_SERVICES_CODE, false);
> + if (!IS_ENABLED(CONFIG_SANDBOX)) {
> + /* Add U-Boot */
> + uboot_start = (gd->start_addr_sp - uboot_stack_size) &
> + ~EFI_PAGE_MASK;
> + uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
> + efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA,
> +false);
> +
> + /* Add Runtime Services */
> + runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> + runtime_end = (ulong)&__efi_runtime_stop;
> + runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> + runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
> + efi_add_memory_map(runtime_start, runtime_pages,
> +EFI_RUNTIME_SERVICES_CODE, false);
> + }
>  
>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
>   /* Request a 32bit 64MB bounce buffer region */
> 

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


Re: [U-Boot] [PATCH v4 13/14] mmc: Separate "mmc swrite" from fastboot

2018-05-16 Thread Alex Kiernan
On Wed, May 16, 2018 at 5:17 PM Joe Hershberger 
wrote:

> On Wed, May 16, 2018 at 12:00 AM, Alex Kiernan 
wrote:
> > On Wed, May 16, 2018 at 12:20 AM Joe Hershberger  > wrote:
> >
> >> On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan 
> > wrote:
> >> > Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> >> > swrite" command is separated from the fastboot code.
> >> >
> >> > Move image-sparse from common to lib so it's clear it's library code.
> >> >
> >> > Signed-off-by: Alex Kiernan 
> >> > ---
> >> >
> >> > Changes in v4:
> >> > - new
> >> >
> >> > Changes in v3: None
> >> > Changes in v2: None
> >> >
> >> >  cmd/Kconfig|  8 
> >> >  cmd/mmc.c  | 12 ++--
> >> >  common/Makefile|  1 -
> >> >  drivers/fastboot/Kconfig   |  1 +
> >> >  lib/Kconfig|  3 +++
> >> >  lib/Makefile   |  1 +
> >> >  {common => lib}/image-sparse.c |  0
> >> >  7 files changed, 19 insertions(+), 7 deletions(-)
> >> >  rename {common => lib}/image-sparse.c (100%)
> >> >
> >> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> >> > index df2194c..b5fa657 100644
> >> > --- a/cmd/Kconfig
> >> > +++ b/cmd/Kconfig
> >> > @@ -826,6 +826,14 @@ config CMD_MMC
> >> > help
> >> >   MMC memory mapped support.
> >> >
> >> > +config CMD_MMC_SWRITE
> >> > +   bool "mmc swrite"
> >> > +   depends on CMD_MMC && MMC_WRITE
> >> > +   select IMAGE_SPARSE
> >> > +   help
> >> > + Enable support for the "mmc swrite" command to write
Android
> > sparse
> >> > + images to eMMC.
> >> > +
> >> >  config CMD_NAND
> >> > bool "nand"
> >> > default y if NAND_SUNXI
> >> > diff --git a/cmd/mmc.c b/cmd/mmc.c
> >> > index cc44525..66c3ee0 100644
> >> > --- a/cmd/mmc.c
> >> > +++ b/cmd/mmc.c
> >> > @@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int
flag,
> >> > return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
> >> >  }
> >> >
> >> > -#if CONFIG_IS_ENABLED(MMC_WRITE)
> >> > -#if defined(CONFIG_FASTBOOT_FLASH)
> >> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
> >> >  static lbaint_t mmc_sparse_write(struct sparse_storage *info,
lbaint_t
> > blk,
> >> >  lbaint_t blkcnt, const void *buffer)
> >> >  {
> >> > @@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
> > int flag,
> >> >  }
> >> >  #endif
> >> >
> >> > +#if CONFIG_IS_ENABLED(MMC_WRITE)
> >> >  static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
> >> > int argc, char * const argv[])
> >> >  {
> >> > @@ -868,11 +868,11 @@ static cmd_tbl_t cmd_mmc[] = {
> >> > U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
> >> >  #if CONFIG_IS_ENABLED(MMC_WRITE)
> >> > U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
> >> > -#if defined(CONFIG_FASTBOOT_FLASH)
> >> > -   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
> >> > -#endif
> >> > U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
> >> >  #endif
> >> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
> >> > +   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
> >> > +#endif
> >> > U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
> >> > U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
> >> > U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
> >> > @@ -927,7 +927,7 @@ U_BOOT_CMD(
> >> > "info - display info of the current MMC device\n"
> >> > "mmc read addr blk# cnt\n"
> >> > "mmc write addr blk# cnt\n"
> >> > -#if defined(CONFIG_FASTBOOT_FLASH)
> >> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
> >> > "mmc swrite addr blk#\n"
> >> >  #endif
> >> > "mmc erase blk# cnt\n"
> >> > diff --git a/common/Makefile b/common/Makefile
> >> > index 9ec40b9..b3da72e 100644
> >> > --- a/common/Makefile
> >> > +++ b/common/Makefile
> >> > @@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
> >> >
> >> >  obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
> >> >  obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
> >> > -obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
> >> >  obj-$(CONFIG_MII) += miiphyutil.o
> >> >  obj-$(CONFIG_CMD_MII) += miiphyutil.o
> >> >  obj-$(CONFIG_PHYLIB) += miiphyutil.o
> >> > diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
> >> > index 51c5789..82e1420 100644
> >> > --- a/drivers/fastboot/Kconfig
> >> > +++ b/drivers/fastboot/Kconfig
> >> > @@ -57,6 +57,7 @@ config FASTBOOT_FLASH
> >> > bool "Enable FASTBOOT FLASH command"
> >> > default y if ARCH_SUNXI
> >> > depends on MMC || (NAND && CMD_MTDPARTS)
> >> > +   select IMAGE_SPARSE
> >
> >> Is this useful if we are NAND and not MMC? It seems no.
> >
> > There's code in drivers/fastboot/fb_nand.c which will write sparse
images,
> > so I think the select 

Re: [U-Boot] [PATCH v4 11/16] efi: Add a comment about duplicated ELF constants

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> These constants are defined in arch-specific code but redefined here. Add
> a TODO to clean this up.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  lib/efi_loader/efi_runtime.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index ac02f64d967..e94b94389d8 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -36,6 +36,10 @@ static efi_status_t __efi_runtime EFIAPI 
> efi_invalid_parameter(void);
>  #define EFI_CACHELINE_SIZE 128
>  #endif
>  
> +/*
> + * TODO(s...@chromium.org): These defines and structs should come from the 
> elf.

%s/elf\./elf/

> + * header for each arch (or a generic header) rather than being repeated 
> here.
> + */
>  #if defined(CONFIG_ARM64)
>  #define R_RELATIVE   1027
>  #define R_MASK   0xULL

I would prefer if we would simply use glibc elf.h. But this will also
involve some rewriting. The value above for example is part of macro
ELF64_R_TYPE(i) in glibc elf.h.

Except for the typo.

Reviewed-by: Heinrich Schuchardt 

> 

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


Re: [U-Boot] [PATCH v4 02/16] efi: Update some comments related to smbios tables

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> Clarify the operation of this code with some additional comments.
> 
> Signed-off-by: Simon Glass 

Reviewed-by: Heinrich Schuchardt 

> ---
> 
> Changes in v4:
> - Remove code already applied
> - Update subject
> 
> Changes in v3:
> - Add comments on aligment
> - Return error value of efi_allocate_pages()
> - Update function comment for write_smbios_table()
> 
> Changes in v2:
> - Update return type of efi_smbios_register() to efi_status_t
> - Use return value of efi_install_configuration_table
> 
>  include/efi_loader.h| 7 +++
>  include/smbios.h| 5 +++--
>  lib/efi_loader/efi_smbios.c | 7 ++-
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 2868ca25abb..2519a7c33a7 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -207,6 +207,13 @@ efi_status_t efi_net_register(void);
>  /* Called by bootefi to make the watchdog available */
>  efi_status_t efi_watchdog_register(void);
>  /* Called by bootefi to make SMBIOS tables available */
> +/**
> + * efi_smbios_register() - write out SMBIOS tables
> + *
> + * Called by bootefi to make SMBIOS tables available
> + *
> + * @return 0 if OK, -ENOMEM if no memory is available for the tables
> + */
>  efi_status_t efi_smbios_register(void);
>  
>  struct efi_simple_file_system_protocol *
> diff --git a/include/smbios.h b/include/smbios.h
> index 79880ef5b5c..97b9ddce237 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -231,8 +231,9 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
>   *
>   * This writes SMBIOS table at a given address.
>   *
> - * @addr:start address to write SMBIOS table
> - * @return:  end address of SMBIOS table
> + * @addr:start address to write SMBIOS table. If this is not
> + *   16-byte-aligned then it will be aligned before the table is written
> + * @return:  end address of SMBIOS table (and start address for next entry)
>   */
>  ulong write_smbios_table(ulong addr);
>  
> diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
> index 482436e2adb..7c3fc8af0b2 100644
> --- a/lib/efi_loader/efi_smbios.c
> +++ b/lib/efi_loader/efi_smbios.c
> @@ -29,7 +29,12 @@ efi_status_t efi_smbios_register(void)
>   if (ret != EFI_SUCCESS)
>   return ret;
>  
> - /* Generate SMBIOS tables */
> + /*
> +  * Generate SMBIOS tables - we know that efi_allocate_pages() returns
> +  * a 4k-aligned address, so it is safe to assume that
> +  * write_smbios_table() will write the table at that address.
> +  */
> + assert(!(dmi & 0xf));
>   write_smbios_table(dmi);
>  
>   /* And expose them to our EFI payload */
> 

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


Re: [U-Boot] [PATCH v4 01/16] efi: Init the 'rows' and 'cols' variables

2018-05-16 Thread Heinrich Schuchardt
On 05/16/2018 05:42 PM, Simon Glass wrote:
> The current code causes a compiler error on gcc 4.8.4 as used by sandbox
> on Ubuntu 14.04, which is fairly recent. Init these variables to fix the
> problem.
> 
> Signed-off-by: Simon Glass 

This patch may silence the compiler but does not solve the bug leading
to the possible usage of unintialized values. See
https://lists.denx.de/pipermail/u-boot/2018-May/328762.html

Best regards

Heinrich Schuchardt


> ---
> 
> Changes in v4:
> - Move the fix to query_console_serial()
> 
> Changes in v3:
> - Add new patch to init the 'rows' and 'cols' variables
> 
> Changes in v2: None
> 
>  lib/efi_loader/efi_console.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index d777db8a3ed..001f68df0a7 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -185,8 +185,11 @@ static int query_console_serial(int *rows, int *cols)
>   return -1;
>  
>   /* Read {depth,rows,cols} */
> - if (term_read_reply(n, 3, 't'))
> + if (term_read_reply(n, 3, 't')) {
> + *rows = -1;
> + *cols = -1;
>   return -1;
> + }
>  
>   *cols = n[2];
>   *rows = n[1];
> 

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


[U-Boot] [PATCH 1/1] efi_loader: avoid using unitialized values as console size

2018-05-16 Thread Heinrich Schuchardt
If a request for the console size would be answered with a response
with less then three values, uninitialized stack memory would be
copied to the number of rows and columns of the terminal.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_console.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 5d1a9a8081e..8365431291c 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -63,7 +63,15 @@ static struct simple_text_output_mode efi_con_mode = {
.cursor_visible = 1,
 };
 
-static int term_read_reply(int *n, int maxnum, char end_char)
+/*
+ * Receive and parse a reply from the terminal.
+ *
+ * @n: array of return values
+ * @num:   number of return values expected
+ * @end_char:  character indicating end of terminal message
+ * @return:non-zero indicates error
+ */
+static int term_read_reply(int *n, int num, char end_char)
 {
char c;
int i = 0;
@@ -80,7 +88,7 @@ static int term_read_reply(int *n, int maxnum, char end_char)
c = getc();
if (c == ';') {
i++;
-   if (i >= maxnum)
+   if (i >= num)
return -1;
n[i] = 0;
continue;
@@ -94,6 +102,8 @@ static int term_read_reply(int *n, int maxnum, char end_char)
n[i] *= 10;
n[i] += c - '0';
}
+   if (i != num - 1)
+   return -1;
 
return 0;
 }
-- 
2.14.2

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


Re: [U-Boot] [PATCH v4 13/14] mmc: Separate "mmc swrite" from fastboot

2018-05-16 Thread Joe Hershberger
On Wed, May 16, 2018 at 12:00 AM, Alex Kiernan  wrote:
> On Wed, May 16, 2018 at 12:20 AM Joe Hershberger 
> wrote:
>
>> On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan 
> wrote:
>> > Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
>> > swrite" command is separated from the fastboot code.
>> >
>> > Move image-sparse from common to lib so it's clear it's library code.
>> >
>> > Signed-off-by: Alex Kiernan 
>> > ---
>> >
>> > Changes in v4:
>> > - new
>> >
>> > Changes in v3: None
>> > Changes in v2: None
>> >
>> >  cmd/Kconfig|  8 
>> >  cmd/mmc.c  | 12 ++--
>> >  common/Makefile|  1 -
>> >  drivers/fastboot/Kconfig   |  1 +
>> >  lib/Kconfig|  3 +++
>> >  lib/Makefile   |  1 +
>> >  {common => lib}/image-sparse.c |  0
>> >  7 files changed, 19 insertions(+), 7 deletions(-)
>> >  rename {common => lib}/image-sparse.c (100%)
>> >
>> > diff --git a/cmd/Kconfig b/cmd/Kconfig
>> > index df2194c..b5fa657 100644
>> > --- a/cmd/Kconfig
>> > +++ b/cmd/Kconfig
>> > @@ -826,6 +826,14 @@ config CMD_MMC
>> > help
>> >   MMC memory mapped support.
>> >
>> > +config CMD_MMC_SWRITE
>> > +   bool "mmc swrite"
>> > +   depends on CMD_MMC && MMC_WRITE
>> > +   select IMAGE_SPARSE
>> > +   help
>> > + Enable support for the "mmc swrite" command to write Android
> sparse
>> > + images to eMMC.
>> > +
>> >  config CMD_NAND
>> > bool "nand"
>> > default y if NAND_SUNXI
>> > diff --git a/cmd/mmc.c b/cmd/mmc.c
>> > index cc44525..66c3ee0 100644
>> > --- a/cmd/mmc.c
>> > +++ b/cmd/mmc.c
>> > @@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
>> > return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
>> >  }
>> >
>> > -#if CONFIG_IS_ENABLED(MMC_WRITE)
>> > -#if defined(CONFIG_FASTBOOT_FLASH)
>> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
>> >  static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t
> blk,
>> >  lbaint_t blkcnt, const void *buffer)
>> >  {
>> > @@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
> int flag,
>> >  }
>> >  #endif
>> >
>> > +#if CONFIG_IS_ENABLED(MMC_WRITE)
>> >  static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
>> > int argc, char * const argv[])
>> >  {
>> > @@ -868,11 +868,11 @@ static cmd_tbl_t cmd_mmc[] = {
>> > U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
>> >  #if CONFIG_IS_ENABLED(MMC_WRITE)
>> > U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
>> > -#if defined(CONFIG_FASTBOOT_FLASH)
>> > -   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
>> > -#endif
>> > U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
>> >  #endif
>> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
>> > +   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
>> > +#endif
>> > U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
>> > U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
>> > U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
>> > @@ -927,7 +927,7 @@ U_BOOT_CMD(
>> > "info - display info of the current MMC device\n"
>> > "mmc read addr blk# cnt\n"
>> > "mmc write addr blk# cnt\n"
>> > -#if defined(CONFIG_FASTBOOT_FLASH)
>> > +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
>> > "mmc swrite addr blk#\n"
>> >  #endif
>> > "mmc erase blk# cnt\n"
>> > diff --git a/common/Makefile b/common/Makefile
>> > index 9ec40b9..b3da72e 100644
>> > --- a/common/Makefile
>> > +++ b/common/Makefile
>> > @@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
>> >
>> >  obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
>> >  obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
>> > -obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
>> >  obj-$(CONFIG_MII) += miiphyutil.o
>> >  obj-$(CONFIG_CMD_MII) += miiphyutil.o
>> >  obj-$(CONFIG_PHYLIB) += miiphyutil.o
>> > diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
>> > index 51c5789..82e1420 100644
>> > --- a/drivers/fastboot/Kconfig
>> > +++ b/drivers/fastboot/Kconfig
>> > @@ -57,6 +57,7 @@ config FASTBOOT_FLASH
>> > bool "Enable FASTBOOT FLASH command"
>> > default y if ARCH_SUNXI
>> > depends on MMC || (NAND && CMD_MTDPARTS)
>> > +   select IMAGE_SPARSE
>
>> Is this useful if we are NAND and not MMC? It seems no.
>
> There's code in drivers/fastboot/fb_nand.c which will write sparse images,
> so I think the select is right.

OK, then this is fine.

> That said, there's nothings in configs/ which actually selects
> FASTBOOT_FLASH_NAND

OK, I guess we can wait for a board to come along that uses it?

> --
> Alex Kiernan
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> 

Re: [U-Boot] [PATCH v1 16/21] display5: net: Add function to read ethaddr from iMX6 fuses

2018-05-16 Thread Joe Hershberger
On Wed, May 16, 2018 at 9:46 AM, Lukasz Majewski  wrote:
> Hi Joe,
>
>> Hi Lukasz,
>>
>> On Fri, May 11, 2018 at 9:51 AM, Lukasz Majewski 
>> wrote:
>> > Signed-off-by: Lukasz Majewski 
>> > ---
>> >
>> >  board/liebherr/display5/display5.c | 21 +
>> >  1 file changed, 21 insertions(+)
>> >
>> > diff --git a/board/liebherr/display5/display5.c
>> > b/board/liebherr/display5/display5.c index 4bade476a5..a3deba216c
>> > 100644 --- a/board/liebherr/display5/display5.c
>> > +++ b/board/liebherr/display5/display5.c
>> > @@ -254,6 +254,25 @@ static void setup_iomux_enet(void)
>> > gpio_direction_input(IMX_GPIO_NR(1, 28)); /*INT#_GBE*/
>> >  }
>> >
>> > +static int setup_mac_from_fuse(void)
>> > +{
>> > +   unsigned char enetaddr[6];
>> > +   int ret;
>> > +
>> > +   ret = eth_env_get_enetaddr("ethaddr", enetaddr);
>> > +   if (ret)/* ethaddr is already set */
>> > +   return 0;
>> > +
>> > +   imx_get_mac_from_fuse(0, enetaddr);
>>
>> Generally this should be registered as a read_rom_hwaddr handler.
>
> This function seems like a generic approach for IMX SoC:
> arch/arm/mach-imx/mac.c
>
> On the other hand the fec_mxc.c driver seems to have such function:
>
> .read_rom_hwaddr= fecmxc_read_rom_hwaddr,
> (which latter on calls the above function).
>
> To use this function in the automatic way I would need to enable DM_ETH
> for this board.

Good idea.

>> Then you won't be recreating the logic around what to do with it.
>>
>> > +
>> > +   if (is_valid_ethaddr(enetaddr)) {
>> > +   eth_env_set_enetaddr("ethaddr", enetaddr);
>> > +   return 0;
>> > +   }
>> > +
>> > +   return 0;
>> > +}
>> > +
>> >  int board_eth_init(bd_t *bd)
>> >  {
>> > struct phy_device *phydev;
>> > @@ -268,6 +287,8 @@ int board_eth_init(bd_t *bd)
>> > if (ret)
>> > return ret;
>> >
>> > +   setup_mac_from_fuse();
>> > +
>> > bus = fec_get_miibus(IMX_FEC_BASE, -1);
>> > if (!bus)
>> > return -ENODEV;
>> > --
>> > 2.11.0
>> >
>> > ___
>> > U-Boot mailing list
>> > U-Boot@lists.denx.de
>> > https://lists.denx.de/listinfo/u-boot
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] ram: stm32_sdram: Adds stm32f429-disco fixes for HardFault at booting

2018-05-16 Thread Patrice CHOTARD
Hi Radoslaw

On 05/16/2018 05:27 PM, Radoslaw Pietrzyk wrote:
> - adds reading FMC swap setting from DTB to SDRAM driver
> - sets FMC swap for stm32f429-disco board
> - changes ram start address to 0x9000
> 
> Signed-off-by: Radoslaw Pietrzyk 
> ---
>   arch/arm/dts/stm32f429-disco-u-boot.dtsi |  2 ++
>   drivers/ram/stm32_sdram.c| 37 
> +---
>   include/configs/stm32f429-discovery.h|  6 +++---
>   3 files changed, 29 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/dts/stm32f429-disco-u-boot.dtsi 
> b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
> index 8a0f642..10e0950 100644
> --- a/arch/arm/dts/stm32f429-disco-u-boot.dtsi
> +++ b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
> @@ -37,6 +37,8 @@
>   clocks = < 0 STM32F4_AHB3_CLOCK(FMC)>;
>   pinctrl-0 = <_pins>;
>   pinctrl-names = "default";
> + st,syscfg = <>;
> + st,swp_fmc = <1>;
>   u-boot,dm-pre-reloc;
>   
>   /*
> diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
> index dc39f33..f6cac8e 100644
> --- a/drivers/ram/stm32_sdram.c
> +++ b/drivers/ram/stm32_sdram.c
> @@ -11,6 +11,8 @@
>   #include 
>   
>   #define MEM_MODE_MASK   GENMASK(2, 0)
> +#define SWP_FMC_OFFSET 10
> +#define SWP_FMC_MASK GENMASK(SWP_FMC_OFFSET+1, SWP_FMC_OFFSET)
>   #define NOT_FOUND   0xff
>   
>   struct stm32_fmc_regs {
> @@ -256,27 +258,36 @@ static int stm32_fmc_ofdata_to_platdata(struct udevice 
> *dev)
>   struct ofnode_phandle_args args;
>   u32 *syscfg_base;
>   u32 mem_remap;
> + u32 swp_fmc;
>   ofnode bank_node;
>   char *bank_name;
>   u8 bank = 0;
>   int ret;
>   
> - mem_remap = dev_read_u32_default(dev, "st,mem_remap", NOT_FOUND);
> - if (mem_remap != NOT_FOUND) {
> - ret = dev_read_phandle_with_args(dev, "st,syscfg", NULL, 0, 0,
> + ret = dev_read_phandle_with_args(dev, "st,syscfg", NULL, 0, 0,
>);
> - if (ret) {
> - debug("%s: can't find syscon device (%d)\n", __func__,
> -   ret);
> - return ret;
> - }
> -
> + if (ret) {
> + dev_dbg(dev, "%s: can't find syscon device (%d)\n", __func__, 
> ret);
> + } else {
>   syscfg_base = (u32 *)ofnode_get_addr(args.node);
>   
> - /* set memory mapping selection */
> - clrsetbits_le32(syscfg_base, MEM_MODE_MASK, mem_remap);
> - } else {
> - debug("%s: cannot find st,mem_remap property\n", __func__);
> + mem_remap = dev_read_u32_default(dev, "st,mem_remap", 
> NOT_FOUND);
> + if (mem_remap != NOT_FOUND) {
> + /* set memory mapping selection */
> + clrsetbits_le32(syscfg_base, MEM_MODE_MASK, mem_remap);
> + } else {
> + dev_dbg(dev, "%s: cannot find st,mem_remap property\n", 
> __func__);
> + }
> + 
> + swp_fmc = dev_read_u32_default(dev, "st,swp_fmc", NOT_FOUND);
> + if (swp_fmc != NOT_FOUND) {
> + /* set fmc swapping selection */
> + clrsetbits_le32(syscfg_base, SWP_FMC_MASK, swp_fmc << 
> SWP_FMC_OFFSET);
> + } else {
> + dev_dbg(dev, "%s: cannot find st,swp_fmc property\n", 
> __func__);
> + }
> +
> + dev_dbg(dev, "syscfg %x = %x\n", (u32)syscfg_base, 
> *syscfg_base);
>   }
>   
>   dev_for_each_subnode(bank_node, dev) {
> diff --git a/include/configs/stm32f429-discovery.h 
> b/include/configs/stm32f429-discovery.h
> index 4fd9c23..46eda1d 100644
> --- a/include/configs/stm32f429-discovery.h
> +++ b/include/configs/stm32f429-discovery.h
> @@ -22,10 +22,10 @@
>   #define CONFIG_NR_DRAM_BANKS1
>   #define CONFIG_SYS_RAM_CS   1
>   #define CONFIG_SYS_RAM_FREQ_DIV 2
> -#define CONFIG_SYS_RAM_BASE  0xD000
> +#define CONFIG_SYS_RAM_BASE  0x9000
>   #define CONFIG_SYS_SDRAM_BASE   CONFIG_SYS_RAM_BASE
> -#define CONFIG_SYS_LOAD_ADDR 0xD040
> -#define CONFIG_LOADADDR  0xD040
> +#define CONFIG_SYS_LOAD_ADDR 0x9040
> +#define CONFIG_LOADADDR  0x9040
>   
>   #define CONFIG_SYS_MAX_FLASH_SECT   12
>   #define CONFIG_SYS_MAX_FLASH_BANKS  2
> 

Acked-by: Patrice Chotard 

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


Re: [U-Boot] [PATCH 2/2] test: Fix test_vboot to call openssl without redirection

2018-05-16 Thread Stephen Warren

On 05/16/2018 01:10 AM, Simon Glass wrote:

The redirection seems to cause this test to fail now. It isn't needed, so
drop it.


I guess I have no particular objection to this, but I will point out 
that the test is working just fine as-is right now, so it might be worth 
investigating more re: what the error is and why it's happening... It'd 
be good to describe the details of the failure in the commit description 
too.

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


[U-Boot] [PATCH v4 02/16] efi: Update some comments related to smbios tables

2018-05-16 Thread Simon Glass
Clarify the operation of this code with some additional comments.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Remove code already applied
- Update subject

Changes in v3:
- Add comments on aligment
- Return error value of efi_allocate_pages()
- Update function comment for write_smbios_table()

Changes in v2:
- Update return type of efi_smbios_register() to efi_status_t
- Use return value of efi_install_configuration_table

 include/efi_loader.h| 7 +++
 include/smbios.h| 5 +++--
 lib/efi_loader/efi_smbios.c | 7 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2868ca25abb..2519a7c33a7 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -207,6 +207,13 @@ efi_status_t efi_net_register(void);
 /* Called by bootefi to make the watchdog available */
 efi_status_t efi_watchdog_register(void);
 /* Called by bootefi to make SMBIOS tables available */
+/**
+ * efi_smbios_register() - write out SMBIOS tables
+ *
+ * Called by bootefi to make SMBIOS tables available
+ *
+ * @return 0 if OK, -ENOMEM if no memory is available for the tables
+ */
 efi_status_t efi_smbios_register(void);
 
 struct efi_simple_file_system_protocol *
diff --git a/include/smbios.h b/include/smbios.h
index 79880ef5b5c..97b9ddce237 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -231,8 +231,9 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
  *
  * This writes SMBIOS table at a given address.
  *
- * @addr:  start address to write SMBIOS table
- * @return:end address of SMBIOS table
+ * @addr:  start address to write SMBIOS table. If this is not
+ * 16-byte-aligned then it will be aligned before the table is written
+ * @return:end address of SMBIOS table (and start address for next entry)
  */
 ulong write_smbios_table(ulong addr);
 
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 482436e2adb..7c3fc8af0b2 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -29,7 +29,12 @@ efi_status_t efi_smbios_register(void)
if (ret != EFI_SUCCESS)
return ret;
 
-   /* Generate SMBIOS tables */
+   /*
+* Generate SMBIOS tables - we know that efi_allocate_pages() returns
+* a 4k-aligned address, so it is safe to assume that
+* write_smbios_table() will write the table at that address.
+*/
+   assert(!(dmi & 0xf));
write_smbios_table(dmi);
 
/* And expose them to our EFI payload */
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 16/16] efi: Rename bootefi_test_finish() to bootefi_run_finish()

2018-05-16 Thread Simon Glass
This function can be used from do_bootefi_exec() so that we use mostly the
same code for a normal EFI application and an EFI test.

Rename the function and use it in both places.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Rebase to master

Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()

Changes in v2: None

 cmd/bootefi.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 23f05aa867a..00a94fc8560 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -268,6 +268,20 @@ static efi_status_t bootefi_run_prepare(struct 
efi_loaded_image *image,
return 0;
 }
 
+/**
+ * bootefi_run_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_run_finish(struct efi_loaded_image *image,
+  struct efi_object *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   list_del(>link);
+}
+
 /*
  * Load an EFI payload into a newly allocated piece of memory, register all
  * EFI objects it would want to access and jump to it.
@@ -350,8 +364,7 @@ static efi_status_t do_bootefi_exec(void *efi,
ret = efi_do_enter(obj.handle, , entry);
 
 exit:
-   /* image has returned, loaded-image obj goes *poof*: */
-   list_del();
+   bootefi_run_finish(, );
 
return ret;
 }
@@ -383,20 +396,6 @@ static efi_status_t bootefi_test_prepare(struct 
efi_loaded_image *image,
   bootefi_image_path);
 }
 
-/**
- * bootefi_test_finish() - finish up after running an EFI test
- *
- * @image: Pointer to a struct which holds the loaded image info
- * @obj: Pointer to a struct which holds the loaded image object
- */
-static void bootefi_test_finish(struct efi_loaded_image *image,
-   struct efi_object *obj)
-{
-   efi_restore_gd();
-   free(image->load_options);
-   list_del(>link);
-}
-
 static int do_bootefi_bootmgr_exec(void)
 {
struct efi_device_path *device_path, *file_path;
@@ -480,7 +479,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_FAILURE;
 
ret = efi_test(, );
-   bootefi_test_finish(, );
+   bootefi_run_finish(, );
if (ret) {
printf("Test failed: err=%d\n", ret);
return CMD_RET_FAILURE;
@@ -497,7 +496,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
/* Execute the test */
r = efi_selftest(obj.handle, );
-   bootefi_test_finish(, );
+   bootefi_run_finish(, );
return r != EFI_SUCCESS;
} else
 #endif
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 15/16] efi: Create a function to set up for running EFI code

2018-05-16 Thread Simon Glass
Add a new bootefi_run_prepare() function which holds common code used to
set up U-Boot to run EFI code. Make use of this from the existing
bootefi_test_prepare() function, as well as do_bootefi_exec().

Also shorten a few variable names.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Rebase to master

Changes in v3:
- Add patch to create a function to set up for running EFI code

Changes in v2: None

 cmd/bootefi.c | 82 +++
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 46bd80d2077..23f05aa867a 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -241,6 +241,33 @@ static efi_status_t efi_install_fdt(void *fdt)
return ret;
 }
 
+static efi_status_t bootefi_run_prepare(struct efi_loaded_image *image,
+   struct efi_object *obj,
+   const char *path,
+   struct efi_device_path *device_path,
+   struct efi_device_path *image_path)
+{
+   efi_status_t ret;
+
+   efi_setup_loaded_image(image, obj, device_path, image_path);
+
+   /* Initialize and populate EFI object list */
+   ret = efi_init_obj_list();
+   if (ret)
+   return ret;
+
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+
+   /* Transfer environment variable bootargs as load options */
+   set_load_options(image, path);
+
+   return 0;
+}
+
 /*
  * Load an EFI payload into a newly allocated piece of memory, register all
  * EFI objects it would want to access and jump to it.
@@ -249,8 +276,8 @@ static efi_status_t do_bootefi_exec(void *efi,
struct efi_device_path *device_path,
struct efi_device_path *image_path)
 {
-   struct efi_loaded_image loaded_image_info = {};
-   struct efi_object loaded_image_info_obj = {};
+   struct efi_loaded_image image;
+   struct efi_object obj;
struct efi_device_path *memdp = NULL;
efi_status_t ret;
 
@@ -271,19 +298,13 @@ static efi_status_t do_bootefi_exec(void *efi,
assert(device_path && image_path);
}
 
-   efi_setup_loaded_image(_image_info, _image_info_obj,
-  device_path, image_path);
-
-   /*
-* gd lives in a fixed register which may get clobbered while we execute
-* the payload. So save it here and restore it on every callback entry
-*/
-   efi_save_gd();
+   ret = bootefi_run_prepare(, , "bootargs", device_path,
+ image_path);
+   if (ret)
+   return ret;
 
-   /* Transfer environment variable bootargs as load options */
-   set_load_options(_image_info, "bootargs");
/* Load the EFI payload */
-   entry = efi_load_pe(efi, _image_info);
+   entry = efi_load_pe(efi, );
if (!entry) {
ret = EFI_LOAD_ERROR;
goto exit;
@@ -291,10 +312,10 @@ static efi_status_t do_bootefi_exec(void *efi,
 
if (memdp) {
struct efi_device_path_memory *mdp = (void *)memdp;
-   mdp->memory_type = loaded_image_info.image_code_type;
-   mdp->start_address = (uintptr_t)loaded_image_info.image_base;
+   mdp->memory_type = image.image_code_type;
+   mdp->start_address = (uintptr_t)image.image_base;
mdp->end_address = mdp->start_address +
-   loaded_image_info.image_size;
+   image.image_size;
}
 
/* we don't support much: */
@@ -304,8 +325,8 @@ static efi_status_t do_bootefi_exec(void *efi,
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
-   if (setjmp(_image_info.exit_jmp)) {
-   ret = loaded_image_info.exit_status;
+   if (setjmp(_jmp)) {
+   ret = image.exit_status;
goto exit;
}
 
@@ -317,7 +338,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 
/* Move into EL2 and keep running there */
armv8_switch_to_el2((ulong)entry,
-   (ulong)_image_info_obj.handle,
+   (ulong),
(ulong), 0, (ulong)efi_run_in_el2,
ES_TO_AARCH64);
 
@@ -326,11 +347,11 @@ static efi_status_t do_bootefi_exec(void *efi,
}
 #endif
 
-   ret = efi_do_enter(loaded_image_info_obj.handle, , entry);
+   ret = efi_do_enter(obj.handle, , entry);
 
 exit:
/* image has returned, loaded-image obj goes *poof*: */
-   

[U-Boot] [PATCH v4 06/16] efi: sandbox: Add required linker sections

2018-05-16 Thread Simon Glass
The EFI loader code requires certain linker sections to exist. Add these
for sandbox so that the EFI loader code will link.

Signed-off-by: Simon Glass 
---

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

 arch/sandbox/cpu/u-boot.lds | 29 +
 arch/sandbox/lib/Makefile   |  2 +-
 arch/sandbox/lib/sections.c | 12 
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 arch/sandbox/lib/sections.c

diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index f97abdfa050..3a6cf55eb99 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -18,6 +18,35 @@ SECTIONS
__u_boot_sandbox_option_end = .;
 
__bss_start = .;
+
+   .__efi_runtime_start : {
+   *(.__efi_runtime_start)
+   }
+
+   .efi_runtime : {
+   *(efi_runtime_text)
+   *(efi_runtime_data)
+   }
+
+   .__efi_runtime_stop : {
+   *(.__efi_runtime_stop)
+   }
+
+   .efi_runtime_rel_start :
+   {
+   *(.__efi_runtime_rel_start)
+   }
+
+   .efi_runtime_rel : {
+   *(.relefi_runtime_text)
+   *(.relefi_runtime_data)
+   }
+
+   .efi_runtime_rel_stop :
+   {
+   *(.__efi_runtime_rel_stop)
+   }
+
 }
 
 INSERT BEFORE .data;
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
index 52eef2e662e..b4ff717e784 100644
--- a/arch/sandbox/lib/Makefile
+++ b/arch/sandbox/lib/Makefile
@@ -5,7 +5,7 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
-obj-y  += interrupts.o
+obj-y  += interrupts.o sections.o
 obj-$(CONFIG_PCI)  += pci_io.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o
diff --git a/arch/sandbox/lib/sections.c b/arch/sandbox/lib/sections.c
new file mode 100644
index 000..697a8167ddf
--- /dev/null
+++ b/arch/sandbox/lib/sections.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2013 Albert ARIBAUD 
+ *
+ */
+
+char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start")));
+char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop")));
+char __efi_runtime_rel_start[0]
+   __attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0]
+   __attribute__((section(".__efi_runtime_rel_stop")));
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 14/16] efi: sandbox: Add a simple 'bootefi test' command

2018-05-16 Thread Simon Glass
This jumps to test code which can call directly into the EFI support. It
does not need a separate image so it is easy to write tests with it.

This test can be executed without causing problems to the run-time
environemnt (e.g. U-Boot does not need to reboot afterwards).

For now the test just outputs a message. To try it:

./sandbox/u-boot -c "bootefi test"
U-Boot 2017.09-00204-g696c9855fe (Sep 17 2017 - 16:43:53 -0600)

DRAM:  128 MiB
MMC:
Using default environment

In:serial
Out:   serial
Err:   serial
SCSI:  Net:   No ethernet found.
IDE:   Bus 0: not available
Found 0 disks
Hello, world!
Test passed

Signed-off-by: Simon Glass 
---

Changes in v4:
- Rebase to master
- Update SPDX tags

Changes in v3:
- Rebase to master

Changes in v2:
- Rebase to master

 cmd/bootefi.c | 26 --
 include/efi_loader.h  |  3 +++
 lib/efi_loader/Kconfig| 10 ++
 lib/efi_loader/Makefile   |  1 +
 lib/efi_loader/efi_test.c | 16 
 5 files changed, 50 insertions(+), 6 deletions(-)
 create mode 100644 lib/efi_loader/efi_test.c

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 9bcdf8bdc48..46bd80d2077 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -335,7 +335,6 @@ exit:
return ret;
 }
 
-#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
 /**
  * bootefi_test_prepare() - prepare to run an EFI test
  *
@@ -391,7 +390,6 @@ static void bootefi_test_finish(struct efi_loaded_image 
*image,
free(image->load_options);
list_del(>link);
 }
-#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
 
 static int do_bootefi_bootmgr_exec(void)
 {
@@ -423,8 +421,10 @@ static int do_bootefi_bootmgr_exec(void)
 /* Interpreter command to boot an arbitrary EFI image from memory */
 static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
-   unsigned long addr;
+   struct efi_loaded_image image;
+   struct efi_object obj;
char *saddr;
+   unsigned long addr;
efi_status_t r;
void *fdt_addr;
 
@@ -466,11 +466,25 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
memcpy((char *)addr, __efi_helloworld_begin, size);
} else
 #endif
+   if (IS_ENABLED(CONFIG_BOOTEFI_TEST) && !strcmp(argv[1], "test")) {
+   int ret;
+
+   if (bootefi_test_prepare(, , "\\test",
+(ulong)_test))
+   return CMD_RET_FAILURE;
+
+   ret = efi_test(, );
+   bootefi_test_finish(, );
+   if (ret) {
+   printf("Test failed: err=%d\n", ret);
+   return CMD_RET_FAILURE;
+   }
+   printf("Test passed\n");
+
+   return 0;
+   }
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   struct efi_loaded_image image;
-   struct efi_object obj;
-
if (bootefi_test_prepare(, , "\\test",
 (uintptr_t)_selftest))
return CMD_RET_FAILURE;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2519a7c33a7..a19f1eaef24 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -435,6 +435,9 @@ efi_status_t EFIAPI efi_set_variable(s16 *variable_name,
 void *efi_bootmgr_load(struct efi_device_path **device_path,
   struct efi_device_path **file_path);
 
+/* Perform EFI tests */
+int efi_test(efi_handle_t image_handle, struct efi_system_table *systab);
+
 #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */
 
 /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 96107a90a90..59bdd389f4f 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -24,3 +24,13 @@ config EFI_LOADER_BOUNCE_BUFFER
  Some hardware does not support DMA to full 64bit addresses. For this
  hardware we can create a bounce buffer so that payloads don't have to
  worry about platform details.
+
+config BOOTEFI_TEST
+   bool "Provide a test for the EFI loader"
+   depends on EFI_LOADER && SANDBOX
+   default y
+   help
+ Provides a test of the EFI loader functionality accessed via the
+ command line ('bootefi test'). This runs within U-Boot so does not
+ need a separate EFI application to work. It aims to include coverage
+ of all EFI code which can be accessed within sandbox.
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index c6046e36d26..2da28f9c90c 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_DM_VIDEO) += efi_gop.o
 obj-$(CONFIG_PARTITIONS) += efi_disk.o
 obj-$(CONFIG_NET) += efi_net.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
+obj-$(CONFIG_BOOTEFI_TEST) += efi_test.o
diff --git 

[U-Boot] [PATCH v4 10/16] efi: sandbox: Add relocation constants

2018-05-16 Thread Simon Glass
Add these so that we can build the EFI loader for sandbox. The values are
for x86_64 so potentially bogus. But we don't support relocation within
sandbox anyway.

Signed-off-by: Simon Glass 
---

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

 lib/efi_loader/efi_runtime.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 52f1301d75b..ac02f64d967 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -47,6 +47,9 @@ static efi_status_t __efi_runtime EFIAPI 
efi_invalid_parameter(void);
 #include 
 #define R_RELATIVE R_386_RELATIVE
 #define R_MASK 0xffULL
+#elif defined(CONFIG_SANDBOX)
+#define R_RELATIVE 8
+#define R_MASK 0xULL
 #else
 #error Need to add relocation awareness
 #endif
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 07/16] efi: sandbox: Add distroboot support

2018-05-16 Thread Simon Glass
With sandbox these values depend on the host system. Let's assume that it
is x86_64 for now.

Signed-off-by: Simon Glass 
---

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

 include/config_distro_bootcmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 8d5feb3ac77..97d6baab4be 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -246,7 +246,7 @@
 #elif defined(CONFIG_ARM)
 #define BOOTENV_EFI_PXE_ARCH "0xa"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
-#elif defined(CONFIG_X86)
+#elif defined(CONFIG_X86) || defined(CONFIG_SANDBOX)
 /* Always assume we're running 64bit */
 #define BOOTENV_EFI_PXE_ARCH "0x7"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:7:UNDI:003000"
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 09/16] Add a comment for board_quiesce_devices()

2018-05-16 Thread Simon Glass
This exported function should have a comment describing what it does. Also
it should really be removed in favour of device_remove(), which handles
this sort of thing now. Add a comment with a TODO.

Signed-off-by: Simon Glass 
---

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

 include/bootm.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/bootm.h b/include/bootm.h
index 9f7956d2e35..0501414e0dc 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -72,6 +72,12 @@ int bootm_decomp_image(int comp, ulong load, ulong 
image_start, int type,
   void *load_buf, void *image_buf, ulong image_len,
   uint unc_len, ulong *load_end);
 
+/*
+ * boards should define this to disable devices when EFI exits from boot
+ * services.
+ *
+ * TODO(s...@chromium.org>): Update this to use driver model's device_remove().
+ */
 void board_quiesce_devices(void);
 
 #endif
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 01/16] efi: Init the 'rows' and 'cols' variables

2018-05-16 Thread Simon Glass
The current code causes a compiler error on gcc 4.8.4 as used by sandbox
on Ubuntu 14.04, which is fairly recent. Init these variables to fix the
problem.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Move the fix to query_console_serial()

Changes in v3:
- Add new patch to init the 'rows' and 'cols' variables

Changes in v2: None

 lib/efi_loader/efi_console.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index d777db8a3ed..001f68df0a7 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -185,8 +185,11 @@ static int query_console_serial(int *rows, int *cols)
return -1;
 
/* Read {depth,rows,cols} */
-   if (term_read_reply(n, 3, 't'))
+   if (term_read_reply(n, 3, 't')) {
+   *rows = -1;
+   *cols = -1;
return -1;
+   }
 
*cols = n[2];
*rows = n[1];
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader

2018-05-16 Thread Simon Glass
A limitation of the EFI loader at present is that it does not build with
sandbox. This makes it hard to write tests, since sandbox is used for most
testing in U-Boot.

This series enables the EFI loader feature. It allows sandbox to build and
run a trivial function which calls the EFI API to output a message.

This series is at u-boot-dm/efi-working

Changes in v4:
- Fix up the sizeof() operations on jmp_buf
- Move the fix to query_console_serial()
- Rebase to master
- Remove code already applied
- Update SPDX tags
- Update subject

Changes in v3:
- Add comments on aligment
- Add new patch to init the 'rows' and 'cols' variables
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
- Add new patch to split out test init/uninit into functions
- Add patch to create a function to set up for running EFI code
- Drop incorrect map_sysmem() in write_smbios_table()
- Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)
- Rebase to master
- Return error value of efi_allocate_pages()
- Update function comment for write_smbios_table()

Changes in v2:
- Rebase to master
- Update return type of efi_smbios_register() to efi_status_t
- Update to use mapmem instead of a cast
- Use return value of efi_install_configuration_table

Simon Glass (16):
  efi: Init the 'rows' and 'cols' variables
  efi: Update some comments related to smbios tables
  efi: sandbox: Adjust memory usage for sandbox
  sandbox: smbios: Update to support sandbox
  sandbox: Add a setjmp() implementation
  efi: sandbox: Add required linker sections
  efi: sandbox: Add distroboot support
  Define board_quiesce_devices() in a shared location
  Add a comment for board_quiesce_devices()
  efi: sandbox: Add relocation constants
  efi: Add a comment about duplicated ELF constants
  efi: sandbox: Enable EFI loader builder for sandbox
  efi: Split out test init/uninit into functions
  efi: sandbox: Add a simple 'bootefi test' command
  efi: Create a function to set up for running EFI code
  efi: Rename bootefi_test_finish() to bootefi_run_finish()

 arch/arm/include/asm/u-boot-arm.h |   1 -
 arch/sandbox/cpu/cpu.c|  13 +++
 arch/sandbox/cpu/os.c |  23 +
 arch/sandbox/cpu/u-boot.lds   |  29 ++
 arch/sandbox/include/asm/setjmp.h |  30 ++
 arch/sandbox/lib/Makefile |   2 +-
 arch/sandbox/lib/sections.c   |  12 +++
 arch/x86/include/asm/u-boot-x86.h |   1 -
 arch/x86/lib/bootm.c  |   4 -
 cmd/bootefi.c | 158 +-
 common/bootm.c|   4 +
 include/bootm.h   |   8 ++
 include/config_distro_bootcmd.h   |   2 +-
 include/efi_loader.h  |  10 ++
 include/os.h  |  21 
 include/smbios.h  |   5 +-
 lib/efi_loader/Kconfig|  12 ++-
 lib/efi_loader/Makefile   |   1 +
 lib/efi_loader/efi_console.c  |   5 +-
 lib/efi_loader/efi_memory.c   |  31 +++---
 lib/efi_loader/efi_runtime.c  |   7 ++
 lib/efi_loader/efi_smbios.c   |   7 +-
 lib/efi_loader/efi_test.c |  16 +++
 lib/smbios.c  |  32 --
 24 files changed, 351 insertions(+), 83 deletions(-)
 create mode 100644 arch/sandbox/include/asm/setjmp.h
 create mode 100644 arch/sandbox/lib/sections.c
 create mode 100644 lib/efi_loader/efi_test.c

-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 04/16] sandbox: smbios: Update to support sandbox

2018-05-16 Thread Simon Glass
At present this code casts addresses to pointers so cannot be used with
sandbox. Update it to use mapmem instead.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3:
- Drop incorrect map_sysmem() in write_smbios_table()

Changes in v2: None

 lib/smbios.c | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index df3d26b0710..fc3dabcbc1b 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -72,9 +73,10 @@ static int smbios_string_table_len(char *start)
 
 static int smbios_write_type0(ulong *current, int handle)
 {
-   struct smbios_type0 *t = (struct smbios_type0 *)*current;
+   struct smbios_type0 *t;
int len = sizeof(struct smbios_type0);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type0));
fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle);
t->vendor = smbios_add_string(t->eos, "U-Boot");
@@ -101,16 +103,18 @@ static int smbios_write_type0(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type1(ulong *current, int handle)
 {
-   struct smbios_type1 *t = (struct smbios_type1 *)*current;
+   struct smbios_type1 *t;
int len = sizeof(struct smbios_type1);
char *serial_str = env_get("serial#");
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type1));
fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -122,15 +126,17 @@ static int smbios_write_type1(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type2(ulong *current, int handle)
 {
-   struct smbios_type2 *t = (struct smbios_type2 *)*current;
+   struct smbios_type2 *t;
int len = sizeof(struct smbios_type2);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type2));
fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -140,15 +146,17 @@ static int smbios_write_type2(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type3(ulong *current, int handle)
 {
-   struct smbios_type3 *t = (struct smbios_type3 *)*current;
+   struct smbios_type3 *t;
int len = sizeof(struct smbios_type3);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type3));
fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -160,6 +168,7 @@ static int smbios_write_type3(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
@@ -198,9 +207,10 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
 
 static int smbios_write_type4(ulong *current, int handle)
 {
-   struct smbios_type4 *t = (struct smbios_type4 *)*current;
+   struct smbios_type4 *t;
int len = sizeof(struct smbios_type4);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type4));
fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle);
t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL;
@@ -214,32 +224,37 @@ static int smbios_write_type4(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type32(ulong *current, int handle)
 {
-   struct smbios_type32 *t = (struct smbios_type32 *)*current;
+   struct smbios_type32 *t;
int len = sizeof(struct smbios_type32);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type32));
fill_smbios_header(t, SMBIOS_SYSTEM_BOOT_INFORMATION, len, handle);
 
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type127(ulong *current, int handle)
 {
-   struct smbios_type127 *t = (struct smbios_type127 *)*current;
+   struct smbios_type127 *t;
int len = sizeof(struct smbios_type127);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type127));
fill_smbios_header(t, SMBIOS_END_OF_TABLE, len, handle);
 
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
@@ -268,7 +283,7 @@ 

[U-Boot] [PATCH v4 05/16] sandbox: Add a setjmp() implementation

2018-05-16 Thread Simon Glass
Add an implementation of setjmp() and longjmp() which rely on the
underlying host C library. Since we cannot know how large the jump buffer
needs to be, pick something that should be suitable and check it at
runtime. At present we need access to the underlying struct as well.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Fix up the sizeof() operations on jmp_buf
- Update SPDX tags

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/cpu.c| 13 +
 arch/sandbox/cpu/os.c | 23 +++
 arch/sandbox/include/asm/setjmp.h | 30 ++
 include/os.h  | 21 +
 4 files changed, 87 insertions(+)
 create mode 100644 arch/sandbox/include/asm/setjmp.h

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index d4ad020012e..cde0b055a67 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -164,3 +165,15 @@ ulong timer_get_boot_us(void)
 
return (count - base_count) / 1000;
 }
+
+int setjmp(jmp_buf jmp)
+{
+   return os_setjmp((ulong *)jmp, sizeof(*jmp));
+}
+
+void longjmp(jmp_buf jmp, int ret)
+{
+   os_longjmp((ulong *)jmp, ret);
+   while (1)
+   ;
+}
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d76d0211a2d..5839932b005 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -628,3 +629,25 @@ void os_localtime(struct rtc_time *rt)
rt->tm_yday = tm->tm_yday;
rt->tm_isdst = tm->tm_isdst;
 }
+
+int os_setjmp(ulong *jmp, int size)
+{
+   jmp_buf dummy;
+
+   /*
+* We cannot rely on the struct name that jmp_buf uses, so use a
+* local variable here
+*/
+   if (size < sizeof(dummy)) {
+   printf("setjmp: jmpbuf is too small (%d bytes, need %d)\n",
+  size, sizeof(jmp_buf));
+   return -ENOSPC;
+   }
+
+   return setjmp((struct __jmp_buf_tag *)jmp);
+}
+
+void os_longjmp(ulong *jmp, int ret)
+{
+   longjmp((struct __jmp_buf_tag *)jmp, ret);
+}
diff --git a/arch/sandbox/include/asm/setjmp.h 
b/arch/sandbox/include/asm/setjmp.h
new file mode 100644
index 000..0fb1a11f234
--- /dev/null
+++ b/arch/sandbox/include/asm/setjmp.h
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) 2018 Google, Inc
+ * Written by Simon Glass 
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_
+
+struct jmp_buf_data {
+   /*
+* We're not sure how long this should be:
+*
+*   amd64: 200 bytes
+*   arm64: 392 bytes
+*   armhf: 392 bytes
+*
+* So allow space for all of those, plus some extra.
+* We don't need to worry about 16-byte alignment, since this does not
+* run on Windows.
+*/
+   ulong data[128];
+};
+
+typedef struct jmp_buf_data jmp_buf[1];
+
+int setjmp(jmp_buf jmp);
+__noreturn void longjmp(jmp_buf jmp, int ret);
+
+#endif /* _SETJMP_H_ */
diff --git a/include/os.h b/include/os.h
index 64e89a06c94..c8e0f52d306 100644
--- a/include/os.h
+++ b/include/os.h
@@ -330,4 +330,25 @@ int os_spl_to_uboot(const char *fname);
  */
 void os_localtime(struct rtc_time *rt);
 
+/**
+ * os_setjmp() - Call setjmp()
+ *
+ * Call the host system's setjmp() function.
+ *
+ * @jmp: Buffer to store current execution state
+ * @size: Size of buffer
+ * @return normal setjmp() value if OK, -ENOSPC if @size is too small
+ */
+int os_setjmp(ulong *jmp, int size);
+
+/**
+ * os_longjmp() - Call longjmp()
+ *
+ * Call the host system's longjmp() function.
+ *
+ * @jmp: Buffer where previous execution state was stored
+ * @ret: Value to pass to longjmp()
+ */
+void os_longjmp(ulong *jmp, int ret);
+
 #endif
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 03/16] efi: sandbox: Adjust memory usage for sandbox

2018-05-16 Thread Simon Glass
With sandbox the U-Boot code is not mapped into the sandbox memory range
so does not need to be excluded when allocating EFI memory. Update the EFI
memory init code to take account of that.

Also use mapmem instead of a cast to convert a memory address to a
pointer.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Update to use mapmem instead of a cast

 lib/efi_loader/efi_memory.c | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 664c651db56..3fbed63728b 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -388,7 +389,7 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t 
size, void **buffer)
r = efi_allocate_pages(0, pool_type, num_pages, );
 
if (r == EFI_SUCCESS) {
-   struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
+   struct efi_pool_allocation *alloc = map_sysmem(t, size);
alloc->num_pages = num_pages;
*buffer = alloc->data;
}
@@ -499,18 +500,22 @@ int efi_memory_init(void)
 
efi_add_known_memory();
 
-   /* Add U-Boot */
-   uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK;
-   uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
-   efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
-
-   /* Add Runtime Services */
-   runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
-   runtime_end = (ulong)&__efi_runtime_stop;
-   runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
-   runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
-   efi_add_memory_map(runtime_start, runtime_pages,
-  EFI_RUNTIME_SERVICES_CODE, false);
+   if (!IS_ENABLED(CONFIG_SANDBOX)) {
+   /* Add U-Boot */
+   uboot_start = (gd->start_addr_sp - uboot_stack_size) &
+   ~EFI_PAGE_MASK;
+   uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
+   efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA,
+  false);
+
+   /* Add Runtime Services */
+   runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
+   runtime_end = (ulong)&__efi_runtime_stop;
+   runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
+   runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
+   efi_add_memory_map(runtime_start, runtime_pages,
+  EFI_RUNTIME_SERVICES_CODE, false);
+   }
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
/* Request a 32bit 64MB bounce buffer region */
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 13/16] efi: Split out test init/uninit into functions

2018-05-16 Thread Simon Glass
We plan to run more than one EFI test. In order to avoid duplicating code,
create functions which handle preparing for running the test and cleaning
up afterwards.

Also shorten the awfully long variable names here.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3:
- Add new patch to split out test init/uninit into functions

Changes in v2: None

 cmd/bootefi.c | 93 +--
 1 file changed, 67 insertions(+), 26 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 11b84c55289..9bcdf8bdc48 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -335,6 +335,64 @@ exit:
return ret;
 }
 
+#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
+/**
+ * bootefi_test_prepare() - prepare to run an EFI test
+ *
+ * This sets things up so we can call EFI functions. This involves preparing
+ * the 'gd' pointer and setting up the load ed image data structures.
+ *
+ * @image: Pointer to a struct which will hold the loaded image info
+ * @obj: Pointer to a struct which will hold the loaded image object
+ * @path: File path to the test being run (often just the test name with a
+ *backslash before it
+ * @test_func: Address of the test function that is being run
+ * @return 0 if OK, -ve on error
+ */
+static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image,
+struct efi_object *obj,
+const char *path, ulong test_func)
+{
+   efi_status_t ret;
+
+   memset(image, '\0', sizeof(*image));
+   memset(obj, '\0', sizeof(*obj));
+   /* Construct a dummy device path */
+   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
+ test_func, test_func);
+   bootefi_image_path = efi_dp_from_file(NULL, 0, path);
+   efi_setup_loaded_image(image, obj, bootefi_device_path,
+  bootefi_image_path);
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+   /* Initialize and populate our EFI object list */
+   ret = efi_init_obj_list();
+   if (ret)
+   return ret;
+   /* Transfer environment variable efi_selftest as load options */
+   set_load_options(image, "efi_selftest");
+
+   return 0;
+}
+
+/**
+ * bootefi_test_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_test_finish(struct efi_loaded_image *image,
+   struct efi_object *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   list_del(>link);
+}
+#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
+
 static int do_bootefi_bootmgr_exec(void)
 {
struct efi_device_path *device_path, *file_path;
@@ -410,33 +468,16 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
 #endif
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   struct efi_loaded_image loaded_image_info = {};
-   struct efi_object loaded_image_info_obj = {};
-
-   /* Construct a dummy device path. */
-   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
- (uintptr_t)_selftest,
- (uintptr_t)_selftest);
-   bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest");
-
-   efi_setup_loaded_image(_image_info,
-  _image_info_obj,
-  bootefi_device_path, bootefi_image_path);
-   /*
-* gd lives in a fixed register which may get clobbered while we
-* execute the payload. So save it here and restore it on every
-* callback entry
-*/
-   efi_save_gd();
-   /* Initialize and populate EFI object list */
-   efi_init_obj_list();
-   /* Transfer environment variable efi_selftest as load options */
-   set_load_options(_image_info, "efi_selftest");
+   struct efi_loaded_image image;
+   struct efi_object obj;
+
+   if (bootefi_test_prepare(, , "\\test",
+(uintptr_t)_selftest))
+   return CMD_RET_FAILURE;
+
/* Execute the test */
-   r = efi_selftest(loaded_image_info_obj.handle, );
-   efi_restore_gd();
-   free(loaded_image_info.load_options);
-   list_del(_image_info_obj.link);
+   r = efi_selftest(obj.handle, );
+   

[U-Boot] [PATCH v4 12/16] efi: sandbox: Enable EFI loader builder for sandbox

2018-05-16 Thread Simon Glass
This allows this feature to build within sandbox. This is for testing
purposes only since it is not possible for sandbox to load native code.

Signed-off-by: Simon Glass 
---

Changes in v4: None
Changes in v3:
- Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)

Changes in v2: None

 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d38780b604e..96107a90a90 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,6 @@
 config EFI_LOADER
bool "Support running EFI Applications in U-Boot"
-   depends on (ARM || X86) && OF_LIBFDT
+   depends on (ARM || X86 || SANDBOX) && OF_LIBFDT
# We do not support bootefi booting ARMv7 in non-secure mode
depends on !ARMV7_NONSEC
# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 11/16] efi: Add a comment about duplicated ELF constants

2018-05-16 Thread Simon Glass
These constants are defined in arch-specific code but redefined here. Add
a TODO to clean this up.

Signed-off-by: Simon Glass 
---

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

 lib/efi_loader/efi_runtime.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index ac02f64d967..e94b94389d8 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -36,6 +36,10 @@ static efi_status_t __efi_runtime EFIAPI 
efi_invalid_parameter(void);
 #define EFI_CACHELINE_SIZE 128
 #endif
 
+/*
+ * TODO(s...@chromium.org): These defines and structs should come from the elf.
+ * header for each arch (or a generic header) rather than being repeated here.
+ */
 #if defined(CONFIG_ARM64)
 #define R_RELATIVE 1027
 #define R_MASK 0xULL
-- 
2.17.0.441.gb46fe60e1d-goog

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


[U-Boot] [PATCH v4 08/16] Define board_quiesce_devices() in a shared location

2018-05-16 Thread Simon Glass
This undocumented function relies on arch-specific code to declare a nop
weak version. Add the weak function in common code instead to avoid having
to duplicate the same function in each arch.

Signed-off-by: Simon Glass 
---

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

 arch/arm/include/asm/u-boot-arm.h | 1 -
 arch/x86/include/asm/u-boot-x86.h | 1 -
 arch/x86/lib/bootm.c  | 4 
 common/bootm.c| 4 
 include/bootm.h   | 2 ++
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/u-boot-arm.h 
b/arch/arm/include/asm/u-boot-arm.h
index 01c3ba87c3f..cc828c45045 100644
--- a/arch/arm/include/asm/u-boot-arm.h
+++ b/arch/arm/include/asm/u-boot-arm.h
@@ -37,7 +37,6 @@ int   arch_early_init_r(void);
 
 /* board/.../... */
 intboard_init(void);
-void   board_quiesce_devices(void);
 
 /* cpu/.../interrupt.c */
 intarch_interrupt_init (void);
diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index 9be45846a53..2340ef83323 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -84,7 +84,6 @@ static inline __attribute__((no_instrument_function)) 
uint64_t rdtsc(void)
 /* board/... */
 void timer_set_tsc_base(uint64_t new_base);
 uint64_t timer_get_tsc(void);
-void board_quiesce_devices(void);
 
 void quick_ram_check(void);
 
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 533ba075bb1..54c22fe6de3 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -27,10 +27,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define COMMAND_LINE_OFFSET 0x9000
 
-__weak void board_quiesce_devices(void)
-{
-}
-
 void bootm_announce_and_cleanup(void)
 {
printf("\nStarting kernel ...\n\n");
diff --git a/common/bootm.c b/common/bootm.c
index a0ffc1cd679..e789f6818aa 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -46,6 +46,10 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int 
flag, int argc,
   char * const argv[], bootm_headers_t *images,
   ulong *os_data, ulong *os_len);
 
+__weak void board_quiesce_devices(void)
+{
+}
+
 #ifdef CONFIG_LMB
 static void boot_start_lmb(bootm_headers_t *images)
 {
diff --git a/include/bootm.h b/include/bootm.h
index 9e42e179878..9f7956d2e35 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -72,4 +72,6 @@ int bootm_decomp_image(int comp, ulong load, ulong 
image_start, int type,
   void *load_buf, void *image_buf, ulong image_len,
   uint unc_len, ulong *load_end);
 
+void board_quiesce_devices(void);
+
 #endif
-- 
2.17.0.441.gb46fe60e1d-goog

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


Re: [U-Boot] [PATCH v2 2/7] serial: serial_msm: fail probe if settings clocks fails

2018-05-16 Thread Simon Glass
On 16 May 2018 at 03:13, Ramon Fried  wrote:
> Failure to set the clocks will causes data abort exception when
> trying to write to AHB uart registers.
> This patch ensures that we don't touch these registers if clock
> setting failed.
>
> Signed-off-by: Ramon Fried 
> ---
> v2: on failure, return actual return code from msm_uart_clk_init
>
>  drivers/serial/serial_msm.c | 6 --
>  1 file changed, 4 insertions(+), 2 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 5/7] mach-snapdragon: Introduce pinctrl driver

2018-05-16 Thread Simon Glass
On 16 May 2018 at 03:13, Ramon Fried  wrote:
> This patch adds pinmux and pinctrl driver for TLMM
> subsystem in snapdragon chipsets.
> Currently, supporting only 8016, but implementation is
> generic and 8096 can be added easily.
>
> Driver is using the generic dt-bindings and doesn't
> introduce any new bindings (yet).
>
> Signed-off-by: Ramon Fried 
> ---
> v2: * restructred the code to be more generic
> * Reduced pin table size by snprintf on runtime as
>   suggested by Simon.
>
>  arch/arm/mach-snapdragon/Makefile |   2 +
>  arch/arm/mach-snapdragon/pinctrl-apq8016.c|  62 +
>  arch/arm/mach-snapdragon/pinctrl-snapdragon.c | 128 ++
>  arch/arm/mach-snapdragon/pinctrl-snapdragon.h |  29 
>  configs/dragonboard410c_defconfig |   5 +
>  .../dt-bindings/pinctrl/pinctrl-snapdragon.h  |  22 +++
>  6 files changed, 248 insertions(+)
>  create mode 100644 arch/arm/mach-snapdragon/pinctrl-apq8016.c
>  create mode 100644 arch/arm/mach-snapdragon/pinctrl-snapdragon.c
>  create mode 100644 arch/arm/mach-snapdragon/pinctrl-snapdragon.h
>  create mode 100644 include/dt-bindings/pinctrl/pinctrl-snapdragon.h

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


Re: [U-Boot] [PATCH] Remove CONFIG_MVGBE from config_whitelist.txt

2018-05-16 Thread Simon Glass
On 16 May 2018 at 02:34, Chris Packham  wrote:
> Now that there are more boards defining this it can be removed from the
> whitelist.
>
> Signed-off-by: Chris Packham 
> ---
>
>  scripts/config_whitelist.txt | 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 v3 07/21] efi: sandbox: Adjust memory usage for sandbox

2018-05-16 Thread Simon Glass
Hi Heinrich,

On 20 February 2018 at 10:12, Heinrich Schuchardt  wrote:
> On 02/19/2018 04:48 PM, Simon Glass wrote:
>>
>> With sandbox the U-Boot code is not mapped into the sandbox memory range
>> so does not need to be excluded when allocating EFI memory. Update the EFI
>> memory init code to take account of that.
>>
>> Also use mapmem instead of a cast to convert a memory address to a
>> pointer.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>> Changes in v3: None
>> Changes in v2:
>> - Update to use mapmem instead of a cast
>>
>>   lib/efi_loader/efi_memory.c | 31 ++-
>>   1 file changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>> index c273a7ba30..b113e08783 100644
>> --- a/lib/efi_loader/efi_memory.c
>> +++ b/lib/efi_loader/efi_memory.c
>> @@ -10,6 +10,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>   #include 
>>   #include 
>>   #include 
>> @@ -389,7 +390,7 @@ efi_status_t efi_allocate_pool(int pool_type,
>> efi_uintn_t size, void **buffer)
>> r = efi_allocate_pages(0, pool_type, num_pages, );
>> if (r == EFI_SUCCESS) {
>> -   struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
>> +   struct efi_pool_allocation *alloc = map_sysmem(t, size);
>
>
> The AllocatePages Service has to return 4096 byte aligned memory.
> AllocatePool has to return 8 byte aligned memory.
>
> I cannot see that this page makes these guarantees.

Well I am not changing that code. All I am doing is correctly mapping
the long address to a sandbox pointer.

>
>> alloc->num_pages = num_pages;
>> *buffer = alloc->data;
>> }
>> @@ -500,18 +501,22 @@ int efi_memory_init(void)
>> efi_add_known_memory();
>
>
> You fail guarantee that the known memory is 4096 byte aligned.

Presumable the existing code does that, and I am not changing it.

>
>>   - /* Add U-Boot */
>> -   uboot_start = (gd->start_addr_sp - uboot_stack_size) &
>> ~EFI_PAGE_MASK;
>> -   uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
>> -   efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA,
>> false);
>> -
>> -   /* Add Runtime Services */
>> -   runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
>> -   runtime_end = (ulong)&__efi_runtime_stop;
>> -   runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
>> -   runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
>> -   efi_add_memory_map(runtime_start, runtime_pages,
>> -  EFI_RUNTIME_SERVICES_CODE, false);
>> +   if (!IS_ENABLED(CONFIG_SANDBOX)) {
>
>
> You are passing all memory aquired via mmap() in the above
> efi_add_known_memory() table.
>
> So here you have to mark any memory range as occupied that has already been
> given away or may be allocated by non-EFI functions from the mmap() assigned
> memory.

This is not mmap(), just a map from U-Boot ulong addresses to sandbox
pointers. So there should be no additional processing needed.

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


Re: [U-Boot] [PATCH v3 18/21] efi: sandbox: Add a simple 'bootefi test' command

2018-05-16 Thread Simon Glass
Hi Heinrich,

On 19 February 2018 at 12:40, Heinrich Schuchardt  wrote:
> On 02/19/2018 04:48 PM, Simon Glass wrote:
>>
>> This jumps to test code which can call directly into the EFI support. It
>> does not need a separate image so it is easy to write tests with it.
>>
>> This test can be executed without causing problems to the run-time
>> environemnt (e.g. U-Boot does not need to reboot afterwards).
>>
>> For now the test just outputs a message. To try it:
>
>
> Please, explain what the use of the command shall be.
> We already have bootefi selftest.
> We shouldn't invent the wheel twice.

These are different wheels, With 'selftest' we build an EFI
application and run it as a binary. With 'test' we just call into the
U-Boot code. IMO the latter is much easier to debug and test since it
is a single application - e.g. it can be run entirely within gdb.

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


Re: [U-Boot] [PATCH 4/8] cmd: avb2.0: avb command for performing verification

2018-05-16 Thread Simon Glass
Hi Igor,

On 16 May 2018 at 02:20, Igor Opaniuk  wrote:
> Hi Simon,
>
>> If there is no need for operations and indirection through function
>> pointers, why not just call the functions directly?
>
> This is the way how libavb is integrated into bootloader. libavb interfaces 
> with
> the bootloader through the supplied AvbOps struct. This includes operations to
> read and write data from partitions, read and write rollback indexes, check
> if the public key used to make a signature should be accepted, and so on.
> This is what Google AVB 2.0 specification says.
> For additional details please check [1].
>
> In this particular patch, all avb commands, except the main "avb
> verify", are used
> to debug these particular callback implementations
> (can be used when enabling this feature on new platform etc.).
> The reason I use indirection through function pointers is that they
> are not supposed
> to be public, and are not intended to be used somehow directly, only by libavb
> (check [2] how libavb is using it)
>
>>> (I've left a notice in the cover letter that checkpatch
>>> will fail on the commit, which introduces libavb; also, there is the ongoing
>>> discussion there regarding why libavb/libavb_ab should be
>>> kept as it's. Please join us, if you don't mind).
>>
>> I do see the cover letter thread but could not find the camel case
>> discussion. Can you please point me to it?
>
> There is no any particular discussion about CamelCase, but a few general
> statements why I should avoid introducing any changes in
> libavb/libavb_ab libraries.
> Regarding our particular case, AvbSlotVerifyResult and AvbSlotVerifyData types
> (I guess you're talking about these CamelCase instances) are defined inside
> libavb library, so obviously I can't simply replace it with something, that
> conforms to the Linux kernel coding style

Maybe I've lost track of the patches, but I thought you were
implementing this library in U-Boot and thus can call things whatever
you like?

We have had a similar thing with EFI, but in that case there was no
reference code to use, so it was easier to just rename things to
kernel style.

In this case it seems that you want to be able to easily merge changes
back and forth between U-Boot's copy of the library and the upstream
one.

I think we have to balance that desire against the impact of having
non-conforming code in the U-Boot code base. So far we have tended to
adjust the code to fit kernel style in these situations.

Anyway I think this is Tom's call and I'm happy with whatever he decides.

[..]

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


Re: [U-Boot] [PATCH v5] tpm2: tis_spi: add the possibility to reset the chip with a gpio

2018-05-16 Thread Simon Glass
On 16 May 2018 at 16:59, Miquel Raynal  wrote:
>
> On some designs, the reset line could not be connected to the SoC reset
> line, in this case, request the GPIO and ensure the chip gets reset.
>
> Signed-off-by: Miquel Raynal 
> ---
>
> Changes since v4:
> =
> * This patch was part of a bigger series, sending it alone as other
>   files seems to be in an acceptable state now.
> * Changed the commit title with the prefix "tpm2: tis_spi:" to refer to
>   the right file ("tpm:" is too generic now).
> * Removed the #ifdef CONFIG_DM_GPIO/#endif couple around the
>   <.../gpio.h> include.
> * Changed the #ifdef CONFIG_DM_GPIO/#endif couple in the code by a
>   if (IS_ENABLED(CONFIG_DM_GPIO)).
>
> Changes since v3:
> =
> * Removed useless reset of rx_buf[0] in tpm_tis_spi_xfer().
> * Changed the way spi_xfer return code is checked: error out on any
>   value != 0 instead of just negative ones.
> * Removed unused functions flagged __maybe_unused as well as well as the
>   __maybe_unused flags themselves when not needed.
> * Simplified the validity check of the GPIO as suggested.
> * Updated the compatible property for the SPI modules (as well as the
>   bindings docuementation) to be simply "tis,tpm2-spi" which should work
>   with most compliant chips. Data is linked to this generic compatible
>   in the TPM driver, other values may be added if needed in the future
>   to fit other chips that would use different values than the current
>   ones (used by Infineon SLB 9670 and ST ST33TPHF20 modules, for
>   instance).
>
>  drivers/tpm/tpm2_tis_spi.c | 16 
>  1 file changed, 16 insertions(+)

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


Re: [U-Boot] help on DM

2018-05-16 Thread Simon Glass
Hi Andy,

On 8 May 2018 at 19:48, Andy Tang  wrote:
> Hi Simon,
>
>
>
> I am working on enabling DM for sata driver. Previously sata was initialized
> by calling
>
> the functions ahci_init() and scsi_scan(). Now I plan to use
> driver/ata/sata_ceva.c as our sata driver.
>
> In board config file I enabled the following configs (dts was added
> properly):
>
>
>
> +CONFIG_DM_SCSI=y
>
> +CONFIG_SATA_CEVA=y
>
> +CONFIG_AHCI=y
>
> +CONFIG_BLK=y
>
> +CONFIG_SCSI_AHCI=y
>
> +CONFIG_SCSI=y
>
>
>
> But I always got the "Synchronous Abort" error. I tracked the code and found
>
> dev->uclass_priv was not allocated properly because
> dev->uclass->uc_drv->per_device_auto_alloc_size is 0.
>
> But I didn’t find where I can set per_device_auto_alloc_size or attach a
> uclass_priv structure to the device.
>
>
>
> I am new to DM. Could you please give me some suggestions here?

So you are expecting that the SCSI uclass should have some per-device
uclass data? I don't think this is the case at present.

Which code is actually crashing here?

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


Re: [U-Boot] [PATCH] common: image-fit: add FIT data-position & data-offset property support

2018-05-16 Thread Simon Glass
Hi Kevin,

On 16 May 2018 at 15:35, Kelvin Cheung  wrote:
> Add FIT data-position & data-offset property support for bootm,
> which are already supported in SPL.
>
> Signed-off-by: Kelvin Cheung 
> ---
>
>  common/image-fit.c | 82 
> +++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 5b93dce..f21db4b 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -359,11 +359,14 @@ void fit_image_print(const void *fit, int 
> image_noffset, const char *p)
>  {
> char *desc;
> uint8_t type, arch, os, comp;
> -   size_t size;
> +   size_t size = 0;
> ulong load, entry;
> const void *data;
> int noffset;
> int ndepth;
> +   bool external_data = false;
> +   int offset;
> +   int len;
> int ret;
>
> /* Mandatory properties */
> @@ -391,7 +394,27 @@ void fit_image_print(const void *fit, int image_noffset, 
> const char *p)
> fit_image_get_comp(fit, image_noffset, );
> printf("%s  Compression:  %s\n", p, genimg_get_comp_name(comp));
>
> -   ret = fit_image_get_data(fit, image_noffset, , );
> +   if (!fit_image_get_data_position(fit, image_noffset, )) {
> +   external_data = true;
> +   } else if (!fit_image_get_data_offset(fit, image_noffset, )) {
> +   external_data = true;
> +   /*
> +* For FIT with external data, figure out where
> +* the external images start. This is the base
> +* for the data-offset properties in each image.
> +*/
> +   size = (fdt_totalsize(fit) + 3) & ~3;
> +   offset += size;
> +   }
> +
> +   if (external_data) {
> +   printf("%s  External Data\n", p);
> +   ret = fit_image_get_data_size(fit, image_noffset, );
> +   data = fit + offset;
> +   size = len;
> +   } else {
> +   ret = fit_image_get_data(fit, image_noffset, , );
> +   }

It looks like you should create which does all of the above, that can
be called in the three places where you repeat this code.

Perhaps fit_image_get_data_buf_size()?

>
>  #ifndef USE_HOSTCC
> printf("%s  Data Start:   ", p);
> @@ -1151,9 +1174,35 @@ int fit_image_verify(const void *fit, int 
> image_noffset)
> size_t  size;
> int noffset = 0;
> char*err_msg = "";
> +   bool external_data = false;
> +   int offset;
> +   int len;
> +   int ret;
>
> /* Get image data and data length */
> -   if (fit_image_get_data(fit, image_noffset, , )) {
> +   if (!fit_image_get_data_position(fit, image_noffset, )) {
> +   external_data = true;
> +   } else if (!fit_image_get_data_offset(fit, image_noffset, )) {
> +   external_data = true;
> +   /*
> +* For FIT with external data, figure out where
> +* the external images start. This is the base
> +* for the data-offset properties in each image.
> +*/
> +   size = (fdt_totalsize(fit) + 3) & ~3;
> +   offset += size;
> +   }
> +
> +   if (external_data) {
> +   debug("External Data\n");
> +   ret = fit_image_get_data_size(fit, image_noffset, );
> +   data = fit + offset;
> +   size = len;
> +   } else {
> +   ret = fit_image_get_data(fit, image_noffset, , );
> +   }
> +
> +   if (ret) {
> err_msg = "Can't get image data/size";
> printf("error!\n%s for '%s' hash node in '%s' image node\n",
>err_msg, fit_get_name(fit, noffset, NULL),
> @@ -1750,6 +1799,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
> uint8_t os_arch;
>  #endif
> const char *prop_name;
> +   bool external_data = false;
> +   int offset;
> +   int data_len;
> int ret;
>
> fit = map_sysmem(addr, 0);
> @@ -1875,7 +1927,29 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
> bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK);
>
> /* get image data address and length */
> -   if (fit_image_get_data(fit, noffset, , )) {
> +   if (!fit_image_get_data_position(fit, noffset, )) {
> +   external_data = true;
> +   } else if (!fit_image_get_data_offset(fit, noffset, )) {
> +   external_data = true;
> +   /*
> +* For FIT with external data, figure out where
> +* the external images start. This is the base
> +* for the data-offset properties in each image.
> +*/
> +   size = (fdt_totalsize(fit) + 3) & ~3;
> +   offset 

Re: [U-Boot] [PATCH 2/2] sandbox: Rename 'num-gpios' property to avoid dtc warning

2018-05-16 Thread Simon Glass
On 4 February 2018 at 04:36, Simon Glass  wrote:
> At present dtc produces these warnings when compiling sandbox:
>
> arch/sandbox/dts/test.dtb: Warning (gpios_property):
> Could not get phandle node for /base-gpios:num-gpios(cell 0)
> arch/sandbox/dts/test.dtb: Warning (gpios_property):
> Missing property '#gpio-cells' in node /reset-ctl or bad phandle
> (referred from /extra-gpios:num-gpios[0])
>
> Both are due to it assuming that the 'num-gpios' property holds a phandle
> pointing to a GPIO node.
>
> To avoid these warnings, rename the sandbox property so that it does not
> include the string 'gpios'.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/sandbox/dts/test.dts | 4 ++--
>  drivers/gpio/sandbox.c| 3 ++-
>  2 files changed, 4 insertions(+), 3 deletions(-)
>

This was applied to u-boot-dm and is now in mainline.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] usb: xhci: zynqmp: Fix header location

2018-05-16 Thread Marek Vasut
On 05/16/2018 04:55 PM, Michal Simek wrote:
> There is no reason to specify header with full soc name.
> Symlink is setup automatically (arch -> arch-zynqmp)
> 
> Signed-off-by: Michal Simek 

Applied, thanks

> ---
> 
>  drivers/usb/host/xhci-zynqmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c
> index 7fe54281c3c4..e44e1ae1d915 100644
> --- a/drivers/usb/host/xhci-zynqmp.c
> +++ b/drivers/usb/host/xhci-zynqmp.c
> @@ -13,7 +13,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include "xhci.h"
> 


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


Re: [U-Boot] [PATCH] ARM: re-enable MVGBE for edminiv2

2018-05-16 Thread Tom Rini
On Wed, May 16, 2018 at 08:31:43PM +1200, Chris Packham wrote:

> This was unintentionally disabled when moving MVGBE to Kconfig.
> 
> Fixes: commit ed52ea507f12 ("net: add Kconfig for MVGBE")
> Signed-off-by: Chris Packham 

Applied to u-boot/master, 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] Please pull u-boot-marvell/master

2018-05-16 Thread Tom Rini
On Wed, May 16, 2018 at 02:05:03PM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull the Kirkwood DT patches from Chris.
> 
> Thanks,
> Stefan
> 
> The following changes since commit 0315d6959fdd9d2a4d89016c311e9c8c8d239a10:
> 
>   ARM: mvebu: a38x: Add missing SPDX license identfier (2018-05-15 09:08:00 
> -0400)
> 
> are available in the Git repository at:
> 
>   git://www.denx.de/git/u-boot-marvell.git 
> 
> for you to fetch changes up to a7925926dc7f81fb5c137d2b4b7c6457694b1ac0:
> 
>   ARM: kirkwood: Add device-tree for sheevaplug (2018-05-16 10:29:53 +0200)
> 

NAK.  With gcc-7.3
(https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/)
I get:
   arm:  +   openrd_base openrd_ultimate openrd_client
+(openrd_base,openrd_ultimate,openrd_client) u-boot-nodtb.bin exceeds file size 
limit:
+(openrd_base,openrd_ultimate,openrd_client)   limit:  393216 bytes
+(openrd_base)   actual: 395632 bytes
+(openrd_base)   excess: 2416 bytes
+(openrd_base,openrd_ultimate,openrd_client) make[1]: *** [Makefile:1014: 
u-boot-nodtb.bin] Error 1
+(openrd_ultimate)   actual: 395664 bytes
+(openrd_ultimate)   excess: 2448 bytes
+(openrd_client)   actual: 395680 bytes
+(openrd_client)   excess: 2464 bytes

And I will be pushing those changes to finally switch travis over to
gcc-7.3 soon (I had thought I had posted them a long while back so that
I could have pulled them in right after v2018.05, but I forgot, so here
we are now..).

-- 
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 v3 13/13] net: fastboot: Merge AOSP UDP fastboot

2018-05-16 Thread Alex Kiernan
On Tue, May 15, 2018 at 5:05 PM Simon Glass  wrote:

> Hi Alex,

> On 15 May 2018 at 07:11, Alex Kiernan  wrote:
> > On Mon, May 14, 2018 at 8:53 PM Simon Glass  wrote:
> >
> >> Hi Alex,
> >
> >> On 14 May 2018 at 03:09, Alex Kiernan  wrote:
> >> > Merge UDP fastboot support from AOSP:
> >> >
> >> >
> >
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
> >> >
> >> > Signed-off-by: Alex Kiernan 
> >> > Signed-off-by: Alex Deymo 
> >> > Signed-off-by: Jocelyn Bohr 
> >> > ---
> >> >
> >> > Changes in v3:
> >> > - use FASTBOOT as our guard in Kconfig not a list of USB || UDP
> >> > - correct mis-translation from AOSP introduced when cleaning up for
> >> >   checkpatch - we should write when buffer is not NULL, rather than
> >> >   erasing, and erase when buffer is NULL
> >> > - use CMD_RET_USAGE from do_fastboot
> >> > - remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
> >> > - rename timed_send_info to fastboot_send_info, rename
> > fastboot_send_info to
> >> >   fastboot_udp_send_info
> >> > - replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
> >> > - move start time into timed_send_info() rather than passing it in
> >> > - make calls to fastboot_udp_send_info a runtime dependency, not a
> > compile
> >> >   time one
> >> > - set ${filesize} to size of downloaded image
> >> > - add progress meter from USB path during download
> >> > - add support for 'oem format' command from the USB path
> >> > - rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this
is
> > the
> >> >   fastboot boot command
> >> > - make getvar implementation table driven
> >> > - add fastboot_buf_addr, fastboot_buf_size to override buffer address
> > and
> >> >   size
> >> > - return correct filesystem type in getvar partition-type on MMC
> >> > - process "fastboot." prefixed env variables in getvar first so you
> >> >   can override the normal values (this also lets you set a fs type
for
> >> >   NAND devices)
> >> > - squash subsequent patches which change this code into this one:
> >> >   - If the fastboot flash/erase commands are disabled, remove that
> > support
> >> > so we still build correctly.
> >> >   - Add NAND support to fastboot UDP flash/erase commands
> >> >   - If we don't have a partition name passed, report it as not found.
> >> >   - Change the behaviour of the fastboot net code such that
> >> > "reboot-bootloader" is no longer written to
> > CONFIG_FASTBOOT_BUF_ADDR for
> >> > use as a marker on reboot (the AOSP code in
> > common/android-bootloader.c
> >> > uses this marker - this code could be reinstated there if that
gets
> >> > merged).
> >> >   - Merge USB and UDP boot code. The USB implementation stays the
same,
> > but
> >> > UDP no longer passes an fdt. We introduce a new environment
variable
> >> > 'fastboot_bootcmd' which if set overrides the hardcoded boot
> > command,
> >> > setting this then allows the UDP implementation to remain the
same.
> > If
> >> > after running 'fastboot_bootcmd' the board has not booted,
control
> > is
> >> > returned to U-Boot and the fastboot process ends.
> >> >   - Separate the fastboot protocol handling from the fastboot UDP
code
> > in
> >> > preparation for reusing it in the USB code.
> >> >
> >> > Changes in v2:
> >> > - ensure fastboot syntax is backward compatible - 'fastboot 0' means
> >> >   'fastboot usb 0'
> >> >
> >> >  cmd/fastboot.c|  91 -
> >> >  drivers/fastboot/Kconfig  |  15 ++
> >> >  drivers/fastboot/Makefile |   2 +
> >> >  drivers/fastboot/fb_command.c | 258
+++
> >> >  drivers/fastboot/fb_common.c  |  48 +++
> >> >  drivers/fastboot/fb_getvar.c  | 222 ++
> >> >  drivers/fastboot/fb_mmc.c |  67 -
> >> >  drivers/fastboot/fb_nand.c|  12 +-
> >> >  include/fastboot.h|  47 +++
> >> >  include/fb_mmc.h  |   8 +-
> >> >  include/fb_nand.h |  10 +-
> >> >  include/net.h |   2 +-
> >> >  include/net/fastboot.h|  21 +++
> >> >  net/Makefile  |   1 +
> >> >  net/fastboot.c| 310
> > ++
> >> >  net/net.c |   7 +
> >> >  16 files changed, 1105 insertions(+), 16 deletions(-)
> >> >  create mode 100644 drivers/fastboot/fb_command.c
> >> >  create mode 100644 drivers/fastboot/fb_getvar.c
> >> >  create mode 100644 include/net/fastboot.h
> >> >  create mode 100644 net/fastboot.c
> >
> >> Reviewed-by: Simon Glass 
> >
> >> Please can you add function comments to the rest of the fastboot.h
> >> stuff, see if you can remove the global variables in that file, and
> >> also add function comments to non-trivial static 

[U-Boot] How to usage eMMC in pSLC mode with LS1012ARDB

2018-05-16 Thread tarkashi

Hello,

We would like to ask about uses eMMC in pSLC mode with LS1012ARDB. 
We want to try to set up pSLC.

However, once we set it, we can not reverse it, so please let us ask the
procedure.

Our LS1012ARDB's eMMC is as follows.
-
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc info
Device: FSL_SDHC
Manufacturer ID: fe
OEM: 14e
Name: P1XXX
Tran Speed: 5200
Rd Block Len: 512
MMC version 4.5
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 4 MiB
User Capacity: 3.6 GiB
Boot Capacity: 2 MiB ENH
RPMB Capacity: 128 KiB ENH
-

From the above information, we think that the area of RPMB and Boot is
pSLC(Enhanced mode).
We want to use "User Capacity" (3.6 GiB), as pSLC(Enhanced mode).

-
=> help mmc
mmc - MMC sub system

Usage:
mmc info - display info of the current MMC device mmc read addr blk# cnt mmc
write addr blk# cnt mmc erase blk# cnt mmc rescan mmc part - lists available
partition on current mmc device mmc dev [dev] [part] - show or set current
mmc device [partition] mmc list - lists available devices mmc hwpartition
[args...] - does hardware partitioning
arguments (sizes in 512-byte blocks):
[user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
[gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
[check|set|complete] - mode, complete set partitioning completed
WARNING: Partitioning is a write-once setting once it is set to complete.
Power cycling is required to initialize partitions after set to complete.
mmc setdsr  - set DSR register value
-

From the explanation of help above, we guess that all "User Capacity" can be
set as pSLC by the following command setting.

mmc hwpartition set user enh 0x0 0x73 wrrel on complete

We guess "0x73" to specify the whole area, but this may not be correct.
( 0x73 = 3.6 x 1024 x 1024 x 1024 / 512 )
Because it is not divisible by 512.

Could you advise how to specify the whole area of "User Capacity"?

Best Regards,




--
Sent from: http://u-boot.10912.n7.nabble.com/
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] ram: stm32_sdram: Adds stm32f429-disco fixes for HardFault at booting

2018-05-16 Thread Radoslaw Pietrzyk
- adds reading FMC swap setting from DTB to SDRAM driver
- sets FMC swap for stm32f429-disco board
- changes ram start address to 0x9000

Signed-off-by: Radoslaw Pietrzyk 
---
 arch/arm/dts/stm32f429-disco-u-boot.dtsi |  2 ++
 drivers/ram/stm32_sdram.c| 37 +---
 include/configs/stm32f429-discovery.h|  6 +++---
 3 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/arch/arm/dts/stm32f429-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
index 8a0f642..10e0950 100644
--- a/arch/arm/dts/stm32f429-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
@@ -37,6 +37,8 @@
clocks = < 0 STM32F4_AHB3_CLOCK(FMC)>;
pinctrl-0 = <_pins>;
pinctrl-names = "default";
+   st,syscfg = <>;
+   st,swp_fmc = <1>;
u-boot,dm-pre-reloc;
 
/*
diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
index dc39f33..f6cac8e 100644
--- a/drivers/ram/stm32_sdram.c
+++ b/drivers/ram/stm32_sdram.c
@@ -11,6 +11,8 @@
 #include 
 
 #define MEM_MODE_MASK  GENMASK(2, 0)
+#define SWP_FMC_OFFSET 10
+#define SWP_FMC_MASK   GENMASK(SWP_FMC_OFFSET+1, SWP_FMC_OFFSET)
 #define NOT_FOUND  0xff
 
 struct stm32_fmc_regs {
@@ -256,27 +258,36 @@ static int stm32_fmc_ofdata_to_platdata(struct udevice 
*dev)
struct ofnode_phandle_args args;
u32 *syscfg_base;
u32 mem_remap;
+   u32 swp_fmc;
ofnode bank_node;
char *bank_name;
u8 bank = 0;
int ret;
 
-   mem_remap = dev_read_u32_default(dev, "st,mem_remap", NOT_FOUND);
-   if (mem_remap != NOT_FOUND) {
-   ret = dev_read_phandle_with_args(dev, "st,syscfg", NULL, 0, 0,
+   ret = dev_read_phandle_with_args(dev, "st,syscfg", NULL, 0, 0,
 );
-   if (ret) {
-   debug("%s: can't find syscon device (%d)\n", __func__,
- ret);
-   return ret;
-   }
-
+   if (ret) {
+   dev_dbg(dev, "%s: can't find syscon device (%d)\n", __func__, 
ret);
+   } else {
syscfg_base = (u32 *)ofnode_get_addr(args.node);
 
-   /* set memory mapping selection */
-   clrsetbits_le32(syscfg_base, MEM_MODE_MASK, mem_remap);
-   } else {
-   debug("%s: cannot find st,mem_remap property\n", __func__);
+   mem_remap = dev_read_u32_default(dev, "st,mem_remap", 
NOT_FOUND);
+   if (mem_remap != NOT_FOUND) {
+   /* set memory mapping selection */
+   clrsetbits_le32(syscfg_base, MEM_MODE_MASK, mem_remap);
+   } else {
+   dev_dbg(dev, "%s: cannot find st,mem_remap property\n", 
__func__);
+   }
+   
+   swp_fmc = dev_read_u32_default(dev, "st,swp_fmc", NOT_FOUND);
+   if (swp_fmc != NOT_FOUND) {
+   /* set fmc swapping selection */
+   clrsetbits_le32(syscfg_base, SWP_FMC_MASK, swp_fmc << 
SWP_FMC_OFFSET);
+   } else {
+   dev_dbg(dev, "%s: cannot find st,swp_fmc property\n", 
__func__);
+   }
+
+   dev_dbg(dev, "syscfg %x = %x\n", (u32)syscfg_base, 
*syscfg_base);
}
 
dev_for_each_subnode(bank_node, dev) {
diff --git a/include/configs/stm32f429-discovery.h 
b/include/configs/stm32f429-discovery.h
index 4fd9c23..46eda1d 100644
--- a/include/configs/stm32f429-discovery.h
+++ b/include/configs/stm32f429-discovery.h
@@ -22,10 +22,10 @@
 #define CONFIG_NR_DRAM_BANKS   1
 #define CONFIG_SYS_RAM_CS  1
 #define CONFIG_SYS_RAM_FREQ_DIV2
-#define CONFIG_SYS_RAM_BASE0xD000
+#define CONFIG_SYS_RAM_BASE0x9000
 #define CONFIG_SYS_SDRAM_BASE  CONFIG_SYS_RAM_BASE
-#define CONFIG_SYS_LOAD_ADDR   0xD040
-#define CONFIG_LOADADDR0xD040
+#define CONFIG_SYS_LOAD_ADDR   0x9040
+#define CONFIG_LOADADDR0x9040
 
 #define CONFIG_SYS_MAX_FLASH_SECT  12
 #define CONFIG_SYS_MAX_FLASH_BANKS 2
-- 
1.9.1

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


Re: [U-Boot] [PATCH v5 4/9] board: ti: dra7xx-evm: turn on USB clocks in late init stage

2018-05-16 Thread Tom Rini
On Wed, May 16, 2018 at 11:04:18AM +0200, Marek Vasut wrote:
> On 05/16/2018 11:00 AM, Jean-Jacques Hiblot wrote:
> > 
> > 
> > On 16/05/2018 00:13, Marek Vasut wrote:
> >> On 05/15/2018 06:10 PM, Jean-Jacques Hiblot wrote:
> >>> Hi Marek,
> >>>
> >>>
> >>> On 04/05/2018 21:06, Marek Vasut wrote:
>  Shouldnt the driver turn this on?
> >>> AFAIK there is no clock driver for the OMAP. So we have to do it
> >>> before
> >>> the driver is probed.
> >> Maybe it's time to implement it instead of piling up those hacks ?
> > I was thinking along the same lines at some point but then I realized
> > that it will make the SPL really big. And we are already tight on some
> > platforms like am335x.
>  But this is not only SPL , right ? And yes, for SPL you might need to
>  poke registers or something.
> >>> IMHO having 2 different ways to enable the clocks in SPL and in u-boot
> >>> is an not improvement over the current situation.
> >>> In any case, This is a subject that can be discussed.
> >> Do you have a better idea ?
> > I would keep it as it is today.
> > 
> > After studying the clock management in Linux, I believe that
> > implementing the clock drivers in u-boot won't be an easy task and
> > moreover won't make things much cleaner.
> > The way clocks are handled in Linux for the omap platforms is not
> > completely standard. There are a lot of clocks that are handled by the
> > clock framework (pll, mux, some gates, ...) but most of the clock gating
> > for peripherals is handled the HWMOD subsystem which automatically
> > enables/disables the clocks of the peripherals. Parameters for this
> > subsystem are hard-coded in platform code (in
> > arch/arm/mach-omap2/omap-hwmod_xxx_data.c) not in the DTS. It also
> > handle clock and power domains.
> > HWMOD is probably going to go away some day, I'm not sure that we want
> > to implement it in u-boot. Until hwmod has completely replaced by more
> > generic frameworks, I would stick to platform code to enable clocks in
> > u-boot.
> 
> But if this keeps going on, eventually we will regress to where we were
> years ago -- having huge platform specific list of registers to poke to
> set a platform up and that'd be it ?

We should certainly re-evaluate the situation once hwmod finally gets
replaced in the kernel.  That's a long-standing and slowly-but-surely
happening thing.

-- 
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 v2] phy: add support for STM32 usb phy controller

2018-05-16 Thread Patrice CHOTARD
Hi Marek

On 05/16/2018 11:37 AM, Marek Vasut wrote:
> On 05/15/2018 03:27 PM, Patrice CHOTARD wrote:
>> Hi Marek
>>
>> On 04/27/2018 11:18 AM, Marek Vasut wrote:
>>> On 04/27/2018 11:01 AM, Patrice Chotard wrote:
 This patch adds phy tranceiver driver for STM32 USB PHY
 Controller (usbphyc) that provides dual port High-Speed
 phy for OTG (single port) and EHCI/OHCI host controller
 (two ports).
>>>
>>> Oh, I see.
>>>
 One port of the phy is shared between the two USB controllers
 through a UTMI+ switch.

 Signed-off-by: Christophe Kerello 
 Signed-off-by: Amelie Delaunay 
 Signed-off-by: Patrice Chotard 
 ---
>>>
>>> [...]
>>>
 +static int stm32_usbphyc_probe(struct udevice *dev)
 +{
 +  struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
 +  struct reset_ctl reset;
 +  ofnode node;
 +  int i, ret;
 +
 +  usbphyc->base = dev_read_addr(dev);
 +  if (usbphyc->base == FDT_ADDR_T_NONE)
 +  return -EINVAL;
 +
 +  /* Enable clock */
 +  ret = clk_get_by_index(dev, 0, >clk);
 +  if (ret)
 +  return ret;
 +
 +  ret = clk_enable(>clk);
 +  if (ret)
 +  return ret;
 +
 +  /* Reset */
 +  ret = reset_get_by_index(dev, 0, );
 +  if (!ret) {
 +  reset_assert();
 +  udelay(2);
 +  reset_deassert();
>>>
>>> Shouldn't the reset delay be a reset controller property ?
>>>
 +  }
>>>
>>> Looks good,
>>> Reviewed-by: Marek Vasut 
>>>
>>> Remind me to pick it after the release please.
>>>
>>
>> As you requested to me, can you pick the patch ?
> 
> I had to tweak the patch a bit, since it didnt apply anymore. Please
> check if it's correct, it should be OK though.

Perfect !

Thanks

Patrice

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


[U-Boot] [PATCH] usb: xhci: zynqmp: Fix header location

2018-05-16 Thread Michal Simek
There is no reason to specify header with full soc name.
Symlink is setup automatically (arch -> arch-zynqmp)

Signed-off-by: Michal Simek 
---

 drivers/usb/host/xhci-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c
index 7fe54281c3c4..e44e1ae1d915 100644
--- a/drivers/usb/host/xhci-zynqmp.c
+++ b/drivers/usb/host/xhci-zynqmp.c
@@ -13,7 +13,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include "xhci.h"
-- 
2.17.0

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


Re: [U-Boot] [PATCH v1 16/21] display5: net: Add function to read ethaddr from iMX6 fuses

2018-05-16 Thread Lukasz Majewski
Hi Joe,

> Hi Lukasz,
> 
> On Fri, May 11, 2018 at 9:51 AM, Lukasz Majewski 
> wrote:
> > Signed-off-by: Lukasz Majewski 
> > ---
> >
> >  board/liebherr/display5/display5.c | 21 +
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/board/liebherr/display5/display5.c
> > b/board/liebherr/display5/display5.c index 4bade476a5..a3deba216c
> > 100644 --- a/board/liebherr/display5/display5.c
> > +++ b/board/liebherr/display5/display5.c
> > @@ -254,6 +254,25 @@ static void setup_iomux_enet(void)
> > gpio_direction_input(IMX_GPIO_NR(1, 28)); /*INT#_GBE*/
> >  }
> >
> > +static int setup_mac_from_fuse(void)
> > +{
> > +   unsigned char enetaddr[6];
> > +   int ret;
> > +
> > +   ret = eth_env_get_enetaddr("ethaddr", enetaddr);
> > +   if (ret)/* ethaddr is already set */
> > +   return 0;
> > +
> > +   imx_get_mac_from_fuse(0, enetaddr);  
> 
> Generally this should be registered as a read_rom_hwaddr handler.

This function seems like a generic approach for IMX SoC:
arch/arm/mach-imx/mac.c

On the other hand the fec_mxc.c driver seems to have such function:

.read_rom_hwaddr= fecmxc_read_rom_hwaddr,
(which latter on calls the above function).

To use this function in the automatic way I would need to enable DM_ETH
for this board.

> 
> Then you won't be recreating the logic around what to do with it.
> 
> > +
> > +   if (is_valid_ethaddr(enetaddr)) {
> > +   eth_env_set_enetaddr("ethaddr", enetaddr);
> > +   return 0;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  int board_eth_init(bd_t *bd)
> >  {
> > struct phy_device *phydev;
> > @@ -268,6 +287,8 @@ int board_eth_init(bd_t *bd)
> > if (ret)
> > return ret;
> >
> > +   setup_mac_from_fuse();
> > +
> > bus = fec_get_miibus(IMX_FEC_BASE, -1);
> > if (!bus)
> > return -ENODEV;
> > --
> > 2.11.0
> >
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot  




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de


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


[U-Boot] [PATCH 0/4] Updates for Turris Mox

2018-05-16 Thread Marek Behún
Here are some updates for Turris Mox board.

The first patch updates Marvell's comphy driver to call function
board_update_comphy_map. The comphy driver contains a weak definition of this
function, which does nothing. Board file can then define this function to
update the serdes map before comphy lanes are initialized.
This is needed because on Turris Mox serdes lane 0 has to be initialized to
different speed when Topaz module is connected and when SFP module is connected.
This is a temporary solution. Once comphy driver for Armada 3720 is in kernel,
the comphy driver in u-boot shall also be rewritten to support changing the
speed even after the comphy lane is initialized.

The second patch changes the turris_mox board file to switch SERDES speed
according to module topology.

The third patch adds support for differentiating whether the board is with eMMC
card or with SD card slot.

The fourth patch adds the gpio command to turris_mox_defconfig.

Signed-off-by: Marek Behun 

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


[U-Boot] [PATCH] sf: Add Macronix MX25U25645G ID

2018-05-16 Thread Marek Vasut
Add ID for the Macronix MX25U25645G flash.

Signed-off-by: Marek Vasut 
Cc: Jagan Teki 
---
 drivers/mtd/spi/spi_flash_ids.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
index a46227f172..3b8f254ca2 100644
--- a/drivers/mtd/spi/spi_flash_ids.c
+++ b/drivers/mtd/spi/spi_flash_ids.c
@@ -85,6 +85,7 @@ const struct spi_flash_info spi_flash_ids[] = {
{"mx25u6435f", INFO(0xc22537, 0x0, 64 * 1024,   128, RD_FULL | 
WR_QPP) },
{"mx25l12855e",INFO(0xc22618, 0x0, 64 * 1024,   256, RD_FULL | 
WR_QPP) },
{"mx25u1635e", INFO(0xc22535, 0x0, 64 * 1024,  32, SECT_4K) },
+   {"mx25u25645g",INFO(0xc22539, 0x0, 64 * 1024,   512, RD_FULL | 
WR_QPP) },
{"mx66u51235f",INFO(0xc2253a, 0x0, 64 * 1024,  1024, RD_FULL | 
WR_QPP) },
{"mx66l1g45g", INFO(0xc2201b, 0x0, 64 * 1024,  2048, RD_FULL | 
WR_QPP) },
 #endif
-- 
2.16.2

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


[U-Boot] [PATCH] sf: Add Winbond W25Q256 ID

2018-05-16 Thread Marek Vasut
Add ID for the Winbond W25Q256 flash.

Signed-off-by: Marek Vasut 
Cc: Jagan Teki 
---
 drivers/mtd/spi/spi_flash_ids.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
index 41879d662a..a46227f172 100644
--- a/drivers/mtd/spi/spi_flash_ids.c
+++ b/drivers/mtd/spi/spi_flash_ids.c
@@ -174,6 +174,7 @@ const struct spi_flash_info spi_flash_ids[] = {
{"w25q32dw",   INFO(0xef6016, 0x0,  64 * 1024,64, RD_FULL | 
WR_QPP | SECT_4K) },
{"w25q64dw",   INFO(0xef6017, 0x0,  64 * 1024,   128, RD_FULL | 
WR_QPP | SECT_4K) },
{"w25q128fw",  INFO(0xef6018, 0x0,  64 * 1024,   256, RD_FULL | 
WR_QPP | SECT_4K) },
+   {"w25q256fw",  INFO(0xef6019, 0x0,  64 * 1024,   512, RD_FULL | 
WR_QPP | SECT_4K) },
 #endif
{}, /* Empty entry to terminate the list */
/*
@@ -188,5 +189,6 @@ const struct spi_flash_info spi_flash_ids[] = {
 * (w25q32dw, w25q32fv_qpi)
 * (w25q64dw, w25q64fv_qpi)
 * (w25q128fw, w25q128fv_qpi)
+* (w25q256fw, w25q256fv_qpi)
 */
 };
-- 
2.16.2

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


Re: [U-Boot] [PATCH 1/6] usb: dwc3: Add dwc3_init/remove with DM_USB

2018-05-16 Thread Marek Vasut
On 05/16/2018 04:26 PM, Michal Simek wrote:
> From: Mugunthan V N 
> 
> The patch is preparing dwc3 core for enabling DM_USB with peripheral
> driver with using driver model support.
> The driver will be bound by the DWC3 wrapper driver based on the
> dr_mode device tree entry.
> 
> Signed-off-by: Mugunthan V N 
> (Remove dwc3-omap changes)
> Signed-off-by: Michal Simek 
> ---
[...]
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index cbe9850a0bda..ad16c9b7c46c 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -712,7 +712,11 @@ struct dwc3 {
>   /* device lock */
>   spinlock_t  lock;
>  
> +#ifndef CONFIG_DM_USB

Shouldnt this be ifdef __UBOOT__ ?

>   struct device   *dev;
> +#else
> + struct udevice  *dev;
> +#endif
>  
>   struct platform_device  *xhci;
>   struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM];
> @@ -987,6 +991,8 @@ struct dwc3_gadget_ep_cmd_params {
>  
>  /* prototypes */
>  int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
> +int dwc3_init(struct dwc3 *dwc);
> +void dwc3_remove(struct dwc3 *dwc);
>  
>  #ifdef CONFIG_USB_DWC3_HOST
>  int dwc3_host_init(struct dwc3 *dwc);
> 


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


Re: [U-Boot] [PATCH 3/6] usb: dwc3: Add generic DWC3 glue logic driver

2018-05-16 Thread Marek Vasut
On 05/16/2018 04:26 PM, Michal Simek wrote:
> By enabling BLK by default this is the next driver which needs to get
> support for DM_USB. Adding generic DWC3 glue logic which only
> parse nodes and read device mode. Based on it probe proper
> host/peripheral DWC3 drivers for it.
> 
> Signed-off-by: Michal Simek 
> ---
> 
>  drivers/usb/dwc3/Kconfig|   6 ++
>  drivers/usb/dwc3/Makefile   |   1 +
>  drivers/usb/dwc3/dwc3-generic.c | 165 
>  3 files changed, 172 insertions(+)
>  create mode 100644 drivers/usb/dwc3/dwc3-generic.c
> 
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index ae7fc1c6304d..943b7630eba4 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -37,6 +37,12 @@ config USB_DWC3_OMAP
>  
> Say 'Y' here if you have one such device
>  
> +config USB_DWC3_GENERIC
> + bool "Xilinx ZynqMP and similar Platforms"
> + depends on DM_USB && USB_DWC3
> + help
> +   Some platforms can reuse this DWC3 generic implementation.
> +
>  config USB_DWC3_UNIPHIER
>   bool "DesignWare USB3 Host Support on UniPhier Platforms"
>   depends on ARCH_UNIPHIER && USB_XHCI_DWC3
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index cd18b8d9ec02..60b5515a67da 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -7,6 +7,7 @@ dwc3-y:= core.o
>  obj-$(CONFIG_USB_DWC3_GADGET)+= gadget.o ep0.o
>  
>  obj-$(CONFIG_USB_DWC3_OMAP)  += dwc3-omap.o
> +obj-$(CONFIG_USB_DWC3_GENERIC)   += dwc3-generic.o
>  obj-$(CONFIG_USB_DWC3_UNIPHIER)  += dwc3-uniphier.o
>  obj-$(CONFIG_USB_DWC3_PHY_OMAP)  += ti_usb_phy.o
>  obj-$(CONFIG_USB_DWC3_PHY_SAMSUNG)   += samsung_usb_phy.o
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> new file mode 100644
> index ..7dd2555c2042
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -0,0 +1,165 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Generic DWC3 Glue layer
> + *
> + * Copyright (C) 2016 - 2018 Xilinx, Inc.
> + *
> + * Based on dwc3-omap.c.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "core.h"
> +#include "gadget.h"
> +#include "linux-compat.h"
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +int usb_gadget_handle_interrupts(int index)
> +{
> + struct dwc3 *priv;
> + struct udevice *dev;
> + int ret;
> +
> + ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, );
> + if (!dev || ret) {
> + pr_err("No USB device found\n");
> + return -ENODEV;
> + }
> +
> + priv = dev_get_priv(dev);
> +
> + dwc3_gadget_uboot_handle_interrupt(priv);
> +
> + return 0;
> +}
> +
> +static int dwc3_generic_peripheral_probe(struct udevice *dev)
> +{
> + struct dwc3 *priv = dev_get_priv(dev);
> +
> + return dwc3_init(priv);
> +}
> +
> +static int dwc3_generic_peripheral_remove(struct udevice *dev)
> +{
> + struct dwc3 *priv = dev_get_priv(dev);
> +
> + dwc3_remove(priv);
> +
> + return 0;
> +}
> +
> +static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
> +{
> + struct dwc3 *priv = dev_get_priv(dev);
> + int node = dev_of_offset(dev);
> +
> + priv->regs = (void *)devfdt_get_addr(dev);
> + priv->regs += DWC3_GLOBALS_REGS_START;
> +
> + priv->maximum_speed = usb_get_maximum_speed(node);
> + if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
> + pr_err("Invalid usb maximum speed\n");
> + return -ENODEV;
> + }
> +
> + priv->dr_mode = usb_get_dr_mode(node);
> + if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
> + pr_err("Invalid usb mode setup\n");
> + return -ENODEV;
> + }
> +
> + return 0;
> +}
> +
> +static int dwc3_generic_peripheral_bind(struct udevice *dev)
> +{
> + return device_probe(dev);
> +}
> +
> +U_BOOT_DRIVER(dwc3_generic_peripheral) = {
> + .name   = "dwc3-generic-peripheral",
> + .id = UCLASS_USB_DEV_GENERIC,
> + .ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata,
> + .probe = dwc3_generic_peripheral_probe,
> + .remove = dwc3_generic_peripheral_remove,
> + .bind = dwc3_generic_peripheral_bind,
> + .platdata_auto_alloc_size = sizeof(struct usb_platdata),
> + .priv_auto_alloc_size = sizeof(struct dwc3),
> + .flags  = DM_FLAG_ALLOC_PRIV_DMA,
> +};
> +
> +static int dwc3_generic_bind(struct udevice *parent)
> +{
> + const void *fdt = gd->fdt_blob;
> + int node;
> + int ret;
> +
> + for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> +  node = fdt_next_subnode(fdt, node)) {
> + const char *name = fdt_get_name(fdt, node, NULL);
> + enum usb_dr_mode dr_mode;
> +

[U-Boot] [PATCH 4/4] board: turris_mox: Add gpio command to defconfig

2018-05-16 Thread Marek Behún
This can be used to detect whether the button is pressed or light the
LED diode.

Signed-off-by: Marek Behun 

diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 7dea7157dc..9538903bd3 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_ARCH_EARLY_INIT_R=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_CLK=y
+CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
-- 
2.16.1

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


[U-Boot] [PATCH 3/4] board: turris_mox: Support differentiating SD version from eMMC

2018-05-16 Thread Marek Behún
The first byte of the string read from SPI bus from which Mox module
toplogy is detected contains ID of the CPU module. This ID can
differentiate between the version with SD card slot and the one with
eMMC card.

Signed-off-by: Marek Behun 

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c 
b/board/CZ.NIC/turris_mox/turris_mox.c
index f7fb2c2955..c8ead5d67b 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -54,8 +54,16 @@ int board_init(void)
return 0;
 }
 
-static int mox_read_topology(const u8 **ptopology, int *psize)
+typedef enum {
+   MOX_UNKNOWN,
+   MOX_EMMC,
+   MOX_SD
+} mox_version_t;
+
+static int mox_read_topology(const u8 **ptopology, int *psize,
+mox_version_t *pversion)
 {
+   static mox_version_t mox_version;
static u8 topology[9];
static int size = 0;
struct spi_slave *slave;
@@ -64,8 +72,12 @@ static int mox_read_topology(const u8 **ptopology, int 
*psize)
int ret, i;
 
if (size) {
-   *ptopology = topology;
-   *psize = size;
+   if (ptopology)
+   *ptopology = topology;
+   if (psize)
+   *psize = size;
+   if (pversion)
+   *pversion = mox_version;
return 0;
}
 
@@ -85,7 +97,17 @@ static int mox_read_topology(const u8 **ptopology, int 
*psize)
if (ret)
goto fail_release;
 
-   if (din[0] != 0x00 && din[0] != 0xff) {
+   switch (din[0]) {
+   case 0x00:
+   mox_version = MOX_EMMC;
+   break;
+   case 0x10:
+   mox_version = MOX_SD;
+   break;
+   case 0xff:
+   mox_version = MOX_UNKNOWN;
+   break;
+   default:
ret = -ENODEV;
goto fail_release;
}
@@ -94,8 +116,12 @@ static int mox_read_topology(const u8 **ptopology, int 
*psize)
topology[i-1] = din[i] & 0xf;
size = i-1;
 
-   *ptopology = topology;
-   *psize = size;
+   if (ptopology)
+   *ptopology = topology;
+   if (psize)
+   *psize = size;
+   if (pversion)
+   *pversion = mox_version;
 
 fail_release:
spi_release_bus(slave);
@@ -110,7 +136,7 @@ void board_update_comphy_map(struct comphy_map *serdes_map, 
int count)
int ret, i, size, has = 0;
const u8 *topology;
 
-   ret = mox_read_topology(, );
+   ret = mox_read_topology(, , NULL);
if (ret)
return;
 
@@ -139,13 +165,17 @@ int last_stage_init(void)
size_t len = 0;
const u8 *topology;
char module_topology[128];
+   mox_version_t version;
 
-   ret = mox_read_topology(, );
+   ret = mox_read_topology(, , );
if (ret) {
printf("Cannot read module topology!\n");
return 0;
}
 
+   printf("Found Turris Mox %s version\n", version == MOX_SD ? "SD" :
+   version == MOX_EMMC ? "eMMC" :
+   "unknown");
printf("Module Topology:\n");
for (i = 0; i < size; ++i) {
size_t mlen;
@@ -179,6 +209,8 @@ int last_stage_init(void)
module_topology[len > 0 ? len - 1 : 0] = '\0';
 
env_set("module_topology", module_topology);
+   env_set("mox_version", version == MOX_SD ? "sd" :
+  version == MOX_EMMC ? "emmc" : "");
 
return 0;
 }
-- 
2.16.1

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


[U-Boot] [PATCH 2/4] board: turris_mox: Change SERDES map depending on module topology

2018-05-16 Thread Marek Behún
When SFP module is present, the SGMII lane speed should be 1.25 Gbps,
otherwise SFP won't work. Topaz still needs 3.125 Gbps.

Signed-off-by: Marek Behun 

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c 
b/board/CZ.NIC/turris_mox/turris_mox.c
index 130d4c606d..f7fb2c2955 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_WDT_ARMADA_3720
 #include 
@@ -53,14 +54,20 @@ int board_init(void)
return 0;
 }
 
-int last_stage_init(void)
+static int mox_read_topology(const u8 **ptopology, int *psize)
 {
+   static u8 topology[9];
+   static int size = 0;
struct spi_slave *slave;
struct udevice *dev;
u8 din[10], dout[10];
int ret, i;
-   size_t len = 0;
-   char module_topology[128];
+
+   if (size) {
+   *ptopology = topology;
+   *psize = size;
+   return 0;
+   }
 
ret = spi_get_bus_and_cs(0, 1, 2000, SPI_CPHA, "spi_generic_drv",
 "mox-modules@1", , );
@@ -78,30 +85,87 @@ int last_stage_init(void)
if (ret)
goto fail_release;
 
-   if (din[0] != 0x00 && din[0] != 0xff)
+   if (din[0] != 0x00 && din[0] != 0xff) {
+   ret = -ENODEV;
goto fail_release;
+   }
+
+   for (i = 1; i < 10 && din[i] != 0xff; ++i)
+   topology[i-1] = din[i] & 0xf;
+   size = i-1;
+
+   *ptopology = topology;
+   *psize = size;
+
+fail_release:
+   spi_release_bus(slave);
+fail_free:
+   spi_free_slave(slave);
+fail:
+   return ret;
+}
+
+void board_update_comphy_map(struct comphy_map *serdes_map, int count)
+{
+   int ret, i, size, has = 0;
+   const u8 *topology;
+
+   ret = mox_read_topology(, );
+   if (ret)
+   return;
+
+   for (i = 0; i < size; ++i) {
+   if (has && (topology[i] == 0x1 || topology[i] == 0x3)) {
+   printf("Warning: two or more incompatible Mox modules "
+  "found, using only first!\n");
+   break;
+   } else if (topology[i] == 0x1) {
+   printf("SFP module found, changing SERDES lane 0 speed"
+  " to 1.25 Gbps\n");
+   serdes_map[0].speed = PHY_SPEED_1_25G;
+   has = topology[i];
+   } else if (topology[i] == 0x3) {
+   printf("Topaz Switch module found, changing SERDES lane"
+  " 0 speed to 3.125 Gbps\n");
+   serdes_map[0].speed = PHY_SPEED_3_125G;
+   has = topology[i];
+   }
+   }
+}
+
+int last_stage_init(void)
+{
+   int ret, i, size;
+   size_t len = 0;
+   const u8 *topology;
+   char module_topology[128];
+
+   ret = mox_read_topology(, );
+   if (ret) {
+   printf("Cannot read module topology!\n");
+   return 0;
+   }
 
printf("Module Topology:\n");
-   for (i = 1; i < 10 && din[i] != 0xff; ++i) {
-   u8 mid = din[i] & 0xf;
+   for (i = 0; i < size; ++i) {
size_t mlen;
const char *mname = "";
 
-   switch (mid) {
+   switch (topology[i]) {
case 0x1:
mname = "sfp-";
-   printf("% 4i: SFP Module\n", i);
+   printf("% 4i: SFP Module\n", i+1);
break;
case 0x2:
mname = "pci-";
-   printf("% 4i: Mini-PCIe Module\n", i);
+   printf("% 4i: Mini-PCIe Module\n", i+1);
break;
case 0x3:
mname = "topaz-";
-   printf("% 4i: Topaz Switch Module\n", i);
+   printf("% 4i: Topaz Switch Module\n", i+1);
break;
default:
-   printf("% 4i: unknown (ID %i)\n", i, mid);
+   printf("% 4i: unknown (ID %i)\n", i+1, topology[i]);
}
 
mlen = strlen(mname);
@@ -116,12 +180,5 @@ int last_stage_init(void)
 
env_set("module_topology", module_topology);
 
-fail_release:
-   spi_release_bus(slave);
-fail_free:
-   spi_free_slave(slave);
-fail:
-   if (ret)
-   printf("Cannot read module topology!\n");
-   return ret;
+   return 0;
 }
-- 
2.16.1

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


[U-Boot] [PATCH 1/4] phy: marvell: Support changing SERDES map in board file

2018-05-16 Thread Marek Behún
This adds a weak definition of board_update_comphy_map to comphy_core,
which does nothing. If this function is defined elsewhere, for example
in board file, the board file can change some parameters of SERDES
configuration.

This is needed on Turris Mox, where the SERDES speed on lane 1 has to
be set differently when SFP module is connected and when Topaz Switch
module is connected.

This is a temporary solution. When the comphy driver for armada-3720
will be added to the kernel, the comphy driver in u-boot shall also be
updated and this should be done differently then.

Signed-off-by: Marek Behun 

 rename drivers/phy/marvell/{comphy.h => comphy_core.h} (96%)
 create mode 100644 include/comphy.h

diff --git a/drivers/phy/marvell/comphy_a3700.h 
b/drivers/phy/marvell/comphy_a3700.h
index a14767d809..b0941ffb37 100644
--- a/drivers/phy/marvell/comphy_a3700.h
+++ b/drivers/phy/marvell/comphy_a3700.h
@@ -6,7 +6,7 @@
 #ifndef _COMPHY_A3700_H_
 #define _COMPHY_A3700_H_
 
-#include "comphy.h"
+#include "comphy_core.h"
 #include "comphy_hpipe.h"
 
 #define MVEBU_REG(offs)\
diff --git a/drivers/phy/marvell/comphy_core.c 
b/drivers/phy/marvell/comphy_core.c
index c6e2cc8897..74b9f11b08 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -11,7 +11,7 @@
 #include 
 #include 
 
-#include "comphy.h"
+#include "comphy_core.h"
 
 #define COMPHY_MAX_CHIP 4
 
@@ -66,6 +66,10 @@ void comphy_print(struct chip_serdes_phy_config *chip_cfg,
}
 }
 
+__weak void board_update_comphy_map(struct comphy_map *serdes_map, int count)
+{
+}
+
 static int comphy_probe(struct udevice *dev)
 {
const void *blob = gd->fdt_blob;
@@ -143,6 +147,8 @@ static int comphy_probe(struct udevice *dev)
lane++;
}
 
+   board_update_comphy_map(comphy_map_data, chip_cfg->comphy_lanes_count);
+
/* Save CP index for MultiCP devices (A8K) */
chip_cfg->cp_index = current_idx++;
/* PHY power UP sequence */
diff --git a/drivers/phy/marvell/comphy.h b/drivers/phy/marvell/comphy_core.h
similarity index 96%
rename from drivers/phy/marvell/comphy.h
rename to drivers/phy/marvell/comphy_core.h
index b588ae41f0..e1da90e75b 100644
--- a/drivers/phy/marvell/comphy.h
+++ b/drivers/phy/marvell/comphy_core.h
@@ -3,11 +3,11 @@
  * Copyright (C) 2015-2016 Marvell International Ltd.
  */
 
-#ifndef _COMPHY_H_
-#define _COMPHY_H_
+#ifndef _COMPHY_CORE_H_
+#define _COMPHY_CORE_H_
 
-#include 
 #include 
+#include 
 
 #if defined(DEBUG)
 #define debug_enter()  printf("> Enter %s\n", __func__);
@@ -80,14 +80,6 @@ struct comphy_mux_data {
struct comphy_mux_options mux_values[MAX_LANE_OPTIONS];
 };
 
-struct comphy_map {
-   u32 type;
-   u32 speed;
-   u32 invert;
-   bool clk_src;
-   bool end_point;
-};
-
 struct chip_serdes_phy_config {
struct comphy_mux_data *mux_data;
int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *,
@@ -183,5 +175,5 @@ void comphy_pcie_config_detect(u32 comphy_max_count,
   struct comphy_map *serdes_map);
 void comphy_pcie_unit_general_config(u32 pex_index);
 
-#endif /* _COMPHY_H_ */
+#endif /* _COMPHY_CORE_H_ */
 
diff --git a/drivers/phy/marvell/comphy_cp110.c 
b/drivers/phy/marvell/comphy_cp110.c
index b0d5d5ca26..6a60da3df0 100644
--- a/drivers/phy/marvell/comphy_cp110.c
+++ b/drivers/phy/marvell/comphy_cp110.c
@@ -9,7 +9,7 @@
 #include 
 #include 
 
-#include "comphy.h"
+#include "comphy_core.h"
 #include "comphy_hpipe.h"
 #include "sata.h"
 #include "utmi_phy.h"
diff --git a/drivers/phy/marvell/comphy_mux.c b/drivers/phy/marvell/comphy_mux.c
index 1f757d8e04..c67ba99762 100644
--- a/drivers/phy/marvell/comphy_mux.c
+++ b/drivers/phy/marvell/comphy_mux.c
@@ -6,7 +6,7 @@
 #include 
 #include 
 
-#include "comphy.h"
+#include "comphy_core.h"
 #include "comphy_hpipe.h"
 
 /*
diff --git a/include/comphy.h b/include/comphy.h
new file mode 100644
index 00..2ebb50d418
--- /dev/null
+++ b/include/comphy.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2015-2016 Marvell International Ltd.
+ */
+
+#ifndef _COMPHY_H_
+#define _COMPHY_H_
+
+#include 
+
+struct comphy_map {
+   u32 type;
+   u32 speed;
+   u32 invert;
+   bool clk_src;
+   bool end_point;
+};
+
+void board_update_comphy_map(struct comphy_map *serdes_map, int count);
+
+#endif /* _COMPHY_H_ */
+
-- 
2.16.1

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


[U-Boot] [PATCH 6/6] usb: xhci: zynqmp: Remove support for !DM_USB

2018-05-16 Thread Michal Simek
Switch to DM_USB was done and there is no need to keep !DM_USB code in
tree.

Signed-off-by: Michal Simek 
---

 drivers/usb/host/Kconfig   |  1 +
 drivers/usb/host/xhci-zynqmp.c | 46 --
 scripts/config_whitelist.txt   |  1 -
 3 files changed, 1 insertion(+), 47 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3455e8113bb8..b4dd005651cf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -75,6 +75,7 @@ config USB_XHCI_STI
 config USB_XHCI_ZYNQMP
bool "Support for Xilinx ZynqMP on-chip xHCI USB controller"
depends on ARCH_ZYNQMP
+   depends on DM_USB
help
  Enables support for the on-chip xHCI controller on Xilinx ZynqMP SoCs.
 
diff --git a/drivers/usb/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c
index 526a42a9a58a..e44e1ae1d915 100644
--- a/drivers/usb/host/xhci-zynqmp.c
+++ b/drivers/usb/host/xhci-zynqmp.c
@@ -55,23 +55,15 @@
 #define USBOTGSS_IRQ_SET_1_DMADISABLECLR_ENBIT(17)
 
 struct zynqmp_xhci {
-#ifdef CONFIG_DM_USB
struct usb_platdata usb_plat;
-#endif
struct xhci_ctrl ctrl;
struct xhci_hccr *hcd;
struct dwc3 *dwc3_reg;
 };
 
-#ifdef CONFIG_DM_USB
 struct zynqmp_xhci_platdata {
fdt_addr_t hcd_base;
 };
-#else
-static struct zynqmp_xhci zynqmp_xhci;
-
-unsigned long ctr_addr[] = CONFIG_ZYNQMP_XHCI_LIST;
-#endif
 
 static int zynqmp_xhci_core_init(struct zynqmp_xhci *zynqmp_xhci)
 {
@@ -89,42 +81,6 @@ static int zynqmp_xhci_core_init(struct zynqmp_xhci 
*zynqmp_xhci)
return ret;
 }
 
-#ifndef CONFIG_DM_USB
-int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
-{
-   struct zynqmp_xhci *ctx = _xhci;
-   int ret = 0;
-   uint32_t hclen;
-
-   if (index < 0 || index >= ARRAY_SIZE(ctr_addr))
-   return -EINVAL;
-
-   ctx->hcd = (struct xhci_hccr *)ctr_addr[index];
-   ctx->dwc3_reg = (struct dwc3 *)((void *)ctx->hcd + DWC3_REG_OFFSET);
-
-   ret = board_usb_init(index, USB_INIT_HOST);
-   if (ret != 0) {
-   puts("Failed to initialize board for USB\n");
-   return ret;
-   }
-
-   ret = zynqmp_xhci_core_init(ctx);
-   if (ret < 0) {
-   puts("Failed to initialize xhci\n");
-   return ret;
-   }
-
-   *hccr = (struct xhci_hccr *)ctx->hcd;
-   hclen = HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase));
-   *hcor = (struct xhci_hcor *)((uintptr_t) *hccr + hclen);
-
-   debug("zynqmp-xhci: init hccr %p and hcor %p hc_length %d\n",
- *hccr, *hcor, hclen);
-
-   return ret;
-}
-#endif
-
 void xhci_hcd_stop(int index)
 {
/*
@@ -135,7 +91,6 @@ void xhci_hcd_stop(int index)
return;
 }
 
-#ifdef CONFIG_DM_USB
 static int xhci_usb_probe(struct udevice *dev)
 {
struct zynqmp_xhci_platdata *plat = dev_get_platdata(dev);
@@ -189,4 +144,3 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
.priv_auto_alloc_size = sizeof(struct zynqmp_xhci),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
 };
-#endif
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 71df6dbebde6..bfbdfcfc80ac 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -4782,7 +4782,6 @@ CONFIG_ZLIB
 CONFIG_ZLT
 CONFIG_ZM7300
 CONFIG_ZYNQMP_EEPROM
-CONFIG_ZYNQMP_XHCI_LIST
 CONFIG_ZYNQ_EEPROM
 CONFIG_ZYNQ_EEPROM_BUS
 CONFIG_ZYNQ_GEM_EEPROM_ADDR
-- 
2.17.0

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


[U-Boot] [PATCH 5/6] arm64: zynqmp: Use DWC3 generic driver and DM_USB

2018-05-16 Thread Michal Simek
Remove harcoded XHCI lists and detect mode, speed based on DT.

Signed-off-by: Michal Simek 
---

 board/xilinx/zynqmp/zynqmp.c  | 46 ---
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |  1 +
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |  1 +
 .../xilinx_zynqmp_zc1751_xm017_dc3_defconfig  |  1 +
 configs/xilinx_zynqmp_zcu100_revC_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |  1 +
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu104_revA_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu104_revC_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |  1 +
 configs/xilinx_zynqmp_zcu111_revA_defconfig   |  1 +
 .../configs/xilinx_zynqmp_zc1751_xm015_dc1.h  |  1 -
 .../configs/xilinx_zynqmp_zc1751_xm016_dc2.h  |  2 -
 .../configs/xilinx_zynqmp_zc1751_xm017_dc3.h  |  3 --
 include/configs/xilinx_zynqmp_zcu100.h|  3 --
 include/configs/xilinx_zynqmp_zcu102.h|  2 -
 include/configs/xilinx_zynqmp_zcu104.h|  2 -
 include/configs/xilinx_zynqmp_zcu106.h|  1 -
 include/configs/xilinx_zynqmp_zcu111.h|  2 -
 20 files changed, 11 insertions(+), 62 deletions(-)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 415fa668a789..551921b888a0 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -601,49 +601,3 @@ int checkboard(void)
puts("Board: Xilinx ZynqMP\n");
return 0;
 }
-
-#ifdef CONFIG_USB_DWC3
-static struct dwc3_device dwc3_device_data0 = {
-   .maximum_speed = USB_SPEED_HIGH,
-   .base = ZYNQMP_USB0_XHCI_BASEADDR,
-   .dr_mode = USB_DR_MODE_PERIPHERAL,
-   .index = 0,
-};
-
-static struct dwc3_device dwc3_device_data1 = {
-   .maximum_speed = USB_SPEED_HIGH,
-   .base = ZYNQMP_USB1_XHCI_BASEADDR,
-   .dr_mode = USB_DR_MODE_PERIPHERAL,
-   .index = 1,
-};
-
-int usb_gadget_handle_interrupts(int index)
-{
-   dwc3_uboot_handle_interrupt(index);
-   return 0;
-}
-
-int board_usb_init(int index, enum usb_init_type init)
-{
-   debug("%s: index %x\n", __func__, index);
-
-#if defined(CONFIG_USB_GADGET_DOWNLOAD)
-   g_dnl_set_serialnumber(CONFIG_SYS_CONFIG_NAME);
-#endif
-
-   switch (index) {
-   case 0:
-   return dwc3_uboot_init(_device_data0);
-   case 1:
-   return dwc3_uboot_init(_device_data1);
-   };
-
-   return -1;
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-   dwc3_uboot_exit(index);
-   return 0;
-}
-#endif
diff --git a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig 
b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig
index 9e2c0127474b..f36ab6f06972 100644
--- a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig
+++ b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig
@@ -84,6 +84,7 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_ZYNQMP=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig 
b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
index bd6d77ed3fcf..56d09c2c07da 100644
--- a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
+++ b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
@@ -80,6 +80,7 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_ZYNQMP=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/xilinx_zynqmp_zc1751_xm017_dc3_defconfig 
b/configs/xilinx_zynqmp_zc1751_xm017_dc3_defconfig
index 2e7ba74c03d2..ea4069d49571 100644
--- a/configs/xilinx_zynqmp_zc1751_xm017_dc3_defconfig
+++ b/configs/xilinx_zynqmp_zc1751_xm017_dc3_defconfig
@@ -76,6 +76,7 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_ZYNQMP=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/xilinx_zynqmp_zcu100_revC_defconfig 
b/configs/xilinx_zynqmp_zcu100_revC_defconfig
index 95dc5c131196..cdab565add4f 100644
--- a/configs/xilinx_zynqmp_zcu100_revC_defconfig
+++ b/configs/xilinx_zynqmp_zcu100_revC_defconfig
@@ -78,6 +78,7 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_ZYNQMP=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig 
b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig
index d3a226d4d2cf..0fa88b985aa2 100644
--- a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig
+++ b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig
@@ -94,6 +94,7 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_ZYNQMP=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_STORAGE=y
diff --git 

[U-Boot] [PATCH 4/6] usb: xhci: zynqmp: Add support for DM_USB

2018-05-16 Thread Michal Simek
The patch is adding support for DM_USB for xhci driver.

Signed-off-by: Michal Simek 
---

 drivers/usb/host/xhci-zynqmp.c | 69 ++
 1 file changed, 69 insertions(+)

diff --git a/drivers/usb/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c
index b1ade582aef6..526a42a9a58a 100644
--- a/drivers/usb/host/xhci-zynqmp.c
+++ b/drivers/usb/host/xhci-zynqmp.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,13 +55,23 @@
 #define USBOTGSS_IRQ_SET_1_DMADISABLECLR_ENBIT(17)
 
 struct zynqmp_xhci {
+#ifdef CONFIG_DM_USB
+   struct usb_platdata usb_plat;
+#endif
+   struct xhci_ctrl ctrl;
struct xhci_hccr *hcd;
struct dwc3 *dwc3_reg;
 };
 
+#ifdef CONFIG_DM_USB
+struct zynqmp_xhci_platdata {
+   fdt_addr_t hcd_base;
+};
+#else
 static struct zynqmp_xhci zynqmp_xhci;
 
 unsigned long ctr_addr[] = CONFIG_ZYNQMP_XHCI_LIST;
+#endif
 
 static int zynqmp_xhci_core_init(struct zynqmp_xhci *zynqmp_xhci)
 {
@@ -78,6 +89,7 @@ static int zynqmp_xhci_core_init(struct zynqmp_xhci 
*zynqmp_xhci)
return ret;
 }
 
+#ifndef CONFIG_DM_USB
 int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
 {
struct zynqmp_xhci *ctx = _xhci;
@@ -111,6 +123,7 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, 
struct xhci_hcor **hcor)
 
return ret;
 }
+#endif
 
 void xhci_hcd_stop(int index)
 {
@@ -121,3 +134,59 @@ void xhci_hcd_stop(int index)
 
return;
 }
+
+#ifdef CONFIG_DM_USB
+static int xhci_usb_probe(struct udevice *dev)
+{
+   struct zynqmp_xhci_platdata *plat = dev_get_platdata(dev);
+   struct zynqmp_xhci *ctx = dev_get_priv(dev);
+   struct xhci_hcor *hcor;
+   int ret;
+
+   ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
+   ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET);
+
+   ret = zynqmp_xhci_core_init(ctx);
+   if (ret) {
+   puts("XHCI: failed to initialize controller\n");
+   return -EINVAL;
+   }
+
+   hcor = (struct xhci_hcor *)((ulong)ctx->hcd +
+ HC_LENGTH(xhci_readl(>hcd->cr_capbase)));
+
+   return xhci_register(dev, ctx->hcd, hcor);
+}
+
+static int xhci_usb_remove(struct udevice *dev)
+{
+   return xhci_deregister(dev);
+}
+
+static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
+{
+   struct zynqmp_xhci_platdata *plat = dev_get_platdata(dev);
+   const void *blob = gd->fdt_blob;
+
+   /* Get the base address for XHCI controller from the device node */
+   plat->hcd_base = fdtdec_get_addr(blob, dev_of_offset(dev), "reg");
+   if (plat->hcd_base == FDT_ADDR_T_NONE) {
+   debug("Can't get the XHCI register base address\n");
+   return -ENXIO;
+   }
+
+   return 0;
+}
+
+U_BOOT_DRIVER(dwc3_generic_host) = {
+   .name = "dwc3-generic-host",
+   .id = UCLASS_USB,
+   .ofdata_to_platdata = xhci_usb_ofdata_to_platdata,
+   .probe = xhci_usb_probe,
+   .remove = xhci_usb_remove,
+   .ops = _usb_ops,
+   .platdata_auto_alloc_size = sizeof(struct zynqmp_xhci_platdata),
+   .priv_auto_alloc_size = sizeof(struct zynqmp_xhci),
+   .flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif
-- 
2.17.0

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


[U-Boot] [PATCH 3/6] usb: dwc3: Add generic DWC3 glue logic driver

2018-05-16 Thread Michal Simek
By enabling BLK by default this is the next driver which needs to get
support for DM_USB. Adding generic DWC3 glue logic which only
parse nodes and read device mode. Based on it probe proper
host/peripheral DWC3 drivers for it.

Signed-off-by: Michal Simek 
---

 drivers/usb/dwc3/Kconfig|   6 ++
 drivers/usb/dwc3/Makefile   |   1 +
 drivers/usb/dwc3/dwc3-generic.c | 165 
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-generic.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index ae7fc1c6304d..943b7630eba4 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -37,6 +37,12 @@ config USB_DWC3_OMAP
 
  Say 'Y' here if you have one such device
 
+config USB_DWC3_GENERIC
+   bool "Xilinx ZynqMP and similar Platforms"
+   depends on DM_USB && USB_DWC3
+   help
+ Some platforms can reuse this DWC3 generic implementation.
+
 config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
depends on ARCH_UNIPHIER && USB_XHCI_DWC3
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index cd18b8d9ec02..60b5515a67da 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -7,6 +7,7 @@ dwc3-y  := core.o
 obj-$(CONFIG_USB_DWC3_GADGET)  += gadget.o ep0.o
 
 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
+obj-$(CONFIG_USB_DWC3_GENERIC) += dwc3-generic.o
 obj-$(CONFIG_USB_DWC3_UNIPHIER)+= dwc3-uniphier.o
 obj-$(CONFIG_USB_DWC3_PHY_OMAP)+= ti_usb_phy.o
 obj-$(CONFIG_USB_DWC3_PHY_SAMSUNG) += samsung_usb_phy.o
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
new file mode 100644
index ..7dd2555c2042
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Generic DWC3 Glue layer
+ *
+ * Copyright (C) 2016 - 2018 Xilinx, Inc.
+ *
+ * Based on dwc3-omap.c.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "core.h"
+#include "gadget.h"
+#include "linux-compat.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int usb_gadget_handle_interrupts(int index)
+{
+   struct dwc3 *priv;
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, );
+   if (!dev || ret) {
+   pr_err("No USB device found\n");
+   return -ENODEV;
+   }
+
+   priv = dev_get_priv(dev);
+
+   dwc3_gadget_uboot_handle_interrupt(priv);
+
+   return 0;
+}
+
+static int dwc3_generic_peripheral_probe(struct udevice *dev)
+{
+   struct dwc3 *priv = dev_get_priv(dev);
+
+   return dwc3_init(priv);
+}
+
+static int dwc3_generic_peripheral_remove(struct udevice *dev)
+{
+   struct dwc3 *priv = dev_get_priv(dev);
+
+   dwc3_remove(priv);
+
+   return 0;
+}
+
+static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
+{
+   struct dwc3 *priv = dev_get_priv(dev);
+   int node = dev_of_offset(dev);
+
+   priv->regs = (void *)devfdt_get_addr(dev);
+   priv->regs += DWC3_GLOBALS_REGS_START;
+
+   priv->maximum_speed = usb_get_maximum_speed(node);
+   if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
+   pr_err("Invalid usb maximum speed\n");
+   return -ENODEV;
+   }
+
+   priv->dr_mode = usb_get_dr_mode(node);
+   if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
+   pr_err("Invalid usb mode setup\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+static int dwc3_generic_peripheral_bind(struct udevice *dev)
+{
+   return device_probe(dev);
+}
+
+U_BOOT_DRIVER(dwc3_generic_peripheral) = {
+   .name   = "dwc3-generic-peripheral",
+   .id = UCLASS_USB_DEV_GENERIC,
+   .ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata,
+   .probe = dwc3_generic_peripheral_probe,
+   .remove = dwc3_generic_peripheral_remove,
+   .bind = dwc3_generic_peripheral_bind,
+   .platdata_auto_alloc_size = sizeof(struct usb_platdata),
+   .priv_auto_alloc_size = sizeof(struct dwc3),
+   .flags  = DM_FLAG_ALLOC_PRIV_DMA,
+};
+
+static int dwc3_generic_bind(struct udevice *parent)
+{
+   const void *fdt = gd->fdt_blob;
+   int node;
+   int ret;
+
+   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
+node = fdt_next_subnode(fdt, node)) {
+   const char *name = fdt_get_name(fdt, node, NULL);
+   enum usb_dr_mode dr_mode;
+   struct udevice *dev;
+
+   debug("%s: subnode name: %s\n", __func__, name);
+   if (strncmp(name, "dwc3@", 4))
+   continue;
+
+   dr_mode = usb_get_dr_mode(node);
+
+   switch (dr_mode) {

[U-Boot] [PATCH 2/6] usb: common: add support to get maximum speed from dt

2018-05-16 Thread Michal Simek
From: Mugunthan V N 

Add support to get maximum speed from dt so that usb drivers
makes use of it for DT parsing.

Signed-off-by: Mugunthan V N 
Signed-off-by: Michal Simek 
(rebase and fix errors)
---

 drivers/usb/common/common.c | 29 +
 include/linux/usb/otg.h |  9 +
 2 files changed, 38 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 17a0ab23ff53..a55def5aba67 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -37,3 +38,31 @@ enum usb_dr_mode usb_get_dr_mode(int node)
 
return USB_DR_MODE_UNKNOWN;
 }
+
+static const char *const speed_names[] = {
+   [USB_SPEED_UNKNOWN] = "UNKNOWN",
+   [USB_SPEED_LOW] = "low-speed",
+   [USB_SPEED_FULL] = "full-speed",
+   [USB_SPEED_HIGH] = "high-speed",
+   [USB_SPEED_WIRELESS] = "wireless",
+   [USB_SPEED_SUPER] = "super-speed",
+};
+
+enum usb_device_speed usb_get_maximum_speed(int node)
+{
+   const void *fdt = gd->fdt_blob;
+   const char *max_speed;
+   int i;
+
+   max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
+   if (!max_speed) {
+   pr_err("usb maximum-speed not found\n");
+   return USB_SPEED_UNKNOWN;
+   }
+
+   for (i = 0; i < ARRAY_SIZE(speed_names); i++)
+   if (!strcmp(max_speed, speed_names[i]))
+   return i;
+
+   return USB_SPEED_UNKNOWN;
+}
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 0b273d8e2e8a..d2604c5cafba 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -25,4 +25,13 @@ enum usb_dr_mode {
  */
 enum usb_dr_mode usb_get_dr_mode(int node);
 
+/**
+ * usb_get_maximum_speed() - Get maximum speed for given device
+ * @node: Node offset to the given device
+ *
+ * The function gets phy interface string from property 'maximum-speed',
+ * and returns the correspondig enum usb_device_speed
+ */
+enum usb_device_speed usb_get_maximum_speed(int node);
+
 #endif /* __LINUX_USB_OTG_H */
-- 
2.17.0

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


[U-Boot] [PATCH 1/6] usb: dwc3: Add dwc3_init/remove with DM_USB

2018-05-16 Thread Michal Simek
From: Mugunthan V N 

The patch is preparing dwc3 core for enabling DM_USB with peripheral
driver with using driver model support.
The driver will be bound by the DWC3 wrapper driver based on the
dr_mode device tree entry.

Signed-off-by: Mugunthan V N 
(Remove dwc3-omap changes)
Signed-off-by: Michal Simek 
---

Origin series here: https://patchwork.ozlabs.org/patch/775108/

- Fix labels as was asked in previous review.
---
 drivers/usb/dwc3/core.c | 57 +
 drivers/usb/dwc3/core.h |  6 +
 2 files changed, 63 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index dbdad22d1134..e533325dda07 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -602,6 +602,8 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
 
 #define DWC3_ALIGN_MASK(16 - 1)
 
+#ifndef CONFIG_DM_USB
+
 /**
  * dwc3_uboot_init - dwc3 core uboot initialization code
  * @dwc3_dev: struct dwc3_device containing initialization data
@@ -788,3 +790,58 @@ MODULE_ALIAS("platform:dwc3");
 MODULE_AUTHOR("Felipe Balbi ");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
+
+#else
+
+int dwc3_init(struct dwc3 *dwc)
+{
+   int ret;
+
+   dwc3_cache_hwparams(dwc);
+
+   ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
+   if (ret) {
+   dev_err(dwc->dev, "failed to allocate event buffers\n");
+   return -ENOMEM;
+   }
+
+   ret = dwc3_core_init(dwc);
+   if (ret) {
+   dev_err(dev, "failed to initialize core\n");
+   goto core_fail;
+   }
+
+   ret = dwc3_event_buffers_setup(dwc);
+   if (ret) {
+   dev_err(dwc->dev, "failed to setup event buffers\n");
+   goto event_fail;
+   }
+
+   ret = dwc3_core_init_mode(dwc);
+   if (ret)
+   goto mode_fail;
+
+   return 0;
+
+mode_fail:
+   dwc3_event_buffers_cleanup(dwc);
+
+event_fail:
+   dwc3_core_exit(dwc);
+
+core_fail:
+   dwc3_free_event_buffers(dwc);
+
+   return ret;
+}
+
+void dwc3_remove(struct dwc3 *dwc)
+{
+   dwc3_core_exit_mode(dwc);
+   dwc3_event_buffers_cleanup(dwc);
+   dwc3_free_event_buffers(dwc);
+   dwc3_core_exit(dwc);
+   kfree(dwc->mem);
+}
+
+#endif
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index cbe9850a0bda..ad16c9b7c46c 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -712,7 +712,11 @@ struct dwc3 {
/* device lock */
spinlock_t  lock;
 
+#ifndef CONFIG_DM_USB
struct device   *dev;
+#else
+   struct udevice  *dev;
+#endif
 
struct platform_device  *xhci;
struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM];
@@ -987,6 +991,8 @@ struct dwc3_gadget_ep_cmd_params {
 
 /* prototypes */
 int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
+int dwc3_init(struct dwc3 *dwc);
+void dwc3_remove(struct dwc3 *dwc);
 
 #ifdef CONFIG_USB_DWC3_HOST
 int dwc3_host_init(struct dwc3 *dwc);
-- 
2.17.0

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


[U-Boot] [PATCH 0/6] Convert Xilinx ZynqMP to DM_USB with generic DWC3 glue logic driver

2018-05-16 Thread Michal Simek

Hi,

this patchset is based on unfinished series send to ML 06/13/2017
by Vignesh
"[U-Boot] [PATCH v2 00/13] driver model bring-up of dwc3 usb peripheral"
We have taken some part of this to Xilinx tree and use it for a while
but it is time to review it and upstream it.

The patchset has 2 patches created by Mugunthan which are a little bit
fixed.
dwc3-generic driver was inspired by omap version.
And the last 3 patches just doing conversion and enable DM_USB for our
platform.

Thanks,
Michal


Michal Simek (4):
  usb: dwc3: Add generic DWC3 glue logic driver
  usb: xhci: zynqmp: Add support for DM_USB
  arm64: zynqmp: Use DWC3 generic driver and DM_USB
  usb: xhci: zynqmp: Remove support for !DM_USB

Mugunthan V N (2):
  usb: dwc3: Add dwc3_init/remove with DM_USB
  usb: common: add support to get maximum speed from dt

 board/xilinx/zynqmp/zynqmp.c  |  46 -
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   1 +
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |   1 +
 .../xilinx_zynqmp_zc1751_xm017_dc3_defconfig  |   1 +
 configs/xilinx_zynqmp_zcu100_revC_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   1 +
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu104_revA_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu104_revC_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu111_revA_defconfig   |   1 +
 drivers/usb/common/common.c   |  29 +++
 drivers/usb/dwc3/Kconfig  |   6 +
 drivers/usb/dwc3/Makefile |   1 +
 drivers/usb/dwc3/core.c   |  57 ++
 drivers/usb/dwc3/core.h   |   6 +
 drivers/usb/dwc3/dwc3-generic.c   | 165 ++
 drivers/usb/host/Kconfig  |   1 +
 drivers/usb/host/xhci-zynqmp.c|  85 +
 .../configs/xilinx_zynqmp_zc1751_xm015_dc1.h  |   1 -
 .../configs/xilinx_zynqmp_zc1751_xm016_dc2.h  |   2 -
 .../configs/xilinx_zynqmp_zc1751_xm017_dc3.h  |   3 -
 include/configs/xilinx_zynqmp_zcu100.h|   3 -
 include/configs/xilinx_zynqmp_zcu102.h|   2 -
 include/configs/xilinx_zynqmp_zcu104.h|   2 -
 include/configs/xilinx_zynqmp_zcu106.h|   1 -
 include/configs/xilinx_zynqmp_zcu111.h|   2 -
 include/linux/usb/otg.h   |   9 +
 scripts/config_whitelist.txt  |   1 -
 30 files changed, 339 insertions(+), 94 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3-generic.c

-- 
2.17.0

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


Re: [U-Boot] [PATCH v5 4/9] board: ti: dra7xx-evm: turn on USB clocks in late init stage

2018-05-16 Thread Jean-Jacques Hiblot



On 16/05/2018 11:04, Marek Vasut wrote:

On 05/16/2018 11:00 AM, Jean-Jacques Hiblot wrote:


On 16/05/2018 00:13, Marek Vasut wrote:

On 05/15/2018 06:10 PM, Jean-Jacques Hiblot wrote:

Hi Marek,


On 04/05/2018 21:06, Marek Vasut wrote:

Shouldnt the driver turn this on?

AFAIK there is no clock driver for the OMAP. So we have to do it
before
the driver is probed.

Maybe it's time to implement it instead of piling up those hacks ?

I was thinking along the same lines at some point but then I realized
that it will make the SPL really big. And we are already tight on some
platforms like am335x.

But this is not only SPL , right ? And yes, for SPL you might need to
poke registers or something.

IMHO having 2 different ways to enable the clocks in SPL and in u-boot
is an not improvement over the current situation.
In any case, This is a subject that can be discussed.

Do you have a better idea ?

I would keep it as it is today.

After studying the clock management in Linux, I believe that
implementing the clock drivers in u-boot won't be an easy task and
moreover won't make things much cleaner.
The way clocks are handled in Linux for the omap platforms is not
completely standard. There are a lot of clocks that are handled by the
clock framework (pll, mux, some gates, ...) but most of the clock gating
for peripherals is handled the HWMOD subsystem which automatically
enables/disables the clocks of the peripherals. Parameters for this
subsystem are hard-coded in platform code (in
arch/arm/mach-omap2/omap-hwmod_xxx_data.c) not in the DTS. It also
handle clock and power domains.
HWMOD is probably going to go away some day, I'm not sure that we want
to implement it in u-boot. Until hwmod has completely replaced by more
generic frameworks, I would stick to platform code to enable clocks in
u-boot.

But if this keeps going on, eventually we will regress to where we were
years ago -- having huge platform specific list of registers to poke to
set a platform up and that'd be it ?

For omap clocks that would be status quo but the rest is moving toward DM


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


Re: [U-Boot] [PATCH 1/1] spi: atcspi200: avoid NULL dereference

2018-05-16 Thread Jagan Teki
On Sun, Mar 18, 2018 at 5:11 PM, Heinrich Schuchardt  wrote:
> For SPI_XFER_BEGIN | SPI_XFER_END the code sets data_out = NULL.
> In the debug statement we should not dereference this value.
> As we do not transfer any data the debug statement is not needed in this
> case anyway.
>
> Signed-off-by: Heinrich Schuchardt 
> ---

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


Re: [U-Boot] [PATCH 1/1] spi: fsl_qspi: remove superfluous assignment

2018-05-16 Thread Jagan Teki
On Sun, Mar 18, 2018 at 5:17 PM, Heinrich Schuchardt  wrote:
> In
>
> void *rx_addr = NULL;
> rx_add = A;
>
> the first assignment has no effect. Remove it.
>
> Signed-off-by: Heinrich Schuchardt 
> ---

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


Re: [U-Boot] [PATCH 1/1] spi: lpc32xx: simplify logical expression

2018-05-16 Thread Jagan Teki
On Sun, Mar 18, 2018 at 5:23 PM, Heinrich Schuchardt  wrote:
> A & A & B == A & B
>
> Signed-off-by: Heinrich Schuchardt 
> ---

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


Re: [U-Boot] [cosmetic PATCH v1] ARM: socfpga: Fix Documentation errors in scu_registers

2018-05-16 Thread Marek Vasut
On 05/15/2018 06:45 PM, Ben Kalo wrote:
> According to ARM Cortex-A9 MPCore TRM section 2.2 - SCU registers
> Access Control register offset is 0x50.
> 
> Signed-off-by: Ben Kalo 
> Cc: Marek Vasut 
> Cc: Albert Aribaud 
> ---
> 
>  arch/arm/mach-socfpga/include/mach/scu.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/include/mach/scu.h 
> b/arch/arm/mach-socfpga/include/mach/scu.h
> index 27224b1..b684a55 100644
> --- a/arch/arm/mach-socfpga/include/mach/scu.h
> +++ b/arch/arm/mach-socfpga/include/mach/scu.h
> @@ -14,8 +14,8 @@ struct scu_registers {
>   u32 _pad_0x10_0x3c[12]; /* 0x10 */
>   u32 fsar;   /* 0x40 */
>   u32 fear;
> - u32 _pad_0x48_0x50[2];
> - u32 acr;/* 0x54 */
> + u32 _pad_0x48_0x4c[2];
> + u32 acr;/* 0x50 */
>   u32 sacr;
>  };
>  
> 
Applied, thanks.

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


Re: [U-Boot] [PATCH v5 4/9] board: ti: dra7xx-evm: turn on USB clocks in late init stage

2018-05-16 Thread Marek Vasut
On 05/16/2018 11:00 AM, Jean-Jacques Hiblot wrote:
> 
> 
> On 16/05/2018 00:13, Marek Vasut wrote:
>> On 05/15/2018 06:10 PM, Jean-Jacques Hiblot wrote:
>>> Hi Marek,
>>>
>>>
>>> On 04/05/2018 21:06, Marek Vasut wrote:
 Shouldnt the driver turn this on?
>>> AFAIK there is no clock driver for the OMAP. So we have to do it
>>> before
>>> the driver is probed.
>> Maybe it's time to implement it instead of piling up those hacks ?
> I was thinking along the same lines at some point but then I realized
> that it will make the SPL really big. And we are already tight on some
> platforms like am335x.
 But this is not only SPL , right ? And yes, for SPL you might need to
 poke registers or something.
>>> IMHO having 2 different ways to enable the clocks in SPL and in u-boot
>>> is an not improvement over the current situation.
>>> In any case, This is a subject that can be discussed.
>> Do you have a better idea ?
> I would keep it as it is today.
> 
> After studying the clock management in Linux, I believe that
> implementing the clock drivers in u-boot won't be an easy task and
> moreover won't make things much cleaner.
> The way clocks are handled in Linux for the omap platforms is not
> completely standard. There are a lot of clocks that are handled by the
> clock framework (pll, mux, some gates, ...) but most of the clock gating
> for peripherals is handled the HWMOD subsystem which automatically
> enables/disables the clocks of the peripherals. Parameters for this
> subsystem are hard-coded in platform code (in
> arch/arm/mach-omap2/omap-hwmod_xxx_data.c) not in the DTS. It also
> handle clock and power domains.
> HWMOD is probably going to go away some day, I'm not sure that we want
> to implement it in u-boot. Until hwmod has completely replaced by more
> generic frameworks, I would stick to platform code to enable clocks in
> u-boot.

But if this keeps going on, eventually we will regress to where we were
years ago -- having huge platform specific list of registers to poke to
set a platform up and that'd be it ?

-- 
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] phy: add support for STM32 usb phy controller

2018-05-16 Thread Marek Vasut
On 05/15/2018 03:27 PM, Patrice CHOTARD wrote:
> Hi Marek
> 
> On 04/27/2018 11:18 AM, Marek Vasut wrote:
>> On 04/27/2018 11:01 AM, Patrice Chotard wrote:
>>> This patch adds phy tranceiver driver for STM32 USB PHY
>>> Controller (usbphyc) that provides dual port High-Speed
>>> phy for OTG (single port) and EHCI/OHCI host controller
>>> (two ports).
>>
>> Oh, I see.
>>
>>> One port of the phy is shared between the two USB controllers
>>> through a UTMI+ switch.
>>>
>>> Signed-off-by: Christophe Kerello 
>>> Signed-off-by: Amelie Delaunay 
>>> Signed-off-by: Patrice Chotard 
>>> ---
>>
>> [...]
>>
>>> +static int stm32_usbphyc_probe(struct udevice *dev)
>>> +{
>>> +   struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
>>> +   struct reset_ctl reset;
>>> +   ofnode node;
>>> +   int i, ret;
>>> +
>>> +   usbphyc->base = dev_read_addr(dev);
>>> +   if (usbphyc->base == FDT_ADDR_T_NONE)
>>> +   return -EINVAL;
>>> +
>>> +   /* Enable clock */
>>> +   ret = clk_get_by_index(dev, 0, >clk);
>>> +   if (ret)
>>> +   return ret;
>>> +
>>> +   ret = clk_enable(>clk);
>>> +   if (ret)
>>> +   return ret;
>>> +
>>> +   /* Reset */
>>> +   ret = reset_get_by_index(dev, 0, );
>>> +   if (!ret) {
>>> +   reset_assert();
>>> +   udelay(2);
>>> +   reset_deassert();
>>
>> Shouldn't the reset delay be a reset controller property ?
>>
>>> +   }
>>
>> Looks good,
>> Reviewed-by: Marek Vasut 
>>
>> Remind me to pick it after the release please.
>>
> 
> As you requested to me, can you pick the patch ?

I had to tweak the patch a bit, since it didnt apply anymore. Please
check if it's correct, it should be OK though.

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


Re: [U-Boot] [PATCH] drivers: usb: dwc3: remove devm_zalloc from linux_compact

2018-05-16 Thread Marek Vasut
On 05/16/2018 03:17 PM, Michal Simek wrote:
> From: Mugunthan V N 
> 
> devm_zalloc() is already defined in dm/device.h header, so
> devm_zalloc can be removed from linux_compact.h beader file.
> 
> Signed-off-by: Mugunthan V N 
> Signed-off-by: Michal Simek 
> ---

Applied, thanks

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


  1   2   >