Re: [U-Boot] [PATCH 00/19] riscv: Adding RISC-V CPU and timer driver

2018-12-03 Thread Anup Patel
On Tue, Nov 13, 2018 at 1:47 PM Bin Meng  wrote:
>
> This adds DM drivers to support RISC-V CPU and timer.
>
> The U-Boot RISC-V SBI support is still working in progress.
> Some patches in this series like adding CSR numbers, exception
> numbers, are prerequisites for the SBI implementation, but it
> does no harm to include them as part of this series.
>
> This series is dependent on Lukas's riscv series @
> http://patchwork.ozlabs.org/project/uboot/list/?series=74999
>
> This series is available at u-boot-x86/riscv-working for testing.
>
>
> Bin Meng (18):
>   dm: cpu: Add timebase frequency to the platdata
>   riscv: qemu: Create a simple-bus driver for the soc node
>   cpu: Add a RISC-V CPU driver
>   riscv: Add a SYSCON driver for Core Local Interruptor
>   timer: Add driver for RISC-V privileged architecture defined timer
>   riscv: kconfig: Allow platform to specify Kconfig options
>   riscv: Enlarge the default SYS_MALLOC_F_LEN
>   riscv: qemu: Probe cpus during boot
>   riscv: Add CSR numbers
>   riscv: Add exception codes for xcause register
>   riscv: Do some basic architecture level cpu initialization
>   riscv: Move trap handler codes to mtrap.S
>   riscv: Fix context restore before returning from trap handler
>   riscv: Return to previous privilege level after trap handling
>   riscv: Adjust the _exit_trap() position to come before handle_trap()
>   riscv: Pass correct exception code to _exit_trap()
>   riscv: Refactor handle_trap() a little for future extension
>   riscv: Allow U-Boot to run on hart 0 only
>

I see that this series tries to setup infrastructure for
implementing SBI runtime servies.

You might want to consider OpenSBI library, will be
eventually available.
(Refer, 
https://linuxplumbersconf.org/event/2/contributions/196/attachments/127/159/Atish_SBI.pdf)

If every bootloader starts implementing SBI runtime
services then there will be lot of fragmentation and SOC
vendors will have to support SBI in variety of bootloaders.

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


Re: [U-Boot] [PATCH 00/19] riscv: Adding RISC-V CPU and timer driver

2018-12-03 Thread Bin Meng
Hi Anup,

On Mon, Dec 3, 2018 at 3:59 PM Anup Patel  wrote:
>
> On Tue, Nov 13, 2018 at 1:47 PM Bin Meng  wrote:
> >
> > This adds DM drivers to support RISC-V CPU and timer.
> >
> > The U-Boot RISC-V SBI support is still working in progress.
> > Some patches in this series like adding CSR numbers, exception
> > numbers, are prerequisites for the SBI implementation, but it
> > does no harm to include them as part of this series.
> >
> > This series is dependent on Lukas's riscv series @
> > http://patchwork.ozlabs.org/project/uboot/list/?series=74999
> >
> > This series is available at u-boot-x86/riscv-working for testing.
> >
> >
> > Bin Meng (18):
> >   dm: cpu: Add timebase frequency to the platdata
> >   riscv: qemu: Create a simple-bus driver for the soc node
> >   cpu: Add a RISC-V CPU driver
> >   riscv: Add a SYSCON driver for Core Local Interruptor
> >   timer: Add driver for RISC-V privileged architecture defined timer
> >   riscv: kconfig: Allow platform to specify Kconfig options
> >   riscv: Enlarge the default SYS_MALLOC_F_LEN
> >   riscv: qemu: Probe cpus during boot
> >   riscv: Add CSR numbers
> >   riscv: Add exception codes for xcause register
> >   riscv: Do some basic architecture level cpu initialization
> >   riscv: Move trap handler codes to mtrap.S
> >   riscv: Fix context restore before returning from trap handler
> >   riscv: Return to previous privilege level after trap handling
> >   riscv: Adjust the _exit_trap() position to come before handle_trap()
> >   riscv: Pass correct exception code to _exit_trap()
> >   riscv: Refactor handle_trap() a little for future extension
> >   riscv: Allow U-Boot to run on hart 0 only
> >
>
> I see that this series tries to setup infrastructure for
> implementing SBI runtime servies.
>
> You might want to consider OpenSBI library, will be
> eventually available.
> (Refer, 
> https://linuxplumbersconf.org/event/2/contributions/196/attachments/127/159/Atish_SBI.pdf)
>
> If every bootloader starts implementing SBI runtime
> services then there will be lot of fragmentation and SOC
> vendors will have to support SBI in variety of bootloaders.

Agreed. In fact Atish contacted me offline some time ago about
contributing in OpenSBI. Definitely I think that's the right approach,
so that I am not sending SBI implementation of my own for U-Boot.

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


Re: [U-Boot] [PATCH v2 13/14] cmd: efishell: export uefi variable helper functions

2018-12-03 Thread AKASHI Takahiro
On Mon, Dec 03, 2018 at 12:54:44AM +0100, Alexander Graf wrote:
> 
> 
> On 05.11.18 10:06, AKASHI Takahiro wrote:
> > Those function will be used for integration with 'env' command
> > so as to handle uefi variables.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  cmd/efishell.c| 4 ++--
> >  include/command.h | 2 ++
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/cmd/efishell.c b/cmd/efishell.c
> > index bd2b99e74079..8122b842dd76 100644
> > --- a/cmd/efishell.c
> > +++ b/cmd/efishell.c
> > @@ -68,7 +68,7 @@ static void dump_var_data(char *data, unsigned long len)
> >   *
> >   *   efi_$guid_$varname = {attributes}(type)value
> >   */
> > -static int do_efi_dump_var(int argc, char * const argv[])
> > +int do_efi_dump_var(int argc, char * const argv[])
> >  {
> > char regex[256];
> > char * const regexlist[] = {regex};
> > @@ -228,7 +228,7 @@ out:
> > return 0;
> >  }
> >  
> > -static int do_efi_set_var(int argc, char * const argv[])
> > +int do_efi_set_var(int argc, char * const argv[])
> >  {
> > char *var_name, *value = NULL;
> > unsigned long size = 0;
> > diff --git a/include/command.h b/include/command.h
> > index 5bb675122cce..2ce8b53f74c8 100644
> > --- a/include/command.h
> > +++ b/include/command.h
> > @@ -50,6 +50,8 @@ extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, 
> > char * const argv[]);
> >  #endif
> >  #if defined(CONFIG_CMD_BOOTEFI)
> >  int do_bootefi_bootmgr_exec(int boot_id);
> > +int do_efi_dump_var(int argc, char * const argv[]);
> > +int do_efi_set_var(int argc, char * const argv[]);
> 
> I guess you're seeing a pattern to my comments by now.

Definitely, but

> This needs to go
> into efi_loader.h. The respective functions need to go into lib/efi_loader.

Those two functions are dedicated for command interfaces, and in my opinion,
it is hard for them to be seen as part of efi_loader functionality.

Thanks,
-Takahiro Akashi

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


Re: [U-Boot] [PATCH v7 4/4] RISC-V: Add S-mode timer implementation

2018-12-03 Thread Anup Patel
On Mon, Dec 3, 2018 at 1:27 PM Bin Meng  wrote:
>
> Hi Anup,
>
> On Mon, Dec 3, 2018 at 3:44 PM Anup Patel  wrote:
> >
> > On Mon, Dec 3, 2018 at 1:08 PM Bin Meng  wrote:
> > >
> > > Hi Anup,
> > >
> > > On Mon, Dec 3, 2018 at 3:31 PM Anup Patel  wrote:
> > > >
> > > > On Mon, Dec 3, 2018 at 12:56 PM Bin Meng  wrote:
> > > > >
> > > > > Hi Anup,
> > > > >
> > > > > On Mon, Dec 3, 2018 at 3:19 PM Anup Patel  wrote:
> > > > > >
> > > > > > On Mon, Dec 3, 2018 at 12:32 PM Bin Meng  wrote:
> > > > > > >
> > > > > > > Hi Anup,
> > > > > > >
> > > > > > > On Mon, Dec 3, 2018 at 2:43 PM Anup Patel  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > On Mon, Dec 3, 2018 at 12:06 PM Bin Meng  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > Hi Anup,
> > > > > > > > >
> > > > > > > > > On Mon, Dec 3, 2018 at 1:28 PM Anup Patel 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > > When running in S-mode, we can use rdtime and rdtimeh 
> > > > > > > > > > instructions
> > > > > > > > > > for reading timer ticks (just like Linux). The frequency of 
> > > > > > > > > > timer
> > > > > > > > > > ticks is passed by prior booting stages in 
> > > > > > > > > > "timebase-frequency" DT
> > > > > > > > > > property of the "/cpus" DT node.
> > > > > > > > > >
> > > > > > > > > > This patch provides a generic timer implementation for 
> > > > > > > > > > U-Boot
> > > > > > > > > > running in S-mode. For U-Boot running in M-mode, specific 
> > > > > > > > > > timer
> > > > > > > > > > drivers will have to be provided.
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Anup Patel 
> > > > > > > > > > ---
> > > > > > > > > >  arch/Kconfig|  1 -
> > > > > > > > > >  arch/riscv/Kconfig  | 22 +++
> > > > > > > > > >  arch/riscv/lib/Makefile |  1 +
> > > > > > > > > >  arch/riscv/lib/time.c   | 60 
> > > > > > > > > > +
> > > > > > > > > >  4 files changed, 78 insertions(+), 6 deletions(-)
> > > > > > > > > >  create mode 100644 arch/riscv/lib/time.c
> > > > > > > > > >
> > > > > > > > > > diff --git a/arch/Kconfig b/arch/Kconfig
> > > > > > > > > > index 9fdd2f7e66..a4fcb3522d 100644
> > > > > > > > > > --- a/arch/Kconfig
> > > > > > > > > > +++ b/arch/Kconfig
> > > > > > > > > > @@ -72,7 +72,6 @@ config RISCV
> > > > > > > > > > imply BLK
> > > > > > > > > > imply CLK
> > > > > > > > > > imply MTD
> > > > > > > > > > -   imply TIMER
> > > > > > > > >
> > > > > > > > > No, please don't do this.
> > > > > > > >
> > > > > > > > I am removing here but selecting it only for M-mode U-Boot.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > > imply CMD_DM
> > > > > > > > > >
> > > > > > > > > >  config SANDBOX
> > > > > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > > > > > > index 732a357a99..20a060454b 100644
> > > > > > > > > > --- a/arch/riscv/Kconfig
> > > > > > > > > > +++ b/arch/riscv/Kconfig
> > > > > > > > > > @@ -44,6 +44,23 @@ config ARCH_RV64I
> > > > > > > > > >
> > > > > > > > > >  endchoice
> > > > > > > > > >
> > > > > > > > > > +choice
> > > > > > > > > > +   prompt "Run Mode"
> > > > > > > > > > +   default RISCV_MMODE
> > > > > > > > > > +
> > > > > > > > > > +config RISCV_MMODE
> > > > > > > > > > +   bool "Machine"
> > > > > > > > > > +   select TIMER
> > > > > > > > > > +   help
> > > > > > > > > > +  Choose this option to build U-Boot for RISC-V 
> > > > > > > > > > M-Mode.
> > > > > > > > > > +
> > > > > > > > > > +config RISCV_SMODE
> > > > > > > > > > +   bool "Supervisor"
> > > > > > > > > > +   help
> > > > > > > > > > +  Choose this option to build U-Boot for RISC-V 
> > > > > > > > > > S-Mode.
> > > > > > > > > > +
> > > > > > > > > > +endchoice
> > > > > > > > > > +
> > > > > > > > >
> > > > > > > > > The above changes deserve separate patch, or merge that in 
> > > > > > > > > the 1st
> > > > > > > > > patch in the series.
> > > > > > > >
> > > > > > > > Sure, I will put Kconfig changes as separate patch.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > >  config RISCV_ISA_C
> > > > > > > > > > bool "Emit compressed instructions"
> > > > > > > > > > default y
> > > > > > > > > > @@ -55,11 +72,6 @@ config RISCV_ISA_C
> > > > > > > > > >  config RISCV_ISA_A
> > > > > > > > > > def_bool y
> > > > > > > > > >
> > > > > > > > > > -config RISCV_SMODE
> > > > > > > > > > -   bool "Run in S-Mode"
> > > > > > > > > > -   help
> > > > > > > > > > - Enable this option to build U-Boot for RISC-V 
> > > > > > > > > > S-Mode
> > > > > > > > > > -
> > > > > > > > > >  config 32BIT
> > > > > > > > > > bool
> > > > > > > > > >
> > > > > > > > > > diff --git a/arch/riscv/lib/Makefile 
> > > > > > > > > > b/arch/riscv/lib/Makefile
> > > > > > > > > > index b58db89752..98aa6d40e7 100644
> > > > > > > > > > --- a/arch/riscv/lib/Makefile
> > > > > > > > > > +++ b/arch/riscv/lib/

Re: [U-Boot] [PATCH v2] efi_loader: set image_base and image_size to correct values

2018-12-03 Thread AKASHI Takahiro
On Sun, Dec 02, 2018 at 11:46:29PM +0100, Alexander Graf wrote:
> 
> 
> On 12.10.18 02:55, AKASHI Takahiro wrote:
> > On Thu, Oct 11, 2018 at 04:18:33PM +0200, Heinrich Schuchardt wrote:
> >> On 10/11/2018 01:11 PM, AKASHI Takahiro wrote:
> >>> Currently, image's image_base points to an address where the image was
> >>> temporarily uploaded for further loading. Since efi_loader relocates
> >>> the image to final destination, image_base and image_size should reflect
> >>> that.
> >>>
> >>> This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2,"
> >>> which shows that 'Unload' function doesn't fit into a range suggested by
> >>> image_base and image_size.
> >>>   TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/
> >>>   LoadedImageBBTestMain.c:1002
> >>>
> >>> Changes in this patch also includes:
> >>> * reverts a patch, "efi_loader: save image relocation address
> >>>   and size" since newly added fields are no longer needed.
> >>> * copy PE headers as well since those information will be needed
> >>>   for module loading, in particular, at gurb.
> >>>   (This bug was reported by Heinrich.)
> >>>
> >>> Signed-off-by: AKASHI Takahiro 
> >>> Reported-by: Heinrich Schuchardt 
> >>> ---
> >>>  lib/efi_loader/efi_image_loader.c | 22 +++---
> >>>  1 file changed, 11 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git a/lib/efi_loader/efi_image_loader.c 
> >>> b/lib/efi_loader/efi_image_loader.c
> >>> index a18ce0a5705e..d1b6c0d3cdf2 100644
> >>> --- a/lib/efi_loader/efi_image_loader.c
> >>> +++ b/lib/efi_loader/efi_image_loader.c
> >>> @@ -59,10 +59,10 @@ static efi_status_t efi_print_image_info(struct 
> >>> efi_loaded_image_obj *obj,
> >>>  {
> >>>   printf("UEFI image");
> >>>   printf(" [0x%p:0x%p]",
> >>> -obj->reloc_base, obj->reloc_base + obj->reloc_size - 1);
> >>> - if (pc && pc >= obj->reloc_base &&
> >>> - pc < obj->reloc_base + obj->reloc_size)
> >>> - printf(" pc=0x%zx", pc - obj->reloc_base);
> >>> +image->image_base, image->image_base + image->image_size - 1);
> >>> + if (pc && pc >= image->image_base &&
> >>> + pc < image->image_base + image->image_size)
> >>> + printf(" pc=0x%zx", pc - image->image_base);
> >>>   if (image->file_path)
> >>>   printf(" '%pD'", image->file_path);
> >>>   printf("\n");
> >>> @@ -212,7 +212,6 @@ void *efi_load_pe(struct efi_loaded_image_obj 
> >>> *handle, void *efi,
> >>>   int rel_idx = IMAGE_DIRECTORY_ENTRY_BASERELOC;
> >>>   void *entry;
> >>>   uint64_t image_base;
> >>> - uint64_t image_size;
> >>>   unsigned long virt_size = 0;
> >>>   int supported = 0;
> >>>  
> >>> @@ -256,7 +255,6 @@ void *efi_load_pe(struct efi_loaded_image_obj 
> >>> *handle, void *efi,
> >>>   IMAGE_NT_HEADERS64 *nt64 = (void *)nt;
> >>>   IMAGE_OPTIONAL_HEADER64 *opt = &nt64->OptionalHeader;
> >>>   image_base = opt->ImageBase;
> >>> - image_size = opt->SizeOfImage;
> >>>   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
> >>>   efi_reloc = efi_alloc(virt_size,
> >>> loaded_image_info->image_code_type);
> >>> @@ -272,7 +270,6 @@ void *efi_load_pe(struct efi_loaded_image_obj 
> >>> *handle, void *efi,
> >>>   } else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> >>>   IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader;
> >>>   image_base = opt->ImageBase;
> >>> - image_size = opt->SizeOfImage;
> >>>   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
> >>>   efi_reloc = efi_alloc(virt_size,
> >>> loaded_image_info->image_code_type);
> >>> @@ -291,6 +288,11 @@ void *efi_load_pe(struct efi_loaded_image_obj 
> >>> *handle, void *efi,
> >>>   return NULL;
> >>>   }
> >>>  
> >>> + /* Copy PE headers */
> >>> + memcpy(efi_reloc, efi, sizeof(*dos) + sizeof(*nt)
> >>> + + nt->FileHeader.SizeOfOptionalHeader
> >>> + + num_sections * sizeof(IMAGE_SECTION_HEADER));
> >>> +
> >>
> >> Why do we have to copy PE headers and the sections below separately? My
> >> understanding is that the relative positions do not need any adjustment.
> > 
> > I think I have already answered your questions here:
> > https://lists.denx.de/pipermail/u-boot/2018-October/343876.html
> > 
> > Did you read it?
> > 
> >> Nothing in the spec requires the COFF header to be at offset
> >> sizeof(dos). You can put the COFF headder anywhere in the file. Please,
> >> read
> > 
> > But as far as I look at grub code (that you pointed out in your e-mail),
> > grub expects that PE headers be also "loaded" within an allocated region
> > (more specifically at the beginning of the region)
> > along with other sections in order to handle a (grub-specific? I don't know)
> > "mods" section.
> 
> Is this patch still required?

I think so as long as we want to make the code more compliant with UEFI spec,
but Heinrich may 

Re: [U-Boot] [PATCH v7 4/4] RISC-V: Add S-mode timer implementation

2018-12-03 Thread Bin Meng
Hi Anup,

On Mon, Dec 3, 2018 at 4:12 PM Anup Patel  wrote:
>
> On Mon, Dec 3, 2018 at 1:27 PM Bin Meng  wrote:
> >
> > Hi Anup,
> >
> > On Mon, Dec 3, 2018 at 3:44 PM Anup Patel  wrote:
> > >
> > > On Mon, Dec 3, 2018 at 1:08 PM Bin Meng  wrote:
> > > >
> > > > Hi Anup,
> > > >
> > > > On Mon, Dec 3, 2018 at 3:31 PM Anup Patel  wrote:
> > > > >
> > > > > On Mon, Dec 3, 2018 at 12:56 PM Bin Meng  wrote:
> > > > > >
> > > > > > Hi Anup,
> > > > > >
> > > > > > On Mon, Dec 3, 2018 at 3:19 PM Anup Patel  
> > > > > > wrote:
> > > > > > >
> > > > > > > On Mon, Dec 3, 2018 at 12:32 PM Bin Meng  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hi Anup,
> > > > > > > >
> > > > > > > > On Mon, Dec 3, 2018 at 2:43 PM Anup Patel  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > On Mon, Dec 3, 2018 at 12:06 PM Bin Meng  
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Anup,
> > > > > > > > > >
> > > > > > > > > > On Mon, Dec 3, 2018 at 1:28 PM Anup Patel 
> > > > > > > > > >  wrote:
> > > > > > > > > > >
> > > > > > > > > > > When running in S-mode, we can use rdtime and rdtimeh 
> > > > > > > > > > > instructions
> > > > > > > > > > > for reading timer ticks (just like Linux). The frequency 
> > > > > > > > > > > of timer
> > > > > > > > > > > ticks is passed by prior booting stages in 
> > > > > > > > > > > "timebase-frequency" DT
> > > > > > > > > > > property of the "/cpus" DT node.
> > > > > > > > > > >
> > > > > > > > > > > This patch provides a generic timer implementation for 
> > > > > > > > > > > U-Boot
> > > > > > > > > > > running in S-mode. For U-Boot running in M-mode, specific 
> > > > > > > > > > > timer
> > > > > > > > > > > drivers will have to be provided.
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Anup Patel 
> > > > > > > > > > > ---
> > > > > > > > > > >  arch/Kconfig|  1 -
> > > > > > > > > > >  arch/riscv/Kconfig  | 22 +++
> > > > > > > > > > >  arch/riscv/lib/Makefile |  1 +
> > > > > > > > > > >  arch/riscv/lib/time.c   | 60 
> > > > > > > > > > > +
> > > > > > > > > > >  4 files changed, 78 insertions(+), 6 deletions(-)
> > > > > > > > > > >  create mode 100644 arch/riscv/lib/time.c
> > > > > > > > > > >
> > > > > > > > > > > diff --git a/arch/Kconfig b/arch/Kconfig
> > > > > > > > > > > index 9fdd2f7e66..a4fcb3522d 100644
> > > > > > > > > > > --- a/arch/Kconfig
> > > > > > > > > > > +++ b/arch/Kconfig
> > > > > > > > > > > @@ -72,7 +72,6 @@ config RISCV
> > > > > > > > > > > imply BLK
> > > > > > > > > > > imply CLK
> > > > > > > > > > > imply MTD
> > > > > > > > > > > -   imply TIMER
> > > > > > > > > >
> > > > > > > > > > No, please don't do this.
> > > > > > > > >
> > > > > > > > > I am removing here but selecting it only for M-mode U-Boot.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > imply CMD_DM
> > > > > > > > > > >
> > > > > > > > > > >  config SANDBOX
> > > > > > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > > > > > > > index 732a357a99..20a060454b 100644
> > > > > > > > > > > --- a/arch/riscv/Kconfig
> > > > > > > > > > > +++ b/arch/riscv/Kconfig
> > > > > > > > > > > @@ -44,6 +44,23 @@ config ARCH_RV64I
> > > > > > > > > > >
> > > > > > > > > > >  endchoice
> > > > > > > > > > >
> > > > > > > > > > > +choice
> > > > > > > > > > > +   prompt "Run Mode"
> > > > > > > > > > > +   default RISCV_MMODE
> > > > > > > > > > > +
> > > > > > > > > > > +config RISCV_MMODE
> > > > > > > > > > > +   bool "Machine"
> > > > > > > > > > > +   select TIMER
> > > > > > > > > > > +   help
> > > > > > > > > > > +  Choose this option to build U-Boot for RISC-V 
> > > > > > > > > > > M-Mode.
> > > > > > > > > > > +
> > > > > > > > > > > +config RISCV_SMODE
> > > > > > > > > > > +   bool "Supervisor"
> > > > > > > > > > > +   help
> > > > > > > > > > > +  Choose this option to build U-Boot for RISC-V 
> > > > > > > > > > > S-Mode.
> > > > > > > > > > > +
> > > > > > > > > > > +endchoice
> > > > > > > > > > > +
> > > > > > > > > >
> > > > > > > > > > The above changes deserve separate patch, or merge that in 
> > > > > > > > > > the 1st
> > > > > > > > > > patch in the series.
> > > > > > > > >
> > > > > > > > > Sure, I will put Kconfig changes as separate patch.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > >  config RISCV_ISA_C
> > > > > > > > > > > bool "Emit compressed instructions"
> > > > > > > > > > > default y
> > > > > > > > > > > @@ -55,11 +72,6 @@ config RISCV_ISA_C
> > > > > > > > > > >  config RISCV_ISA_A
> > > > > > > > > > > def_bool y
> > > > > > > > > > >
> > > > > > > > > > > -config RISCV_SMODE
> > > > > > > > > > > -   bool "Run in S-Mode"
> > > > > > > > > > > -   help
> > > > > > > > > > > - Enable this option to build U-Boot for RISC-V 
> > > > > > > > > > > S-Mode
> > > > > > > > > > > -
> 

Re: [U-Boot] [PATCH] cmd: bmp: manage centered display

2018-12-03 Thread Patrick DELAUNAY
Hi Anatolij,

> From: Anatolij Gustschin 
> Sent: samedi 1 décembre 2018 15:06
> 
> Hi Patrick,
> 
> On Wed, 14 Nov 2018 10:18:22 +0100
> Patrick Delaunay patrick.delau...@st.com wrote:
> ...
> >
> > +#define BMP_ALIGN_CENTER   0x7FFF
> 
> this already exists when including splash.h, I dropped it in v2.

Ok, I don't see that splash.h is included in cmd/bmp.c.

In fact I hesitate to move this define in commun bmp include (in include/lcd.h 
with bmp_display prototype for exmaple) 
to avoid a other double definition:

common/lcd.c:392 #define BMP_ALIGN_CENTER   0x7FFF
drivers/video/video_bmp.c:143:#define BMP_ALIGN_CENTER  0x7fff
include/splash.h:78:#define BMP_ALIGN_CENTER0x7FFF

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


[U-Boot] [PATCH] nand: vybrid: Use calloc() instead of malloc() to allocate struct nfc

2018-12-03 Thread Lukasz Majewski
Without this change it is possible that Vybrid's NFC driver malloc() call
will obtain some memory used (and correctly free'd) by some previous
driver (in this case pinctrl for Vybrid).

As a result some fields of struct nfc - in out case mtd->_get_device - are
"pre initialized" with some random values.

On the latter stage of booting, when e.g. somebody calls 'mtdparts default'
the "data abort" is observed when __get_mtd_device() function is called.

The mtd->_get_device pointer is not NULL and wrong value is referenced.

Signed-off-by: Lukasz Majewski 

---

 drivers/mtd/nand/raw/vf610_nfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index fce7e5f299..3326c2b096 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -646,7 +646,7 @@ static int vf610_nfc_nand_init(int devnum, void __iomem 
*addr)
.flash_bbt = 1,
};
 
-   nfc = malloc(sizeof(*nfc));
+   nfc = calloc(1, sizeof(*nfc));
if (!nfc) {
printf(KERN_ERR "%s: Memory exhausted!\n", __func__);
return -ENOMEM;
-- 
2.11.0

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


Re: [U-Boot] [PATCH] cmd: bmp: manage centered display

2018-12-03 Thread Anatolij Gustschin
Hi Patrick,

On Mon, 3 Dec 2018 08:45:57 +
Patrick DELAUNAY patrick.delau...@st.com wrote:
...
> > > +#define BMP_ALIGN_CENTER 0x7FFF  
> > 
> > this already exists when including splash.h, I dropped it in v2.  
> 
> Ok, I don't see that splash.h is included in cmd/bmp.c.

In mainline U-Boot it is included, please see [1].

 
> In fact I hesitate to move this define in commun bmp include
> (in include/lcd.h with bmp_display prototype for exmaple) 
> to avoid a other double definition:
> 
> common/lcd.c:392 #define BMP_ALIGN_CENTER 0x7FFF
> drivers/video/video_bmp.c:143:#define BMP_ALIGN_CENTER0x7fff
> include/splash.h:78:#define BMP_ALIGN_CENTER  0x7FFF

I've sent a patch cleaning up multiple defines, please see [2].

[1] 
http://git.denx.de/?p=u-boot.git;a=blob;f=cmd/bmp.c;h=02bdf48b4d422ced97dea7587f07d74c0aee6d6e;hb=HEAD#l20
[2] http://patchwork.ozlabs.org/patch/1006354

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


Re: [U-Boot] [PATCH v3 1/1] efi_loader: rework fdt handling in distro boot script

2018-12-03 Thread Alexander Graf


> Am 03.12.2018 um 03:22 schrieb AKASHI Takahiro :
> 
>> On Sun, Dec 02, 2018 at 11:58:45PM +0100, Alexander Graf wrote:
>> 
>> 
>>> On 27.11.18 01:33, AKASHI Takahiro wrote:
>>> The current scenario for default UEFI booting, scan_dev_for_efi, has
>>> several issues:
>>> * load dtb dynamically even if its loacation (device) is not the same
>>>  as BOOTEFI_NAME binary's, (reported by Alex)
>>> * invoke 'bootmgr' only if BOOTEFI_NAME binary does exit even though
>>>  'bootmgr' can and should work independently whether or not the binary
>>>  exist,
>>> * in addition, invoke 'bootmgr' with dynamically-loaded dtb.
>>>  This behavior is not expected. (reported by Alex)
>>> * always assume that a 'fdtfile' variable is defined,
>>>  ("test -e ${devtype} ${devnum}:${distro_bootpart} "${prefix}${efi_fdtfile}"
>>>  always returns true even if fdtfile is NULL with prefix=="/".)
>>> * redundantly check for 'fdt_addr_r' in boot_efi_binary
>>> 
>>> In this patch, all the issues above are sorted out.
>>> Please note that the default behavior can be customized with:
>>>fdtfile: a dtb file name
>>>efi_dtb_prefixes: a list of paths for searching for a dtb file
>>> 
>>> (this feature does work even without this patch.)
>>> 
>>> Signed-off-by: AKASHI Takahiro 
>>> ---
>>> include/config_distro_bootcmd.h | 38 +
>>> 1 file changed, 20 insertions(+), 18 deletions(-)
>>> 
>>> diff --git a/include/config_distro_bootcmd.h 
>>> b/include/config_distro_bootcmd.h
>>> index 373fee78a999..256698309eb9 100644
>>> --- a/include/config_distro_bootcmd.h
>>> +++ b/include/config_distro_bootcmd.h
>>> @@ -115,7 +115,7 @@
>>>  */
>>> #define BOOTENV_EFI_SET_FDTFILE_FALLBACK  \
>>>"if test -z \"${fdtfile}\" -a -n \"${soc}\"; then "   \
>>> -  "setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; "   \
>>> +  "efi_fdtfile=${soc}-${board}${boardver}.dtb; "   \
>>>"fi; "
>>> #else
>>> #define BOOTENV_EFI_SET_FDTFILE_FALLBACK
>>> @@ -124,26 +124,20 @@
>>> 
>>> #define BOOTENV_SHARED_EFI\
>>>"boot_efi_binary="\
>>> -"if fdt addr ${fdt_addr_r}; then "\
>>> -"bootefi bootmgr ${fdt_addr_r};"  \
>>> -"else "   \
>>> -"bootefi bootmgr ${fdtcontroladdr};"  \
>>> -"fi;" \
>>>"load ${devtype} ${devnum}:${distro_bootpart} "   \
>>>"${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; "  \
>>> -"if fdt addr ${fdt_addr_r}; then "\
>>> -"bootefi ${kernel_addr_r} ${fdt_addr_r};" \
>>> -"else "   \
>>> -"bootefi ${kernel_addr_r} ${fdtcontroladdr};" \
>>> -"fi\0"\
>>> +"bootefi ${kernel_addr_r} ${efi_fdt_addr};\0"  \
>>>\
>>>"load_efi_dtb="   \
>>> -"load ${devtype} ${devnum}:${distro_bootpart} "   \
>>> -"${fdt_addr_r} ${prefix}${efi_fdtfile}\0" \
>>> +"load ${devtype} ${devnum}:${distro_bootpart} "  \
>>> +"${fdt_addr_r} ${prefix}${efi_fdtfile}; "  \
>>> +"if fdt addr ${fdt_addr_r}; then "  \
>>> +"efi_fdt_addr=${fdt_addr_r}; "  \
>>> +"fi;\0"  \
>>>\
>>>"efi_dtb_prefixes=/ /dtb/ /dtb/current/\0"\
>>> -"scan_dev_for_efi="   \
>>> -"setenv efi_fdtfile ${fdtfile}; " \
>>> +"set_efi_fdt_addr="  \
>>> +"efi_fdtfile=${fdtfile}; " \
>>>BOOTENV_EFI_SET_FDTFILE_FALLBACK  \
>>>"for prefix in ${efi_dtb_prefixes}; do "  \
>>>"if test -e ${devtype} "  \
>>> @@ -151,19 +145,26 @@
>>>"${prefix}${efi_fdtfile}; then "  \
>>>"run load_efi_dtb; "  \
>>>"fi;" \
>>> -"done;"   \
>>> +"done;\0"   \
>>> +\
>>> +"scan_dev_for_efi="   \
>>>"if test -e ${devtype} ${devnum}:${distro_bootpart} " \
>>>"efi/boot/"BOOTEFI_NAME"; then "  \
>>>"echo Found EFI removable media binary "  \
>>>"efi/boot/"BOOTEFI_NAME"; "   \
>>> +"efi_fdt_addr=${fdtcontroladd

[U-Boot] [PATCH 2/2] nand: vybrid: Extend the vf610 NFC NAND driver to support device tree (and DM)

2018-12-03 Thread Lukasz Majewski
This commit adds support for device tree and enumeration via device model
for the Vybrid's NFC NAND driver.

Signed-off-by: Lukasz Majewski 
---

 drivers/mtd/nand/raw/vf610_nfc.c | 47 
 1 file changed, 47 insertions(+)

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index 619d0403e9..fce7e5f299 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -31,6 +31,11 @@
 #include 
 #include 
 #include 
+#if CONFIG_NAND_VF610_NFC_DT
+#include 
+#include 
+#include 
+#endif
 
 /* Register Offsets */
 #define NFC_FLASH_CMD1 0x3F00
@@ -760,9 +765,51 @@ error:
return err;
 }
 
+#if CONFIG_NAND_VF610_NFC_DT
+static const struct udevice_id vf610_nfc_dt_ids[] = {
+   {
+   .compatible = "fsl,vf610-nfc",
+   },
+   { /* sentinel */ }
+};
+
+static int vf610_nfc_dt_probe(struct udevice *dev)
+{
+   struct resource res;
+   int ret;
+
+   ret = dev_read_resource(dev, 0, &res);
+   if (ret)
+   return ret;
+
+   return vf610_nfc_nand_init(0, devm_ioremap(dev, res.start,
+  resource_size(&res)));
+}
+
+U_BOOT_DRIVER(vf610_nfc_dt) = {
+   .name = "vf610-nfc-dt",
+   .id = UCLASS_MTD,
+   .of_match = vf610_nfc_dt_ids,
+   .probe = vf610_nfc_dt_probe,
+};
+
+void board_nand_init(void)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_get_device_by_driver(UCLASS_MTD,
+ DM_GET_DRIVER(vf610_nfc_dt),
+ &dev);
+   if (ret && ret != -ENODEV)
+   pr_err("Failed to initialize NAND controller. (error %d)\n",
+  ret);
+}
+#else
 void board_nand_init(void)
 {
int err = vf610_nfc_nand_init(0, (void __iomem *)CONFIG_SYS_NAND_BASE);
if (err)
printf("VF610 NAND init failed (err %d)\n", err);
 }
+#endif /* CONFIG_NAND_VF610_NFC_DT */
-- 
2.11.0

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


[U-Boot] [PATCH 1/2] Kconfig: Add entry for VF610 NAND NFC device tree aware driver

2018-12-03 Thread Lukasz Majewski
This commit provides code to add proper entry to Kconfig to enable
support for VF610 device tree aware driver.

Signed-off-by: Lukasz Majewski 

---

 drivers/mtd/nand/raw/Kconfig | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 008f7b4b4b..fd1723feda 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -88,6 +88,15 @@ config NAND_VF610_NFC
  The driver supports a maximum 2k page size. The driver
  currently does not support hardware ECC.
 
+if NAND_VF610_NFC
+
+config NAND_VF610_NFC_DT
+bool "Support Vybrid's vf610 NAND controller as a DT device"
+depends on OF_CONTROL && MTD
+help
+  Enable the driver for Vybrid's vf610 NAND flash on platforms
+ using device tree.
+
 choice
prompt "Hardware ECC strength"
depends on NAND_VF610_NFC
@@ -103,6 +112,8 @@ config SYS_NAND_VF610_NFC_60_ECC_BYTES
 
 endchoice
 
+endif
+
 config NAND_PXA3XX
bool "Support for NAND on PXA3xx and Armada 370/XP/38x"
select SYS_NAND_SELF_INIT
-- 
2.11.0

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


[U-Boot] [PATCH 0/5] Update STM32 gpio and pinctrl drivers

2018-12-03 Thread Patrice Chotard

This series adds:
- Add gpio holes management in gpio and pinctrl drivers
- Remove useless CONFIG_CLK flag from gpio driver
- Move code outside pinctrl probe()

There is a dependency with 
http://patchwork.ozlabs.org/project/uboot/list/?series=78259
which must be applied first.



Patrice Chotard (5):
  pinctrl: stm32: Move gpio_dev list filling outside probe()
  gpio: stm32f7: Add gpio bank holes management
  gpio: stm32f7: Move STM32_GPIOS_PER_BANK into gpio.h
  gpio: stm32f7: Remove CONFIG_CLK flag.
  pinctrl: stm32: Update stm32_pinctrl_get_gpio_dev()

 arch/arm/include/asm/arch-stm32/gpio.h|   5 ++
 arch/arm/mach-stm32mp/include/mach/gpio.h |   6 ++
 drivers/gpio/stm32f7_gpio.c   | 104 -
 drivers/pinctrl/pinctrl_stm32.c   | 105 ++
 4 files changed, 159 insertions(+), 61 deletions(-)

-- 
1.9.1

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


[U-Boot] [PATCH 1/5] pinctrl: stm32: Move gpio_dev list filling outside probe()

2018-12-03 Thread Patrice Chotard
Move gpio_dev list filling outside probe() to speed-up U-boot
boot sequence execution. This list is populated only when needed.

Signed-off-by: Patrice Chotard 
---

 drivers/pinctrl/pinctrl_stm32.c | 63 +
 1 file changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index bb63da373900..aa92c90b8997 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -54,6 +54,39 @@ static int stm32_pinctrl_get_af(struct udevice *dev, 
unsigned int offset)
return af;
 }
 
+static int stm32_populate_gpio_dev_list(struct udevice *dev)
+{
+   struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
+   struct udevice *gpio_dev;
+   struct udevice *child;
+   struct stm32_gpio_bank *gpio_bank;
+   int ret;
+
+   /*
+* parse pin-controller sub-nodes (ie gpio bank nodes) and fill
+* a list with all gpio device reference which belongs to the
+* current pin-controller. This list is used to find pin_name and
+* pin muxing
+*/
+   list_for_each_entry(child, &dev->child_head, sibling_node) {
+   ret = uclass_get_device_by_name(UCLASS_GPIO, child->name,
+   &gpio_dev);
+   if (ret < 0)
+   continue;
+
+   gpio_bank = malloc(sizeof(*gpio_bank));
+   if (!gpio_bank) {
+   dev_err(dev, "Not enough memory\n");
+   return -ENOMEM;
+   }
+
+   gpio_bank->gpio_dev = gpio_dev;
+   list_add_tail(&gpio_bank->list, &priv->gpio_dev);
+   }
+
+   return 0;
+}
+
 static int stm32_pinctrl_get_pins_count(struct udevice *dev)
 {
struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
@@ -67,6 +100,8 @@ static int stm32_pinctrl_get_pins_count(struct udevice *dev)
if (priv->pinctrl_ngpios)
return priv->pinctrl_ngpios;
 
+   if (list_empty(&priv->gpio_dev))
+   stm32_populate_gpio_dev_list(dev);
/*
 * walk through all banks to retrieve the pin-controller
 * pins number
@@ -88,6 +123,9 @@ static struct udevice *stm32_pinctrl_get_gpio_dev(struct 
udevice *dev,
struct gpio_dev_priv *uc_priv;
int first_pin = 0;
 
+   if (list_empty(&priv->gpio_dev))
+   stm32_populate_gpio_dev_list(dev);
+
/* look up for the bank which owns the requested pin */
list_for_each_entry(gpio_bank, &priv->gpio_dev, list) {
uc_priv = dev_get_uclass_priv(gpio_bank->gpio_dev);
@@ -174,35 +212,10 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice 
*dev,
 int stm32_pinctrl_probe(struct udevice *dev)
 {
struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
-   struct udevice *gpio_dev;
-   struct udevice *child;
-   struct stm32_gpio_bank *gpio_bank;
int ret;
 
INIT_LIST_HEAD(&priv->gpio_dev);
 
-   /*
-* parse pin-controller sub-nodes (ie gpio bank nodes) and fill
-* a list with all gpio device reference which belongs to the
-* current pin-controller. This list is used to find pin_name and
-* pin muxing
-*/
-   list_for_each_entry(child, &dev->child_head, sibling_node) {
-   ret = uclass_get_device_by_name(UCLASS_GPIO, child->name,
-   &gpio_dev);
-   if (ret < 0)
-   continue;
-
-   gpio_bank = malloc(sizeof(*gpio_bank));
-   if (!gpio_bank) {
-   dev_err(dev, "Not enough memory\n");
-   return -ENOMEM;
-   }
-
-   gpio_bank->gpio_dev = gpio_dev;
-   list_add_tail(&gpio_bank->list, &priv->gpio_dev);
-   }
-
/* hwspinlock property is optional, just log the error */
ret = hwspinlock_get_by_index(dev, 0, &priv->hws);
if (ret)
-- 
1.9.1

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


[U-Boot] [PATCH 4/5] gpio: stm32f7: Remove CONFIG_CLK flag.

2018-12-03 Thread Patrice Chotard
As all STM32 SoCs supports CONFIG_CLK flag,
it becomes useless in this driver, remove it.

Signed-off-by: Patrice Chotard 
---

 drivers/gpio/stm32f7_gpio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/stm32f7_gpio.c b/drivers/gpio/stm32f7_gpio.c
index 34cdafa1e402..f160b4e68957 100644
--- a/drivers/gpio/stm32f7_gpio.c
+++ b/drivers/gpio/stm32f7_gpio.c
@@ -151,6 +151,7 @@ static int gpio_stm32_probe(struct udevice *dev)
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct ofnode_phandle_args args;
+   struct clk clk;
fdt_addr_t addr;
const char *name;
int ret;
@@ -184,8 +185,6 @@ static int gpio_stm32_probe(struct udevice *dev)
(u32 *)priv->regs, uc_priv->bank_name, uc_priv->gpio_count,
priv->gpio_range);
 
-#ifdef CONFIG_CLK
-   struct clk clk;
ret = clk_get_by_index(dev, 0, &clk);
if (ret < 0)
return ret;
@@ -197,7 +196,6 @@ static int gpio_stm32_probe(struct udevice *dev)
return ret;
}
debug("clock enabled for device %s\n", dev->name);
-#endif
 
return 0;
 }
-- 
1.9.1

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


[U-Boot] [PATCH 2/5] gpio: stm32f7: Add gpio bank holes management

2018-12-03 Thread Patrice Chotard
In some STM32 SoC packages, GPIO bank has not always 16 gpios.
Several cases can occur, gpio hole can be located at the beginning,
middle or end of the gpio bank or a combination of these 3
configurations.

For that, gpio bindings offer the gpio-ranges DT property which
described the gpio bank mapping.

Signed-off-by: Patrice Chotard 
---

 arch/arm/include/asm/arch-stm32/gpio.h|  3 +
 arch/arm/mach-stm32mp/include/mach/gpio.h |  4 ++
 drivers/gpio/stm32f7_gpio.c   | 99 ++-
 3 files changed, 92 insertions(+), 14 deletions(-)

diff --git a/arch/arm/include/asm/arch-stm32/gpio.h 
b/arch/arm/include/asm/arch-stm32/gpio.h
index 84859b144795..8ba15b735596 100644
--- a/arch/arm/include/asm/arch-stm32/gpio.h
+++ b/arch/arm/include/asm/arch-stm32/gpio.h
@@ -109,6 +109,9 @@ struct stm32_gpio_regs {
 
 struct stm32_gpio_priv {
struct stm32_gpio_regs *regs;
+   unsigned int gpio_range;
 };
 
+int stm32_offset_to_index(struct udevice *dev, unsigned int offset);
+
 #endif /* _GPIO_H_ */
diff --git a/arch/arm/mach-stm32mp/include/mach/gpio.h 
b/arch/arm/mach-stm32mp/include/mach/gpio.h
index 5151150b8d88..46bef21f79f3 100644
--- a/arch/arm/mach-stm32mp/include/mach/gpio.h
+++ b/arch/arm/mach-stm32mp/include/mach/gpio.h
@@ -110,5 +110,9 @@ struct stm32_gpio_regs {
 
 struct stm32_gpio_priv {
struct stm32_gpio_regs *regs;
+   unsigned int gpio_range;
 };
+
+int stm32_offset_to_index(struct udevice *dev, unsigned int offset);
+
 #endif /* _STM32_GPIO_H_ */
diff --git a/drivers/gpio/stm32f7_gpio.c b/drivers/gpio/stm32f7_gpio.c
index a690c437ebc6..3c9477ff 100644
--- a/drivers/gpio/stm32f7_gpio.c
+++ b/drivers/gpio/stm32f7_gpio.c
@@ -20,12 +20,41 @@
 #define MODE_BITS_MASK 3
 #define BSRR_BIT(gpio_pin, value)  BIT(gpio_pin + (value ? 0 : 16))
 
+/*
+ * convert gpio offset to gpio index taking into account gpio holes
+ * into gpio bank
+ */
+int stm32_offset_to_index(struct udevice *dev, unsigned int offset)
+{
+   struct stm32_gpio_priv *priv = dev_get_priv(dev);
+   int idx = 0;
+   int i;
+
+   for (i = 0; i < STM32_GPIOS_PER_BANK; i++) {
+   if (priv->gpio_range & BIT(i)) {
+   if (idx == offset)
+   return idx;
+   idx++;
+   }
+   }
+   /* shouldn't happen */
+   return -EINVAL;
+}
+
 static int stm32_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct stm32_gpio_regs *regs = priv->regs;
-   int bits_index = MODE_BITS(offset);
-   int mask = MODE_BITS_MASK << bits_index;
+   int bits_index;
+   int mask;
+   int idx;
+
+   idx = stm32_offset_to_index(dev, offset);
+   if (idx < 0)
+   return idx;
+
+   bits_index = MODE_BITS(idx);
+   mask = MODE_BITS_MASK << bits_index;
 
clrsetbits_le32(®s->moder, mask, STM32_GPIO_MODE_IN << bits_index);
 
@@ -37,12 +66,20 @@ static int stm32_gpio_direction_output(struct udevice *dev, 
unsigned offset,
 {
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct stm32_gpio_regs *regs = priv->regs;
-   int bits_index = MODE_BITS(offset);
-   int mask = MODE_BITS_MASK << bits_index;
+   int bits_index;
+   int mask;
+   int idx;
+
+   idx = stm32_offset_to_index(dev, offset);
+   if (idx < 0)
+   return idx;
+
+   bits_index = MODE_BITS(idx);
+   mask = MODE_BITS_MASK << bits_index;
 
clrsetbits_le32(®s->moder, mask, STM32_GPIO_MODE_OUT << bits_index);
 
-   writel(BSRR_BIT(offset, value), ®s->bsrr);
+   writel(BSRR_BIT(idx, value), ®s->bsrr);
 
return 0;
 }
@@ -51,16 +88,26 @@ static int stm32_gpio_get_value(struct udevice *dev, 
unsigned offset)
 {
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct stm32_gpio_regs *regs = priv->regs;
+   int idx;
+
+   idx = stm32_offset_to_index(dev, offset);
+   if (idx < 0)
+   return idx;
 
-   return readl(®s->idr) & BIT(offset) ? 1 : 0;
+   return readl(®s->idr) & BIT(idx) ? 1 : 0;
 }
 
 static int stm32_gpio_set_value(struct udevice *dev, unsigned offset, int 
value)
 {
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct stm32_gpio_regs *regs = priv->regs;
+   int idx;
 
-   writel(BSRR_BIT(offset, value), ®s->bsrr);
+   idx = stm32_offset_to_index(dev, offset);
+   if (idx < 0)
+   return idx;
+
+   writel(BSRR_BIT(idx, value), ®s->bsrr);
 
return 0;
 }
@@ -69,10 +116,18 @@ static int stm32_gpio_get_function(struct udevice *dev, 
unsigned int offset)
 {
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct stm32_gpio_regs *regs = priv->regs;
-   int bits_index = MODE_BITS(offset);
-   int mask = MODE_BITS_MASK << bits_index;
+   int bits_index;
+   int mask;
+   

[U-Boot] [PATCH 5/5] pinctrl: stm32: Update stm32_pinctrl_get_gpio_dev()

2018-12-03 Thread Patrice Chotard
Due to gpio holes management, stm32_pinctrl_get_gpio_dev() must
be updated.

stm32_pinctrl_get_gpio_dev() returns from a given pin selectors
the corresponding bank gpio device and the gpio_offset inside this
gpio bank.

Update also all functions which makes usage of stm32_pinctrl_get_gpio_dev.

Signed-off-by: Patrice Chotard 
---

 drivers/pinctrl/pinctrl_stm32.c | 42 +++--
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index aa92c90b8997..24affe0414ce 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -28,8 +28,6 @@ struct stm32_gpio_bank {
 
 #ifndef CONFIG_SPL_BUILD
 
-#define MAX_PIN_PER_BANK   16
-
 static char pin_name[PINNAME_SIZE];
 #define PINMUX_MODE_COUNT  5
 static const char * const pinmux_mode[PINMUX_MODE_COUNT] = {
@@ -116,12 +114,13 @@ static int stm32_pinctrl_get_pins_count(struct udevice 
*dev)
 }
 
 static struct udevice *stm32_pinctrl_get_gpio_dev(struct udevice *dev,
- unsigned int selector)
+ unsigned int selector,
+ unsigned int *idx)
 {
struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
struct stm32_gpio_bank *gpio_bank;
struct gpio_dev_priv *uc_priv;
-   int first_pin = 0;
+   int pin_count = 0;
 
if (list_empty(&priv->gpio_dev))
stm32_populate_gpio_dev_list(dev);
@@ -130,11 +129,19 @@ static struct udevice *stm32_pinctrl_get_gpio_dev(struct 
udevice *dev,
list_for_each_entry(gpio_bank, &priv->gpio_dev, list) {
uc_priv = dev_get_uclass_priv(gpio_bank->gpio_dev);
 
-   if (selector < (first_pin + uc_priv->gpio_count))
-   /* we found the bank */
-   return gpio_bank->gpio_dev;
+   if (selector < (pin_count + uc_priv->gpio_count)) {
+   /*
+* we found the bank, convert pin selector to
+* gpio bank index
+*/
+   *idx = stm32_offset_to_index(gpio_bank->gpio_dev,
+selector - pin_count);
+   if (*idx < 0)
+   return NULL;
 
-   first_pin += uc_priv->gpio_count;
+   return gpio_bank->gpio_dev;
+   }
+   pin_count += uc_priv->gpio_count;
}
 
return NULL;
@@ -145,9 +152,10 @@ static const char *stm32_pinctrl_get_pin_name(struct 
udevice *dev,
 {
struct gpio_dev_priv *uc_priv;
struct udevice *gpio_dev;
+   unsigned int gpio_idx;
 
/* look up for the bank which owns the requested pin */
-   gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector);
+   gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector, &gpio_idx);
if (!gpio_dev) {
snprintf(pin_name, PINNAME_SIZE, "Error");
} else {
@@ -155,7 +163,7 @@ static const char *stm32_pinctrl_get_pin_name(struct 
udevice *dev,
 
snprintf(pin_name, PINNAME_SIZE, "%s%d",
 uc_priv->bank_name,
-selector % MAX_PIN_PER_BANK);
+gpio_idx);
}
 
return pin_name;
@@ -168,23 +176,21 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice 
*dev,
 {
struct udevice *gpio_dev;
const char *label;
-   int gpio_pin;
int mode;
int af_num;
+   unsigned int gpio_idx;
 
/* look up for the bank which owns the requested pin */
-   gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector);
+   gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector, &gpio_idx);
 
if (!gpio_dev)
return -ENODEV;
 
-   /* translate pin-controller pin number to gpio pin number */
-   gpio_pin = selector % MAX_PIN_PER_BANK;
+   mode = gpio_get_raw_function(gpio_dev, gpio_idx, &label);
 
-   mode = gpio_get_raw_function(gpio_dev, gpio_pin, &label);
+   dev_dbg(dev, "selector = %d gpio_idx = %d mode = %d\n",
+   selector, gpio_idx, mode);
 
-   dev_dbg(dev, "selector = %d gpio_pin = %d mode = %d\n",
-   selector, gpio_pin, mode);
 
switch (mode) {
case GPIOF_UNKNOWN:
@@ -194,7 +200,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
snprintf(buf, size, "%s", pinmux_mode[mode]);
break;
case GPIOF_FUNC:
-   af_num = stm32_pinctrl_get_af(gpio_dev, gpio_pin);
+   af_num = stm32_pinctrl_get_af(gpio_dev, gpio_idx);
snprintf(buf, size, "%s %d", pinmux_mode[mode], af_num);
break;
case GPIOF_OUTPUT:
-- 
1.9.1

_

[U-Boot] [PATCH 3/5] gpio: stm32f7: Move STM32_GPIOS_PER_BANK into gpio.h

2018-12-03 Thread Patrice Chotard
To allow access to this define by other driver, move
it into gpio.h

Signed-off-by: Patrice Chotard 
---

 arch/arm/include/asm/arch-stm32/gpio.h| 2 ++
 arch/arm/mach-stm32mp/include/mach/gpio.h | 2 ++
 drivers/gpio/stm32f7_gpio.c   | 1 -
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-stm32/gpio.h 
b/arch/arm/include/asm/arch-stm32/gpio.h
index 8ba15b735596..570e80a6ba80 100644
--- a/arch/arm/include/asm/arch-stm32/gpio.h
+++ b/arch/arm/include/asm/arch-stm32/gpio.h
@@ -7,6 +7,8 @@
 #ifndef _GPIO_H_
 #define _GPIO_H_
 
+#define STM32_GPIOS_PER_BANK   16
+
 enum stm32_gpio_port {
STM32_GPIO_PORT_A = 0,
STM32_GPIO_PORT_B,
diff --git a/arch/arm/mach-stm32mp/include/mach/gpio.h 
b/arch/arm/mach-stm32mp/include/mach/gpio.h
index 46bef21f79f3..5ca76d21ff1e 100644
--- a/arch/arm/mach-stm32mp/include/mach/gpio.h
+++ b/arch/arm/mach-stm32mp/include/mach/gpio.h
@@ -8,6 +8,8 @@
 #define _STM32_GPIO_H_
 #include 
 
+#define STM32_GPIOS_PER_BANK   16
+
 enum stm32_gpio_port {
STM32_GPIO_PORT_A = 0,
STM32_GPIO_PORT_B,
diff --git a/drivers/gpio/stm32f7_gpio.c b/drivers/gpio/stm32f7_gpio.c
index 3c9477ff..34cdafa1e402 100644
--- a/drivers/gpio/stm32f7_gpio.c
+++ b/drivers/gpio/stm32f7_gpio.c
@@ -15,7 +15,6 @@
 #include 
 #include 
 
-#define STM32_GPIOS_PER_BANK   16
 #define MODE_BITS(gpio_pin)(gpio_pin * 2)
 #define MODE_BITS_MASK 3
 #define BSRR_BIT(gpio_pin, value)  BIT(gpio_pin + (value ? 0 : 16))
-- 
1.9.1

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


[U-Boot] ensure active menuitem is inside menu

2018-12-03 Thread Frank Wunderlich
Hi,

setting active menuitem currently can be outside of menu which results in 
invisible selection

attached Patch fixes this

regards Frank>From 1d9c4cb8b3e2dd9b0a7a6a2d4a21684d0a099dbf Mon Sep 17 00:00:00 2001
From: Frank Wunderlich 
Date: Sun, 2 Dec 2018 11:23:53 +0100
Subject: [PATCH] ensure active menuitem is inside menu

if active menuitem is defined via environment var it can be outside the menu (>=menuitem-count)

this patch resets this definition back to 0

Signed-off-by: Frank Wunderlich 
---
 cmd/bootmenu.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 979ac4a638..7f88c1ed63 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -351,6 +351,12 @@ static struct bootmenu_data *bootmenu_create(int delay)
 	}
 
 	menu->count = i;
+
+	if ((menu->active >= menu->count)||(menu->active < 0)) { //ensure active menuitem is inside menu
+		printf("active menuitem (%d) is outside menu (0..%d)\n",menu->active,menu->count-1);
+		menu->active=0;
+	}
+
 	return menu;
 
 cleanup:
-- 
2.17.1

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


Re: [U-Boot] [PATCH v7 4/4] RISC-V: Add S-mode timer implementation

2018-12-03 Thread Anup Patel
On Mon, Dec 3, 2018 at 2:16 PM Bin Meng  wrote:
>
> Hi Anup,
>
> On Mon, Dec 3, 2018 at 4:12 PM Anup Patel  wrote:
> >
> > On Mon, Dec 3, 2018 at 1:27 PM Bin Meng  wrote:
> > >
> > > Hi Anup,
> > >
> > > On Mon, Dec 3, 2018 at 3:44 PM Anup Patel  wrote:
> > > >
> > > > On Mon, Dec 3, 2018 at 1:08 PM Bin Meng  wrote:
> > > > >
> > > > > Hi Anup,
> > > > >
> > > > > On Mon, Dec 3, 2018 at 3:31 PM Anup Patel  wrote:
> > > > > >
> > > > > > On Mon, Dec 3, 2018 at 12:56 PM Bin Meng  wrote:
> > > > > > >
> > > > > > > Hi Anup,
> > > > > > >
> > > > > > > On Mon, Dec 3, 2018 at 3:19 PM Anup Patel  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > On Mon, Dec 3, 2018 at 12:32 PM Bin Meng  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > Hi Anup,
> > > > > > > > >
> > > > > > > > > On Mon, Dec 3, 2018 at 2:43 PM Anup Patel 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > > On Mon, Dec 3, 2018 at 12:06 PM Bin Meng 
> > > > > > > > > >  wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hi Anup,
> > > > > > > > > > >
> > > > > > > > > > > On Mon, Dec 3, 2018 at 1:28 PM Anup Patel 
> > > > > > > > > > >  wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > When running in S-mode, we can use rdtime and rdtimeh 
> > > > > > > > > > > > instructions
> > > > > > > > > > > > for reading timer ticks (just like Linux). The 
> > > > > > > > > > > > frequency of timer
> > > > > > > > > > > > ticks is passed by prior booting stages in 
> > > > > > > > > > > > "timebase-frequency" DT
> > > > > > > > > > > > property of the "/cpus" DT node.
> > > > > > > > > > > >
> > > > > > > > > > > > This patch provides a generic timer implementation for 
> > > > > > > > > > > > U-Boot
> > > > > > > > > > > > running in S-mode. For U-Boot running in M-mode, 
> > > > > > > > > > > > specific timer
> > > > > > > > > > > > drivers will have to be provided.
> > > > > > > > > > > >
> > > > > > > > > > > > Signed-off-by: Anup Patel 
> > > > > > > > > > > > ---
> > > > > > > > > > > >  arch/Kconfig|  1 -
> > > > > > > > > > > >  arch/riscv/Kconfig  | 22 +++
> > > > > > > > > > > >  arch/riscv/lib/Makefile |  1 +
> > > > > > > > > > > >  arch/riscv/lib/time.c   | 60 
> > > > > > > > > > > > +
> > > > > > > > > > > >  4 files changed, 78 insertions(+), 6 deletions(-)
> > > > > > > > > > > >  create mode 100644 arch/riscv/lib/time.c
> > > > > > > > > > > >
> > > > > > > > > > > > diff --git a/arch/Kconfig b/arch/Kconfig
> > > > > > > > > > > > index 9fdd2f7e66..a4fcb3522d 100644
> > > > > > > > > > > > --- a/arch/Kconfig
> > > > > > > > > > > > +++ b/arch/Kconfig
> > > > > > > > > > > > @@ -72,7 +72,6 @@ config RISCV
> > > > > > > > > > > > imply BLK
> > > > > > > > > > > > imply CLK
> > > > > > > > > > > > imply MTD
> > > > > > > > > > > > -   imply TIMER
> > > > > > > > > > >
> > > > > > > > > > > No, please don't do this.
> > > > > > > > > >
> > > > > > > > > > I am removing here but selecting it only for M-mode U-Boot.
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > > imply CMD_DM
> > > > > > > > > > > >
> > > > > > > > > > > >  config SANDBOX
> > > > > > > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > > > > > > > > index 732a357a99..20a060454b 100644
> > > > > > > > > > > > --- a/arch/riscv/Kconfig
> > > > > > > > > > > > +++ b/arch/riscv/Kconfig
> > > > > > > > > > > > @@ -44,6 +44,23 @@ config ARCH_RV64I
> > > > > > > > > > > >
> > > > > > > > > > > >  endchoice
> > > > > > > > > > > >
> > > > > > > > > > > > +choice
> > > > > > > > > > > > +   prompt "Run Mode"
> > > > > > > > > > > > +   default RISCV_MMODE
> > > > > > > > > > > > +
> > > > > > > > > > > > +config RISCV_MMODE
> > > > > > > > > > > > +   bool "Machine"
> > > > > > > > > > > > +   select TIMER
> > > > > > > > > > > > +   help
> > > > > > > > > > > > +  Choose this option to build U-Boot for 
> > > > > > > > > > > > RISC-V M-Mode.
> > > > > > > > > > > > +
> > > > > > > > > > > > +config RISCV_SMODE
> > > > > > > > > > > > +   bool "Supervisor"
> > > > > > > > > > > > +   help
> > > > > > > > > > > > +  Choose this option to build U-Boot for 
> > > > > > > > > > > > RISC-V S-Mode.
> > > > > > > > > > > > +
> > > > > > > > > > > > +endchoice
> > > > > > > > > > > > +
> > > > > > > > > > >
> > > > > > > > > > > The above changes deserve separate patch, or merge that 
> > > > > > > > > > > in the 1st
> > > > > > > > > > > patch in the series.
> > > > > > > > > >
> > > > > > > > > > Sure, I will put Kconfig changes as separate patch.
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > >  config RISCV_ISA_C
> > > > > > > > > > > > bool "Emit compressed instructions"
> > > > > > > > > > > > default y
> > > > > > > > > > > > @@ -55,11 +72,6 @@ config RISCV_ISA_C
> > > > > > > > > > > >  config RISCV_ISA_A
> > > > > > > > > > > > de

Re: [U-Boot] ensure active menuitem is inside menu

2018-12-03 Thread Simon Goldschmidt
On Mon, Dec 3, 2018 at 11:23 AM Frank Wunderlich
 wrote:
>
> Hi,
>
> setting active menuitem currently can be outside of menu which results in 
> invisible selection
>
> attached Patch fixes this

Have you read the section "Submitting Patches" in the README file?

https://github.com/u-boot/u-boot/blob/master/README#L4980

In short, patches should be send inline, not as attachment. I guess
patchwork cannot extract the patches either when sent as attachment.

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


Re: [U-Boot] ensure active menuitem is inside menu

2018-12-03 Thread Frank Wunderlich
Hi

Patchwork had extracted the Patch...

https://patchwork.ozlabs.org/patch/1006783/

but next time i append Patch in the Mail-text

Regards Frank

> Gesendet: Montag, 03. Dezember 2018 um 11:50 Uhr
> Von: "Simon Goldschmidt" 
> An: "Frank Wunderlich" 
> Cc: "U-Boot Mailing List" 
> Betreff: Re: [U-Boot] ensure active menuitem is inside menu
>
> On Mon, Dec 3, 2018 at 11:23 AM Frank Wunderlich
>  wrote:
> >
> > Hi,
> >
> > setting active menuitem currently can be outside of menu which results in 
> > invisible selection
> >
> > attached Patch fixes this
> 
> Have you read the section "Submitting Patches" in the README file?
> 
> https://github.com/u-boot/u-boot/blob/master/README#L4980
> 
> In short, patches should be send inline, not as attachment. I guess
> patchwork cannot extract the patches either when sent as attachment.
> 
> Regards,
> Simon
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RESEND][PATCH] power: regulator: denied disable on always-on regulator

2018-12-03 Thread Felix Brack
On 15.11.2018 13:45, Patrice Chotard wrote:
> From: Patrick Delaunay 
> 
> Don't disable regulator which are tagged as "regulator-always-on" in DT.
> 
> Signed-off-by: Patrick Delaunay 
> Reviewed-by: Simon Glass 
> Reviewed-by: Jack Mitchell 
> Tested-by: Jack Mitchell 
> Signed-off-by: Patrice Chotard 
> ---
> 
>  drivers/power/regulator/regulator-uclass.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/power/regulator/regulator-uclass.c 
> b/drivers/power/regulator/regulator-uclass.c
> index 4da8e43259fc..4511625ff251 100644
> --- a/drivers/power/regulator/regulator-uclass.c
> +++ b/drivers/power/regulator/regulator-uclass.c
> @@ -106,10 +106,15 @@ int regulator_get_enable(struct udevice *dev)
>  int regulator_set_enable(struct udevice *dev, bool enable)
>  {
>   const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
> + struct dm_regulator_uclass_platdata *uc_pdata;
>  
>   if (!ops || !ops->set_enable)
>   return -ENOSYS;
>  
> + uc_pdata = dev_get_uclass_platdata(dev);
> + if (!enable && uc_pdata->always_on)
> + return -EACCES;
> +
>   return ops->set_enable(dev, enable);
>  }
>  
> 
This patch has been around since May 2018 (albeit superseded). A request
from Patrice Chotard to Jaehoon Chung about the patch status change
never got answered. Looking Patchwork I don't see any post from Jaehoon
after May 8. 2018.
Please don't get me wrong: I just want to make sure this patch doesn't
get forgotten, knowing very well, that it was posted (resent) just 2
weeks ago. Expecting quite a few board maintainers to enable DM_MMC in
the coming weeks and months this patch might get important to more
people as it prevents powering off the MMC supply voltage during power
cycling.
If the patch is on someones radar that's fine with me.

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


Re: [U-Boot] ensure active menuitem is inside menu

2018-12-03 Thread Simon Goldschmidt
On Mon, Dec 3, 2018 at 11:58 AM Frank Wunderlich
 wrote:
>
> Hi
>
> Patchwork had extracted the Patch...
>
> https://patchwork.ozlabs.org/patch/1006783/

Oh, sorry then. Somehow I failed to find it :-/

Regards,
Simon

>
> but next time i append Patch in the Mail-text
>
> Regards Frank
>
> > Gesendet: Montag, 03. Dezember 2018 um 11:50 Uhr
> > Von: "Simon Goldschmidt" 
> > An: "Frank Wunderlich" 
> > Cc: "U-Boot Mailing List" 
> > Betreff: Re: [U-Boot] ensure active menuitem is inside menu
> >
> > On Mon, Dec 3, 2018 at 11:23 AM Frank Wunderlich
> >  wrote:
> > >
> > > Hi,
> > >
> > > setting active menuitem currently can be outside of menu which results in 
> > > invisible selection
> > >
> > > attached Patch fixes this
> >
> > Have you read the section "Submitting Patches" in the README file?
> >
> > https://github.com/u-boot/u-boot/blob/master/README#L4980
> >
> > In short, patches should be send inline, not as attachment. I guess
> > patchwork cannot extract the patches either when sent as attachment.
> >
> > Regards,
> > Simon
> >
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] driver/spi: fsl_qspi: Remove non-DM stuff

2018-12-03 Thread Schrempf Frieder
Hi,

On 07.09.18 06:19, Ashish Kumar wrote:
> Convert fsl_qspi.c to complete DM mode.
> 
> Signed-off-by: Ashish Kumar 
> Tested-by: Rajat Srivastava 
> Tested-by: Ye Li 
> ---
> 
> Tested on LS1088ARDB(arm64).
> Tested on LS1021ATWR(arm32) by Rajat
> Tested on i.mx6 and i.mx7 by Ye Li
> 
> Depends on patch series:
> http://patchwork.ozlabs.org/patch/935858/
> http://patchwork.ozlabs.org/patch/935860/

This patch breaks the build if you enable CONFIG_SPL_SPI_SUPPORT. I 
guess that SPL does not use DM for SPI.

How is the SPI support for SPL supposed to work?
Will it use DM in the future?

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


Re: [U-Boot] [PATCH v3 5/5] arc: select BOUNCE_BUFFER for CMD_NAND on AXS10x

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
> The NAND driver of AXS10x depends on the availability of the bounce
> buffer.  As the NAND driver is gated by CMD_NAND only, we need to
> select BOUNCE_BUFFER conditionally (on CMD_NAND) for TARGET_AXS101 and
> TARGET_AXS103.
> 
> Signed-off-by: Philipp Tomsich 
> ---
> 
> Changes in v3: None
> Changes in v2: None
> 
>  arch/arc/Kconfig | 2 ++
>  include/configs/axs10x.h | 4 
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index fa6b344..50369d5 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -146,9 +146,11 @@ config TARGET_NSIM
>  
>  config TARGET_AXS101
>   bool "Support Synopsys Designware SDP board AXS101"
> + select BOUNCE_BUFFER if CMD_NAND
>  
>  config TARGET_AXS103
>   bool "Support Synopsys Designware SDP board AXS103"
> + select BOUNCE_BUFFER if CMD_NAND

I'd say that more appropriate place is "board/synopsys/axs10x/Kconfig".
Because:
 - This is related to the particular board, architecture has nothing to
   do with this
 - Only 1 line of change will be required as both boards use the same
   Kconfig file

>  config TARGET_EMSDP
>   bool "Synopsys EM Software Development Platform"
> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
> index 8febe09..bd1c902 100644
> --- a/include/configs/axs10x.h
> +++ b/include/configs/axs10x.h
> @@ -82,8 +82,4 @@
>   * Console configuration
>   */
>  
> -/*
> - * Misc utility configuration
> - */
> -
>  #endif /* _CONFIG_AXS10X_H_ */

As already mentioned maybe move it to the patch which moves
the option to Kconfig?

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


Re: [U-Boot] [PATCH] rockchip: rk3288: dts: remove 'vmmc' from emmc node

2018-12-03 Thread Fabio Estevam
Hi Kever,

On Mon, Dec 3, 2018 at 2:00 AM Kever Yang  wrote:
>
> The U-Boot eMMC does not need to care about the power for Rockchip
> SoC, because if the board is using eMMC, the power will default on
> (for bootrom), and we do not do power management for it like kernel,
> so the 'vmmc', 'vqmmc' is only useful for SD in U-Boot.

Devicetree should represent the hardware and should not rely on
details of BootROM / kernel / U-Boot.

If these supplies are present in the hardware, they should be
represented in the devicetree.

What is the exact issue you are trying to solve?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC changes

2018-12-03 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 952061352acfd24034e6990b6b7d32cded020c0a:

  drivers: rtc: correctly convert seconds to time structure (2018-12-01 
18:03:14 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-updates-for-2019.01-rc1

for you to fetch changes up to 6ef705b1575045f7b63bf011a0774228159715b2:

  arc: devboards: Implement checkboard() (2018-12-03 14:26:53 +0300)


We introduce much better automatic identification of ARC cores.

 1. Try to match found HW features to known ARC core templates
 2. Print CPU frequency for all ARC boards
 3. Add more board-specific info


Alexey Brodkin (6):
  arc: emsdp: Bump RAM size to 16 Mb
  ARC: Improve identification of ARC cores
  arc: Get rid of board-specific print_cpuinfo()
  arc: emsdp: Read real CPU clock value from hardware
  arc: emsdp: Refactor register and bit accesses
  arc: devboards: Implement checkboard()

 arch/arc/include/asm/arcregs.h |  25 +-
 arch/arc/lib/cpu.c | 200 
+++-
---
 board/synopsys/axs10x/axs10x.c |   8 +
 board/synopsys/emsdp/emsdp.c   |  70 
---
 board/synopsys/hsdk/hsdk.c |   8 ++---
 board/synopsys/iot_devkit/iot_devkit.c |  10 --
 include/configs/emsdp.h|   2 +-
 7 files changed, 274 insertions(+), 49 deletions(-)

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


[U-Boot] [PATCH 00/30] dm: sound: Convert to driver model

2018-12-03 Thread Simon Glass
The sound subsystem has never been converted to driver model. It is not
widely used and is a little bit complicating since it needs an audio
codec, an i2s device and a sound device to bring them together.

Sound is the main subsystem holding back removal of CONFIG_DM_I2C_COMPAT.

This series takes a stab at doing the conversion. So far this is only
tested on snow. I intend to test also on spring and pit/pi when I can.
I do not have smdk5250/5420 or arndale to test with.


Simon Glass (30):
  sandbox: Increase the pre-relocation memory
  snow: Expand U-Boot size
  dm: sound: samsung: Make local function static
  dm: sound: Rename en_sound_codec to sound_codec
  dm: sound: Drop unused pre-device-tree code
  dm: sound: samsung: Rename i2stx_info to samsung_i2s_priv
  dm: sound: Drop codec_type
  dm: sound: wm8994: Pass private data to internal functions
  dm: sound: max98095: Pass private data to internal functions
  dm: sound: wm8994: Create a new common init function
  dm: sound: wm899c: Split out interface setup code
  dm: sound: max98095: Split out interface setup code
  dm: sound: wm8994: Drop global i2c-address variable
  dm: sound: max98095: Drop global i2c-address variable
  dm: sound: wm8994: Drop g_codec_info and g_wm8994_info
  dm: sound: max98095: Drop g_codec_info and g_max98095_info
  dm: sound: wm8994: Drop wm8994_i2c_init()
  dm: sound: Fix up header ordering
  dm: sound: exynos: Correct codec bus address
  dm: sound: Create an option to use driver model for sound
  dm: sound: Rename samsung_i2s_priv to i2s_uc_priv
  dm: sound: Create a uclass for audio codecs
  dm: sound: Create a uclass for i2s
  dm: sound: Create a uclass for sound
  dm: core: Add a function to read into a unsigned int
  dm: sound: Start i2c IDs from 0
  dm: sound: Add conversion to driver model
  dm: exynos: sound: Convert to use driver model
  dm: exynos: Drop CONFIG_DM_I2C_COMPAT
  dm: sound: Complete migration to driver model

 Kconfig   |   2 +
 arch/arm/dts/exynos5250-smdk5250.dts  |  21 +-
 arch/arm/dts/exynos5250-snow.dts  |  25 +-
 arch/arm/dts/exynos5250-spring.dts|  24 +-
 arch/arm/dts/exynos5250.dtsi  |  15 +-
 arch/arm/dts/exynos5420-peach-pit.dts |  24 +-
 arch/arm/dts/exynos5420-smdk5420.dts  |  21 +-
 arch/arm/dts/exynos54xx.dtsi  |   7 +
 arch/sandbox/dts/test.dts |  23 ++
 arch/sandbox/include/asm/test.h   |  40 +++
 cmd/sound.c   |  13 +-
 configs/arndale_defconfig |   1 +
 configs/peach-pi_defconfig|   2 +-
 configs/peach-pit_defconfig   |   2 +-
 configs/sandbox64_defconfig   |   1 -
 configs/sandbox_defconfig |   2 +-
 configs/sandbox_flattree_defconfig|   1 -
 configs/sandbox_noblk_defconfig   |   1 -
 configs/sandbox_spl_defconfig |   1 -
 configs/smdk5250_defconfig|   2 +-
 configs/smdk5420_defconfig|   1 -
 configs/snow_defconfig|   2 +-
 configs/spring_defconfig  |   2 +-
 drivers/core/read.c   |  23 ++
 drivers/sound/Makefile|   5 +-
 drivers/sound/codec-uclass.c  |  26 ++
 drivers/sound/i2s-uclass.c|  25 ++
 drivers/sound/max98095.c  | 316 -
 drivers/sound/max98095.h  |   2 +-
 drivers/sound/samsung-i2s.c   | 139 ++--
 drivers/sound/samsung_sound.c | 104 ++
 drivers/sound/sandbox.c   | 177 +-
 drivers/sound/sound-i2s.c | 208 ---
 drivers/sound/sound-uclass.c  | 129 +++
 drivers/sound/wm8994.c| 475 --
 drivers/sound/wm8994.h|   2 +-
 include/audio_codec.h |  48 +++
 include/dm/read.h |  58 
 include/dm/uclass-id.h|   3 +
 include/i2s.h |  33 +-
 include/sound.h   |  72 +++-
 test/dm/Makefile  |   3 +
 test/dm/audio.c   |  34 ++
 test/dm/i2s.c |  32 ++
 test/dm/sound.c   |  34 ++
 test/dm/test-fdt.c|  35 ++
 46 files changed, 1483 insertions(+), 733 deletions(-)
 create mode 100644 drivers/sound/codec-uclass.c
 create mode 100644 drivers/sound/i2s-uclass.c
 create mode 100644 drivers/sound/samsung_sound.c
 delete mode 100644 drivers/sound/sound-i2s.c
 create mode 100644 drivers/sound/sound-uclass.c
 create mode 100644 include/audio_codec.h
 create mode 100644 test/dm/audio.c
 create mode 100644 test/dm/i2s.c
 create mode 100644 test/dm/sound.c

-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 06/30] dm: sound: samsung: Rename i2stx_info to samsung_i2s_priv

2018-12-03 Thread Simon Glass
This struct is only used by the Samsung I2C driver and should move into
that driver. For now, rename it so it is clear that is driver-private
info.

Signed-off-by: Simon Glass 
---

 drivers/sound/samsung-i2s.c |  6 +++---
 drivers/sound/sound-i2s.c   | 10 +-
 include/i2s.h   |  8 
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c
index 8f5cd191a2b..7f4388137a5 100644
--- a/drivers/sound/samsung-i2s.c
+++ b/drivers/sound/samsung-i2s.c
@@ -255,8 +255,8 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, 
unsigned int blc)
return 0;
 }
 
-int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned int *data,
-   unsigned long data_size)
+int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data,
+unsigned long data_size)
 {
int i;
int start;
@@ -293,7 +293,7 @@ int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, 
unsigned int *data,
return 0;
 }
 
-int i2s_tx_init(struct i2stx_info *pi2s_tx)
+int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx)
 {
int ret;
struct i2s_reg *i2s_reg =
diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c
index f0f0b79bc52..106842a23db 100644
--- a/drivers/sound/sound-i2s.c
+++ b/drivers/sound/sound-i2s.c
@@ -20,15 +20,15 @@
 #define SOUND_400_HZ 400
 #define SOUND_BITS_IN_BYTE 8
 
-static struct i2stx_info g_i2stx_pri;
+static struct samsung_i2s_priv g_i2stx_pri;
 
 /*
  * get_sound_i2s_values gets values for i2s parameters
  *
- * @param i2stx_info   i2s transmitter transfer param structure
+ * @param samsung_i2s_priv i2s transmitter transfer param structure
  * @param blob FDT blob if enabled else NULL
  */
-static int get_sound_i2s_values(struct i2stx_info *i2s, const void *blob)
+static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, const void *blob)
 {
int node;
int error = 0;
@@ -97,7 +97,7 @@ static int get_sound_i2s_values(struct i2stx_info *i2s, const 
void *blob)
  * @param pi2s_tx  i2s parameters required by codec
  * @return  int value, 0 for success
  */
-static int codec_init(const void *blob, struct i2stx_info *pi2s_tx)
+static int codec_init(const void *blob, struct samsung_i2s_priv *pi2s_tx)
 {
int ret;
const char *codectype;
@@ -145,7 +145,7 @@ static int codec_init(const void *blob, struct i2stx_info 
*pi2s_tx)
 int sound_init(const void *blob)
 {
int ret;
-   struct i2stx_info *pi2s_tx = &g_i2stx_pri;
+   struct samsung_i2s_priv *pi2s_tx = &g_i2stx_pri;
 
/* Get the I2S Values */
if (get_sound_i2s_values(pi2s_tx, blob) < 0) {
diff --git a/include/i2s.h b/include/i2s.h
index e6d45ec26d7..800473abd9c 100644
--- a/include/i2s.h
+++ b/include/i2s.h
@@ -76,7 +76,7 @@ struct i2s_reg {
 };
 
 /* This structure stores the i2s related information */
-struct i2stx_info {
+struct samsung_i2s_priv {
unsigned int rfs;   /* LR clock frame size */
unsigned int bfs;   /* Bit slock frame size */
unsigned int audio_pll_clk; /* Audio pll frequency in Hz */
@@ -96,8 +96,8 @@ struct i2stx_info {
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, unsigned *data,
-   unsigned long data_size);
+int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, uint *data,
+unsigned long data_size);
 
 /*
  * Initialise i2s transmiter
@@ -106,6 +106,6 @@ int i2s_transfer_tx_data(struct i2stx_info *pi2s_tx, 
unsigned *data,
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_tx_init(struct i2stx_info *pi2s_tx);
+int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx);
 
 #endif /* __I2S_H__ */
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 01/30] sandbox: Increase the pre-relocation memory

2018-12-03 Thread Simon Glass
This is close to full now, so increase it to avoid problems with adding
more devices.

Signed-off-by: Simon Glass 
---

 Kconfig| 2 ++
 configs/sandbox64_defconfig| 1 -
 configs/sandbox_defconfig  | 1 -
 configs/sandbox_flattree_defconfig | 1 -
 configs/sandbox_noblk_defconfig| 1 -
 configs/sandbox_spl_defconfig  | 1 -
 6 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index dca9bb4e432..477a3c4ae03 100644
--- a/Kconfig
+++ b/Kconfig
@@ -125,6 +125,7 @@ config SYS_BOOT_GET_KBD
 config SYS_MALLOC_F
bool "Enable malloc() pool before relocation"
default y if DM
+
help
  Before relocation, memory is very limited on many platforms. Still,
  we can provide a small malloc() pool if needed. Driver model in
@@ -135,6 +136,7 @@ config SYS_MALLOC_F_LEN
hex "Size of malloc() pool before relocation"
depends on SYS_MALLOC_F
default 0x1000 if AM33XX
+   default 0x2800 if SANDBOX
default 0x400
help
  Before relocation, memory is very limited on many platforms. Still,
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index e6680d9a594..aede14569df 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SANDBOX64=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 5a744f47917..4d65a01dc5b 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEBUG_UART=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 756b839b081..4f3757c8bc5 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_FIT=y
diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig
index e71e2d3860c..6c7d08e42e1 100644
--- a/configs/sandbox_noblk_defconfig
+++ b/configs/sandbox_noblk_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_FIT=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 452a2ef4a50..2f838125289 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -1,7 +1,6 @@
 CONFIG_SYS_TEXT_BASE=0
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_SPL=y
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 04/30] dm: sound: Rename en_sound_codec to sound_codec

2018-12-03 Thread Simon Glass
The en_ prefix is confusing and not needed. Drop it.

Signed-off-by: Simon Glass 
---

 include/sound.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sound.h b/include/sound.h
index 77bfe6a93b2..149e12dbc60 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -8,7 +8,7 @@
 #define __SOUND_H__
 
 /* sound codec enum */
-enum en_sound_codec {
+enum sound_codec {
CODEC_WM_8994,
CODEC_WM_8995,
CODEC_MAX_98095,
@@ -25,7 +25,7 @@ enum sound_compat {
 struct sound_codec_info {
int i2c_bus;
int i2c_dev_addr;
-   enum en_sound_codec codec_type;
+   enum sound_codec codec_type;
 };
 
 /*
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 07/30] dm: sound: Drop codec_type

2018-12-03 Thread Simon Glass
This field is not really used. It is always set to a known value. Drop it
to simplify the code.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 14 --
 drivers/sound/wm8994.c   | 10 --
 include/sound.h  |  9 -
 3 files changed, 33 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index d05c261a399..efaaeb8f3b8 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -24,12 +24,7 @@
 #include "i2s.h"
 #include "max98095.h"
 
-enum max98095_type {
-   MAX98095,
-};
-
 struct max98095_priv {
-   enum max98095_type devtype;
unsigned int sysclk;
unsigned int rate;
unsigned int fmt;
@@ -484,14 +479,6 @@ static int max98095_do_init(struct sound_codec_info 
*pcodec_info,
/* shift the device address by 1 for 7 bit addressing */
g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1;
 
-   if (pcodec_info->codec_type == CODEC_MAX_98095) {
-   g_max98095_info.devtype = MAX98095;
-   } else {
-   debug("%s: Codec id [%d] not defined\n", __func__,
- pcodec_info->codec_type);
-   return -1;
-   }
-
ret = max98095_device_init(&g_max98095_info, aif_id);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
@@ -555,7 +542,6 @@ static int get_max98095_codec_values(struct 
sound_codec_info *pcodec_info,
debug("%s: Unknown compat id %d\n", __func__, compat);
return -1;
}
-   pcodec_info->codec_type = CODEC_MAX_98095;
if (error == -1) {
debug("fail to get max98095 codec node properties\n");
return -1;
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 34bc4eb516f..2e84e92a2e0 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -847,8 +847,6 @@ static int get_codec_values(struct sound_codec_info 
*pcodec_info,
return -1;
}
 
-   pcodec_info->codec_type = CODEC_WM_8994;
-
if (error == -1) {
debug("fail to get wm8994 codec node properties\n");
return -1;
@@ -875,14 +873,6 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
wm8994_i2c_init(pcodec_info->i2c_bus);
 
-   if (pcodec_info->codec_type == CODEC_WM_8994) {
-   g_wm8994_info.type = WM8994;
-   } else {
-   debug("%s: Codec id [%d] not defined\n", __func__,
- pcodec_info->codec_type);
-   return -1;
-   }
-
ret = wm8994_device_init(&g_wm8994_info, aif_id);
if (ret < 0) {
debug("%s: wm8994 codec chip init failed\n", __func__);
diff --git a/include/sound.h b/include/sound.h
index 149e12dbc60..c4ac3193fe7 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -7,14 +7,6 @@
 #ifndef __SOUND_H__
 #define __SOUND_H__
 
-/* sound codec enum */
-enum sound_codec {
-   CODEC_WM_8994,
-   CODEC_WM_8995,
-   CODEC_MAX_98095,
-   CODEC_MAX
-};
-
 /* sound codec enum */
 enum sound_compat {
AUDIO_COMPAT_SPI,
@@ -25,7 +17,6 @@ enum sound_compat {
 struct sound_codec_info {
int i2c_bus;
int i2c_dev_addr;
-   enum sound_codec codec_type;
 };
 
 /*
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 03/30] dm: sound: samsung: Make local function static

2018-12-03 Thread Simon Glass
Several functions are not exported from this file. Make them static so
this is clear.

Signed-off-by: Simon Glass 
---

 drivers/sound/samsung-i2s.c | 8 
 drivers/sound/wm8994.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c
index f39abf5e2a9..8f5cd191a2b 100644
--- a/drivers/sound/samsung-i2s.c
+++ b/drivers/sound/samsung-i2s.c
@@ -111,7 +111,7 @@ static void i2s_set_bitclk_framesize(struct i2s_reg 
*i2s_reg, unsigned bfs)
  * @param flushTx fifo flush command (0x00 - do not flush
  * 0x80 - flush tx fifo)
  */
-void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush)
+static void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush)
 {
/* Flush the FIFO */
setbits_le32(&i2s_reg->fic, flush);
@@ -126,7 +126,7 @@ void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush)
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir)
+static int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir)
 {
unsigned int mod = readl(&i2s_reg->mod);
 
@@ -148,7 +148,7 @@ int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir)
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt)
+static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt)
 {
unsigned int mod = readl(&i2s_reg->mod);
unsigned int tmp = 0;
@@ -225,7 +225,7 @@ int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt)
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc)
+static int i2s_set_samplesize(struct i2s_reg *i2s_reg, unsigned int blc)
 {
unsigned int mod = readl(&i2s_reg->mod);
 
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 3241aa1..e671f6b85ec 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -156,7 +156,7 @@ static int wm8994_update_bits(unsigned int reg, unsigned 
short mask,
  *
  * @return -1 for error and 0  Success.
  */
-int wm8994_set_fmt(int aif_id, unsigned int fmt)
+static int wm8994_set_fmt(int aif_id, unsigned int fmt)
 {
int ms_reg;
int aif_reg;
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 05/30] dm: sound: Drop unused pre-device-tree code

2018-12-03 Thread Simon Glass
CONFIG_OF_CONTROL is enabled for all boards that use sound, so remove the
dead code.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 6 --
 drivers/sound/wm8994.c   | 6 --
 2 files changed, 12 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 7c37bd07015..d05c261a399 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -522,7 +522,6 @@ static int get_max98095_codec_values(struct 
sound_codec_info *pcodec_info,
const void *blob)
 {
int error = 0;
-#if CONFIG_IS_ENABLED(OF_CONTROL)
enum fdt_compat_id compat;
int node;
int parent;
@@ -556,11 +555,6 @@ static int get_max98095_codec_values(struct 
sound_codec_info *pcodec_info,
debug("%s: Unknown compat id %d\n", __func__, compat);
return -1;
}
-#else
-   pcodec_info->i2c_bus = AUDIO_I2C_BUS;
-   pcodec_info->i2c_dev_addr = AUDIO_I2C_REG;
-   debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr);
-#endif
pcodec_info->codec_type = CODEC_MAX_98095;
if (error == -1) {
debug("fail to get max98095 codec node properties\n");
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index e671f6b85ec..34bc4eb516f 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -813,7 +813,6 @@ static int get_codec_values(struct sound_codec_info 
*pcodec_info,
const void *blob)
 {
int error = 0;
-#if CONFIG_IS_ENABLED(OF_CONTROL)
enum fdt_compat_id compat;
int node;
int parent;
@@ -847,11 +846,6 @@ static int get_codec_values(struct sound_codec_info 
*pcodec_info,
debug("%s: Unknown compat id %d\n", __func__, compat);
return -1;
}
-#else
-   pcodec_info->i2c_bus = AUDIO_I2C_BUS;
-   pcodec_info->i2c_dev_addr = AUDIO_I2C_REG;
-   debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr);
-#endif
 
pcodec_info->codec_type = CODEC_WM_8994;
 
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 09/30] dm: sound: max98095: Pass private data to internal functions

2018-12-03 Thread Simon Glass
At present the driver-private data is global. To allow this code to be
used with driver model, change it to pass the data down to each function.
Use the name 'priv' consistently throughout.

Also rename max98095_update_bits() to max98095_bic_or() which is more
descriptive and shorter, thus breaking fewer lines with the parameter
addition.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 152 ---
 1 file changed, 78 insertions(+), 74 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index efaaeb8f3b8..6edf3736d79 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -41,12 +41,14 @@ int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 
32000, 44100, 48000,
 /*
  * Writes value to a device register through i2c
  *
+ * @param priv Private data for driver
  * @param reg  reg number to be write
  * @param data data to be writen to the above registor
  *
  * @return int value 1 for change, 0 for no change or negative error code.
  */
-static int max98095_i2c_write(unsigned int reg, unsigned char data)
+static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg,
+ unsigned char data)
 {
debug("%s: Write Addr : 0x%02X, Data :  0x%02X\n",
  __func__, reg, data);
@@ -56,12 +58,14 @@ static int max98095_i2c_write(unsigned int reg, unsigned 
char data)
 /*
  * Read a value from a device register through i2c
  *
+ * @param priv Private data for driver
  * @param reg  reg number to be read
  * @param data address of read data to be stored
  *
  * @return int value 0 for success, -1 in case of error.
  */
-static unsigned int max98095_i2c_read(unsigned int reg, unsigned char *data)
+static unsigned int max98095_i2c_read(struct max98095_priv *priv,
+ unsigned int reg, unsigned char *data)
 {
int ret;
 
@@ -78,24 +82,25 @@ static unsigned int max98095_i2c_read(unsigned int reg, 
unsigned char *data)
 /*
  * update device register bits through i2c
  *
+ * @param priv Private data for driver
  * @param reg  codec register
  * @param mask register mask
  * @param valuenew value
  *
  * @return int value 0 for success, non-zero error code.
  */
-static int max98095_update_bits(unsigned int reg, unsigned char mask,
-   unsigned char value)
+static int max98095_bic_or(struct max98095_priv *priv, unsigned int reg,
+  unsigned char mask, unsigned char value)
 {
int change, ret = 0;
unsigned char old, new;
 
-   if (max98095_i2c_read(reg, &old) != 0)
+   if (max98095_i2c_read(priv, reg, &old) != 0)
return -1;
new = (old & ~mask) | (value & mask);
change  = (old != new) ? 1 : 0;
if (change)
-   ret = max98095_i2c_write(reg, new);
+   ret = max98095_i2c_write(priv, reg, new);
if (ret < 0)
return ret;
 
@@ -128,13 +133,13 @@ static int rate_value(int rate, u8 *value)
 /*
  * Sets hw params for max98095
  *
- * @param max98095 max98095 information pointer
+ * @param priv max98095 information pointer
  * @param rate Sampling rate
  * @param bits_per_sample  Bits per sample
  *
  * @return -1 for error  and 0  Success.
  */
-static int max98095_hw_params(struct max98095_priv *max98095,
+static int max98095_hw_params(struct max98095_priv *priv,
  enum en_max_audio_interface aif_id,
  unsigned int rate, unsigned int bits_per_sample)
 {
@@ -156,12 +161,12 @@ static int max98095_hw_params(struct max98095_priv 
*max98095,
 
switch (bits_per_sample) {
case 16:
-   error = max98095_update_bits(M98095_DAI_FORMAT,
-M98095_DAI_WS, 0);
+   error = max98095_bic_or(priv, M98095_DAI_FORMAT, M98095_DAI_WS,
+   0);
break;
case 24:
-   error = max98095_update_bits(M98095_DAI_FORMAT,
-M98095_DAI_WS, M98095_DAI_WS);
+   error = max98095_bic_or(priv, M98095_DAI_FORMAT, M98095_DAI_WS,
+   M98095_DAI_WS);
break;
default:
debug("%s: Illegal bits per sample %d.\n",
@@ -174,18 +179,18 @@ static int max98095_hw_params(struct max98095_priv 
*max98095,
  __func__, rate);
return -1;
}
-   max98095->rate = rate;
+   priv->rate = rate;
 
-   error |= max98095_update_bits(M98095_DAI_CLKMODE,
- M98095_CLKMODE_MASK, regval);
+   error |= max98095_bic_or(priv, M98095_DAI_CLKMODE, M98095_CLKMODE_MASK,
+regval);
 
/* Update sample rate mode */
if (rate < 5)
-   error |= max980

[U-Boot] [PATCH 02/30] snow: Expand U-Boot size

2018-12-03 Thread Simon Glass
Now that we have EFI, etc. enabled, U-Boot is larger than it was. Expand
the region allocated for it.

Signed-off-by: Simon Glass 
---

 arch/arm/dts/exynos5250-snow.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts
index 29c13c1257e..e99f6e72bf6 100644
--- a/arch/arm/dts/exynos5250-snow.dts
+++ b/arch/arm/dts/exynos5250-snow.dts
@@ -88,7 +88,7 @@
 
ro-boot {
label = "u-boot";
-   reg = <0x6000 0x9a000>;
+   reg = <0x6000 0xb>;
read-only;
type = "blob boot,dtb";
required;
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 10/30] dm: sound: wm8994: Create a new common init function

2018-12-03 Thread Simon Glass
With driver model we cannot pass in the global struct, but instead want
to pass in the driver-private data. Split some of the code out of
wm8994_init() to handle this.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 56 +-
 1 file changed, 33 insertions(+), 23 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 3f56af9db4b..f83fcf9f430 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -867,44 +867,54 @@ static int get_codec_values(struct sound_codec_info 
*pcodec_info,
return 0;
 }
 
-/* WM8994 Device Initialisation */
-int wm8994_init(const void *blob, enum en_audio_interface aif_id,
-   int sampling_rate, int mclk_freq, int bits_per_sample,
-   unsigned int channels)
+static int _wm8994_init(struct wm8994_priv *priv,
+   enum en_audio_interface aif_id, int sampling_rate,
+   int mclk_freq, int bits_per_sample,
+   unsigned int channels)
 {
-   int ret = 0;
-   struct sound_codec_info *pcodec_info = &g_codec_info;
-
-   /* Get the codec Values */
-   if (get_codec_values(pcodec_info, blob) < 0) {
-   debug("FDT Codec values failed\n");
-   return -1;
-   }
-
-   /* shift the device address by 1 for 7 bit addressing */
-   g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
-   wm8994_i2c_init(pcodec_info->i2c_bus);
+   int ret;
 
-   ret = wm8994_device_init(&g_wm8994_info, aif_id);
+   ret = wm8994_device_init(priv, aif_id);
if (ret < 0) {
debug("%s: wm8994 codec chip init failed\n", __func__);
return ret;
}
 
-   ret =  wm8994_set_sysclk(&g_wm8994_info, aif_id, WM8994_SYSCLK_MCLK1,
-   mclk_freq);
+   ret =  wm8994_set_sysclk(priv, aif_id, WM8994_SYSCLK_MCLK1, mclk_freq);
if (ret < 0) {
debug("%s: wm8994 codec set sys clock failed\n", __func__);
return ret;
}
 
-   ret = wm8994_hw_params(&g_wm8994_info, aif_id, sampling_rate,
-  bits_per_sample, channels);
+   ret = wm8994_hw_params(priv, aif_id, sampling_rate, bits_per_sample,
+  channels);
 
if (ret == 0) {
-   ret = wm8994_set_fmt(&g_wm8994_info, aif_id,
-SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+   ret = wm8994_set_fmt(priv, aif_id, SND_SOC_DAIFMT_I2S |
+SND_SOC_DAIFMT_NB_NF |
 SND_SOC_DAIFMT_CBS_CFS);
}
+
return ret;
 }
+
+/* WM8994 Device Initialisation */
+int wm8994_init(const void *blob, enum en_audio_interface aif_id,
+   int sampling_rate, int mclk_freq, int bits_per_sample,
+   unsigned int channels)
+{
+   struct sound_codec_info *pcodec_info = &g_codec_info;
+
+   /* Get the codec Values */
+   if (get_codec_values(pcodec_info, blob) < 0) {
+   debug("FDT Codec values failed\n");
+   return -1;
+   }
+
+   /* shift the device address by 1 for 7 bit addressing */
+   g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
+   wm8994_i2c_init(pcodec_info->i2c_bus);
+
+   return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq,
+   bits_per_sample, channels);
+}
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 08/30] dm: sound: wm8994: Pass private data to internal functions

2018-12-03 Thread Simon Glass
At present the driver-private data is global. To allow this code to be
used with driver model, change it to pass the data down to each function.
Use the name 'priv' consistently throughout.

Also rename wm8994_update_bits() to wm8994_bic_or() which is more
descriptive and shorter, thus breaking fewer lines with the parameter
addition.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 296 +
 1 file changed, 154 insertions(+), 142 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 2e84e92a2e0..3f56af9db4b 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -77,12 +77,14 @@ static void wm8994_i2c_init(int bus_no)
 /*
  * Writes value to a device register through i2c
  *
+ * @param priv Private data for driver
  * @param reg  reg number to be write
  * @param data data to be writen to the above registor
  *
  * @return int value 1 for change, 0 for no change or negative error code.
  */
-static int wm8994_i2c_write(unsigned int reg, unsigned short data)
+static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg,
+   unsigned short data)
 {
unsigned char val[2];
 
@@ -96,12 +98,14 @@ static int wm8994_i2c_write(unsigned int reg, unsigned 
short data)
 /*
  * Read a value from a device register through i2c
  *
+ * @param priv Private data for driver
  * @param reg  reg number to be read
  * @param data address of read data to be stored
  *
  * @return int value 0 for success, -1 in case of error.
  */
-static unsigned int  wm8994_i2c_read(unsigned int reg , unsigned short *data)
+static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg,
+   unsigned short *data)
 {
unsigned char val[2];
int ret;
@@ -123,6 +127,7 @@ static unsigned int  wm8994_i2c_read(unsigned int reg , 
unsigned short *data)
 /*
  * update device register bits through i2c
  *
+ * @param priv Private data for driver
  * @param reg  codec register
  * @param mask register mask
  * @param valuenew value
@@ -130,18 +135,18 @@ static unsigned int  wm8994_i2c_read(unsigned int reg , 
unsigned short *data)
  * @return int value 1 if change in the register value,
  * 0 for no change or negative error code.
  */
-static int wm8994_update_bits(unsigned int reg, unsigned short mask,
-   unsigned short value)
+static int wm8994_bic_or(struct wm8994_priv *priv, unsigned int reg,
+unsigned short mask, unsigned short value)
 {
int change , ret = 0;
unsigned short old, new;
 
-   if (wm8994_i2c_read(reg, &old) != 0)
+   if (wm8994_i2c_read(priv, reg, &old) != 0)
return -1;
new = (old & ~mask) | (value & mask);
change  = (old != new) ? 1 : 0;
if (change)
-   ret = wm8994_i2c_write(reg, new);
+   ret = wm8994_i2c_write(priv, reg, new);
if (ret < 0)
return ret;
 
@@ -151,12 +156,13 @@ static int wm8994_update_bits(unsigned int reg, unsigned 
short mask,
 /*
  * Sets i2s set format
  *
+ * @param priv wm8994 information
  * @param aif_id   Interface ID
  * @param fmt  i2S format
  *
  * @return -1 for error and 0  Success.
  */
-static int wm8994_set_fmt(int aif_id, unsigned int fmt)
+static int wm8994_set_fmt(struct wm8994_priv *priv, int aif_id, uint fmt)
 {
int ms_reg;
int aif_reg;
@@ -254,12 +260,13 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt)
return -1;
}
 
-   error = wm8994_update_bits(aif_reg, WM8994_AIF1_BCLK_INV |
-   WM8994_AIF1_LRCLK_INV_MASK | WM8994_AIF1_FMT_MASK, aif);
+   error = wm8994_bic_or(priv, aif_reg, WM8994_AIF1_BCLK_INV |
+ WM8994_AIF1_LRCLK_INV_MASK |
+  WM8994_AIF1_FMT_MASK, aif);
 
-   error |= wm8994_update_bits(ms_reg, WM8994_AIF1_MSTR_MASK, ms);
-   error |= wm8994_update_bits(aif_clk, WM8994_AIF1CLK_ENA_MASK,
-   WM8994_AIF1CLK_ENA);
+   error |= wm8994_bic_or(priv, ms_reg, WM8994_AIF1_MSTR_MASK, ms);
+   error |= wm8994_bic_or(priv, aif_clk, WM8994_AIF1CLK_ENA_MASK,
+  WM8994_AIF1CLK_ENA);
if (error < 0) {
debug("%s: codec register access error\n", __func__);
return -1;
@@ -271,7 +278,7 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt)
 /*
  * Sets hw params FOR WM8994
  *
- * @param wm8994   wm8994 information pointer
+ * @param priv wm8994 information pointer
  * @param aif_id   Audio interface ID
  * @param sampling_rateSampling rate
  * @param bits_per_sample  Bits per sample
@@ -279,9 +286,9 @@ static int wm8994_set_fmt(int aif_id, unsigned int fmt)
  *
  * @return -1 for error  

[U-Boot] [PATCH 15/30] dm: sound: wm8994: Drop g_codec_info and g_wm8994_info

2018-12-03 Thread Simon Glass
These are only used in two functions so can be made local.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index a79f46bcc3a..be27e2b1e7e 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -61,9 +61,6 @@ static int bclk_divs[] = {
640, 880, 960, 1280, 1760, 1920
 };
 
-static struct wm8994_priv g_wm8994_info;
-static struct sound_codec_info g_codec_info;
-
 /*
  * Initialise I2C for wm 8994
  *
@@ -909,24 +906,25 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
int sampling_rate, int mclk_freq, int bits_per_sample,
unsigned int channels)
 {
-   struct sound_codec_info *pcodec_info = &g_codec_info;
+   struct sound_codec_info pcodec_info;
+   struct wm8994_priv wm8994_info;
int ret;
 
/* Get the codec Values */
-   if (get_codec_values(pcodec_info, blob) < 0) {
+   if (get_codec_values(&pcodec_info, blob) < 0) {
debug("FDT Codec values failed\n");
return -1;
}
 
/* shift the device address by 1 for 7 bit addressing */
-   g_wm8994_info.i2c_addr = pcodec_info->i2c_dev_addr;
-   wm8994_i2c_init(pcodec_info->i2c_bus);
-   ret = wm8994_device_init(&g_wm8994_info);
+   wm8994_info.i2c_addr = pcodec_info.i2c_dev_addr;
+   wm8994_i2c_init(pcodec_info.i2c_bus);
+   ret = wm8994_device_init(&wm8994_info);
if (ret < 0) {
debug("%s: wm8994 codec chip init failed\n", __func__);
return ret;
}
 
-   return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq,
+   return _wm8994_init(&wm8994_info, aif_id, sampling_rate, mclk_freq,
bits_per_sample, channels);
 }
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 27/30] dm: sound: Add conversion to driver model

2018-12-03 Thread Simon Glass
Move the existing hardware drivers over to use driver model.

Signed-off-by: Simon Glass 
---

 arch/arm/dts/exynos5250-smdk5250.dts |   1 +
 arch/arm/dts/exynos5420-smdk5420.dts |   1 +
 drivers/sound/Makefile   |   6 +-
 drivers/sound/max98095.c |  59 +++-
 drivers/sound/samsung-i2s.c  |  91 +++-
 drivers/sound/samsung_sound.c| 101 +++
 drivers/sound/wm8994.c   |  53 +-
 7 files changed, 306 insertions(+), 6 deletions(-)
 create mode 100644 drivers/sound/samsung_sound.c

diff --git a/arch/arm/dts/exynos5250-smdk5250.dts 
b/arch/arm/dts/exynos5250-smdk5250.dts
index 8b695442b1a..bf60b82d449 100644
--- a/arch/arm/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/dts/exynos5250-smdk5250.dts
@@ -62,6 +62,7 @@
i2c@12C7 {
soundcodec@1a {
reg = <0x1a>;
+   u-boot,i2c-offset-len = <2>;
compatible = "wolfson,wm8994-codec";
};
};
diff --git a/arch/arm/dts/exynos5420-smdk5420.dts 
b/arch/arm/dts/exynos5420-smdk5420.dts
index cab5ddb61fa..daaa4666964 100644
--- a/arch/arm/dts/exynos5420-smdk5420.dts
+++ b/arch/arm/dts/exynos5420-smdk5420.dts
@@ -84,6 +84,7 @@
i2c@12C7 {
soundcodec@1a {
reg = <0x1a>;
+   u-boot,i2c-offset-len = <2>;
compatible = "wolfson,wm8994-codec";
};
};
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index 70d32c6d6f6..75fa31ec534 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -6,9 +6,13 @@
 obj-$(CONFIG_SOUND)+= sound.o
 obj-$(CONFIG_DM_SOUND) += codec-uclass.o
 obj-$(CONFIG_DM_SOUND) += i2s-uclass.o
-obj-$(CONFIG_I2S)  += sound-i2s.o
 obj-$(CONFIG_DM_SOUND) += sound-uclass.o
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung-i2s.o
 obj-$(CONFIG_SOUND_SANDBOX)+= sandbox.o
+ifdef CONFIG_DM_SOUND
+obj-$(CONFIG_I2S_SAMSUNG)  += samsung_sound.o
+else
+obj-$(CONFIG_I2S)  += sound-i2s.o
+endif
 obj-$(CONFIG_SOUND_WM8994) += wm8994.o
 obj-$(CONFIG_SOUND_MAX98095)   += max98095.o
diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 7a3dbd09840..d6710dfaa7a 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -11,6 +11,8 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +30,7 @@ struct max98095_priv {
unsigned int rate;
unsigned int fmt;
int i2c_addr;
+   struct udevice *dev;
 };
 
 /* Index 0 is reserved. */
@@ -48,7 +51,12 @@ static int max98095_i2c_write(struct max98095_priv *priv, 
unsigned int reg,
 {
debug("%s: Write Addr : 0x%02X, Data :  0x%02X\n",
  __func__, reg, data);
+#ifdef CONFIG_DM_SOUND
+   debug("dev = %s\n", priv->dev->name);
+   return dm_i2c_write(priv->dev, reg, &data, 1);
+#else
return i2c_write(priv->i2c_addr, reg, 1, &data, 1);
+#endif
 }
 
 /*
@@ -65,7 +73,11 @@ static unsigned int max98095_i2c_read(struct max98095_priv 
*priv,
 {
int ret;
 
+#ifdef CONFIG_DM_SOUND
+   return dm_i2c_read(priv->dev, reg, data, 1);
+#else
ret = i2c_read(priv->i2c_addr, reg, 1, data, 1);
+#endif
if (ret != 0) {
debug("%s: Error while reading register %#04x\n",
  __func__, reg);
@@ -484,7 +496,7 @@ static int max98095_do_init(struct max98095_priv *priv,
 
ret = max98095_setup_interface(priv, aif_id);
if (ret < 0) {
-   debug("%s: max98095 codec chip init failed\n", __func__);
+   debug("%s: max98095 setup interface failed\n", __func__);
return ret;
}
 
@@ -507,6 +519,7 @@ static int max98095_do_init(struct max98095_priv *priv,
return ret;
 }
 
+#ifndef CONFIG_DM_SOUND
 static int get_max98095_codec_values(struct sound_codec_info *pcodec_info,
const void *blob)
 {
@@ -582,3 +595,47 @@ int max98095_init(const void *blob, enum 
en_max_audio_interface aif_id,
 
return ret;
 }
+#endif
+
+static int max98095_set_params(struct udevice *dev, int interface, int rate,
+  int mclk_freq, int bits_per_sample,
+  uint channels)
+{
+   struct max98095_priv *priv = dev_get_priv(dev);
+
+   return max98095_do_init(priv, interface, rate, mclk_freq,
+   bits_per_sample);
+}
+
+static int max98095_probe(struct udevice *dev)
+{
+   struct max98095_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   priv->dev = dev;
+   ret = max98095_device_init(priv);
+   if (ret < 0) {
+   debug("%s: max98095 codec chip init failed\n", __func__);
+   return ret;
+   }
+
+   return 0;
+}
+
+static const struct audio_codec_ops max98095_ops = {
+   .set_params = max98095_set_params,
+};

[U-Boot] [PATCH 16/30] dm: sound: max98095: Drop g_codec_info and g_max98095_info

2018-12-03 Thread Simon Glass
These are only used in two functions so can be made local.

Also change the first argument of max98095_do_init() to suit.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 2ec67bf24a8..d7313f9ad75 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -31,9 +31,6 @@ struct max98095_priv {
int i2c_addr;
 };
 
-static struct sound_codec_info g_codec_info;
-struct max98095_priv g_max98095_info;
-
 /* Index 0 is reserved. */
 int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
88200, 96000};
@@ -479,31 +476,30 @@ static int max98095_setup_interface(struct max98095_priv 
*priv,
return 0;
 }
 
-static int max98095_do_init(struct sound_codec_info *pcodec_info,
+static int max98095_do_init(struct max98095_priv *priv,
enum en_max_audio_interface aif_id,
int sampling_rate, int mclk_freq,
int bits_per_sample)
 {
int ret = 0;
 
-   ret = max98095_setup_interface(&g_max98095_info, aif_id);
+   ret = max98095_setup_interface(priv, aif_id);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
return ret;
}
 
-   ret = max98095_set_sysclk(&g_max98095_info, mclk_freq);
+   ret = max98095_set_sysclk(priv, mclk_freq);
if (ret < 0) {
debug("%s: max98095 codec set sys clock failed\n", __func__);
return ret;
}
 
-   ret = max98095_hw_params(&g_max98095_info, aif_id, sampling_rate,
+   ret = max98095_hw_params(priv, aif_id, sampling_rate,
 bits_per_sample);
 
if (ret == 0) {
-   ret = max98095_set_fmt(&g_max98095_info,
-  SND_SOC_DAIFMT_I2S |
+   ret = max98095_set_fmt(priv, SND_SOC_DAIFMT_I2S |
   SND_SOC_DAIFMT_NB_NF |
   SND_SOC_DAIFMT_CBS_CFS,
   aif_id);
@@ -564,24 +560,25 @@ int max98095_init(const void *blob, enum 
en_max_audio_interface aif_id,
 {
int ret;
int old_bus = i2c_get_bus_num();
-   struct sound_codec_info *pcodec_info = &g_codec_info;
+   struct sound_codec_info pcodec_info;
+   struct max98095_priv max98095_info;
 
-   if (get_max98095_codec_values(pcodec_info, blob) < 0) {
+   if (get_max98095_codec_values(&pcodec_info, blob) < 0) {
debug("FDT Codec values failed\n");
return -1;
}
 
-   i2c_set_bus_num(pcodec_info->i2c_bus);
+   i2c_set_bus_num(pcodec_info.i2c_bus);
 
/* shift the device address by 1 for 7 bit addressing */
-   g_max98095_info.i2c_addr = pcodec_info->i2c_dev_addr >> 1;
-   ret = max98095_device_init(&g_max98095_info);
+   max98095_info.i2c_addr = pcodec_info.i2c_dev_addr >> 1;
+   ret = max98095_device_init(&max98095_info);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
return ret;
}
 
-   ret = max98095_do_init(pcodec_info, aif_id, sampling_rate, mclk_freq,
+   ret = max98095_do_init(&max98095_info, aif_id, sampling_rate, mclk_freq,
   bits_per_sample);
i2c_set_bus_num(old_bus);
 
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 11/30] dm: sound: wm899c: Split out interface setup code

2018-12-03 Thread Simon Glass
With driver model we want to do a minimal probe when the device is probed
and then set up the codec interface later when a sound is actully played.

Split this setup code out into its own function to help with this.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index f83fcf9f430..20a48231ebd 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -659,8 +659,7 @@ static int wm8994_init_volume_aif1_dac1(struct wm8994_priv 
*priv)
  *
  * @returns -1 for error  and 0 Success.
  */
-static int wm8994_device_init(struct wm8994_priv *priv,
- enum en_audio_interface aif_id)
+static int wm8994_device_init(struct wm8994_priv *priv)
 {
const char *devname;
unsigned short reg_data;
@@ -671,7 +670,7 @@ static int wm8994_device_init(struct wm8994_priv *priv,
ret = wm8994_i2c_read(priv, WM8994_SOFTWARE_RESET, ®_data);
if (ret < 0) {
debug("Failed to read ID register\n");
-   goto err;
+   return ret;
}
 
if (reg_data == WM8994_ID) {
@@ -680,21 +679,28 @@ static int wm8994_device_init(struct wm8994_priv *priv,
priv->type = WM8994;
} else {
debug("Device is not a WM8994, ID is %x\n", ret);
-   ret = -1;
-   goto err;
+   return -ENXIO;
}
 
ret = wm8994_i2c_read(priv, WM8994_CHIP_REVISION, ®_data);
if (ret < 0) {
debug("Failed to read revision register: %d\n", ret);
-   goto err;
+   return ret;
}
priv->revision = reg_data;
debug("%s revision %c\n", devname, 'A' + priv->revision);
 
+   return 0;
+}
+
+static int wm8994_setup_interface(struct wm8994_priv *priv,
+ enum en_audio_interface aif_id)
+{
+   int ret;
+
/* VMID Selection */
-   ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1,
-WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3);
+   ret = wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1,
+   WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3);
 
/* Charge Pump Enable */
ret |= wm8994_bic_or(priv, WM8994_CHARGE_PUMP_1, WM8994_CP_ENA_MASK,
@@ -807,10 +813,10 @@ static int wm8994_device_init(struct wm8994_priv *priv,
if (ret < 0)
goto err;
 
-   debug("%s: Codec chip init ok\n", __func__);
+   debug("%s: Codec chip setup ok\n", __func__);
return 0;
 err:
-   debug("%s: Codec chip init error\n", __func__);
+   debug("%s: Codec chip setup error\n", __func__);
return -1;
 }
 
@@ -874,7 +880,7 @@ static int _wm8994_init(struct wm8994_priv *priv,
 {
int ret;
 
-   ret = wm8994_device_init(priv, aif_id);
+   ret = wm8994_setup_interface(priv, aif_id);
if (ret < 0) {
debug("%s: wm8994 codec chip init failed\n", __func__);
return ret;
@@ -904,6 +910,7 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
unsigned int channels)
 {
struct sound_codec_info *pcodec_info = &g_codec_info;
+   int ret;
 
/* Get the codec Values */
if (get_codec_values(pcodec_info, blob) < 0) {
@@ -914,6 +921,11 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
/* shift the device address by 1 for 7 bit addressing */
g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
wm8994_i2c_init(pcodec_info->i2c_bus);
+   ret = wm8994_device_init(&g_wm8994_info);
+   if (ret < 0) {
+   debug("%s: wm8994 codec chip init failed\n", __func__);
+   return ret;
+   }
 
return _wm8994_init(&g_wm8994_info, aif_id, sampling_rate, mclk_freq,
bits_per_sample, channels);
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 14/30] dm: sound: max98095: Drop global i2c-address variable

2018-12-03 Thread Simon Glass
We can put this in the private structure and avoid a global.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 51556c07f5e..2ec67bf24a8 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -28,11 +28,11 @@ struct max98095_priv {
unsigned int sysclk;
unsigned int rate;
unsigned int fmt;
+   int i2c_addr;
 };
 
 static struct sound_codec_info g_codec_info;
 struct max98095_priv g_max98095_info;
-unsigned int g_max98095_i2c_dev_addr;
 
 /* Index 0 is reserved. */
 int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
@@ -52,7 +52,7 @@ static int max98095_i2c_write(struct max98095_priv *priv, 
unsigned int reg,
 {
debug("%s: Write Addr : 0x%02X, Data :  0x%02X\n",
  __func__, reg, data);
-   return i2c_write(g_max98095_i2c_dev_addr, reg, 1, &data, 1);
+   return i2c_write(priv->i2c_addr, reg, 1, &data, 1);
 }
 
 /*
@@ -69,7 +69,7 @@ static unsigned int max98095_i2c_read(struct max98095_priv 
*priv,
 {
int ret;
 
-   ret = i2c_read(g_max98095_i2c_dev_addr, reg, 1, data, 1);
+   ret = i2c_read(priv->i2c_addr, reg, 1, data, 1);
if (ret != 0) {
debug("%s: Error while reading register %#04x\n",
  __func__, reg);
@@ -574,7 +574,7 @@ int max98095_init(const void *blob, enum 
en_max_audio_interface aif_id,
i2c_set_bus_num(pcodec_info->i2c_bus);
 
/* shift the device address by 1 for 7 bit addressing */
-   g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1;
+   g_max98095_info.i2c_addr = pcodec_info->i2c_dev_addr >> 1;
ret = max98095_device_init(&g_max98095_info);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 22/30] dm: sound: Create a uclass for audio codecs

2018-12-03 Thread Simon Glass
An audio codec provides a way to convert digital data to sound and vice
versa. Add a simple uclass which just supports setting the parameters for
the codec.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/test.dts   |  7 -
 arch/sandbox/include/asm/test.h | 10 ++
 drivers/sound/Makefile  |  1 +
 drivers/sound/codec-uclass.c| 26 
 drivers/sound/sandbox.c | 55 +
 include/audio_codec.h   | 48 
 include/dm/uclass-id.h  |  1 +
 test/dm/Makefile|  1 +
 test/dm/audio.c | 34 
 9 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 drivers/sound/codec-uclass.c
 create mode 100644 include/audio_codec.h
 create mode 100644 test/dm/audio.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 252aa7b6b63..4e4eaa2dceb 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -42,7 +42,12 @@
osd0 = "/osd";
};
 
-   cros_ec: cros-ec {
+   audio: audio-codec {
+   compatible = "sandbox,audio-codec";
+   #sound-dai-cells = <1>;
+   };
+
+   cros_ec: cros-ec {
reg = <0 0>;
compatible = "google,cros-ec-sandbox";
 
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 5e818392959..f70e0d84177 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -121,4 +121,14 @@ int sandbox_pwm_get_config(struct udevice *dev, uint 
channel, uint *period_nsp,
  */
 void sandbox_sf_set_block_protect(struct udevice *dev, int bp_mask);
 
+/**
+ * sandbox_get_codec_params() - Read back codec parameters
+ *
+ * This reads back the parameters set by audio_codec_set_params() for the
+ * sandbox audio driver. Arguments are as for that function.
+ */
+void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep,
+ int *mclk_freqp, int *bits_per_samplep,
+ uint *channelsp);
+
 #endif
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index 696c5aecbe9..ae5fabed846 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -4,6 +4,7 @@
 # R. Chandrasekar 
 
 obj-$(CONFIG_SOUND)+= sound.o
+obj-$(CONFIG_DM_SOUND) += codec-uclass.o
 obj-$(CONFIG_I2S)  += sound-i2s.o
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung-i2s.o
 obj-$(CONFIG_SOUND_SANDBOX)+= sandbox.o
diff --git a/drivers/sound/codec-uclass.c b/drivers/sound/codec-uclass.c
new file mode 100644
index 000..1ec77acfc1c
--- /dev/null
+++ b/drivers/sound/codec-uclass.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+
+int audio_codec_set_params(struct udevice *dev, int interface, int rate,
+  int mclk_freq, int bits_per_sample, uint channels)
+{
+   struct audio_codec_ops *ops = audio_codec_get_ops(dev);
+
+   if (!ops->set_params)
+   return -ENOSYS;
+
+   return ops->set_params(dev, interface, rate, mclk_freq, bits_per_sample,
+  channels);
+}
+
+UCLASS_DRIVER(audio_codec) = {
+   .id = UCLASS_AUDIO_CODEC,
+   .name   = "audio-codec",
+};
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c
index 94eff542824..d24eb9ae9ce 100644
--- a/drivers/sound/sandbox.c
+++ b/drivers/sound/sandbox.c
@@ -4,9 +4,19 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 
+struct sandbox_codec_priv {
+   int interface;
+   int rate;
+   int mclk_freq;
+   int bits_per_sample;
+   uint channels;
+};
+
 int sound_play(uint32_t msec, uint32_t frequency)
 {
sandbox_sdl_sound_start(frequency);
@@ -20,3 +30,48 @@ int sound_init(const void *blob)
 {
return sandbox_sdl_sound_init();
 }
+
+void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep,
+ int *mclk_freqp, int *bits_per_samplep,
+ uint *channelsp)
+{
+   struct sandbox_codec_priv *priv = dev_get_priv(dev);
+
+   *interfacep = priv->interface;
+   *ratep = priv->rate;
+   *mclk_freqp = priv->mclk_freq;
+   *bits_per_samplep = priv->bits_per_sample;
+   *channelsp = priv->channels;
+}
+
+static int sandbox_codec_set_params(struct udevice *dev, int interface,
+   int rate, int mclk_freq,
+   int bits_per_sample, uint channels)
+{
+   struct sandbox_codec_priv *priv = dev_get_priv(dev);
+
+   priv->interface = interface;
+   priv->rate = rate;
+   priv->mclk_freq = mclk_freq;
+   priv->bits_per_sample = bits_per_sample;
+   priv->channels = channels;
+
+   return 0;
+}
+
+static const struct audio_codec_ops sandbox_code

[U-Boot] [PATCH 13/30] dm: sound: wm8994: Drop global i2c-address variable

2018-12-03 Thread Simon Glass
We can put this in the private structure and avoid a global.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 20a48231ebd..a79f46bcc3a 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -38,6 +38,7 @@ struct wm8994_priv {
int mclk[WM8994_MAX_AIF];   /* master clock frequency in Hz */
int aifclk[WM8994_MAX_AIF]; /* audio interface clock in Hz   */
struct wm8994_fll_config fll[2]; /* fll config to configure fll */
+   int i2c_addr;
 };
 
 /* wm 8994 supported sampling rate values */
@@ -61,7 +62,6 @@ static int bclk_divs[] = {
 };
 
 static struct wm8994_priv g_wm8994_info;
-static unsigned char g_wm8994_i2c_dev_addr;
 static struct sound_codec_info g_codec_info;
 
 /*
@@ -92,7 +92,7 @@ static int wm8994_i2c_write(struct wm8994_priv *priv, 
unsigned int reg,
val[1] = (unsigned char)(data & 0xff);
debug("Write Addr : 0x%04X, Data :  0x%04X\n", reg, data);
 
-   return i2c_write(g_wm8994_i2c_dev_addr, reg, 2, val, 2);
+   return i2c_write(priv->i2c_addr, reg, 2, val, 2);
 }
 
 /*
@@ -110,7 +110,7 @@ static unsigned int wm8994_i2c_read(struct wm8994_priv 
*priv, unsigned int reg,
unsigned char val[2];
int ret;
 
-   ret = i2c_read(g_wm8994_i2c_dev_addr, reg, 2, val, 2);
+   ret = i2c_read(priv->i2c_addr, reg, 2, val, 2);
if (ret != 0) {
debug("%s: Error while reading register %#04x\n",
  __func__, reg);
@@ -919,7 +919,7 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
}
 
/* shift the device address by 1 for 7 bit addressing */
-   g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr;
+   g_wm8994_info.i2c_addr = pcodec_info->i2c_dev_addr;
wm8994_i2c_init(pcodec_info->i2c_bus);
ret = wm8994_device_init(&g_wm8994_info);
if (ret < 0) {
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 30/30] dm: sound: Complete migration to driver model

2018-12-03 Thread Simon Glass
All users of sound are converted to use driver model. Drop the old code
and the CONFIG_DM_SOUND option.

Signed-off-by: Simon Glass 
---

 cmd/sound.c   |  12 ---
 drivers/sound/Kconfig |   6 --
 drivers/sound/Makefile|  10 +-
 drivers/sound/max98095.c  |  88 
 drivers/sound/sandbox.c   |  11 --
 drivers/sound/sound-i2s.c | 206 --
 drivers/sound/wm8994.c|  95 --
 include/sound.h   |  11 --
 test/dm/Makefile  |   6 +-
 9 files changed, 6 insertions(+), 439 deletions(-)
 delete mode 100644 drivers/sound/sound-i2s.c

diff --git a/cmd/sound.c b/cmd/sound.c
index b063863bc9a..d00a7738167 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -15,18 +15,12 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Initilaise sound subsystem */
 static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
-#ifdef CONFIG_DM_SOUND
struct udevice *dev;
-#endif
int ret;
 
-#ifdef CONFIG_DM_SOUND
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
if (!ret)
ret = sound_setup(dev);
-#else
-   ret = sound_init(gd->fdt_blob);
-#endif
if (ret) {
printf("Initialise Audio driver failed\n");
return CMD_RET_FAILURE;
@@ -38,9 +32,7 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 /* play sound from buffer */
 static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
-#ifdef CONFIG_DM_SOUND
struct udevice *dev;
-#endif
int ret = 0;
int msec = 1000;
int freq = 400;
@@ -50,13 +42,9 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
if (argc > 2)
freq = simple_strtoul(argv[2], NULL, 10);
 
-#ifdef CONFIG_DM_SOUND
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
if (!ret)
ret = sound_beep(dev, msec, freq);
-#else
-   ret = sound_play(msec, freq);
-#endif
if (ret) {
printf("Sound device failed to play (err=%d)\n", ret);
return CMD_RET_FAILURE;
diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig
index 93f6c36af32..5de86c05c60 100644
--- a/drivers/sound/Kconfig
+++ b/drivers/sound/Kconfig
@@ -12,12 +12,6 @@ config SOUND
  audio codecs are called from the sound-i2s code. This could be
  converted to driver model.
 
-config DM_SOUND
-   bool "Use driver model for sound"
-   help
- Enable this option to use driver model for sound devices. This is a
- migration option and will be removed.
-
 config I2S
bool "Enable I2S support"
depends on SOUND
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index 75fa31ec534..df46a48568b 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -4,15 +4,11 @@
 # R. Chandrasekar 
 
 obj-$(CONFIG_SOUND)+= sound.o
-obj-$(CONFIG_DM_SOUND) += codec-uclass.o
-obj-$(CONFIG_DM_SOUND) += i2s-uclass.o
-obj-$(CONFIG_DM_SOUND) += sound-uclass.o
+obj-$(CONFIG_SOUND)+= codec-uclass.o
+obj-$(CONFIG_SOUND)+= i2s-uclass.o
+obj-$(CONFIG_SOUND)+= sound-uclass.o
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung-i2s.o
 obj-$(CONFIG_SOUND_SANDBOX)+= sandbox.o
-ifdef CONFIG_DM_SOUND
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung_sound.o
-else
-obj-$(CONFIG_I2S)  += sound-i2s.o
-endif
 obj-$(CONFIG_SOUND_WM8994) += wm8994.o
 obj-$(CONFIG_SOUND_MAX98095)   += max98095.o
diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index d6710dfaa7a..fa204bf7a96 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -29,7 +29,6 @@ struct max98095_priv {
unsigned int sysclk;
unsigned int rate;
unsigned int fmt;
-   int i2c_addr;
struct udevice *dev;
 };
 
@@ -51,12 +50,7 @@ static int max98095_i2c_write(struct max98095_priv *priv, 
unsigned int reg,
 {
debug("%s: Write Addr : 0x%02X, Data :  0x%02X\n",
  __func__, reg, data);
-#ifdef CONFIG_DM_SOUND
-   debug("dev = %s\n", priv->dev->name);
return dm_i2c_write(priv->dev, reg, &data, 1);
-#else
-   return i2c_write(priv->i2c_addr, reg, 1, &data, 1);
-#endif
 }
 
 /*
@@ -73,11 +67,7 @@ static unsigned int max98095_i2c_read(struct max98095_priv 
*priv,
 {
int ret;
 
-#ifdef CONFIG_DM_SOUND
return dm_i2c_read(priv->dev, reg, data, 1);
-#else
-   ret = i2c_read(priv->i2c_addr, reg, 1, data, 1);
-#endif
if (ret != 0) {
debug("%s: Error while reading register %#04x\n",
  __func__, reg);
@@ -519,84 +509,6 @@ static int max98095_do_init(struct max98095_priv *priv,
return ret;
 }
 
-#ifndef CONFIG_DM_SOUND
-static int get_max98095_codec_values(struct sound_codec_info *pcodec_info,
-   const void *blob)
-{
-   int error = 0;
-   enum fdt_compat_id compat;
-   int node;
-   int parent;
-
- 

[U-Boot] [PATCH 23/30] dm: sound: Create a uclass for i2s

2018-12-03 Thread Simon Glass
The i2s bus is commonly used with audio codecs. It provides a way to
stream digital data sychronously in both directions. U-Boot only supports
audio output, so this uclass is very simple, with a single tx_data()
method.

Add a uclass and a test for i2s.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/test.dts   |  7 +++-
 arch/sandbox/include/asm/test.h | 10 ++
 drivers/sound/Makefile  |  1 +
 drivers/sound/i2s-uclass.c  | 25 ++
 drivers/sound/sandbox.c | 58 -
 include/dm/uclass-id.h  |  1 +
 include/i2s.h   | 25 ++
 test/dm/Makefile|  1 +
 test/dm/i2s.c   | 32 ++
 9 files changed, 158 insertions(+), 2 deletions(-)
 create mode 100644 drivers/sound/i2s-uclass.c
 create mode 100644 test/dm/i2s.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 4e4eaa2dceb..01ab409b388 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -47,7 +47,7 @@
#sound-dai-cells = <1>;
};
 
-   cros_ec: cros-ec {
+   cros_ec: cros-ec {
reg = <0 0>;
compatible = "google,cros-ec-sandbox";
 
@@ -378,6 +378,11 @@
u-boot,dm-pre-reloc;
};
 
+   i2s: i2s {
+   compatible = "sandbox,i2s";
+   #sound-dai-cells = <1>;
+   };
+
misc-test {
compatible = "sandbox,misc_sandbox";
};
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index f70e0d84177..71bd50bd5bc 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -131,4 +131,14 @@ void sandbox_get_codec_params(struct udevice *dev, int 
*interfacep, int *ratep,
  int *mclk_freqp, int *bits_per_samplep,
  uint *channelsp);
 
+/**
+ * sandbox_get_i2s_sum() - Read back the sum of the audio data so far
+ *
+ * This data is provided to the sandbox driver by the I2S tx_data() method.
+ *
+ * @dev: Device to check
+ * @return sum of audio data
+ */
+int sandbox_get_i2s_sum(struct udevice *dev);
+
 #endif
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index ae5fabed846..4aced9d22b9 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_SOUND)+= sound.o
 obj-$(CONFIG_DM_SOUND) += codec-uclass.o
+obj-$(CONFIG_DM_SOUND) += i2s-uclass.o
 obj-$(CONFIG_I2S)  += sound-i2s.o
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung-i2s.o
 obj-$(CONFIG_SOUND_SANDBOX)+= sandbox.o
diff --git a/drivers/sound/i2s-uclass.c b/drivers/sound/i2s-uclass.c
new file mode 100644
index 000..e2b4b2322dd
--- /dev/null
+++ b/drivers/sound/i2s-uclass.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+
+int i2s_tx_data(struct udevice *dev, uint *data, uint data_size)
+{
+   struct i2s_ops *ops = i2s_get_ops(dev);
+
+   if (!ops->tx_data)
+   return -ENOSYS;
+
+   return ops->tx_data(dev, data, data_size);
+}
+
+UCLASS_DRIVER(i2s) = {
+   .id = UCLASS_I2S,
+   .name   = "i2s",
+   .per_device_auto_alloc_size = sizeof(struct i2s_uc_priv),
+};
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c
index d24eb9ae9ce..59931ec0a12 100644
--- a/drivers/sound/sandbox.c
+++ b/drivers/sound/sandbox.c
@@ -4,8 +4,9 @@
  */
 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -17,6 +18,10 @@ struct sandbox_codec_priv {
uint channels;
 };
 
+struct sandbox_i2s_priv {
+   int sum;/* Use to sum the provided audio data */
+};
+
 int sound_play(uint32_t msec, uint32_t frequency)
 {
sandbox_sdl_sound_start(frequency);
@@ -44,6 +49,13 @@ void sandbox_get_codec_params(struct udevice *dev, int 
*interfacep, int *ratep,
*channelsp = priv->channels;
 }
 
+int sandbox_get_i2s_sum(struct udevice *dev)
+{
+   struct sandbox_i2s_priv *priv = dev_get_priv(dev);
+
+   return priv->sum;
+}
+
 static int sandbox_codec_set_params(struct udevice *dev, int interface,
int rate, int mclk_freq,
int bits_per_sample, uint channels)
@@ -59,6 +71,32 @@ static int sandbox_codec_set_params(struct udevice *dev, int 
interface,
return 0;
 }
 
+static int sandbox_i2s_tx_data(struct udevice *dev, u32 *data, uint data_size)
+{
+   struct sandbox_i2s_priv *priv = dev_get_priv(dev);
+
+   while (data_size-- > 0)
+   priv->sum += *data++;
+
+   return 0;
+}
+
+static int sandbox_i2s_probe(struct udevice *dev)
+{
+   struct i2s_uc_priv *uc_priv = dev_get_uclass_priv(dev);
+
+   /* Use hard-coded values here */
+   uc_priv->rfs = 256;
+   uc_priv->bfs = 32;
+   uc_priv->audio_pll_clk

[U-Boot] [PATCH 18/30] dm: sound: Fix up header ordering

2018-12-03 Thread Simon Glass
Tidy up the ordering of header files in the sounds files.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c| 11 +--
 drivers/sound/samsung-i2s.c | 36 ++--
 drivers/sound/wm8994.c  |  8 
 3 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index d7313f9ad75..6a98dac04bb 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -10,17 +10,16 @@
  * published by the Free Software Foundation.
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include "i2s.h"
 #include "max98095.h"
 
diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c
index 7f4388137a5..c07d3cdb4c8 100644
--- a/drivers/sound/samsung-i2s.c
+++ b/drivers/sound/samsung-i2s.c
@@ -4,13 +4,13 @@
  * R. Chandrasekar 
  */
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 #define FIC_TX2COUNT(x)(((x) >>  24) & 0xf)
 #define FIC_TX1COUNT(x)(((x) >>  16) & 0xf)
@@ -170,7 +170,7 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned 
int fmt)
default:
debug("%s: Invalid format priority [0x%x]\n", __func__,
  (fmt & SND_SOC_DAIFMT_FORMAT_MASK));
-   return -1;
+   return -ERANGE;
}
 
/*
@@ -189,7 +189,7 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned 
int fmt)
default:
debug("%s: Invalid clock ploarity input [0x%x]\n", __func__,
  (fmt & SND_SOC_DAIFMT_INV_MASK));
-   return -1;
+   return -ERANGE;
}
 
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -201,13 +201,13 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned 
int fmt)
ret = i2s_set_sysclk_dir(i2s_reg, SND_SOC_CLOCK_OUT);
if (ret != 0) {
debug("%s:set i2s clock direction failed\n", __func__);
-   return -1;
+   return ret;
}
break;
default:
debug("%s: Invalid master selection [0x%x]\n", __func__,
  (fmt & SND_SOC_DAIFMT_MASTER_MASK));
-   return -1;
+   return -ERANGE;
}
 
mod &= ~(MOD_SDF_MASK | MOD_LR_RLOW | MOD_SLAVE);
@@ -248,7 +248,7 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, 
unsigned int blc)
default:
debug("%s: Invalid sample size input [0x%x]\n",
  __func__, blc);
-   return -1;
+   return -ERANGE;
}
writel(mod, &i2s_reg->mod);
 
@@ -265,7 +265,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, 
unsigned int *data,
 
if (data_size < FIFO_LENGTH) {
debug("%s : Invalid data size\n", __func__);
-   return -1; /* invalid pcm data size */
+   return -ENODATA; /* invalid pcm data size */
}
 
/* fill the tx buffer before stating the tx transmit */
@@ -284,7 +284,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, 
unsigned int *data,
if (get_timer(start) > TIMEOUT_I2S_TX) {
i2s_txctrl(i2s_reg, I2S_TX_OFF);
debug("%s: I2S Transfer Timeout\n", __func__);
-   return -1;
+   return -ETIMEDOUT;
}
}
}
@@ -312,20 +312,20 @@ int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx)
ret = set_epll_clk(pi2s_tx->audio_pll_clk);
} else {
debug("%s: unsupported i2s-%d bus\n", __func__, pi2s_tx->id);
-   return -1;
+   return -ERANGE;
}
 
-   if (ret != 0) {
+   if (ret) {
debug("%s: epll clock set rate failed\n", __func__);
-   return -1;
+   return ret;
}
 
/* Select Clk Source for Audio 0 or 1 */
ret = set_i2s_clk_source(pi2s_tx->id);
-   if (ret == -1) {
+   if (ret) {
debug("%s: unsupported clock for i2s-%d\n", __func__,
  pi2s_tx->id);
-   return -1;
+   return ret;
}
 
if (pi2s_tx->id == 0) {
@@ -341,10 +341,10 @@ int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx)
(pi2s_tx->samplingrate * (pi2s_tx->rfs)),
pi2s_tx->id);
}
-   if (ret == -1) {
+   if (ret) {
debug("%s: unsupported prescalar for i2s-%d\n", __func__,
  pi2s_tx->id);
-   return -1;
+   return ret;
}
 
/* Configure I2s 

[U-Boot] [PATCH 12/30] dm: sound: max98095: Split out interface setup code

2018-12-03 Thread Simon Glass
With driver model we want to do a minimal probe when the device is probed
and then set up the codec interface later when a sound is actully played.

Split this setup code out into its own function to help with this.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.c | 36 
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 6edf3736d79..51556c07f5e 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -384,12 +384,14 @@ static int max98095_reset(struct max98095_priv *priv)
  *
  * @returns -1 for error  and 0 Success.
  */
-static int max98095_device_init(struct max98095_priv *priv,
-   enum en_max_audio_interface aif_id)
+static int max98095_device_init(struct max98095_priv *priv)
 {
unsigned char id;
int error = 0;
 
+   /* Enable codec clock */
+   set_xclkout();
+
/* reset the codec, the DSP core, and disable all interrupts */
error = max98095_reset(priv);
if (error != 0) {
@@ -406,11 +408,19 @@ static int max98095_device_init(struct max98095_priv 
*priv,
if (error < 0) {
debug("%s: Failure reading hardware revision: %d\n",
  __func__, id);
-   goto err_access;
+   return error;
}
debug("%s: Hardware revision: %c\n", __func__, (id - 0x40) + 'A');
 
-   error |= max98095_i2c_write(priv, M98095_097_PWR_SYS, M98095_PWRSV);
+   return 0;
+}
+
+static int max98095_setup_interface(struct max98095_priv *priv,
+   enum en_max_audio_interface aif_id)
+{
+   int error;
+
+   error = max98095_i2c_write(priv, M98095_097_PWR_SYS, M98095_PWRSV);
 
/*
 * initialize registers to hardware default configuring audio
@@ -463,7 +473,6 @@ static int max98095_device_init(struct max98095_priv *priv,
else
error |= max98095_i2c_write(priv, M98095_096_PWR_DAC_CK, 0x07);
 
-err_access:
if (error < 0)
return -1;
 
@@ -477,13 +486,7 @@ static int max98095_do_init(struct sound_codec_info 
*pcodec_info,
 {
int ret = 0;
 
-   /* Enable codec clock */
-   set_xclkout();
-
-   /* shift the device address by 1 for 7 bit addressing */
-   g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1;
-
-   ret = max98095_device_init(&g_max98095_info, aif_id);
+   ret = max98095_setup_interface(&g_max98095_info, aif_id);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
return ret;
@@ -569,6 +572,15 @@ int max98095_init(const void *blob, enum 
en_max_audio_interface aif_id,
}
 
i2c_set_bus_num(pcodec_info->i2c_bus);
+
+   /* shift the device address by 1 for 7 bit addressing */
+   g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1;
+   ret = max98095_device_init(&g_max98095_info);
+   if (ret < 0) {
+   debug("%s: max98095 codec chip init failed\n", __func__);
+   return ret;
+   }
+
ret = max98095_do_init(pcodec_info, aif_id, sampling_rate, mclk_freq,
   bits_per_sample);
i2c_set_bus_num(old_bus);
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 17/30] dm: sound: wm8994: Drop wm8994_i2c_init()

2018-12-03 Thread Simon Glass
This function has only one line in it. Drop it.

Signed-off-by: Simon Glass 
---

 drivers/sound/wm8994.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index be27e2b1e7e..a888a0b4c95 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -61,16 +61,6 @@ static int bclk_divs[] = {
640, 880, 960, 1280, 1760, 1920
 };
 
-/*
- * Initialise I2C for wm 8994
- *
- * @param bus no   i2c bus number in which wm8994 is connected
- */
-static void wm8994_i2c_init(int bus_no)
-{
-   i2c_set_bus_num(bus_no);
-}
-
 /*
  * Writes value to a device register through i2c
  *
@@ -918,7 +908,7 @@ int wm8994_init(const void *blob, enum en_audio_interface 
aif_id,
 
/* shift the device address by 1 for 7 bit addressing */
wm8994_info.i2c_addr = pcodec_info.i2c_dev_addr;
-   wm8994_i2c_init(pcodec_info.i2c_bus);
+   i2c_set_bus_num(pcodec_info.i2c_bus);
ret = wm8994_device_init(&wm8994_info);
if (ret < 0) {
debug("%s: wm8994 codec chip init failed\n", __func__);
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 29/30] dm: exynos: Drop CONFIG_DM_I2C_COMPAT

2018-12-03 Thread Simon Glass
This option is not needed anymore for all exynos boards except arndale.
Update the config.

Signed-off-by: Simon Glass 
---

 configs/peach-pi_defconfig  | 1 -
 configs/peach-pit_defconfig | 1 -
 configs/smdk5250_defconfig  | 1 -
 configs/smdk5420_defconfig  | 1 -
 configs/snow_defconfig  | 1 -
 configs/spring_defconfig| 1 -
 6 files changed, 6 deletions(-)

diff --git a/configs/peach-pi_defconfig b/configs/peach-pi_defconfig
index 2f82c2d82c7..e1e662d159f 100644
--- a/configs/peach-pi_defconfig
+++ b/configs/peach-pi_defconfig
@@ -28,7 +28,6 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5800-peach-pi"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
diff --git a/configs/peach-pit_defconfig b/configs/peach-pit_defconfig
index 3a177f14f7c..96ed4bd3be5 100644
--- a/configs/peach-pit_defconfig
+++ b/configs/peach-pit_defconfig
@@ -27,7 +27,6 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5420-peach-pit"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
diff --git a/configs/smdk5250_defconfig b/configs/smdk5250_defconfig
index 90ee0ffbc9d..1e058227e41 100644
--- a/configs/smdk5250_defconfig
+++ b/configs/smdk5250_defconfig
@@ -30,7 +30,6 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5250-smdk5250"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_S5P=y
diff --git a/configs/smdk5420_defconfig b/configs/smdk5420_defconfig
index 433e9a8447f..4e4558944cc 100644
--- a/configs/smdk5420_defconfig
+++ b/configs/smdk5420_defconfig
@@ -25,7 +25,6 @@ CONFIG_CMD_TIME=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5420-smdk5420"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_S5P=y
diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index 4d1c53d4291..10e11fbb337 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -34,7 +34,6 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5250-snow"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_I2C_CROS_EC_LDO=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
diff --git a/configs/spring_defconfig b/configs/spring_defconfig
index 8f9436c74af..844a87734b8 100644
--- a/configs/spring_defconfig
+++ b/configs/spring_defconfig
@@ -34,7 +34,6 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DEFAULT_DEVICE_TREE="exynos5250-spring"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_DM_I2C_COMPAT=y
 CONFIG_I2C_CROS_EC_LDO=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 25/30] dm: core: Add a function to read into a unsigned int

2018-12-03 Thread Simon Glass
The current dev_read...() functions use s32 and u32 which are convenient
for device tree but not so useful for normal code, which often wants to
use normal integers for values.

Add a helper which supports returning an unsigned int. Also add signed
versions of the unsigned readers.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/test.dts |  2 ++
 drivers/core/read.c   | 23 
 include/dm/read.h | 58 +++
 test/dm/test-fdt.c| 35 +++
 4 files changed, 118 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index dbbd0495e7c..f44090377d3 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -87,6 +87,8 @@
test2-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 6 1 3 2 1>,
<&gpio_b 7 2 3 2 1>, <&gpio_b 8 4 3 2 1>,
<&gpio_b 9 0xc 3 2 1>;
+   int-value = <1234>;
+   uint-value = <(-1234)>;
};
 
junk {
diff --git a/drivers/core/read.c b/drivers/core/read.c
index 96766c7876a..4644a8c0cee 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -21,6 +21,29 @@ int dev_read_u32_default(struct udevice *dev, const char 
*propname, int def)
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
 }
 
+int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp)
+{
+   return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp);
+}
+
+int dev_read_s32_default(struct udevice *dev, const char *propname, int def)
+{
+   return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
+}
+
+int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp)
+{
+   u32 val;
+   int ret;
+
+   ret = ofnode_read_u32(dev_ofnode(dev), propname, &val);
+   if (ret)
+   return ret;
+   *outp = val;
+
+   return 0;
+}
+
 const char *dev_read_string(struct udevice *dev, const char *propname)
 {
return ofnode_read_string(dev_ofnode(dev), propname);
diff --git a/include/dm/read.h b/include/dm/read.h
index a27b8554fb1..27f751ba7a2 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -64,6 +64,38 @@ int dev_read_u32(struct udevice *dev, const char *propname, 
u32 *outp);
  */
 int dev_read_u32_default(struct udevice *dev, const char *propname, int def);
 
+/**
+ * dev_read_s32() - read a signed 32-bit integer from a device's DT property
+ *
+ * @dev:   device to read DT property from
+ * @propname:  name of the property to read from
+ * @outp:  place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp);
+
+/**
+ * dev_read_s32_default() - read a signed 32-bit int from a device's DT 
property
+ *
+ * @dev:   device to read DT property from
+ * @propname:  name of the property to read from
+ * @def:   default value to return if the property has no value
+ * @return property value, or @def if not found
+ */
+int dev_read_s32_default(struct udevice *dev, const char *propname, int def);
+
+/**
+ * dev_read_u32u() - read a 32-bit integer from a device's DT property
+ *
+ * This version uses a standard uint type.
+ *
+ * @dev:   device to read DT property from
+ * @propname:  name of the property to read from
+ * @outp:  place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp);
+
 /**
  * dev_read_string() - Read a string from a device's DT property
  *
@@ -467,6 +499,32 @@ static inline int dev_read_u32_default(struct udevice *dev,
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
 }
 
+static inline int dev_read_s32(struct udevice *dev,
+  const char *propname, s32 *outp)
+{
+   return ofnode_read_s32(dev_ofnode(dev), propname, outp);
+}
+
+static inline int dev_read_s32_default(struct udevice *dev,
+  const char *propname, int def)
+{
+   return ofnode_read_s32_default(dev_ofnode(dev), propname, def);
+}
+
+static inline int dev_read_u32u(struct udevice *dev,
+   const char *propname, uint *outp)
+{
+   u32 val;
+   int ret;
+
+   ret = ofnode_read_u32(dev_ofnode(dev), propname, &val);
+   if (ret)
+   return ret;
+   *outp = val;
+
+   return 0;
+}
+
 static inline const char *dev_read_string(struct udevice *dev,
  const char *propname)
 {
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 0fbd9be765a..b32f82fdcf1 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -658,3 +658,38 @@ static int dm_test_first_child(struct unit_test_state *uts)
return 0;
 }
 DM_TEST(dm_test_first_child, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test integer functions in dm_read_...() */
+static int dm_test_read_int(str

[U-Boot] [PATCH 26/30] dm: sound: Start i2c IDs from 0

2018-12-03 Thread Simon Glass
The current ID enums start from 1 but there does not seem to be any reason
that they cannot start with 0. Adjust the code to avoid the +1 in
codec_init() and elsewhere.

Signed-off-by: Simon Glass 
---

 drivers/sound/max98095.h  |  2 +-
 drivers/sound/sound-i2s.c |  6 ++
 drivers/sound/wm8994.c| 23 ---
 drivers/sound/wm8994.h|  2 +-
 4 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/sound/max98095.h b/drivers/sound/max98095.h
index 44b1e3a97b4..13ae177a86b 100644
--- a/drivers/sound/max98095.h
+++ b/drivers/sound/max98095.h
@@ -13,7 +13,7 @@
 
 /*  Available audio interface ports in wm8994 codec */
 enum en_max_audio_interface {
-   AIF1 = 1,
+   AIF1,
AIF2,
 };
 
diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c
index ed130750b2e..a2fc78154f1 100644
--- a/drivers/sound/sound-i2s.c
+++ b/drivers/sound/sound-i2s.c
@@ -120,13 +120,11 @@ static int codec_init(const void *blob, struct 
i2s_uc_priv *pi2s_tx)
debug("device = %s\n", codectype);
if (!strcmp(codectype, "wm8994")) {
/* Check the codec type and initialise the same */
-   ret = wm8994_init(blob, pi2s_tx->id + 1,
- pi2s_tx->samplingrate,
+   ret = wm8994_init(blob, pi2s_tx->id, pi2s_tx->samplingrate,
  (pi2s_tx->samplingrate * (pi2s_tx->rfs)),
  pi2s_tx->bitspersample, pi2s_tx->channels);
} else if (!strcmp(codectype, "max98095")) {
-   ret = max98095_init(blob, pi2s_tx->id + 1,
-   pi2s_tx->samplingrate,
+   ret = max98095_init(blob, pi2s_tx->id, pi2s_tx->samplingrate,
(pi2s_tx->samplingrate * (pi2s_tx->rfs)),
pi2s_tx->bitspersample);
} else {
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index 1714f430f39..b8c3ffb67eb 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -285,7 +285,6 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int 
aif_id,
int aif1 = 0;
int aif2 = 0;
int rate_val = 0;
-   int id = aif_id - 1;
int i, cur_val, best_val, bclk_rate, best;
unsigned short reg_data;
int ret = 0;
@@ -343,10 +342,11 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int 
aif_id,
 
/* AIFCLK/fs ratio; look for a close match in either direction */
best = 0;
-   best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[id]);
+   best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[aif_id]);
 
for (i = 1; i < ARRAY_SIZE(fs_ratios); i++) {
-   cur_val = abs(fs_ratios[i] * sampling_rate - priv->aifclk[id]);
+   cur_val = abs(fs_ratios[i] * sampling_rate -
+ priv->aifclk[aif_id]);
if (cur_val >= best_val)
continue;
best = i;
@@ -363,7 +363,8 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int 
aif_id,
 */
best = 0;
for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
-   cur_val = (priv->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate;
+   cur_val = (priv->aifclk[aif_id] * 10 / bclk_divs[i]) -
+   bclk_rate;
if (cur_val < 0) /* BCLK table is sorted */
break;
best = i;
@@ -375,7 +376,7 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int 
aif_id,
return -1;
}
 
-   bclk_rate = priv->aifclk[id] * 10 / bclk_divs[best];
+   bclk_rate = priv->aifclk[aif_id] * 10 / bclk_divs[best];
bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT;
 
if (wm8994_i2c_read(priv, aif1_reg, ®_data) != 0) {
@@ -386,7 +387,7 @@ static int wm8994_hw_params(struct wm8994_priv *priv, int 
aif_id,
if ((channels == 1) && ((reg_data & 0x18) == 0x18))
aif2 |= WM8994_AIF1_MONO;
 
-   if (priv->aifclk[id] == 0) {
+   if (priv->aifclk[aif_id] == 0) {
debug("%s:Audio interface clock not set\n", __func__);
return -1;
}
@@ -424,12 +425,12 @@ static int configure_aif_clock(struct wm8994_priv *priv, 
int aif)
int ret;
 
/* AIF(1/0) register adress offset calculated */
-   if (aif-1)
+   if (aif)
offset = 4;
else
offset = 0;
 
-   switch (priv->sysclk[aif - 1]) {
+   switch (priv->sysclk[aif]) {
case WM8994_SYSCLK_MCLK1:
reg1 |= SEL_MCLK1;
rate = priv->mclk[0];
@@ -452,7 +453,7 @@ static int configure_aif_clock(struct wm8994_priv *priv, 
int aif)
 
default:
debug("%s: Invalid input clock selection [%d]\n",
- __func__, priv->sysclk[aif - 1]);
+ __func__, priv->sysclk[a

[U-Boot] [PATCH 21/30] dm: sound: Rename samsung_i2s_priv to i2s_uc_priv

2018-12-03 Thread Simon Glass
This structure contains information that is likely needed by any i2s
driver so it seems useful to attach it to the (forthcoming) i2c uclass.
For now, just rename it.

Signed-off-by: Simon Glass 
---

 drivers/sound/samsung-i2s.c |  4 ++--
 drivers/sound/sound-i2s.c   | 10 +-
 include/i2s.h   |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c
index c07d3cdb4c8..5cd585808ab 100644
--- a/drivers/sound/samsung-i2s.c
+++ b/drivers/sound/samsung-i2s.c
@@ -255,7 +255,7 @@ static int i2s_set_samplesize(struct i2s_reg *i2s_reg, 
unsigned int blc)
return 0;
 }
 
-int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, unsigned int *data,
+int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data,
 unsigned long data_size)
 {
int i;
@@ -293,7 +293,7 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, 
unsigned int *data,
return 0;
 }
 
-int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx)
+int i2s_tx_init(struct i2s_uc_priv *pi2s_tx)
 {
int ret;
struct i2s_reg *i2s_reg =
diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c
index 106842a23db..ed130750b2e 100644
--- a/drivers/sound/sound-i2s.c
+++ b/drivers/sound/sound-i2s.c
@@ -20,15 +20,15 @@
 #define SOUND_400_HZ 400
 #define SOUND_BITS_IN_BYTE 8
 
-static struct samsung_i2s_priv g_i2stx_pri;
+static struct i2s_uc_priv g_i2stx_pri;
 
 /*
  * get_sound_i2s_values gets values for i2s parameters
  *
- * @param samsung_i2s_priv i2s transmitter transfer param structure
+ * @param i2s_uc_priv  i2s transmitter transfer param structure
  * @param blob FDT blob if enabled else NULL
  */
-static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, const void *blob)
+static int get_sound_i2s_values(struct i2s_uc_priv *i2s, const void *blob)
 {
int node;
int error = 0;
@@ -97,7 +97,7 @@ static int get_sound_i2s_values(struct samsung_i2s_priv *i2s, 
const void *blob)
  * @param pi2s_tx  i2s parameters required by codec
  * @return  int value, 0 for success
  */
-static int codec_init(const void *blob, struct samsung_i2s_priv *pi2s_tx)
+static int codec_init(const void *blob, struct i2s_uc_priv *pi2s_tx)
 {
int ret;
const char *codectype;
@@ -145,7 +145,7 @@ static int codec_init(const void *blob, struct 
samsung_i2s_priv *pi2s_tx)
 int sound_init(const void *blob)
 {
int ret;
-   struct samsung_i2s_priv *pi2s_tx = &g_i2stx_pri;
+   struct i2s_uc_priv *pi2s_tx = &g_i2stx_pri;
 
/* Get the I2S Values */
if (get_sound_i2s_values(pi2s_tx, blob) < 0) {
diff --git a/include/i2s.h b/include/i2s.h
index 800473abd9c..f23862ca040 100644
--- a/include/i2s.h
+++ b/include/i2s.h
@@ -76,7 +76,7 @@ struct i2s_reg {
 };
 
 /* This structure stores the i2s related information */
-struct samsung_i2s_priv {
+struct i2s_uc_priv {
unsigned int rfs;   /* LR clock frame size */
unsigned int bfs;   /* Bit slock frame size */
unsigned int audio_pll_clk; /* Audio pll frequency in Hz */
@@ -96,7 +96,7 @@ struct samsung_i2s_priv {
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, uint *data,
+int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data,
 unsigned long data_size);
 
 /*
@@ -106,6 +106,6 @@ int i2s_transfer_tx_data(struct samsung_i2s_priv *pi2s_tx, 
uint *data,
  *
  * @return int value 0 for success, -1 in case of error
  */
-int i2s_tx_init(struct samsung_i2s_priv *pi2s_tx);
+int i2s_tx_init(struct i2s_uc_priv *pi2s_tx);
 
 #endif /* __I2S_H__ */
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


[U-Boot] [PATCH 20/30] dm: sound: Create an option to use driver model for sound

2018-12-03 Thread Simon Glass
The U-Boot sound system provides basic support for beeping. At present it
does not use driver model, but it needs to be converted. Add an option to
enable driver model for sound. For now it is not connected to anything.
Future work will add drivers which use this option. It will then be
removed once everything is converted.

Signed-off-by: Simon Glass 
---

 configs/sandbox_defconfig | 1 +
 drivers/sound/Kconfig | 6 ++
 2 files changed, 7 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 4d65a01dc5b..ad7b25c5f35 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -176,6 +176,7 @@ CONFIG_SANDBOX_SERIAL=y
 CONFIG_SMEM=y
 CONFIG_SANDBOX_SMEM=y
 CONFIG_SOUND=y
+CONFIG_DM_SOUND=y
 CONFIG_SOUND_SANDBOX=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_SPMI=y
diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig
index 5de86c05c60..93f6c36af32 100644
--- a/drivers/sound/Kconfig
+++ b/drivers/sound/Kconfig
@@ -12,6 +12,12 @@ config SOUND
  audio codecs are called from the sound-i2s code. This could be
  converted to driver model.
 
+config DM_SOUND
+   bool "Use driver model for sound"
+   help
+ Enable this option to use driver model for sound devices. This is a
+ migration option and will be removed.
+
 config I2S
bool "Enable I2S support"
depends on SOUND
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


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

2018-12-03 Thread Simon Glass
Hi.

On Mon, 3 Dec 2018 at 00:42, Simon Goldschmidt
 wrote:
>
> On Mon, Dec 3, 2018 at 8:27 AM Kever Yang  wrote:
> >
> > Hi Tom,
> >
> > With this merge, my boards can't work correctly in SPL, the console
> > output is mess up.
> >
> > I have test on rk3229 and rk3399 boards, and finally I identify that
> > below patch is the root cause:
> >
> > 6f57c34473 serial: ns16550: fix debug uart putc called before init
>
> Henri Roosen reported this to me last week. The root cause seems to be
> that the ns16550 baudrate prescaler is read as 0 on his rk3399 board.
>
> He helped me try an additional fix but that didn't work either.
>
> So we can either try and fix this if it is only a problem for rockchip
> boards or revert the patch and I'll think of a different solution to
> fix this issue (debug uart putc called before init) for the socfpga
> platform.
>
> I still think it would be good to fix this globally: there's nothing
> keeping us from accidentally adding putc code before the debug uart is
> initialized and this is something that should be detected, I think.

I think it would be better to have this discussion on the patch rather
than the pull request.

Regards,
Simon

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


[U-Boot] [PATCH 28/30] dm: exynos: sound: Convert to use driver model

2018-12-03 Thread Simon Glass
Update snow's device tree and config to use driver model for sound. Also
update the others as best we can.

Spring does not appear to have audio support in the kernel. The smdk5250
and smdk5420 boards use a wolfson codec which I cannot test with. So the
only board that is tested and known to work is snow.

Signed-off-by: Simon Glass 
---

 arch/arm/dts/exynos5250-smdk5250.dts  | 20 ++--
 arch/arm/dts/exynos5250-snow.dts  | 21 -
 arch/arm/dts/exynos5250-spring.dts| 24 
 arch/arm/dts/exynos5250.dtsi  | 15 ++-
 arch/arm/dts/exynos5420-peach-pit.dts | 24 
 arch/arm/dts/exynos5420-smdk5420.dts  | 20 ++--
 arch/arm/dts/exynos54xx.dtsi  |  7 +++
 configs/arndale_defconfig |  1 +
 configs/peach-pi_defconfig|  1 +
 configs/peach-pit_defconfig   |  1 +
 configs/smdk5250_defconfig|  1 +
 configs/snow_defconfig|  1 +
 configs/spring_defconfig  |  1 +
 drivers/sound/samsung_sound.c |  3 +++
 14 files changed, 118 insertions(+), 22 deletions(-)

diff --git a/arch/arm/dts/exynos5250-smdk5250.dts 
b/arch/arm/dts/exynos5250-smdk5250.dts
index bf60b82d449..e542a790761 100644
--- a/arch/arm/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/dts/exynos5250-smdk5250.dts
@@ -60,10 +60,26 @@
};
 
i2c@12C7 {
-   soundcodec@1a {
+   wm8994: soundcodec@1a {
reg = <0x1a>;
u-boot,i2c-offset-len = <2>;
-   compatible = "wolfson,wm8994-codec";
+   compatible = "wolfson,wm8994";
+   #sound-dai-cells = <1>;
+   };
+   };
+
+   sound {
+   compatible = "google,smdk5250-audio-wm8994";
+
+   samsung,model = "SMDK5250-I2S-WM8994";
+   samsung,audio-codec = <&wm8994>;
+
+   cpu {
+   sound-dai = <&i2s0 0>;
+   };
+
+   codec {
+   sound-dai = <&wm8994 0>;
};
};
 
diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts
index cb5067b9669..7587dc0ff24 100644
--- a/arch/arm/dts/exynos5250-snow.dts
+++ b/arch/arm/dts/exynos5250-snow.dts
@@ -40,7 +40,6 @@
mmc3 = "/mmc@1223";
serial0 = "/serial@12C3";
console = "/serial@12C3";
-   i2s = "/sound@383";
};
 
 memory {
@@ -214,9 +213,10 @@
};
};
 
-   soundcodec@11 {
+   max98095: codec@11 {
+   compatible = "maxim,max98095";
reg = <0x11>;
-   compatible = "maxim,max98095-codec";
+   #sound-dai-cells = <1>;
};
};
 
@@ -273,9 +273,20 @@
};
};
 
-   sound@383 {
-   samsung,codec-type = "max98095";
+   sound {
+   compatible = "google,snow-audio-max98095";
+
+   samsung,model = "Snow-I2S-MAX98095";
+   samsung,audio-codec = <&max98095>;
codec-enable-gpio = <&gpx1 7 GPIO_ACTIVE_HIGH>;
+
+   cpu {
+   sound-dai = <&i2s0 0>;
+   };
+
+   codec {
+   sound-dai = <&max98095 0>;
+   };
};
 
sound@12d6 {
diff --git a/arch/arm/dts/exynos5250-spring.dts 
b/arch/arm/dts/exynos5250-spring.dts
index 7633d36874f..191e12af6a1 100644
--- a/arch/arm/dts/exynos5250-spring.dts
+++ b/arch/arm/dts/exynos5250-spring.dts
@@ -34,7 +34,6 @@
mmc0 = "/mmc@1220";
serial0 = "/serial@12C3";
console = "/serial@12C3";
-   i2s = "/sound@383";
};
 
memory {
@@ -639,10 +638,27 @@
};
};
 
-   soundcodec@20 {
-   reg = <0x20>;
-   compatible = "maxim,max98088-codec";
+   max98095: soundcodec@10 {
+   reg = <0x10>;
+   compatible = "maxim,max98095";
+   #sound-dai-cells = <1>;
};
+
+   sound {
+   compatible = "google,spring-audio-max98095";
+
+   samsung,model = "Spring-I2S-MAX98095";
+   samsung,audio-codec = <&max98095>;
+
+   cpu {
+   sound-dai = <&i2s0 0>;
+   };
+
+   codec {
+   sound-dai = <&max98095 0>;
+   };
+   };
+
 };
 
 #include "cros-ec-keyboard.dtsi"
diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
index 502c687802e..66c5b6dca95 100644
--- a/arch/arm/dts/exynos5250.dtsi
+++ b/arch/arm/dts/exynos5250.dtsi
@@ -78,9 +78,12 @@
#size-cells = <0>;
};
 
-   sound@38

[U-Boot] [PATCH 24/30] dm: sound: Create a uclass for sound

2018-12-03 Thread Simon Glass
The sound drive pulls together the audio codec and i2s drivers in order to
actually make sounds. It supports setup() and play() methods. The
sound_find_codec_i2s() function allows locating the linked codec and i2s
devices. They can be referred to from uclass-private data.

Add a uclass and a test for sound.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/test.dts   |  11 +++
 arch/sandbox/include/asm/test.h |  20 +
 cmd/sound.c |  21 +-
 drivers/sound/Makefile  |   1 +
 drivers/sound/sandbox.c |  65 
 drivers/sound/sound-uclass.c| 129 
 include/dm/uclass-id.h  |   1 +
 include/sound.h |  66 
 test/dm/Makefile|   1 +
 test/dm/sound.c |  34 +
 10 files changed, 348 insertions(+), 1 deletion(-)
 create mode 100644 drivers/sound/sound-uclass.c
 create mode 100644 test/dm/sound.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 01ab409b388..dbbd0495e7c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -536,6 +536,17 @@
compatible = "sandbox,smem";
};
 
+   sound {
+   compatible = "sandbox,sound";
+   cpu {
+   sound-dai = <&i2s 0>;
+   };
+
+   codec {
+   sound-dai = <&audio 0>;
+   };
+   };
+
spi@0 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 71bd50bd5bc..74f96188220 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -141,4 +141,24 @@ void sandbox_get_codec_params(struct udevice *dev, int 
*interfacep, int *ratep,
  */
 int sandbox_get_i2s_sum(struct udevice *dev);
 
+/**
+ * sandbox_get_setup_called() - Returns the number of times setup(*) was called
+ *
+ * This is used in the sound test
+ *
+ * @dev: Device to check
+ * @return call count for the setup() method
+ */
+int sandbox_get_setup_called(struct udevice *dev);
+
+/**
+ * sandbox_get_sound_sum() - Read back the sum of the sound data so far
+ *
+ * This data is provided to the sandbox driver by the sound play() method.
+ *
+ * @dev: Device to check
+ * @return sum of audio data
+ */
+int sandbox_get_sound_sum(struct udevice *dev);
+
 #endif
diff --git a/cmd/sound.c b/cmd/sound.c
index d1cbc14f8df..b063863bc9a 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -14,9 +15,18 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Initilaise sound subsystem */
 static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
+#ifdef CONFIG_DM_SOUND
+   struct udevice *dev;
+#endif
int ret;
 
+#ifdef CONFIG_DM_SOUND
+   ret = uclass_first_device_err(UCLASS_SOUND, &dev);
+   if (!ret)
+   ret = sound_setup(dev);
+#else
ret = sound_init(gd->fdt_blob);
+#endif
if (ret) {
printf("Initialise Audio driver failed\n");
return CMD_RET_FAILURE;
@@ -28,6 +38,9 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 /* play sound from buffer */
 static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
+#ifdef CONFIG_DM_SOUND
+   struct udevice *dev;
+#endif
int ret = 0;
int msec = 1000;
int freq = 400;
@@ -37,9 +50,15 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
if (argc > 2)
freq = simple_strtoul(argv[2], NULL, 10);
 
+#ifdef CONFIG_DM_SOUND
+   ret = uclass_first_device_err(UCLASS_SOUND, &dev);
+   if (!ret)
+   ret = sound_beep(dev, msec, freq);
+#else
ret = sound_play(msec, freq);
+#endif
if (ret) {
-   printf("play failed");
+   printf("Sound device failed to play (err=%d)\n", ret);
return CMD_RET_FAILURE;
}
 
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index 4aced9d22b9..70d32c6d6f6 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SOUND) += sound.o
 obj-$(CONFIG_DM_SOUND) += codec-uclass.o
 obj-$(CONFIG_DM_SOUND) += i2s-uclass.o
 obj-$(CONFIG_I2S)  += sound-i2s.o
+obj-$(CONFIG_DM_SOUND) += sound-uclass.o
 obj-$(CONFIG_I2S_SAMSUNG)  += samsung-i2s.o
 obj-$(CONFIG_SOUND_SANDBOX)+= sandbox.o
 obj-$(CONFIG_SOUND_WM8994) += wm8994.o
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c
index 59931ec0a12..d8a971ca060 100644
--- a/drivers/sound/sandbox.c
+++ b/drivers/sound/sandbox.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -22,6 +23,12 @@ struct sandbox_i2s_priv {
int sum;/* Use to sum the provided audio data */
 };
 
+struct sandbox_sound_priv {
+

Re: [U-Boot] [PATCH v3 4/5] mmc: tegra: select BOUNCE_BUFFER unconditionally

2018-12-03 Thread Simon Glass
On Fri, 30 Nov 2018 at 14:13, Philipp Tomsich
 wrote:
>
> The driver for the SDHCI_TEGRA depends on the bounce buffer utility
> functions. Unconditionally select BOUNCE_BUFFER, when this driver is
> enabled.
>
> This also includes the post-processing to drop unused comments after
> running moveconfig.
>
> Signed-off-by: Philipp Tomsich 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  drivers/mmc/Kconfig| 1 +
>  include/configs/tegra-common.h | 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)

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


[U-Boot] [PATCH 19/30] dm: sound: exynos: Correct codec bus address

2018-12-03 Thread Simon Glass
The codec is at address 0x11 on the i2c bus, in 7-bit format. The device
tree and code are in 8-bit format (i.e. shifted left one bit). Fix both.

Signed-off-by: Simon Glass 
---

 arch/arm/dts/exynos5250-snow.dts | 4 ++--
 drivers/sound/max98095.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts
index e99f6e72bf6..cb5067b9669 100644
--- a/arch/arm/dts/exynos5250-snow.dts
+++ b/arch/arm/dts/exynos5250-snow.dts
@@ -214,8 +214,8 @@
};
};
 
-   soundcodec@22 {
-   reg = <0x22>;
+   soundcodec@11 {
+   reg = <0x11>;
compatible = "maxim,max98095-codec";
};
};
diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 6a98dac04bb..7a3dbd09840 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -569,8 +569,7 @@ int max98095_init(const void *blob, enum 
en_max_audio_interface aif_id,
 
i2c_set_bus_num(pcodec_info.i2c_bus);
 
-   /* shift the device address by 1 for 7 bit addressing */
-   max98095_info.i2c_addr = pcodec_info.i2c_dev_addr >> 1;
+   max98095_info.i2c_addr = pcodec_info.i2c_dev_addr;
ret = max98095_device_init(&max98095_info);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
-- 
2.20.0.rc1.387.gf8505762e3-goog

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


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
> The bounce buffer is used by a few drivers (most of the MMC drivers)
> to overcome limitations in their respective DMA implementation.
> 
> This moves the configuration to Kconfig and makes it user-selectable
> (even though it will be a required feature to make those drivers
> work): the expected usage is for drivers depending on this to 'select'
> it unconditionally from their respective Kconfig (see follow-up
> patches).
> 
> This commit includes a full migration using moveconfig.py to ensure
> that each commit compiles; successive commits will introduce
> individual dependencies for drivers and then undo some of the changes
> to the defconfig files.
> 
> Signed-off-by: Philipp Tomsich 
> 
> ---

[snip]

> diff --git a/common/Kconfig b/common/Kconfig
> index 57bd16d..5bbd00a 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
> the relocation phase. The board function checkboard() is called to do
> this.
>  
> +config BOUNCE_BUFFER
> + bool "Include bounce buffer API"
> + help
> +   Some peripherals support DMA from a subset of physically
> +   addressable memory only.  To support such peripherals, the
> +   bounce buffer API uses a temporary buffer: it copies data
> +   to/from DMA regions while managing cache operations.
> +
> +   A second possible use of bounce buffers is their ability to
> +   provide aligned buffers for DMA operations.
> +

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
> index 1b2966f..8febe09 100644
> --- a/include/configs/axs10x.h
> +++ b/include/configs/axs10x.h
> @@ -85,6 +85,5 @@
>  /*
>   * Misc utility configuration
>   */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  #endif /* _CONFIG_AXS10X_H_ */

...

> diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
> index 385d59e..a77f262 100644
> --- a/include/configs/emsdp.h
> +++ b/include/configs/emsdp.h
> @@ -19,7 +19,6 @@
>  #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE
>  
>  /* Required by DW MMC driver */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /*
>   * Environment

...
 
> diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
> index cdf4fdd..bafd8d0 100644
> --- a/include/configs/hsdk.h
> +++ b/include/configs/hsdk.h
> @@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
>  /*
>   * Misc utility configuration
>   */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /* Cli configuration */
>  #define CONFIG_SYS_CBSIZESZ_2K
> diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
> index 4ffe114..1f40d61 100644
> --- a/include/configs/iot_devkit.h
> +++ b/include/configs/iot_devkit.h
> @@ -72,7 +72,6 @@
>   CONFIG_ENV_SIZE
>  
>  /* Required by DW MMC driver */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /*
>   * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

So maybe we need to split this first commit in 3 parts and
squash it with 2, 3 and 4.

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


Re: [U-Boot] [PATCH v3 5/5] arc: select BOUNCE_BUFFER for CMD_NAND on AXS10x

2018-12-03 Thread Philipp Tomsich
Alexey,

> On 03.12.2018, at 12:20, Alexey Brodkin  wrote:
> 
> Hi Philipp,
> 
> On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
>> The NAND driver of AXS10x depends on the availability of the bounce
>> buffer.  As the NAND driver is gated by CMD_NAND only, we need to
>> select BOUNCE_BUFFER conditionally (on CMD_NAND) for TARGET_AXS101 and
>> TARGET_AXS103.
>> 
>> Signed-off-by: Philipp Tomsich 
>> ---
>> 
>> Changes in v3: None
>> Changes in v2: None
>> 
>> arch/arc/Kconfig | 2 ++
>> include/configs/axs10x.h | 4 
>> 2 files changed, 2 insertions(+), 4 deletions(-)
>> 
>> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
>> index fa6b344..50369d5 100644
>> --- a/arch/arc/Kconfig
>> +++ b/arch/arc/Kconfig
>> @@ -146,9 +146,11 @@ config TARGET_NSIM
>> 
>> config TARGET_AXS101
>>  bool "Support Synopsys Designware SDP board AXS101"
>> +select BOUNCE_BUFFER if CMD_NAND
>> 
>> config TARGET_AXS103
>>  bool "Support Synopsys Designware SDP board AXS103"
>> +select BOUNCE_BUFFER if CMD_NAND
> 
> I'd say that more appropriate place is "board/synopsys/axs10x/Kconfig".
> Because:
> - This is related to the particular board, architecture has nothing to
>   do with this
> - Only 1 line of change will be required as both boards use the same
>   Kconfig file

Happily, if you tell me how I can add a ‘select’ for this config-option in
board/synopsys/axs10x/Kconfig w/o unintended side-effects …
In other words: I failed when I tried to override CMD_NAND in that file.

Thanks,
Philipp.


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


Re: [U-Boot] [PATCH V2 05/15] imx: rename mx8m,MX8M to imx8m,IMX8M

2018-12-03 Thread Peng Fan
Hi Jon,

Your patch could not be applied to master branch, seems this patch is based on 
NXP vendor tree?

Thanks,
Peng.

> -Original Message-
> From: Jon Nettleton [mailto:j...@solid-run.com]
> Sent: 2018年11月29日 13:02
> To: Peng Fan 
> Cc: sba...@denx.de; Fabio Estevam ; U-Boot
> Mailing List ; dl-linux-imx 
> Subject: Re: [U-Boot] [PATCH V2 05/15] imx: rename mx8m,MX8M to
> imx8m,IMX8M
> 
> On Tue, Nov 20, 2018 at 11:21 AM Peng Fan  wrote:
> >
> > Rename mx8m,MX8M to imx8m,IMX8M
> >
> > Signed-off-by: Peng Fan 
> > ---
> >
> > V2:
> >  None
> >
> >  arch/arm/Kconfig   |  4
> ++--
> >  arch/arm/Makefile  |  4
> ++--
> >  arch/arm/include/asm/arch-imx/cpu.h|  4 ++--
> >  arch/arm/include/asm/{arch-mx8m => arch-imx8m}/clock.h |  0
> >  .../include/asm/{arch-mx8m => arch-imx8m}/crm_regs.h   |  4 ++--
> >  arch/arm/include/asm/{arch-mx8m => arch-imx8m}/ddr.h   |  4 ++--
> >  arch/arm/include/asm/{arch-mx8m => arch-imx8m}/gpio.h  |  4 ++--
> >  .../include/asm/{arch-mx8m => arch-imx8m}/imx-regs.h   |  4 ++--
> >  .../mx8mq_pins.h => arch-imx8m/imx8mq_pins.h}  |  4 ++--
> >  .../include/asm/{arch-mx8m => arch-imx8m}/sys_proto.h  |  4 ++--
> >  arch/arm/include/asm/mach-imx/iomux-v3.h   |  2 +-
> >  arch/arm/include/asm/mach-imx/regs-lcdif.h |  6 +++---
> >  arch/arm/include/asm/mach-imx/sys_proto.h  |  2 +-
> >  arch/arm/mach-imx/Makefile |  8
> 
> >  arch/arm/mach-imx/cpu.c| 16
> 
> >  arch/arm/mach-imx/{mx8m => imx8m}/Kconfig  |  6
> +++---
> >  arch/arm/mach-imx/{mx8m => imx8m}/Makefile |  0
> >  arch/arm/mach-imx/{mx8m => imx8m}/clock.c  |  4
> ++--
> >  arch/arm/mach-imx/{mx8m => imx8m}/clock_slice.c|  0
> >  arch/arm/mach-imx/{mx8m => imx8m}/lowlevel_init.S  |  0
> >  arch/arm/mach-imx/{mx8m => imx8m}/soc.c|  0
> >  arch/arm/mach-imx/imx_bootaux.c|  4
> ++--
> >  arch/arm/mach-imx/spl.c|  6
> +++---
> >  drivers/gpio/mxc_gpio.c| 18
> +-
> >  drivers/misc/mxc_ocotp.c   |  6
> +++---
> >  drivers/mmc/fsl_esdhc.c|  8
> 
> >  drivers/net/fec_mxc.c  |  2 +-
> >  27 files changed, 62 insertions(+), 62 deletions(-)  rename
> > arch/arm/include/asm/{arch-mx8m => arch-imx8m}/clock.h (100%)
> rename
> > arch/arm/include/asm/{arch-mx8m => arch-imx8m}/crm_regs.h (65%)
> > rename arch/arm/include/asm/{arch-mx8m => arch-imx8m}/ddr.h (98%)
> > rename arch/arm/include/asm/{arch-mx8m => arch-imx8m}/gpio.h (63%)
> > rename arch/arm/include/asm/{arch-mx8m => arch-imx8m}/imx-regs.h
> (99%)
> > rename arch/arm/include/asm/{arch-mx8m/mx8mq_pins.h =>
> > arch-imx8m/imx8mq_pins.h} (99%)  rename
> > arch/arm/include/asm/{arch-mx8m => arch-imx8m}/sys_proto.h (82%)
> > rename arch/arm/mach-imx/{mx8m => imx8m}/Kconfig (57%)  rename
> > arch/arm/mach-imx/{mx8m => imx8m}/Makefile (100%)  rename
> > arch/arm/mach-imx/{mx8m => imx8m}/clock.c (99%)  rename
> > arch/arm/mach-imx/{mx8m => imx8m}/clock_slice.c (100%)  rename
> > arch/arm/mach-imx/{mx8m => imx8m}/lowlevel_init.S (100%)  rename
> > arch/arm/mach-imx/{mx8m => imx8m}/soc.c (100%)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index
> > f0e7fde137..1a58adc1fb 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -674,7 +674,7 @@ config ARCH_IMX8
> > select DM
> > select OF_CONTROL
> >
> > -config ARCH_MX8M
> > +config ARCH_IMX8M
> > bool "NXP i.MX8M platform"
> > select ARM64
> > select DM
> > @@ -1427,7 +1427,7 @@ source "arch/arm/mach-imx/mx7ulp/Kconfig"
> >
> >  source "arch/arm/mach-imx/imx8/Kconfig"
> >
> > -source "arch/arm/mach-imx/mx8m/Kconfig"
> > +source "arch/arm/mach-imx/imx8m/Kconfig"
> >
> >  source "arch/arm/mach-imx/mxs/Kconfig"
> >
> > diff --git a/arch/arm/Makefile b/arch/arm/Makefile index
> > 4b6c5e1935..63c2a5a0a0 100644
> > --- a/arch/arm/Makefile
> > +++ b/arch/arm/Makefile
> > @@ -102,11 +102,11 @@ libs-y += arch/arm/cpu/  libs-y += arch/arm/lib/
> >
> >  ifeq ($(CONFIG_SPL_BUILD),y)
> > -ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC),
> > mx25 mx5 mx6 mx7 mx35 mx8m))
> > +ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter $(SOC),
> > +mx25 mx5 mx6 mx7 mx35 imx8m))
> >  libs-y += arch/arm/mach-imx/
> >  endif
> >  else
> > -ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs
> > mx8m imx8 vf610))
> > +ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs
> > +imx8m imx8 vf610))
> >  libs-y += arch/arm/mach-imx/
> >  endif
> >  endif
> > diff --git a/arch/arm/include/asm/arch-imx/cpu.h
> > b/arch/arm/include/asm/arch-imx/cpu.h
> > index 46431b72ed..66

[U-Boot] [PULL u-boot] Please pull u-boot-amlogic-20181203

2018-12-03 Thread Neil Armstrong
Hi Tom,

I hope it's not too late, It's a single patch from Loic he reposted last week.

Thanks,
Neil

The following changes since commit 952061352acfd24034e6990b6b7d32cded020c0a:

  drivers: rtc: correctly convert seconds to time structure (2018-12-01 
18:03:14 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-amlogic.git tags/u-boot-amlogic-20181203

for you to fetch changes up to 8973d816588a8479eeb0e3a9f1e730922d3efc07:

  ARM: meson: Add regmap support for clock driver (2018-12-03 13:34:21 +0100)


ARM: meson: Add regmap support for clock driver and sync DT with 4.19


Loic Devulder (1):
  ARM: meson: Add regmap support for clock driver

 arch/arm/dts/meson-gx.dtsi| 31 +++---
 arch/arm/dts/meson-gxbb-nanopi-k2.dts | 48 ++
 arch/arm/dts/meson-gxbb.dtsi  | 14 ---
 arch/arm/dts/meson-gxl-mali.dtsi  |  2 +-
 arch/arm/dts/meson-gxl-s905x-libretech-cc.dts |  5 +--
 arch/arm/dts/meson-gxl-s905x-p212.dtsi|  8 ++--
 arch/arm/dts/meson-gxl.dtsi   | 26 +---
 arch/arm/dts/meson-gxm-khadas-vim2.dts| 24 +++
 drivers/clk/clk_meson.c   | 59 ++-
 9 files changed, 151 insertions(+), 66 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] imx8m: ddr: removed unused macros

2018-12-03 Thread Peng Fan
Remove unused DDRC register macros.

Signed-off-by: Peng Fan 
---

To address comments: 
https://lists.denx.de/pipermail/u-boot/2018-November/348351.html

 arch/arm/include/asm/arch-imx8m/ddr.h | 188 --
 1 file changed, 188 deletions(-)

diff --git a/arch/arm/include/asm/arch-imx8m/ddr.h 
b/arch/arm/include/asm/arch-imx8m/ddr.h
index 020f814f44..53d46256d8 100644
--- a/arch/arm/include/asm/arch-imx8m/ddr.h
+++ b/arch/arm/include/asm/arch-imx8m/ddr.h
@@ -356,194 +356,6 @@ enum msg_response {
TRAIN_FAIL = 0xff,
 };
 
-#define DDRC_MSTR_0 0x3d40
-#define DDRC_STAT_0 0x3d44
-#define DDRC_MSTR1_00x3d48
-#define DDRC_MRCTRL0_0  0x3d400010
-#define DDRC_MRCTRL1_0  0x3d400014
-#define DDRC_MRSTAT_0   0x3d400018
-#define DDRC_MRCTRL2_0  0x3d40001c
-#define DDRC_DERATEEN_0 0x3d400020
-#define DDRC_DERATEINT_00x3d400024
-#define DDRC_MSTR2_00x3d400028
-#define DDRC_PWRCTL_0   0x3d400030
-#define DDRC_PWRTMG_0   0x3d400034
-#define DDRC_HWLPCTL_0  0x3d400038
-#define DDRC_HWFFCCTL_0 0x3d40003c
-#define DDRC_HWFFCSTAT_00x3d400040
-#define DDRC_RFSHCTL0_0 0x3d400050
-#define DDRC_RFSHCTL1_0 0x3d400054
-#define DDRC_RFSHCTL2_0 0x3d400058
-#define DDRC_RFSHCTL3_0 0x3d400060
-#define DDRC_RFSHTMG_0  0x3d400064
-#define DDRC_ECCCFG0_0  0x3d400070
-#define DDRC_ECCCFG1_0  0x3d400074
-#define DDRC_ECCSTAT_0  0x3d400078
-#define DDRC_ECCCLR_0   0x3d40007c
-#define DDRC_ECCERRCNT_00x3d400080
-#define DDRC_ECCCADDR0_00x3d400084
-#define DDRC_ECCCADDR1_00x3d400088
-#define DDRC_ECCCSYN0_0 0x3d40008c
-#define DDRC_ECCCSYN1_0 0x3d400090
-#define DDRC_ECCCSYN2_0 0x3d400094
-#define DDRC_ECCBITMASK0_0  0x3d400098
-#define DDRC_ECCBITMASK1_0  0x3d40009c
-#define DDRC_ECCBITMASK2_0  0x3d4000a0
-#define DDRC_ECCUADDR0_00x3d4000a4
-#define DDRC_ECCUADDR1_00x3d4000a8
-#define DDRC_ECCUSYN0_0 0x3d4000ac
-#define DDRC_ECCUSYN1_0 0x3d4000b0
-#define DDRC_ECCUSYN2_0 0x3d4000b4
-#define DDRC_ECCPOISONADDR0_0   0x3d4000b8
-#define DDRC_ECCPOISONADDR1_0   0x3d4000bc
-#define DDRC_CRCPARCTL0_0   0x3d4000c0
-#define DDRC_CRCPARCTL1_0   0x3d4000c4
-#define DDRC_CRCPARCTL2_0   0x3d4000c8
-#define DDRC_CRCPARSTAT_0   0x3d4000cc
-#define DDRC_INIT0_00x3d4000d0
-#define DDRC_INIT1_00x3d4000d4
-#define DDRC_INIT2_00x3d4000d8
-#define DDRC_INIT3_00x3d4000dc
-#define DDRC_INIT4_00x3d4000e0
-#define DDRC_INIT5_00x3d4000e4
-#define DDRC_INIT6_00x3d4000e8
-#define DDRC_INIT7_00x3d4000ec
-#define DDRC_DIMMCTL_0  0x3d4000f0
-#define DDRC_RANKCTL_0  0x3d4000f4
-#define DDRC_DRAMTMG0_0 0x3d400100
-#define DDRC_DRAMTMG1_0 0x3d400104
-#define DDRC_DRAMTMG2_0 0x3d400108
-#define DDRC_DRAMTMG3_0 0x3d40010c
-#define DDRC_DRAMTMG4_0 0x3d400110
-#define DDRC_DRAMTMG5_0 0x3d400114
-#define DDRC_DRAMTMG6_0 0x3d400118
-#define DDRC_DRAMTMG7_0 0x3d40011c
-#define DDRC_DRAMTMG8_0 0x3d400120
-#define DDRC_DRAMTMG9_0 0x3d400124
-#define DDRC_DRAMTMG10_00x3d400128
-#define DDRC_DRAMTMG11_00x3d40012c
-#define DDRC_DRAMTMG12_00x3d400130
-#define DDRC_DRAMTMG13_00x3d400134
-#define DDRC_DRAMTMG14_00x3d400138
-#define DDRC_DRAMTMG15_00x3d40013C
-#define DDRC_DRAMTMG16_00x3d400140
-#define DDRC_DRAMTMG17_00x3d400144
-
-#define DDRC_ZQCTL0_0   0x3d400180
-#define DDRC_ZQCTL1_0   0x3d400184
-#define DDRC_ZQCTL2_0   0x3d400188
-#define DDRC_ZQSTAT_0   0x3d40018c
-#define DDRC_DFITMG0_0  0x3d400190
-#define DDRC_DFITMG1_0  0x3d400194
-#define DDRC_DFILPCFG0_00x3d400198
-#define DDRC_DFILPCFG1_00x3d40019c
-#define DDRC_DFIUPD0_0  0x3d4001a0
-#define DDRC_DFIUPD1_0  0x3d4001a4
-#define DDRC_DFIUPD2_0  0x3d4001a8
-
-#define DDRC_DFIMISC_0  0x3d4001b0
-#define DDRC_DFITMG2_0  0x3d4001b4
-#define DDRC_DFITMG3_0  0x3d4001b8
-#define DDRC_DFISTAT_0  0x3d4001bc
-
-#define DDRC_DBICTL_0   0x3d4001c0
-#define DDRC_DFIPHYMSTR_0   0x3d4001c4
-#define DDRC_TRAINCTL0_00x3d4001d0
-#define DDRC_TRAINCTL1_00x3d4001d4
-#define DDRC_TRAINCTL2_00x3d4001d8
-#define DDRC_TRAINSTAT_00x3d4001dc
-#define DDRC_ADDRMAP0_0 0x3d400200
-#define DDRC_ADDRMAP1_0 0x3d400204
-#define DDRC_ADDRMAP2_0 0x3d400208
-#define DDRC_ADDRMAP3_0 0x3d40020c
-#define DDRC_ADDRMAP4_0 0x3d400210
-#define DDRC_ADDRMAP5_0 0x3d400214
-#define DDRC_ADDRMAP6_0 0x3d400218
-#define DDRC_ADDRMAP7_0

Re: [U-Boot] [PATCH v3 5/5] arc: select BOUNCE_BUFFER for CMD_NAND on AXS10x

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:28 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:20, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The NAND driver of AXS10x depends on the availability of the bounce
buffer.  As the NAND driver is gated by CMD_NAND only, we need to
select BOUNCE_BUFFER conditionally (on CMD_NAND) for TARGET_AXS101 and
TARGET_AXS103.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>
---

Changes in v3: None
Changes in v2: None

arch/arc/Kconfig | 2 ++
include/configs/axs10x.h | 4 
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index fa6b344..50369d5 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -146,9 +146,11 @@ config TARGET_NSIM

config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
+ select BOUNCE_BUFFER if CMD_NAND

config TARGET_AXS103
bool "Support Synopsys Designware SDP board AXS103"
+ select BOUNCE_BUFFER if CMD_NAND

I'd say that more appropriate place is "board/synopsys/axs10x/Kconfig".
Because:
- This is related to the particular board, architecture has nothing to
  do with this
- Only 1 line of change will be required as both boards use the same
  Kconfig file

Happily, if you tell me how I can add a ‘select’ for this config-option in
board/synopsys/axs10x/Kconfig w/o unintended side-effects …
In other words: I failed when I tried to override CMD_NAND in that file.

Ok I see now. We need to have either "bool" or "tristate" Kconfig entry to
specify "select". So we'll need to introduce another hidden variable in
board/synopsys/axs10x/Kconfig to get it working... in that case I think your
initial proposal looks better.

Sorry for the noise then.

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


Re: [U-Boot] [PATCH] tools: zynqmpimage: round up partition size

2018-12-03 Thread Michal Simek
+Alex

On 28. 11. 18 11:47, Michael Tretter wrote:
> The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
> which implies that the partition size is 4 byte aligned. When writing the
> partition, mkimage calculates "Total Partition Word Length" by dividing
> the size by 4. This implicitly cuts unaligned bytes at the end of the
> added binary.
> 
> Instead of rounding down, the size must be round up to 4 bytes and the
> binary padded accordingly.
> 
> Signed-off-by: Michael Tretter 
> ---
>  tools/zynqmpbif.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
> index 6c8f66055d..885a037da6 100644
> --- a/tools/zynqmpbif.c
> +++ b/tools/zynqmpbif.c
> @@ -316,19 +316,29 @@ static int bif_add_pmufw(struct bif_entry *bf, const 
> char *data, size_t len)
>   return 0;
>  }
>  
> -static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
> +static int bif_add_part(struct bif_entry *bf, char *data, size_t len)
>  {
>   size_t parthdr_offset = 0;
> + size_t len_padded = ROUND(len, 4);
> +
>   struct partition_header parthdr = {
> - .len_enc = cpu_to_le32(len / 4),
> - .len_unenc = cpu_to_le32(len / 4),
> - .len = cpu_to_le32(len / 4),
> + .len_enc = cpu_to_le32(len_padded / 4),
> + .len_unenc = cpu_to_le32(len_padded / 4),
> + .len = cpu_to_le32(len_padded / 4),
>   .entry_point = cpu_to_le64(bf->entry),
>   .load_address = cpu_to_le64(bf->load),
>   };
>   int r;
>   uint32_t csum;
>  
> + if (len != len_padded) {
> + data = realloc(data, len_padded);
> + while (len < len_padded) {
> + data[len] = 0;
> + len++;
> + }
> + }
> +
>   if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
>   return bif_add_pmufw(bf, data, len);
>  
> 

I am not using this for creating boot image but I have tested it on
regular example and it is still working.

I have applied this to my branch.
Alex: If you have any comment on this please let us know and I can
remove it from my queue.

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


Re: [U-Boot] [PATCH] tools: zynqmpimage: round up partition size

2018-12-03 Thread Alexander Graf


On 03.12.18 14:14, Michal Simek wrote:
> +Alex
> 
> On 28. 11. 18 11:47, Michael Tretter wrote:
>> The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
>> which implies that the partition size is 4 byte aligned. When writing the
>> partition, mkimage calculates "Total Partition Word Length" by dividing
>> the size by 4. This implicitly cuts unaligned bytes at the end of the
>> added binary.
>>
>> Instead of rounding down, the size must be round up to 4 bytes and the
>> binary padded accordingly.
>>
>> Signed-off-by: Michael Tretter 
>> ---
>>  tools/zynqmpbif.c | 18 ++
>>  1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
>> index 6c8f66055d..885a037da6 100644
>> --- a/tools/zynqmpbif.c
>> +++ b/tools/zynqmpbif.c
>> @@ -316,19 +316,29 @@ static int bif_add_pmufw(struct bif_entry *bf, const 
>> char *data, size_t len)
>>  return 0;
>>  }
>>  
>> -static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
>> +static int bif_add_part(struct bif_entry *bf, char *data, size_t len)
>>  {
>>  size_t parthdr_offset = 0;
>> +size_t len_padded = ROUND(len, 4);
>> +
>>  struct partition_header parthdr = {
>> -.len_enc = cpu_to_le32(len / 4),
>> -.len_unenc = cpu_to_le32(len / 4),
>> -.len = cpu_to_le32(len / 4),
>> +.len_enc = cpu_to_le32(len_padded / 4),
>> +.len_unenc = cpu_to_le32(len_padded / 4),
>> +.len = cpu_to_le32(len_padded / 4),
>>  .entry_point = cpu_to_le64(bf->entry),
>>  .load_address = cpu_to_le64(bf->load),
>>  };
>>  int r;
>>  uint32_t csum;
>>  
>> +if (len != len_padded) {
>> +data = realloc(data, len_padded);
>> +while (len < len_padded) {
>> +data[len] = 0;
>> +len++;
>> +}
>> +}
>> +
>>  if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
>>  return bif_add_pmufw(bf, data, len);
>>  
>>
> 
> I am not using this for creating boot image but I have tested it on
> regular example and it is still working.
> 
> I have applied this to my branch.
> Alex: If you have any comment on this please let us know and I can
> remove it from my queue.

I don't think I've ever had a not-multiple-of-4 payload, so I never ran
into this.

The one thing that I'm not fully sure of is the realloc(). I don't think
that data is necessarily always a pointer that way allocated using malloc().

If you look at bif_add_bit() for example the data pointer is an offset
into a pointer from read_full_file(). So realloc() won't work on it.

I think it's safer to just allocate a completely new buffer here and
copy the payload if unaligned.


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


Re: [U-Boot] [PATCH v2 03/14] efi_loader: bootmgr: allow for running a given load option

2018-12-03 Thread Alexander Graf


On 03.12.18 04:20, AKASHI Takahiro wrote:
> On Mon, Dec 03, 2018 at 12:22:37AM +0100, Alexander Graf wrote:
>>
>>
>> On 05.11.18 10:06, AKASHI Takahiro wrote:
>>> With an extra argument, efi_bootmgr_load() can now load an efi binary
>>> based on a "Boot" variable specified.
>>>
>>> Signed-off-by: AKASHI Takahiro 
>>
>> I don't see you changing the caller, so this hunk won't compile on its own?
> 
> You're correct.
> 
>> Please make sure that every single step in your patch set compiles.
> 
> I will try to double-check in the future.
> 
>>> ---
>>>  include/efi_loader.h | 3 ++-
>>>  lib/efi_loader/efi_bootmgr.c | 8 +++-
>>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/efi_loader.h b/include/efi_loader.h
>>> index d83de906fbce..ce0f420b5004 100644
>>> --- a/include/efi_loader.h
>>> +++ b/include/efi_loader.h
>>> @@ -540,7 +540,8 @@ struct efi_load_option {
>>>  
>>>  void efi_deserialize_load_option(struct efi_load_option *lo, u8 *data);
>>>  unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 
>>> **data);
>>> -void *efi_bootmgr_load(struct efi_device_path **device_path,
>>> +void *efi_bootmgr_load(int boot_id,
>>> +  struct efi_device_path **device_path,
>>>struct efi_device_path **file_path);
>>>  
>>>  #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
>>> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
>>> index a095df3f540b..74eb832a8c92 100644
>>> --- a/lib/efi_loader/efi_bootmgr.c
>>> +++ b/lib/efi_loader/efi_bootmgr.c
>>> @@ -170,7 +170,8 @@ error:
>>>   * available load-options, finding and returning the first one that can
>>>   * be loaded successfully.
>>>   */
>>> -void *efi_bootmgr_load(struct efi_device_path **device_path,
>>> +void *efi_bootmgr_load(int boot_id,
>>> +  struct efi_device_path **device_path,
>>>struct efi_device_path **file_path)
>>>  {
>>> uint16_t *bootorder;
>>> @@ -183,6 +184,11 @@ void *efi_bootmgr_load(struct efi_device_path 
>>> **device_path,
>>> bs = systab.boottime;
>>> rs = systab.runtime;
>>>  
>>> +   if (boot_id != -1) {
>>> +   image = try_load_entry(boot_id, device_path, file_path);
>>> +   goto error;
>>
>> I think at this point it might be better to split the function, no?
> 
> It's one way to fix, but I want simply to fix the issue by
> modifying the caller, do_bootefi_bootmgr_exec() because
> 
>> You're not actually reusing any code from efi_bootmgr_load with the 2
>> instantiation types (explicit boot id, loop through boot order).
> 
> I will add "BootNext" support to efi_bootmgr_load() so that it will be
> a single point of loading. See my relevant patch:
> https://lists.denx.de/pipermail/u-boot/2018-November/349281.html

I don't fully understand. I would expect BootNext to only take effect
when *not* booting an explicit ID? So that would fit quite nicely into a
function based split.


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


Re: [U-Boot] [PATCH v2 04/14] cmd: add efishell command

2018-12-03 Thread Alexander Graf


On 03.12.18 07:42, AKASHI Takahiro wrote:
> On Mon, Dec 03, 2018 at 12:42:43AM +0100, Alexander Graf wrote:
>>
>>
>> On 05.11.18 10:06, AKASHI Takahiro wrote:
>>> Currently, there is no easy way to add or modify UEFI variables.
>>> In particular, bootmgr supports BootOrder/Boot variables, it is
>>> quite hard to define them as u-boot variables because they are represented
>>> in a complicated and encoded format.
>>>
>>> The new command, efishell, helps address these issues and give us
>>> more friendly interfaces:
>>>  * efishell boot add: add Boot variable
>>>  * efishell boot rm: remove Boot variable
>>>  * efishell boot dump: display all Boot variables
>>>  * efishell boot order: set/display a boot order (BootOrder)
>>>  * efishell setvar: set an UEFI variable (with limited functionality)
>>>  * efishell dumpvar: display all UEFI variables
>>>
>>> As the name suggests, this command basically provides a subset fo UEFI
>>> shell commands with simplified functionality.
>>>
>>> Signed-off-by: AKASHI Takahiro 
>>> ---
>>>  cmd/Makefile   |   2 +-
>>>  cmd/efishell.c | 673 +
>>>  cmd/efishell.h |   5 +
>>>  3 files changed, 679 insertions(+), 1 deletion(-)
>>>  create mode 100644 cmd/efishell.c
>>>  create mode 100644 cmd/efishell.h
>>>
>>> diff --git a/cmd/Makefile b/cmd/Makefile
>>> index d9cdaf6064b8..bd531d505a8e 100644
>>> --- a/cmd/Makefile
>>> +++ b/cmd/Makefile
>>> @@ -24,7 +24,7 @@ obj-$(CONFIG_CMD_BINOP) += binop.o
>>>  obj-$(CONFIG_CMD_BLOCK_CACHE) += blkcache.o
>>>  obj-$(CONFIG_CMD_BMP) += bmp.o
>>>  obj-$(CONFIG_CMD_BOOTCOUNT) += bootcount.o
>>> -obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
>>> +obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o efishell.o
>>
>> Please create a separate command line option for efishell and make it
>> disabled by default.
> 
> OK.
> 
>> I think it's a really really useful debugging aid, but in a normal
>> environment people should only need to run efi binaries (plus bootmgr)
>> and modify efi variables, no?
> 
> The ultimate goal would be to provide this command as a separate
> application. In this case, however, it won't much different from
> uefi shell itself :)
> 
>>
>>
>>>  obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
>>>  obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
>>>  obj-$(CONFIG_CMD_BOOTZ) += bootz.o
>>> diff --git a/cmd/efishell.c b/cmd/efishell.c
>>> new file mode 100644
>>> index ..abc8216c7bd6
>>> --- /dev/null
>>> +++ b/cmd/efishell.c
>>> @@ -0,0 +1,673 @@
>>> +// SPDX-License-Identifier: GPL-2.0+
>>> +/*
>>> + *  EFI Shell-like command
>>> + *
>>> + *  Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include "efishell.h"
>>> +
>>> +DECLARE_GLOBAL_DATA_PTR;
>>
>> Where in this file do you need gd?
> 
> OK.
> # I thought this should always be declared in any file by default.

You only need to declare it when you need gd :). Most efi_loader code
should be able to live just fine without.

[...]

>>> +   /* optional data */
>>> +   lo.optional_data = (u8 *)(argc == 6 ? "" : argv[6]);
>>> +
>>> +   size = efi_serialize_load_option(&lo, (u8 **)&data);
>>> +   if (!size) {
>>> +   ret = CMD_RET_FAILURE;
>>> +   goto out;
>>> +   }
>>> +
>>> +   ret = efi_set_variable(var_name16, &guid,
>>> +  EFI_VARIABLE_BOOTSERVICE_ACCESS |
>>> +  EFI_VARIABLE_RUNTIME_ACCESS, size, data);
>>> +   ret = (ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE);
>>> +out:
>>> +   free(data);
>>> +#if 0 /* FIXME */
>>
>> Eh, what? :)
> 
> Well, in the past, I saw u-boot hang-out if free()'s were enabled.
> Now I found that we must free data with efi_free_pool() instead of free().

It depends on how data was allocated, yes.

> 
>>> +   free(device_path);
>>> +   free(file_path);
>>> +#endif
>>> +   free(lo.label);
>>> +   return ret;
>>> +}
>>> +

[...]

>>> diff --git a/cmd/efishell.h b/cmd/efishell.h
>>> new file mode 100644
>>> index ..6f70b402b26b
>>> --- /dev/null
>>> +++ b/cmd/efishell.h
>>> @@ -0,0 +1,5 @@
>>> +// SPDX-License-Identifier: GPL-2.0+
>>> +
>>> +#include 
>>> +
>>> +efi_status_t efi_init_obj_list(void);
>>
>> Why isn't this in efi_loader.h? That's the subsystem that exports it, no?
> 
> Agree. Moreover, I think of refactoring the code and moving 
> efi_init_obj_list()
> to a new file, lib/efi_loader/efi_setup.c, so that we can add more
> features directly as part of the initialization code.

Well, as Heinrich already indicated, the long term goal would be to have
UEFI handles implicitly generated for DM devices. So we wouldn't need to
maintain our own copy of the already existing object model.


Alex

> Features may include USB removable disk support for which I already posted
> a patch set[1] and yet-coming capsule-on-disk supp

Re: [U-Boot] [PATCH 1/2] Kconfig: Add entry for VF610 NAND NFC device tree aware driver

2018-12-03 Thread Stefan Agner
On 03.12.2018 10:24, Lukasz Majewski wrote:
> This commit provides code to add proper entry to Kconfig to enable
> support for VF610 device tree aware driver.

Looks like a start, but ideally we should also move all the board/system
specific properties to device-tree (e.g.
CONFIG_SYS_NAND_VF610_NFC_45_ECC_BYTES).

--
Stefan

> 
> Signed-off-by: Lukasz Majewski 
> 
> ---
> 
>  drivers/mtd/nand/raw/Kconfig | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
> index 008f7b4b4b..fd1723feda 100644
> --- a/drivers/mtd/nand/raw/Kconfig
> +++ b/drivers/mtd/nand/raw/Kconfig
> @@ -88,6 +88,15 @@ config NAND_VF610_NFC
> The driver supports a maximum 2k page size. The driver
> currently does not support hardware ECC.
>  
> +if NAND_VF610_NFC
> +
> +config NAND_VF610_NFC_DT
> +bool "Support Vybrid's vf610 NAND controller as a DT device"
> +depends on OF_CONTROL && MTD
> +help
> +  Enable the driver for Vybrid's vf610 NAND flash on platforms
> +   using device tree.
> +
>  choice
>   prompt "Hardware ECC strength"
>   depends on NAND_VF610_NFC
> @@ -103,6 +112,8 @@ config SYS_NAND_VF610_NFC_60_ECC_BYTES
>  
>  endchoice
>  
> +endif
> +
>  config NAND_PXA3XX
>   bool "Support for NAND on PXA3xx and Armada 370/XP/38x"
>   select SYS_NAND_SELF_INIT
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Philipp Tomsich
Alexey,

> On 03.12.2018, at 12:17, Alexey Brodkin  wrote:
> 
> Hi Philipp,
> 
> On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
>> The bounce buffer is used by a few drivers (most of the MMC drivers)
>> to overcome limitations in their respective DMA implementation.
>> 
>> This moves the configuration to Kconfig and makes it user-selectable
>> (even though it will be a required feature to make those drivers
>> work): the expected usage is for drivers depending on this to 'select'
>> it unconditionally from their respective Kconfig (see follow-up
>> patches).
>> 
>> This commit includes a full migration using moveconfig.py to ensure
>> that each commit compiles; successive commits will introduce
>> individual dependencies for drivers and then undo some of the changes
>> to the defconfig files.
>> 
>> Signed-off-by: Philipp Tomsich 
>> 
>> ---
> 
> [snip]
> 
>> diff --git a/common/Kconfig b/common/Kconfig
>> index 57bd16d..5bbd00a 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
>>the relocation phase. The board function checkboard() is called to do
>>this.
>> 
>> +config BOUNCE_BUFFER
>> +bool "Include bounce buffer API"
>> +help
>> +  Some peripherals support DMA from a subset of physically
>> +  addressable memory only.  To support such peripherals, the
>> +  bounce buffer API uses a temporary buffer: it copies data
>> +  to/from DMA regions while managing cache operations.
>> +
>> +  A second possible use of bounce buffers is their ability to
>> +  provide aligned buffers for DMA operations.
>> +
> 
> Here you only add BOUNCE_BUFFER option and yet it is not dependent
> on anything, right?
> 
>> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
>> index 1b2966f..8febe09 100644
>> --- a/include/configs/axs10x.h
>> +++ b/include/configs/axs10x.h
>> @@ -85,6 +85,5 @@
>> /*
>>  * Misc utility configuration
>>  */
>> -#define CONFIG_BOUNCE_BUFFER
>> 
>> #endif /* _CONFIG_AXS10X_H_ */
> 
> ...
> 
>> diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
>> index 385d59e..a77f262 100644
>> --- a/include/configs/emsdp.h
>> +++ b/include/configs/emsdp.h
>> @@ -19,7 +19,6 @@
>> #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE
>> 
>> /* Required by DW MMC driver */
>> -#define CONFIG_BOUNCE_BUFFER
>> 
>> /*
>>  * Environment
> 
> ...
> 
>> diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
>> index cdf4fdd..bafd8d0 100644
>> --- a/include/configs/hsdk.h
>> +++ b/include/configs/hsdk.h
>> @@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
>> /*
>>  * Misc utility configuration
>>  */
>> -#define CONFIG_BOUNCE_BUFFER
>> 
>> /* Cli configuration */
>> #define CONFIG_SYS_CBSIZESZ_2K
>> diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
>> index 4ffe114..1f40d61 100644
>> --- a/include/configs/iot_devkit.h
>> +++ b/include/configs/iot_devkit.h
>> @@ -72,7 +72,6 @@
>>  CONFIG_ENV_SIZE
>> 
>> /* Required by DW MMC driver */
>> -#define CONFIG_BOUNCE_BUFFER
>> 
>> /*
>>  * Environment
> 
> And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
> which breaks MMC on these boards.
> 
> I understand that you're fixing that in the subsequent commit but
> I'd prefer all changes to be bisectable, i.e. have normally working system
> on each and every commit.
> 
> Moreover IMHO it doesn't look logical to remove "#define 
> CONFIG_BOUNCE_BUFFER" here
> while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
> next commit.

In this patch, moveconfig has moved the selction this into the respective 
_defconfig files
for the  AXS10x boards.

The later patches merely add the infrastructure to Kconfig to ensure this is 
automatically
selected and can’t be turned off...

> 
> So maybe we need to split this first commit in 3 parts and
> squash it with 2, 3 and 4.


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


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Philipp Tomsich
Alexey,

> On 03.12.2018, at 13:35, Alexey Brodkin  wrote:
> 
> Hi Philipp,
> 
> On Mon, 2018-12-03 at 13:32 +0100, Philipp Tomsich wrote:
>> Alexey,
>> 
>>> On 03.12.2018, at 12:17, Alexey Brodkin >> > wrote:
>>> 
>>> Hi Philipp,
>>> 
>>> On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
 The bounce buffer is used by a few drivers (most of the MMC drivers)
 to overcome limitations in their respective DMA implementation.
 
 This moves the configuration to Kconfig and makes it user-selectable
 (even though it will be a required feature to make those drivers
 work): the expected usage is for drivers depending on this to 'select'
 it unconditionally from their respective Kconfig (see follow-up
 patches).
 
 This commit includes a full migration using moveconfig.py to ensure
 that each commit compiles; successive commits will introduce
 individual dependencies for drivers and then undo some of the changes
 to the defconfig files.
 
 Signed-off-by: Philipp Tomsich >>> >
 
 ---
>>> 
>>> [snip]
>>> 
 diff --git a/common/Kconfig b/common/Kconfig
 index 57bd16d..5bbd00a 100644
 --- a/common/Kconfig
 +++ b/common/Kconfig
 @@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
   the relocation phase. The board function checkboard() is called to do
   this.
 
 +config BOUNCE_BUFFER
 + bool "Include bounce buffer API"
 + help
 +   Some peripherals support DMA from a subset of physically
 +   addressable memory only.  To support such peripherals, the
 +   bounce buffer API uses a temporary buffer: it copies data
 +   to/from DMA regions while managing cache operations.
 +
 +   A second possible use of bounce buffers is their ability to
 +   provide aligned buffers for DMA operations.
 +
>>> 
>>> Here you only add BOUNCE_BUFFER option and yet it is not dependent
>>> on anything, right?
>>> 
 diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
 index 1b2966f..8febe09 100644
 --- a/include/configs/axs10x.h
 +++ b/include/configs/axs10x.h
 @@ -85,6 +85,5 @@
 /*
  * Misc utility configuration
  */
 -#define CONFIG_BOUNCE_BUFFER
 
 #endif /* _CONFIG_AXS10X_H_ */
>>> 
>>> ...
>>> 
 diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
 index 385d59e..a77f262 100644
 --- a/include/configs/emsdp.h
 +++ b/include/configs/emsdp.h
 @@ -19,7 +19,6 @@
 #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE
 
 /* Required by DW MMC driver */
 -#define CONFIG_BOUNCE_BUFFER
 
 /*
  * Environment
>>> 
>>> ...
>>> 
 diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
 index cdf4fdd..bafd8d0 100644
 --- a/include/configs/hsdk.h
 +++ b/include/configs/hsdk.h
 @@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
 /*
  * Misc utility configuration
  */
 -#define CONFIG_BOUNCE_BUFFER
 
 /* Cli configuration */
 #define CONFIG_SYS_CBSIZE SZ_2K
 diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
 index 4ffe114..1f40d61 100644
 --- a/include/configs/iot_devkit.h
 +++ b/include/configs/iot_devkit.h
 @@ -72,7 +72,6 @@
 CONFIG_ENV_SIZE
 
 /* Required by DW MMC driver */
 -#define CONFIG_BOUNCE_BUFFER
 
 /*
  * Environment
>>> 
>>> And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
>>> which breaks MMC on these boards.
>>> 
>>> I understand that you're fixing that in the subsequent commit but
>>> I'd prefer all changes to be bisectable, i.e. have normally working system
>>> on each and every commit.
>>> 
>>> Moreover IMHO it doesn't look logical to remove "#define 
>>> CONFIG_BOUNCE_BUFFER" here
>>> while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in 
>>> the next commit.
>> 
>> In this patch, moveconfig has moved the selction this into the respective 
>> _defconfig files
>> for the  AXS10x boards.
> 
> Hm... are you sure axs101_defconfig & axs103_defconfig were updated in this 
> patch?
> I didn't see them there.

You are right: my ARC toolchain wasn’t configured …
I’ll need to debug my toolchain configs and rerun my moveconfig.

Thanks for pointing this out.

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


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:32 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:17, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:

Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The bounce buffer is used by a few drivers (most of the MMC drivers)
to overcome limitations in their respective DMA implementation.

This moves the configuration to Kconfig and makes it user-selectable
(even though it will be a required feature to make those drivers
work): the expected usage is for drivers depending on this to 'select'
it unconditionally from their respective Kconfig (see follow-up
patches).

This commit includes a full migration using moveconfig.py to ensure
that each commit compiles; successive commits will introduce
individual dependencies for drivers and then undo some of the changes
to the defconfig files.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>

---

[snip]

diff --git a/common/Kconfig b/common/Kconfig
index 57bd16d..5bbd00a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
  the relocation phase. The board function checkboard() is called to do
  this.

+config BOUNCE_BUFFER
+ bool "Include bounce buffer API"
+ help
+   Some peripherals support DMA from a subset of physically
+   addressable memory only.  To support such peripherals, the
+   bounce buffer API uses a temporary buffer: it copies data
+   to/from DMA regions while managing cache operations.
+
+   A second possible use of bounce buffers is their ability to
+   provide aligned buffers for DMA operations.
+

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 1b2966f..8febe09 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -85,6 +85,5 @@
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

#endif /* _CONFIG_AXS10X_H_ */

...

diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 385d59e..a77f262 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -19,7 +19,6 @@
#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

...

diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index cdf4fdd..bafd8d0 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

/* Cli configuration */
#define CONFIG_SYS_CBSIZE SZ_2K
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe114..1f40d61 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -72,7 +72,6 @@
CONFIG_ENV_SIZE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

In this patch, moveconfig has moved the selction this into the respective 
_defconfig files
for the  AXS10x boards.

Hm... are you sure axs101_defconfig & axs103_defconfig were updated in this 
patch?
I didn't see them there.

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


[U-Boot] [PATCH] ARM: DTS: Resync am3517-evm.dts with Linux 4.20

2018-12-03 Thread Adam Ford
The DTS file for the AM3517 had the incorrect CD polarity.  Resync with
the fixed DTS file from Linux.

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/am3517-evm-ui.dtsi b/arch/arm/dts/am3517-evm-ui.dtsi
new file mode 100644
index 00..e841918c1c
--- /dev/null
+++ b/arch/arm/dts/am3517-evm-ui.dtsi
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2018 Logic PD, Inc - http://www.logicpd.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+/ {
+   codec1 {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "tlv320aic23-hifi";
+
+   simple-audio-card,widgets =
+   "Microphone", "Mic In",
+   "Line", "Line In",
+   "Line", "Line Out";
+
+   simple-audio-card,routing =
+   "Line Out", "LOUT",
+   "Line Out", "ROUT",
+   "LLINEIN", "Line In",
+   "RLINEIN", "Line In",
+   "MICIN", "Mic In";
+
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <&sound_master>;
+   simple-audio-card,frame-master = <&sound_master>;
+
+   simple-audio-card,cpu {
+   sound-dai = <&mcbsp1>;
+   };
+
+   sound_master: simple-audio-card,codec {
+   sound-dai = <&tlv320aic23_1>;
+   system-clock-frequency = <1200>;
+   };
+   };
+
+   codec2 {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "tlv320aic23-hifi";
+
+   simple-audio-card,widgets =
+   "Microphone", "Mic In",
+   "Line", "Line In",
+   "Line", "Line Out";
+
+   simple-audio-card,routing =
+   "Line Out", "LOUT",
+   "Line Out", "ROUT",
+   "LLINEIN", "Line In",
+   "RLINEIN", "Line In",
+   "MICIN", "Mic In";
+
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <&sound_master2>;
+   simple-audio-card,frame-master = <&sound_master2>;
+
+   simple-audio-card,cpu {
+   sound-dai = <&mcbsp2>;
+   };
+
+   sound_master2: simple-audio-card,codec {
+   sound-dai = <&tlv320aic23_2>;
+   system-clock-frequency = <1200>;
+   };
+   };
+
+   expander-keys {
+   compatible = "gpio-keys-polled";
+   poll-interval = <100>;
+
+   record {
+   label = "Record";
+   /* linux,code = ; */
+   gpios = <&tca6416_2 15 GPIO_ACTIVE_LOW>;
+   };
+
+   play {
+   label = "Play";
+   linux,code = ;
+   gpios = <&tca6416_2 14 GPIO_ACTIVE_LOW>;
+   };
+
+   Stop {
+   label = "Stop";
+   linux,code = ;
+   gpios = <&tca6416_2 13 GPIO_ACTIVE_LOW>;
+   };
+
+   fwd {
+   label = "FWD";
+   linux,code = ;
+   gpios = <&tca6416_2 12 GPIO_ACTIVE_LOW>;
+   };
+
+   rwd {
+   label = "RWD";
+   linux,code = ;
+   gpios = <&tca6416_2 11 GPIO_ACTIVE_LOW>;
+   };
+
+   shift {
+   label = "Shift";
+   linux,code = ;
+   gpios = <&tca6416_2 10 GPIO_ACTIVE_LOW>;
+   };
+
+   Mode {
+   label = "Mode";
+   linux,code = ;
+   gpios = <&tca6416_2 9 GPIO_ACTIVE_LOW>;
+   };
+
+   Menu {
+   label = "Menu";
+   linux,code = ;
+   gpios = <&tca6416_2 8 GPIO_ACTIVE_LOW>;
+   };
+
+   Up {
+   label = "Up";
+   linux,code = ;
+   gpios = <&tca6416_2 7 GPIO_ACTIVE_LOW>;
+   };
+
+   Down {
+   label = "Down";
+   linux,code = ;
+   gpios = <&tca6416_2 6 GPIO_ACTIVE_LOW>;
+   };
+   };
+};
+
+&i2c2 {
+   /* Audio codecs */
+   tlv320aic23_1: codec@1a {
+   compatible = "ti,tlv320aic23";
+   reg = <0x1a>;
+   #sound-dai-cells= <0>;
+   status = "oka

Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:38 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 13:35, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Mon, 2018-12-03 at 13:32 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:17, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The bounce buffer is used by a few drivers (most of the MMC drivers)
to overcome limitations in their respective DMA implementation.

This moves the configuration to Kconfig and makes it user-selectable
(even though it will be a required feature to make those drivers
work): the expected usage is for drivers depending on this to 'select'
it unconditionally from their respective Kconfig (see follow-up
patches).

This commit includes a full migration using moveconfig.py to ensure
that each commit compiles; successive commits will introduce
individual dependencies for drivers and then undo some of the changes
to the defconfig files.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>

---

[snip]

diff --git a/common/Kconfig b/common/Kconfig
index 57bd16d..5bbd00a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
  the relocation phase. The board function checkboard() is called to do
  this.

+config BOUNCE_BUFFER
+ bool "Include bounce buffer API"
+ help
+   Some peripherals support DMA from a subset of physically
+   addressable memory only.  To support such peripherals, the
+   bounce buffer API uses a temporary buffer: it copies data
+   to/from DMA regions while managing cache operations.
+
+   A second possible use of bounce buffers is their ability to
+   provide aligned buffers for DMA operations.
+

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 1b2966f..8febe09 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -85,6 +85,5 @@
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

#endif /* _CONFIG_AXS10X_H_ */

...

diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 385d59e..a77f262 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -19,7 +19,6 @@
#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

...

diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index cdf4fdd..bafd8d0 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

/* Cli configuration */
#define CONFIG_SYS_CBSIZE SZ_2K
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe114..1f40d61 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -72,7 +72,6 @@
CONFIG_ENV_SIZE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

In this patch, moveconfig has moved the selction this into the respective 
_defconfig files
for the  AXS10x boards.

But still if CONFIG_BOUNCE_BUFFER is gone shouldn't we remove a relevant 
comment as well?


Hm... are you sure axs101_defconfig & axs103_defconfig were updated in this 
patch?
I didn't see them there.

You are right: my ARC toolchain wasn’t configured …
I’ll need to debug my toolchain configs and rerun my moveconfig.

You may want to see how ARC toolchain is retrieved by TravisCI job:
http://git.denx.de/?p=u-boot.git;a=blob;f=.travis.yml#l78

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


[U-Boot] [PATCH] travis: Bump ARC tools to arc-2018.09

2018-12-03 Thread Alexey Brodkin
Build tested in Travis, see:
https://travis-ci.org/abrodkin/u-boot/jobs/462808237

Signed-off-by: Alexey Brodkin 
---
 .travis.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a061f02399c0..ed07d817fa47 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,7 +42,7 @@ install:
  - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
  # prepare buildman environment
  - echo -e "[toolchain]\nroot = /usr" > ~/.buildman
- - echo -e "arc = /tmp/arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
+ - echo -e "arc = /tmp/arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
  - echo -e "\n[toolchain-alias]\nsh = sh2\n" >> ~/.buildman
  - cat ~/.buildman
  - virtualenv /tmp/venv
@@ -75,8 +75,8 @@ before_script:
   echo -e "\n[toolchain-alias]\nx86 = i386" >> ~/.buildman;
 fi
   - if [[ "${TOOLCHAIN}" == arc ]]; then
-   wget 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2017.09-release/arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install.tar.gz
 &&
-   tar -C /tmp -xf 
arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install.tar.gz;
+   wget 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2018.09-release/arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install.tar.gz
 &&
+   tar -C /tmp -xf 
arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install.tar.gz;
 fi
   - if [[ "${TOOLCHAIN}" == *xtensa* ]]; then
wget 
https://github.com/foss-xtensa/toolchain/releases/download/2018.02/x86_64-2018.02-${TOOLCHAIN}.tar.gz
 &&
-- 
2.19.1

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


[U-Boot] [PATCH] serial: omap: Add code for early debugging

2018-12-03 Thread Felix Brack
This patch adds code missing when CONFIG_DEBUG_UART_OMAP is enabled as
early debugging UART. The code is basically copied from the ns16550
driver.

Signed-off-by: Felix Brack 
---

 drivers/serial/serial_omap.c | 42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c
index ee6ad9c9e5..a31d73766d 100644
--- a/drivers/serial/serial_omap.c
+++ b/drivers/serial/serial_omap.c
@@ -7,7 +7,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -20,6 +19,47 @@
 
 #ifdef CONFIG_DEBUG_UART_OMAP
 
+#ifndef CONFIG_SYS_NS16550_IER
+#define CONFIG_SYS_NS16550_IER  0x00
+#endif
+
+#define UART_MCRVAL 0x00
+#define UART_LCRVAL UART_LCR_8N1
+
+static inline void serial_out_shift(void *addr, int shift, int value)
+{
+#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
+   outb(value, (ulong)addr);
+#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_LITTLE_ENDIAN)
+   out_le32(addr, value);
+#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
+   out_be32(addr, value);
+#elif defined(CONFIG_SYS_NS16550_MEM32)
+   writel(value, addr);
+#elif defined(CONFIG_SYS_BIG_ENDIAN)
+   writeb(value, addr + (1 << shift) - 1);
+#else
+   writeb(value, addr);
+#endif
+}
+
+static inline int serial_in_shift(void *addr, int shift)
+{
+#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
+   return inb((ulong)addr);
+#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_LITTLE_ENDIAN)
+   return in_le32(addr);
+#elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
+   return in_be32(addr);
+#elif defined(CONFIG_SYS_NS16550_MEM32)
+   return readl(addr);
+#elif defined(CONFIG_SYS_BIG_ENDIAN)
+   return readb(addr + (1 << shift) - 1);
+#else
+   return readb(addr);
+#endif
+}
+
 #include 
 
 static inline void _debug_uart_init(void)
-- 
2.17.1

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


Re: [U-Boot] [PATCH 1/2] net: phy: Move fixed link code to separate routine

2018-12-03 Thread Michal Simek
Hi Joe,

On 27. 11. 18 7:19, Siva Durga Prasad Paladugu wrote:
> This patch moves fixed-link functionality code to a separate
> routine inorder to make it more modular and cleaner.
> 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
>  drivers/net/phy/phy.c | 34 +++---
>  1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index e837eb7..3cb2785 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -875,18 +875,18 @@ void phy_connect_dev(struct phy_device *phydev, struct 
> eth_device *dev)
>   debug("%s connected to %s\n", dev->name, phydev->drv->name);
>  }
>  
> +#ifdef CONFIG_PHY_FIXED
>  #ifdef CONFIG_DM_ETH
> -struct phy_device *phy_connect(struct mii_dev *bus, int addr,
> -struct udevice *dev,
> -phy_interface_t interface)
> +static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
> + struct udevice *dev,
> + phy_interface_t interface)
>  #else
> -struct phy_device *phy_connect(struct mii_dev *bus, int addr,
> -struct eth_device *dev,
> -phy_interface_t interface)
> +static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
> + struct eth_device *dev,
> + phy_interface_t interface)
>  #endif
>  {
>   struct phy_device *phydev = NULL;
> -#ifdef CONFIG_PHY_FIXED
>   int sn;
>   const char *name;
>  
> @@ -900,7 +900,27 @@ struct phy_device *phy_connect(struct mii_dev *bus, int 
> addr,
>   }
>   sn = fdt_next_subnode(gd->fdt_blob, sn);
>   }
> +
> + return phydev;
> +}
>  #endif
> +
> +#ifdef CONFIG_DM_ETH
> +struct phy_device *phy_connect(struct mii_dev *bus, int addr,
> +struct udevice *dev,
> +phy_interface_t interface)
> +#else
> +struct phy_device *phy_connect(struct mii_dev *bus, int addr,
> +struct eth_device *dev,
> +phy_interface_t interface)
> +#endif
> +{
> + struct phy_device *phydev = NULL;
> +
> +#ifdef CONFIG_PHY_FIXED
> + phydev = phy_connect_fixed(bus, dev, interface);
> +#endif
> +
>   if (!phydev)
>   phydev = phy_find_by_mask(bus, 1 << addr, interface);
>  
> 

can you please take a look at this?
Unfortunately there are no IDs to check that's why we had to do it in
this way. I would like to get this to v2019.01.

Thanks,
Michal

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


[U-Boot] [PATCH] ARM: DTS: Resync LogicPD SOM-LV with Linux 4.20

2018-12-03 Thread Adam Ford
There have been a few fixes to the device trees, so this
re-syncs the dts/dtsi files with Linux

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts 
b/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts
index 4cd72b5e61..32d0dc371f 100644
--- a/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts
+++ b/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts
@@ -15,18 +15,3 @@
model = "LogicPD Zoom OMAP35xx SOM-LV Development Kit";
compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3";
 };
-
-&omap3_pmx_core2 {
-   pinctrl-names = "default";
-   pinctrl-0 = <&hsusb2_2_pins>;
-   hsusb2_2_pins: pinmux_hsusb2_2_pins {
-   pinctrl-single,pins = <
-   OMAP3430_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3)
/* etk_d10.hsusb2_clk */
-   OMAP3430_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3)
/* etk_d11.hsusb2_stp */
-   OMAP3430_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d12.hsusb2_dir */
-   OMAP3430_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d13.hsusb2_nxt */
-   OMAP3430_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d14.hsusb2_data0 */
-   OMAP3430_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d15.hsusb2_data1 */
-   >;
-   };
-};
diff --git a/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts 
b/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts
index 2aca9111c6..2428373952 100644
--- a/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts
+++ b/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts
@@ -15,18 +15,3 @@
model = "LogicPD Zoom DM3730 SOM-LV Development Kit";
compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3630", "ti,omap3";
 };
-
-&omap3_pmx_core2 {
-   pinctrl-names = "default";
-   pinctrl-0 = <&hsusb2_2_pins>;
-   hsusb2_2_pins: pinmux_hsusb2_2_pins {
-   pinctrl-single,pins = <
-   OMAP3630_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3)
/* etk_d10.hsusb2_clk */
-   OMAP3630_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3)
/* etk_d11.hsusb2_stp */
-   OMAP3630_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d12.hsusb2_dir */
-   OMAP3630_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d13.hsusb2_nxt */
-   OMAP3630_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d14.hsusb2_data0 */
-   OMAP3630_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | 
MUX_MODE3)/* etk_d15.hsusb2_data1 */
-   >;
-   };
-};
diff --git a/arch/arm/dts/logicpd-som-lv.dtsi b/arch/arm/dts/logicpd-som-lv.dtsi
index 03485509c8..98b682a808 100644
--- a/arch/arm/dts/logicpd-som-lv.dtsi
+++ b/arch/arm/dts/logicpd-som-lv.dtsi
@@ -129,7 +129,7 @@
 };
 
 &mmc3 {
-   interrupts-extended = <&intc 94>;
+   interrupts-extended = <&intc 94 &omap3_pmx_core 0x136>;
pinctrl-0 = <&mmc3_pins &wl127x_gpio>;
pinctrl-names = "default";
vmmc-supply = <&wl12xx_vmmc>;
@@ -232,20 +232,6 @@
>;
};
 
-   i2c2_pins: pinmux_i2c2_pins {
-   pinctrl-single,pins = <
-   OMAP3_CORE1_IOPAD(0x21be, PIN_INPUT | MUX_MODE0)
/* i2c2_scl */
-   OMAP3_CORE1_IOPAD(0x21c0, PIN_INPUT | MUX_MODE0)
/* i2c2_sda */
-   >;
-   };
-
-   i2c3_pins: pinmux_i2c3_pins {
-   pinctrl-single,pins = <
-   OMAP3_CORE1_IOPAD(0x21c2, PIN_INPUT | MUX_MODE0)
/* i2c3_scl */
-   OMAP3_CORE1_IOPAD(0x21c4, PIN_INPUT | MUX_MODE0)
/* i2c3_sda */
-   >;
-   };
-
tsc2004_pins: pinmux_tsc2004_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x2186, PIN_INPUT | MUX_MODE4)
/* mcbsp4_dr.gpio_153 */
@@ -267,6 +253,33 @@
OMAP3_WKUP_IOPAD(0x2a0c, PIN_OUTPUT | MUX_MODE4)
/* sys_boot1.gpio_3 */
>;
};
+   i2c2_pins: pinmux_i2c2_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x21be, PIN_INPUT | MUX_MODE0)
/* i2c2_scl */
+   OMAP3_CORE1_IOPAD(0x21c0, PIN_INPUT | MUX_MODE0)
/* i2c2_sda */
+   >;
+   };
+   i2c3_pins: pinmux_i2c3_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x21c2, PIN_INPUT | MUX_MODE0)
/* i2c3_scl */
+   OMAP3_CORE1_IOPAD(0x21c4, PIN_INPUT | MUX_MODE0)
/* i2c3_sda */
+   >;
+   };
+};
+
+&omap3_pmx_core2 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&hsusb2_2_pins>;
+   hsusb2_2_pins: pinmux_hsusb2_2_pins {
+   pinctrl-single,pins = <
+   OMAP3

[U-Boot] [PATCH] ARM: DTS: Resync LogicPD-Torpedo-37xx-devkit with Linux 4.20

2018-12-03 Thread Adam Ford
Migrate some small device tree fixes from Linux 4.20.

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/logicpd-torpedo-37xx-devkit.dts 
b/arch/arm/dts/logicpd-torpedo-37xx-devkit.dts
index 9d5d53fbe9..c39cf2ca54 100644
--- a/arch/arm/dts/logicpd-torpedo-37xx-devkit.dts
+++ b/arch/arm/dts/logicpd-torpedo-37xx-devkit.dts
@@ -35,7 +35,7 @@
  * jumpering combinations for the long run.
  */
 &mmc3 {
-   interrupts-extended = <&intc 94 &omap3_pmx_core2 0x46>;
+   interrupts-extended = <&intc 94 &omap3_pmx_core 0x136>;
pinctrl-0 = <&mmc3_pins &mmc3_core2_pins>;
pinctrl-names = "default";
vmmc-supply = <&wl12xx_vmmc>;
-- 
2.17.1

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


[U-Boot] [PATCH] arm64: zynqmp: Add new header file for zcu104 RevC

2018-12-03 Thread Michal Simek
From: T Karthik Reddy 

Created a new header file for zcu104 RevC board and added below
configurations to use MAC address from EEPROM.
CONFIG_ZYNQ_GEM_EEPROM_ADDR
CONFIG_ZYNQ_EEPROM_BUS
Added CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET=0x20 to
xilinx_zynqmp_zcu104_revC_defconfig

Signed-off-by: T Karthik Reddy 
Signed-off-by: Siva Durga Prasad Paladugu 
Signed-off-by: Michal Simek 
---

 configs/xilinx_zynqmp_zcu104_revC_defconfig |  3 ++-
 include/configs/xilinx_zynqmp_zcu104_revC.h | 17 +
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 include/configs/xilinx_zynqmp_zcu104_revC.h

diff --git a/configs/xilinx_zynqmp_zcu104_revC_defconfig 
b/configs/xilinx_zynqmp_zcu104_revC_defconfig
index 33258e41b201..0357b1744545 100644
--- a/configs/xilinx_zynqmp_zcu104_revC_defconfig
+++ b/configs/xilinx_zynqmp_zcu104_revC_defconfig
@@ -1,5 +1,5 @@
 CONFIG_ARM=y
-CONFIG_SYS_CONFIG_NAME="xilinx_zynqmp_zcu104"
+CONFIG_SYS_CONFIG_NAME="xilinx_zynqmp_zcu104_revC"
 CONFIG_ARCH_ZYNQMP=y
 CONFIG_SYS_TEXT_BASE=0x800
 CONFIG_SYS_MALLOC_F_LEN=0x8000
@@ -53,6 +53,7 @@ CONFIG_CMD_PCA953X=y
 CONFIG_SYS_I2C_ZYNQ=y
 CONFIG_ZYNQ_I2C1=y
 CONFIG_MISC=y
+CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET=0x20
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ZYNQ=y
diff --git a/include/configs/xilinx_zynqmp_zcu104_revC.h 
b/include/configs/xilinx_zynqmp_zcu104_revC.h
new file mode 100644
index ..8b3ae36d0f32
--- /dev/null
+++ b/include/configs/xilinx_zynqmp_zcu104_revC.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration for Xilinx ZynqMP zcu104
+ *
+ * (C) Copyright 2018 Xilinx, Inc.
+ * Michal Simek 
+ */
+
+#ifndef __CONFIG_ZYNQMP_ZCU104_REVC_H
+#define __CONFIG_ZYNQMP_ZCU104_REVC_H
+
+#include 
+
+#define CONFIG_ZYNQ_GEM_EEPROM_ADDR 0x54
+#define CONFIG_ZYNQ_EEPROM_BUS 1
+
+#endif /* __CONFIG_ZYNQMP_ZCU104_REVC_H */
-- 
1.9.1

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


[U-Boot] [PATCH 1/3] ARM: DTS: da850: Sync from Linux 4.20

2018-12-03 Thread Adam Ford
Re-sync with 4.20 due some some natural evolution.

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/da850.dtsi b/arch/arm/dts/da850.dtsi
index c66cf78953..47aa53ba6b 100644
--- a/arch/arm/dts/da850.dtsi
+++ b/arch/arm/dts/da850.dtsi
@@ -7,10 +7,19 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  */
-#include "skeleton.dtsi"
 #include 
 
 / {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   chosen { };
+   aliases { };
+
+   memory@c000 {
+   device_type = "memory";
+   reg = <0xc000 0x0>;
+   };
+
arm {
#address-cells = <1>;
#size-cells = <1>;
@@ -23,6 +32,25 @@
reg = <0xfffee000 0x2000>;
};
};
+   clocks: clocks {
+   ref_clk: ref_clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-output-names = "ref_clk";
+   };
+   sata_refclk: sata_refclk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-output-names = "sata_refclk";
+   status = "disabled";
+   };
+   usb_refclkin: usb_refclkin {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-output-names = "usb_refclkin";
+   status = "disabled";
+   };
+   };
dsp: dsp@1180 {
compatible = "ti,da850-dsp";
reg = <0x1180 0x4>,
@@ -33,6 +61,8 @@
reg-names = "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig";
interrupt-parent = <&intc>;
interrupts = <28>;
+   clocks = <&psc0 15>;
+   resets = <&psc0 15>;
status = "disabled";
};
soc@1c0 {
@@ -43,17 +73,57 @@
ranges = <0x0 0x01c0 0x40>;
interrupt-parent = <&intc>;
 
+   psc0: clock-controller@1 {
+   compatible = "ti,da850-psc0";
+   reg = <0x1 0x1000>;
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   #power-domain-cells = <1>;
+   clocks = <&pll0_sysclk 1>, <&pll0_sysclk 2>,
+<&pll0_sysclk 4>, <&pll0_sysclk 6>,
+<&async1_clk>;
+   clock-names = "pll0_sysclk1", "pll0_sysclk2",
+ "pll0_sysclk4", "pll0_sysclk6",
+ "async1";
+   };
+   pll0: clock-controller@11000 {
+   compatible = "ti,da850-pll0";
+   reg = <0x11000 0x1000>;
+   clocks = <&ref_clk>, <&pll1_sysclk 3>;
+   clock-names = "clksrc", "extclksrc";
+
+   pll0_pllout: pllout {
+   #clock-cells = <0>;
+   };
+   pll0_sysclk: sysclk {
+   #clock-cells = <1>;
+   };
+   pll0_auxclk: auxclk {
+   #clock-cells = <0>;
+   };
+   pll0_obsclk: obsclk {
+   #clock-cells = <0>;
+   };
+   };
pmx_core: pinmux@14120 {
compatible = "pinctrl-single";
reg = <0x14120 0x50>;
-   #address-cells = <1>;
-   #size-cells = <0>;
#pinctrl-cells = <2>;
pinctrl-single,bit-per-mux;
pinctrl-single,register-width = <32>;
pinctrl-single,function-mask = <0xf>;
+   /* pin base, nr pins & gpio function */
+   pinctrl-single,gpio-range = <&range   0 17 0x8>,
+   <&range  17  8 0x4>,
+   <&range  26  8 0x4>,
+   <&range  34 80 0x8>,
+   <&range 129 31 0x8>;
status = "disabled";
 
+   range: gpio-range {
+   #pinctrl-single,gpio-range-cells = <3>;
+   };
+
serial0_rtscts_pins: pinmux_serial0_rtscts_pins {
pinctrl-single,bits = <
/* UART0_RTS UART0_CTS */
@@ -264,8 +334,41 @@
usb_phy: usb-phy {
compatible 

[U-Boot] [PATCH 2/3] ARM: dts: da850-lcdk: Sync from Linux 4.20

2018-12-03 Thread Adam Ford
Re-synce the device tree files from Linux 4.20

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/da850-lcdk.dts b/arch/arm/dts/da850-lcdk.dts
index a1f4d6d5a5..0177e3ed20 100644
--- a/arch/arm/dts/da850-lcdk.dts
+++ b/arch/arm/dts/da850-lcdk.dts
@@ -21,8 +21,8 @@
stdout-path = "serial2:115200n8";
};
 
-   memory {
-   device_type = "memory";
+   memory@c000 {
+   /* 128 MB DDR2 SDRAM @ 0xc000 */
reg = <0xc000 0x0800>;
};
 
@@ -123,6 +123,10 @@
};
 };
 
+&ref_clk {
+   clock-frequency = <2400>;
+};
+
 &pmx_core {
status = "okay";
 
@@ -175,6 +179,11 @@
status = "okay";
 };
 
+&sata_refclk {
+   status = "okay";
+   clock-frequency = <1>;
+};
+
 &sata {
status = "okay";
 };
-- 
2.17.1

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


[U-Boot] [PATCH 3/3] ARM: DTS: da850-evm: Re-sync da850-evm.dts from Linux 4.20

2018-12-03 Thread Adam Ford
There has been some natural evolution of the device tree, so
resync with 4.20

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/da850-evm.dts b/arch/arm/dts/da850-evm.dts
index 0e82bb988f..a3c9b34672 100644
--- a/arch/arm/dts/da850-evm.dts
+++ b/arch/arm/dts/da850-evm.dts
@@ -27,6 +27,65 @@
spi0 = &spi1;
};
 
+   backlight: backlight-pwm {
+   pinctrl-names = "default";
+   pinctrl-0 = <&ecap2_pins>;
+   power-supply = <&backlight_lcd>;
+   compatible = "pwm-backlight";
+   /*
+* The PWM here corresponds to production hardware. The
+* schematic needs to be 1015171 (15 March 2010), Rev A
+* or newer.
+*/
+   pwms = <&ecap2 0 5 0>;
+   brightness-levels = <0 10 20 30 40 50 60 70 80 90 99>;
+   default-brightness-level = <7>;
+   };
+
+   panel {
+   compatible = "ti,tilcdc,panel";
+   pinctrl-names = "default";
+   pinctrl-0 = <&lcd_pins>;
+   /*
+* The vpif and the LCD are mutually exclusive.
+* To enable VPIF, change the status below to 'disabled' then
+* then change the status of the vpif below to 'okay'
+*/
+   status = "okay";
+   enable-gpios = <&gpio 40 GPIO_ACTIVE_HIGH>; /* lcd_panel_pwr */
+
+   panel-info {
+   ac-bias = <255>;
+   ac-bias-intrpt  = <0>;
+   dma-burst-sz= <16>;
+   bpp = <16>;
+   fdd = <0x80>;
+   sync-edge   = <0>;
+   sync-ctrl   = <1>;
+   raster-order= <0>;
+   fifo-th = <0>;
+   };
+
+   display-timings {
+   native-mode = <&timing0>;
+   timing0: 480x272 {
+   clock-frequency = <900>;
+   hactive = <480>;
+   vactive = <272>;
+   hfront-porch = <3>;
+   hback-porch = <2>;
+   hsync-len = <42>;
+   vback-porch = <3>;
+   vfront-porch = <4>;
+   vsync-len = <11>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   de-active = <1>;
+   pixelclk-active = <1>;
+   };
+   };
+   };
+
vbat: fixedregulator0 {
compatible = "regulator-fixed";
regulator-name = "vbat";
@@ -35,6 +94,15 @@
regulator-boot-on;
};
 
+   backlight_lcd: backlight-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "lcd_backlight_pwr";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = <&gpio 47 GPIO_ACTIVE_HIGH>; /* lcd_backlight_pwr */
+   enable-active-high;
+   };
+
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "DA850/OMAP-L138 EVM";
@@ -63,6 +131,14 @@
};
 };
 
+&ecap2 {
+   status = "okay";
+};
+
+&ref_clk {
+   clock-frequency = <2400>;
+};
+
 &pmx_core {
status = "okay";
 
@@ -93,6 +169,10 @@
};
 };
 
+&sata {
+   status = "okay";
+};
+
 &serial0 {
status = "okay";
 };
@@ -109,6 +189,10 @@
status = "okay";
 };
 
+&lcdc {
+   status = "okay";
+};
+
 &i2c0 {
status = "okay";
clock-frequency = <10>;
@@ -137,6 +221,12 @@
gpio-controller;
#gpio-cells = <2>;
};
+   tca6416_bb: gpio@21 {
+   compatible = "ti,tca6416";
+   reg = <0x21>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
 };
 
 &wdt {
@@ -336,5 +426,10 @@
 &vpif {
pinctrl-names = "default";
pinctrl-0 = <&vpif_capture_pins>, <&vpif_display_pins>;
-   status = "okay";
+   /*
+* The vpif and the LCD are mutually exclusive.
+* To enable VPIF, disable the ti,tilcdc,panel then
+* change the status below to 'okay'
+*/
+   status = "disabled";
 };
-- 
2.17.1

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


Re: [U-Boot] [PATCH] tools: zynqmpimage: round up partition size

2018-12-03 Thread Michal Simek
On 03. 12. 18 14:42, Alexander Graf wrote:
> 
> 
> On 03.12.18 14:14, Michal Simek wrote:
>> +Alex
>>
>> On 28. 11. 18 11:47, Michael Tretter wrote:
>>> The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
>>> which implies that the partition size is 4 byte aligned. When writing the
>>> partition, mkimage calculates "Total Partition Word Length" by dividing
>>> the size by 4. This implicitly cuts unaligned bytes at the end of the
>>> added binary.
>>>
>>> Instead of rounding down, the size must be round up to 4 bytes and the
>>> binary padded accordingly.
>>>
>>> Signed-off-by: Michael Tretter 
>>> ---
>>>  tools/zynqmpbif.c | 18 ++
>>>  1 file changed, 14 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
>>> index 6c8f66055d..885a037da6 100644
>>> --- a/tools/zynqmpbif.c
>>> +++ b/tools/zynqmpbif.c
>>> @@ -316,19 +316,29 @@ static int bif_add_pmufw(struct bif_entry *bf, const 
>>> char *data, size_t len)
>>> return 0;
>>>  }
>>>  
>>> -static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
>>> +static int bif_add_part(struct bif_entry *bf, char *data, size_t len)
>>>  {
>>> size_t parthdr_offset = 0;
>>> +   size_t len_padded = ROUND(len, 4);
>>> +
>>> struct partition_header parthdr = {
>>> -   .len_enc = cpu_to_le32(len / 4),
>>> -   .len_unenc = cpu_to_le32(len / 4),
>>> -   .len = cpu_to_le32(len / 4),
>>> +   .len_enc = cpu_to_le32(len_padded / 4),
>>> +   .len_unenc = cpu_to_le32(len_padded / 4),
>>> +   .len = cpu_to_le32(len_padded / 4),
>>> .entry_point = cpu_to_le64(bf->entry),
>>> .load_address = cpu_to_le64(bf->load),
>>> };
>>> int r;
>>> uint32_t csum;
>>>  
>>> +   if (len != len_padded) {
>>> +   data = realloc(data, len_padded);
>>> +   while (len < len_padded) {
>>> +   data[len] = 0;
>>> +   len++;
>>> +   }
>>> +   }
>>> +
>>> if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
>>> return bif_add_pmufw(bf, data, len);
>>>  
>>>
>>
>> I am not using this for creating boot image but I have tested it on
>> regular example and it is still working.
>>
>> I have applied this to my branch.
>> Alex: If you have any comment on this please let us know and I can
>> remove it from my queue.
> 
> I don't think I've ever had a not-multiple-of-4 payload, so I never ran
> into this.
> 
> The one thing that I'm not fully sure of is the realloc(). I don't think
> that data is necessarily always a pointer that way allocated using malloc().
> 
> If you look at bif_add_bit() for example the data pointer is an offset
> into a pointer from read_full_file(). So realloc() won't work on it.
> 
> I think it's safer to just allocate a completely new buffer here and
> copy the payload if unaligned.

ok. Let me just wait a little bit to finish this discussion.

Thanks,
Michal

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


Re: [U-Boot] [PATCH 1/2] Kconfig: Add entry for VF610 NAND NFC device tree aware driver

2018-12-03 Thread Lukasz Majewski
Hi Stefan,

> On 03.12.2018 10:24, Lukasz Majewski wrote:
> > This commit provides code to add proper entry to Kconfig to enable
> > support for VF610 device tree aware driver.  
> 
> Looks like a start, 

Indeed - this is a start. Vybrid is a bit behind the current u-boot
peace of development.

I'm trying to give it some momentum.

> but ideally we should also move all the
> board/system specific properties to device-tree (e.g.
> CONFIG_SYS_NAND_VF610_NFC_45_ECC_BYTES).

Yes, that would be a long term goal. However, those configs are already
moved to Kconfig, so there is no urgent need to make the conversion
now.

> 
> --
> Stefan
> 
> > 
> > Signed-off-by: Lukasz Majewski 
> > 
> > ---
> > 
> >  drivers/mtd/nand/raw/Kconfig | 11 +++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/drivers/mtd/nand/raw/Kconfig
> > b/drivers/mtd/nand/raw/Kconfig index 008f7b4b4b..fd1723feda 100644
> > --- a/drivers/mtd/nand/raw/Kconfig
> > +++ b/drivers/mtd/nand/raw/Kconfig
> > @@ -88,6 +88,15 @@ config NAND_VF610_NFC
> >   The driver supports a maximum 2k page size. The driver
> >   currently does not support hardware ECC.
> >  
> > +if NAND_VF610_NFC
> > +
> > +config NAND_VF610_NFC_DT
> > +bool "Support Vybrid's vf610 NAND controller as a DT
> > device"
> > +depends on OF_CONTROL && MTD
> > +help
> > +  Enable the driver for Vybrid's vf610 NAND flash on
> > platforms
> > + using device tree.
> > +
> >  choice
> > prompt "Hardware ECC strength"
> > depends on NAND_VF610_NFC
> > @@ -103,6 +112,8 @@ config SYS_NAND_VF610_NFC_60_ECC_BYTES
> >  
> >  endchoice
> >  
> > +endif
> > +
> >  config NAND_PXA3XX
> > bool "Support for NAND on PXA3xx and Armada 370/XP/38x"
> > select SYS_NAND_SELF_INIT  




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-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de


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


[U-Boot] adding saveenv-command for bananapi r2

2018-12-03 Thread Frank Wunderlich
From f5a9045316f962f397497bd169a20dc293b14641 Mon Sep 17 00:00:00 2001
From: Frank Wunderlich 
Date: Mon, 3 Dec 2018 15:32:58 +0100
Subject: [PATCH] adding saveenv-command for bananapi r2

BananaPi r2 can be booted from sd-card and emmc
saving the environment have to choose the storage
from which the device has booted

also the offset is set to 1MB to make sure env is written
to block "user data area" between uboot and first partition

https://www.fw-web.de/dokuwiki/lib/exe/fetch.php?cache=&media=bpi-r2:boot-structure.png

Signed-off-by: Frank Wunderlich 
---
 board/mediatek/mt7623/mt7623_rfb.c | 22 ++
 configs/mt7623n_bpir2_defconfig|  3 +++
 include/configs/mt7623.h   |  3 +++
 3 files changed, 28 insertions(+)

diff --git a/board/mediatek/mt7623/mt7623_rfb.c 
b/board/mediatek/mt7623/mt7623_rfb.c
index 08468b50ea..542314adfc 100644
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
@@ -14,3 +14,25 @@ int board_init(void)
 
return 0;
 }
+
+int mmc_get_boot_dev(void)
+{
+   int g_mmc_devid = -1;
+   char *uflag = (char *)0x81D0;
+   if (strncmp(uflag,"eMMC",4)==0)
+   {
+   g_mmc_devid = 0;
+   printf("Boot From Emmc(id:%d)\n\n", g_mmc_devid);
+   }
+   else
+   {
+   g_mmc_devid = 1;
+   printf("Boot From SD(id:%d)\n\n", g_mmc_devid);
+   }
+   return g_mmc_devid;
+}
+
+int mmc_get_env_dev(void)
+{
+   return mmc_get_boot_dev();
+}
diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig
index 3a4de72e23..640c881ce9 100644
--- a/configs/mt7623n_bpir2_defconfig
+++ b/configs/mt7623n_bpir2_defconfig
@@ -52,3 +52,6 @@ CONFIG_MTK_TIMER=y
 CONFIG_WDT_MTK=y
 CONFIG_LZMA=y
 # CONFIG_EFI_LOADER is not set
+
+#enables savenenv-command
+CONFIG_ENV_IS_IN_MMC=y
diff --git a/include/configs/mt7623.h b/include/configs/mt7623.h
index 68da920e30..91d6369dd2 100644
--- a/include/configs/mt7623.h
+++ b/include/configs/mt7623.h
@@ -53,4 +53,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS  \
FDT_HIGH
 
+#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_ENV_OFFSET  0x10
+
 #endif
-- 
2.17.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] tools: zynqmpimage: round up partition size

2018-12-03 Thread Michael Tretter
On Mon, 03 Dec 2018 14:42:59 +0100, Alexander Graf wrote:
> On 03.12.18 14:14, Michal Simek wrote:
> > +Alex
> > 
> > On 28. 11. 18 11:47, Michael Tretter wrote:  
> >> The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
> >> which implies that the partition size is 4 byte aligned. When writing the
> >> partition, mkimage calculates "Total Partition Word Length" by dividing
> >> the size by 4. This implicitly cuts unaligned bytes at the end of the
> >> added binary.
> >>
> >> Instead of rounding down, the size must be round up to 4 bytes and the
> >> binary padded accordingly.
> >>
> >> Signed-off-by: Michael Tretter 
> >> ---
> >>  tools/zynqmpbif.c | 18 ++
> >>  1 file changed, 14 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
> >> index 6c8f66055d..885a037da6 100644
> >> --- a/tools/zynqmpbif.c
> >> +++ b/tools/zynqmpbif.c
> >> @@ -316,19 +316,29 @@ static int bif_add_pmufw(struct bif_entry *bf, const 
> >> char *data, size_t len)
> >>return 0;
> >>  }
> >>  
> >> -static int bif_add_part(struct bif_entry *bf, const char *data, size_t 
> >> len)
> >> +static int bif_add_part(struct bif_entry *bf, char *data, size_t len)
> >>  {
> >>size_t parthdr_offset = 0;
> >> +  size_t len_padded = ROUND(len, 4);
> >> +
> >>struct partition_header parthdr = {
> >> -  .len_enc = cpu_to_le32(len / 4),
> >> -  .len_unenc = cpu_to_le32(len / 4),
> >> -  .len = cpu_to_le32(len / 4),
> >> +  .len_enc = cpu_to_le32(len_padded / 4),
> >> +  .len_unenc = cpu_to_le32(len_padded / 4),
> >> +  .len = cpu_to_le32(len_padded / 4),
> >>.entry_point = cpu_to_le64(bf->entry),
> >>.load_address = cpu_to_le64(bf->load),
> >>};
> >>int r;
> >>uint32_t csum;
> >>  
> >> +  if (len != len_padded) {
> >> +  data = realloc(data, len_padded);
> >> +  while (len < len_padded) {
> >> +  data[len] = 0;
> >> +  len++;
> >> +  }
> >> +  }
> >> +
> >>if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
> >>return bif_add_pmufw(bf, data, len);
> >>  
> >>  
> > 
> > I am not using this for creating boot image but I have tested it on
> > regular example and it is still working.
> > 
> > I have applied this to my branch.
> > Alex: If you have any comment on this please let us know and I can
> > remove it from my queue.  
> 
> I don't think I've ever had a not-multiple-of-4 payload, so I never ran
> into this.
> 
> The one thing that I'm not fully sure of is the realloc(). I don't think
> that data is necessarily always a pointer that way allocated using malloc().
> 
> If you look at bif_add_bit() for example the data pointer is an offset
> into a pointer from read_full_file(). So realloc() won't work on it.
>
> I think it's safer to just allocate a completely new buffer here and
> copy the payload if unaligned.

Thanks. I thought about aligning data in read_full_file(), but the size
read by read_full_file() is not used in bif_add_elf(). I further
assumed that the bitstream is always correctly aligned (because I never
saw anything else) and will never hit the realloc() path, but I'm
not sure if this is a safe assumption.

As realloc() does not work in bif_add_part(), I can only malloc() a
new aligned buffer and cannot free() the old one. I guess that is fine.

I will send a v2.

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


Re: [U-Boot] [PATCH 1/2] net: zynq_gem: Added 64-bit addressing support

2018-12-03 Thread Michal Simek
On 26. 11. 18 11:57, Siva Durga Prasad Paladugu wrote:
> From: Vipul Kumar 
> 
> This patch adds 64-bit addressing support for zynq gem.
> This means it can perform send and receive operations on
> 64-bit address buffers.
> 
> Signed-off-by: Vipul Kumar 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
>  drivers/net/zynq_gem.c | 63 
> ++
>  1 file changed, 54 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
> index bc33126..ee528db 100644
> --- a/drivers/net/zynq_gem.c
> +++ b/drivers/net/zynq_gem.c
> @@ -86,10 +86,17 @@ DECLARE_GLOBAL_DATA_PTR;
>  /* Set with binary 00011000 to use 1536 byte(1*max length frame/buffer) */
>  #define ZYNQ_GEM_DMACR_RXBUF 0x0018
>  
> +#if defined(CONFIG_PHYS_64BIT)
> +# define ZYNQ_GEM_DMA_BUS_WIDTH  BIT(30) /* 64 bit bus */
> +#else
> +# define ZYNQ_GEM_DMA_BUS_WIDTH  (0 << 30) /* 32 bit bus */
> +#endif
> +
>  #define ZYNQ_GEM_DMACR_INIT  (ZYNQ_GEM_DMACR_BLENGTH | \
>   ZYNQ_GEM_DMACR_RXSIZE | \
>   ZYNQ_GEM_DMACR_TXSIZE | \
> - ZYNQ_GEM_DMACR_RXBUF)
> + ZYNQ_GEM_DMACR_RXBUF | \
> + ZYNQ_GEM_DMA_BUS_WIDTH)
>  
>  #define ZYNQ_GEM_TSR_DONE0x0020 /* Tx done mask */
>  
> @@ -147,12 +154,20 @@ struct zynq_gem_regs {
>   u32 transmit_q1_ptr; /* 0x440 - Transmit priority queue 1 */
>   u32 reserved8[15];
>   u32 receive_q1_ptr; /* 0x480 - Receive priority queue 1 */
> + u32 reserved10[17];
> + u32 upper_txqbase; /* 0x4C8 - Upper tx_q base addr */
> + u32 reserved11[2];
> + u32 upper_rxqbase; /* 0x4D4 - Upper rx_q base addr */
>  };
>  
>  /* BD descriptors */
>  struct emac_bd {
>   u32 addr; /* Next descriptor pointer */
>   u32 status;
> +#if defined(CONFIG_PHYS_64BIT)
> + u32 addr_hi;
> + u32 reserved;
> +#endif
>  };
>  
>  #define RX_BUF 32
> @@ -390,13 +405,21 @@ static int zynq_gem_init(struct udevice *dev)
>   for (i = 0; i < RX_BUF; i++) {
>   priv->rx_bd[i].status = 0xF000;
>   priv->rx_bd[i].addr =
> - ((ulong)(priv->rxbuffers) +
> - (i * PKTSIZE_ALIGN));
> - }
> + (lower_32_bits((ulong)(priv->rxbuffers)
> + + (i * PKTSIZE_ALIGN)));
> +#if defined(CONFIG_PHYS_64BIT)
> + priv->rx_bd[i].addr_hi =
> + (upper_32_bits((ulong)(priv->rxbuffers)
> + + (i * PKTSIZE_ALIGN)));
> +#endif
> + }
>   /* WRAP bit to last BD */
>   priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
>   /* Write RxBDs to IP */
> - writel((ulong)priv->rx_bd, ®s->rxqbase);
> + writel(lower_32_bits((ulong)priv->rx_bd), ®s->rxqbase);
> +#if defined(CONFIG_PHYS_64BIT)
> + writel(upper_32_bits((ulong)priv->rx_bd), ®s->upper_rxqbase);
> +#endif
>  
>   /* Setup for DMA Configuration register */
>   writel(ZYNQ_GEM_DMACR_INIT, ®s->dmacr);
> @@ -406,12 +429,18 @@ static int zynq_gem_init(struct udevice *dev)
>  
>   /* Disable the second priority queue */
>   dummy_tx_bd->addr = 0;
> +#if defined(CONFIG_PHYS_64BIT)
> + dummy_tx_bd->addr_hi = 0;
> +#endif
>   dummy_tx_bd->status = ZYNQ_GEM_TXBUF_WRAP_MASK |
>   ZYNQ_GEM_TXBUF_LAST_MASK|
>   ZYNQ_GEM_TXBUF_USED_MASK;
>  
>   dummy_rx_bd->addr = ZYNQ_GEM_RXBUF_WRAP_MASK |
>   ZYNQ_GEM_RXBUF_NEW_MASK;
> +#if defined(CONFIG_PHYS_64BIT)
> + dummy_rx_bd->addr_hi = 0;
> +#endif
>   dummy_rx_bd->status = 0;
>  
>   writel((ulong)dummy_tx_bd, ®s->transmit_q1_ptr);
> @@ -485,7 +514,8 @@ static int zynq_gem_init(struct udevice *dev)
>  
>  static int zynq_gem_send(struct udevice *dev, void *ptr, int len)
>  {
> - u32 addr, size;
> + dma_addr_t addr;
> + u32 size;
>   struct zynq_gem_priv *priv = dev_get_priv(dev);
>   struct zynq_gem_regs *regs = priv->iobase;
>   struct emac_bd *current_bd = &priv->tx_bd[1];
> @@ -493,17 +523,26 @@ static int zynq_gem_send(struct udevice *dev, void 
> *ptr, int len)
>   /* Setup Tx BD */
>   memset(priv->tx_bd, 0, sizeof(struct emac_bd));
>  
> - priv->tx_bd->addr = (ulong)ptr;
> + priv->tx_bd->addr = lower_32_bits((ulong)ptr);
> +#if defined(CONFIG_PHYS_64BIT)
> + priv->tx_bd->addr_hi = upper_32_bits((ulong)ptr);
> +#endif
>   priv->tx_bd->status = (len & ZYNQ_GEM

Re: [U-Boot] [PATCH] tools: zynqmpimage: round up partition size

2018-12-03 Thread Alexander Graf


On 03.12.18 16:19, Michael Tretter wrote:
> On Mon, 03 Dec 2018 14:42:59 +0100, Alexander Graf wrote:
>> On 03.12.18 14:14, Michal Simek wrote:
>>> +Alex
>>>
>>> On 28. 11. 18 11:47, Michael Tretter wrote:  
 The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
 which implies that the partition size is 4 byte aligned. When writing the
 partition, mkimage calculates "Total Partition Word Length" by dividing
 the size by 4. This implicitly cuts unaligned bytes at the end of the
 added binary.

 Instead of rounding down, the size must be round up to 4 bytes and the
 binary padded accordingly.

 Signed-off-by: Michael Tretter 
 ---
  tools/zynqmpbif.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

 diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
 index 6c8f66055d..885a037da6 100644
 --- a/tools/zynqmpbif.c
 +++ b/tools/zynqmpbif.c
 @@ -316,19 +316,29 @@ static int bif_add_pmufw(struct bif_entry *bf, const 
 char *data, size_t len)
return 0;
  }
  
 -static int bif_add_part(struct bif_entry *bf, const char *data, size_t 
 len)
 +static int bif_add_part(struct bif_entry *bf, char *data, size_t len)
  {
size_t parthdr_offset = 0;
 +  size_t len_padded = ROUND(len, 4);
 +
struct partition_header parthdr = {
 -  .len_enc = cpu_to_le32(len / 4),
 -  .len_unenc = cpu_to_le32(len / 4),
 -  .len = cpu_to_le32(len / 4),
 +  .len_enc = cpu_to_le32(len_padded / 4),
 +  .len_unenc = cpu_to_le32(len_padded / 4),
 +  .len = cpu_to_le32(len_padded / 4),
.entry_point = cpu_to_le64(bf->entry),
.load_address = cpu_to_le64(bf->load),
};
int r;
uint32_t csum;
  
 +  if (len != len_padded) {
 +  data = realloc(data, len_padded);
 +  while (len < len_padded) {
 +  data[len] = 0;
 +  len++;
 +  }
 +  }
 +
if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
return bif_add_pmufw(bf, data, len);
  
  
>>>
>>> I am not using this for creating boot image but I have tested it on
>>> regular example and it is still working.
>>>
>>> I have applied this to my branch.
>>> Alex: If you have any comment on this please let us know and I can
>>> remove it from my queue.  
>>
>> I don't think I've ever had a not-multiple-of-4 payload, so I never ran
>> into this.
>>
>> The one thing that I'm not fully sure of is the realloc(). I don't think
>> that data is necessarily always a pointer that way allocated using malloc().
>>
>> If you look at bif_add_bit() for example the data pointer is an offset
>> into a pointer from read_full_file(). So realloc() won't work on it.
>>
>> I think it's safer to just allocate a completely new buffer here and
>> copy the payload if unaligned.
> 
> Thanks. I thought about aligning data in read_full_file(), but the size
> read by read_full_file() is not used in bif_add_elf(). I further
> assumed that the bitstream is always correctly aligned (because I never
> saw anything else) and will never hit the realloc() path, but I'm
> not sure if this is a safe assumption.
> 
> As realloc() does not work in bif_add_part(), I can only malloc() a
> new aligned buffer and cannot free() the old one. I guess that is fine.

Yes. We're already leaking the old buffer, so leaking yet another one
isn't a big issue either ;).

> I will send a v2.

Thanks! And please CC me on patches to zynqmpbif next time :).


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


Re: [U-Boot] [PATCH] usb: composite: Move bitmap related operations to ./include/linux/bitmap.h

2018-12-03 Thread Stefan Agner
On 02.12.2018 09:49, Lukasz Majewski wrote:
> The BITMAP related operations can now be moved to ./include/linux/bitmap.h
> file to mimic the Linux kernel directory tree.
> 
> This change also allows removing the lin_gadget_compat.h header file
> (which is a legacy code only for composite U-boot layer).
> It was also possible to remove #includes from several USB gadget drivers
> as relevant bit operations have been mored out earlier from this file.

s/mored/moved

Otherwise looks good to me:
Reviewed-by: Stefan Agner 

--
Stefan

> 
> Signed-off-by: Lukasz Majewski 
> 
> ---
> 
>  drivers/usb/dwc3/gadget.c  |  1 -
>  drivers/usb/dwc3/ti_usb_phy.c  |  1 -
>  drivers/usb/eth/r8152.c|  1 -
>  drivers/usb/gadget/at91_udc.c  |  1 -
>  drivers/usb/gadget/atmel_usba_udc.c|  1 -
>  drivers/usb/gadget/dwc2_udc_otg.c  |  1 -
>  drivers/usb/gadget/dwc2_udc_otg_phy.c  |  1 -
>  drivers/usb/gadget/dwc2_udc_otg_priv.h |  1 -
>  drivers/usb/gadget/f_mass_storage.c|  2 +-
>  drivers/usb/gadget/pxa25x_udc.c|  1 -
>  include/linux/bitmap.h | 23 ++
>  include/linux/types.h  |  3 +++
>  include/linux/usb/composite.h  |  2 +-
>  include/usb/lin_gadget_compat.h| 35 
> --
>  14 files changed, 28 insertions(+), 46 deletions(-)
>  create mode 100644 include/linux/bitmap.h
>  delete mode 100644 include/usb/lin_gadget_compat.h
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index e340cb268f..085f7b8968 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -16,7 +16,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> diff --git a/drivers/usb/dwc3/ti_usb_phy.c b/drivers/usb/dwc3/ti_usb_phy.c
> index d168e868e3..e7ea12c163 100644
> --- a/drivers/usb/dwc3/ti_usb_phy.c
> +++ b/drivers/usb/dwc3/ti_usb_phy.c
> @@ -19,7 +19,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c
> index 941158abdd..e5f73e3d4c 100644
> --- a/drivers/usb/eth/r8152.c
> +++ b/drivers/usb/eth/r8152.c
> @@ -10,7 +10,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include "usb_ether.h"
> diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
> index 39ea87005c..2a6626b443 100644
> --- a/drivers/usb/gadget/at91_udc.c
> +++ b/drivers/usb/gadget/at91_udc.c
> @@ -24,7 +24,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  
>  #include "at91_udc.h"
>  
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c
> b/drivers/usb/gadget/atmel_usba_udc.c
> index c9d483318f..dffa5117f9 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -16,7 +16,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  
>  #include "atmel_usba_udc.h"
>  
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c
> index e3edd10e29..3c7ad033e3 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -33,7 +33,6 @@
>  
>  #include "dwc2_udc_otg_regs.h"
>  #include "dwc2_udc_otg_priv.h"
> -#include 
>  
>  /***/
>  
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_phy.c
> b/drivers/usb/gadget/dwc2_udc_otg_phy.c
> index 47aa78ae94..c4338af0d7 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_phy.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg_phy.c
> @@ -33,7 +33,6 @@
>  
>  #include "dwc2_udc_otg_regs.h"
>  #include "dwc2_udc_otg_priv.h"
> -#include 
>  
>  #include 
>  
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_priv.h
> b/drivers/usb/gadget/dwc2_udc_otg_priv.h
> index b64e222b6d..aaa90187fb 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_priv.h
> +++ b/drivers/usb/gadget/dwc2_udc_otg_priv.h
> @@ -12,7 +12,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  
>  /*-*/
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c
> index a3101afa0d..45c7b58eed 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -256,7 +256,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  
>  /**/
> diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
> index 44092df25b..09c0a30b2b 100644
> --- a/drivers/usb/gadget/pxa25x_udc.c
> +++ b/drivers/usb/gadget/pxa25x_udc.c
> @@ -29,7 +29,6 @@
>  
>  #include 
>  #include 
> -#include 
>  #include 
>  
>  #include "pxa25x_udc.h"
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> new file mode 100644
> index 00..4a54ae0509
> --- /dev/null
> +++ b/include/linux/bitmap.h
> @@ -0,0

[U-Boot] [RFC] Monthly developer call?

2018-12-03 Thread Tom Rini
Hey all,

It's come up a few times that perhaps we should have a regular real-time
meeting of some sort, since that F2F meetings we've had historically
have been so helpful.  So, what I'd like to propose is a monthly meeting
/ video call on the 3rd Monday of the month, starting in January.  For a
time I propose 4PM UTC, which is 11AM US Eastern, 8AM US Eastern and
unfortunately very late / early in Asia.  I am open to alternating times
too as there's not really a chance of a time that works for everyone.

For a "how" I'm going to say we should use https://zoom.us/ as they have
good support for Linux as a host as well as traditional mobile / desktop
platforms.  We use it at work and it's reasonably problem free and
there's local dial-in numbers pretty much world-wide.

-- 
Tom


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


[U-Boot] [PATCH 2/2] arm64: zynqmp: Enable 2 NAND chips for zc1751 dc2

2018-12-03 Thread Michal Simek
This board contains 2 nand chips that's why enable this feature.

Signed-off-by: Michal Simek 
---

 configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig 
b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
index 572582cbf533..3afaa2c6c373 100644
--- a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
+++ b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig
@@ -58,6 +58,7 @@ CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
 CONFIG_NAND=y
 CONFIG_NAND_ARASAN=y
+CONFIG_SYS_NAND_MAX_CHIPS=2
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_SST=y
-- 
1.9.1

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


Re: [U-Boot] Please pull ARC changes

2018-12-03 Thread Tom Rini
On Mon, Dec 03, 2018 at 11:32:10AM +, Alexey Brodkin wrote:

> Hi Tom,
> 
> The following changes since commit 952061352acfd24034e6990b6b7d32cded020c0a:
> 
>   drivers: rtc: correctly convert seconds to time structure (2018-12-01 
> 18:03:14 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-arc.git tags/arc-updates-for-2019.01-rc1
> 
> for you to fetch changes up to 6ef705b1575045f7b63bf011a0774228159715b2:
> 
>   arc: devboards: Implement checkboard() (2018-12-03 14:26:53 +0300)
> 

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] [PULL u-boot] Please pull u-boot-amlogic-20181203

2018-12-03 Thread Tom Rini
On Mon, Dec 03, 2018 at 01:38:18PM +0100, Neil Armstrong wrote:

> Hi Tom,
> 
> I hope it's not too late, It's a single patch from Loic he reposted last week.
> 
> Thanks,
> Neil
> 
> The following changes since commit 952061352acfd24034e6990b6b7d32cded020c0a:
> 
>   drivers: rtc: correctly convert seconds to time structure (2018-12-01 
> 18:03:14 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-amlogic.git tags/u-boot-amlogic-20181203
> 
> for you to fetch changes up to 8973d816588a8479eeb0e3a9f1e730922d3efc07:
> 
>   ARM: meson: Add regmap support for clock driver (2018-12-03 13:34:21 +0100)
> 

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


[U-Boot] [PATCH 1/2] mtd: nand: arasan_nfc: Add support for nand multi chip select

2018-12-03 Thread Michal Simek
From: T Karthik Reddy 

This patch adds support for nand multi chip select.
Also adding CONFIG_SYS_NAND_MAX_CHIPS to Kconfig to specify maximum number
of nand chips.

Signed-off-by: Tummala Karthik Reddy 
Signed-off-by: Siva Durga Prasad Paladugu 
Signed-off-by: Michal Simek 
---

 drivers/mtd/nand/raw/Kconfig  |  7 +++
 drivers/mtd/nand/raw/arasan_nfc.c | 27 +--
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 008f7b4b4ba1..86e8b5e55d8a 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -243,6 +243,13 @@ config SYS_NAND_BUSWIDTH_16BIT
not available while configuring controller. So a static 
CONFIG_NAND_xx
is needed to know the device's bus-width in advance.
 
+config SYS_NAND_MAX_CHIPS
+   int "NAND max chips"
+   default 1
+   depends on NAND_ARASAN
+   help
+ The maximum number of NAND chips per device to be supported.
+
 if SPL
 
 config SYS_NAND_U_BOOT_LOCATIONS
diff --git a/drivers/mtd/nand/raw/arasan_nfc.c 
b/drivers/mtd/nand/raw/arasan_nfc.c
index dc531ccb6822..2cd3f64dc63c 100644
--- a/drivers/mtd/nand/raw/arasan_nfc.c
+++ b/drivers/mtd/nand/raw/arasan_nfc.c
@@ -90,6 +90,8 @@ struct arasan_nand_command_format {
 #define ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT   16
 #define ARASAN_NAND_MEM_ADDR2_PAGE_MASK0xFF
 #define ARASAN_NAND_MEM_ADDR2_CS_MASK  0xC000
+#define ARASAN_NAND_MEM_ADDR2_CS0_MASK (0x3 << 30)
+#define ARASAN_NAND_MEM_ADDR2_CS1_MASK (0x1 << 30)
 #define ARASAN_NAND_MEM_ADDR2_BCH_MASK 0xE00
 #define ARASAN_NAND_MEM_ADDR2_BCH_SHIFT25
 
@@ -261,6 +263,16 @@ static struct nand_chip 
nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
 
 static void arasan_nand_select_chip(struct mtd_info *mtd, int chip)
 {
+   u32 reg_val;
+
+   reg_val = readl(&arasan_nand_base->memadr_reg2);
+   if (chip == 0) {
+   reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS0_MASK;
+   writel(reg_val, &arasan_nand_base->memadr_reg2);
+   } else if (chip == 1) {
+   reg_val |= ARASAN_NAND_MEM_ADDR2_CS1_MASK;
+   writel(reg_val, &arasan_nand_base->memadr_reg2);
+   }
 }
 
 static void arasan_nand_enable_ecc(void)
@@ -713,9 +725,6 @@ static int arasan_nand_send_wrcmd(struct 
arasan_nand_command_format *curr_cmd,
reg_val &= ~ARASAN_NAND_MEM_ADDR2_PAGE_MASK;
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
-   reg_val = readl(&arasan_nand_base->memadr_reg2);
-   reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
-   writel(reg_val, &arasan_nand_base->memadr_reg2);
 
return 0;
 }
@@ -804,9 +813,6 @@ static int arasan_nand_erase(struct 
arasan_nand_command_format *curr_cmd,
reg_val &= ~ARASAN_NAND_MEM_ADDR2_PAGE_MASK;
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
-   reg_val = readl(&arasan_nand_base->memadr_reg2);
-   reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
-   writel(reg_val, &arasan_nand_base->memadr_reg2);
writel(curr_cmd->pgm, &arasan_nand_base->pgm_reg);
 
while (!(readl(&arasan_nand_base->intsts_reg) &
@@ -859,10 +865,6 @@ static int arasan_nand_read_status(struct 
arasan_nand_command_format *curr_cmd,
reg_val |= (1 << ARASAN_NAND_PKT_REG_PKT_CNT_SHFT) | 1;
writel(reg_val, &arasan_nand_base->pkt_reg);
 
-   reg_val = readl(&arasan_nand_base->memadr_reg2);
-   reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
-   writel(reg_val, &arasan_nand_base->memadr_reg2);
-
writel(curr_cmd->pgm, &arasan_nand_base->pgm_reg);
while (!(readl(&arasan_nand_base->intsts_reg) &
ARASAN_NAND_INT_STS_XFR_CMPLT_MASK) && timeout) {
@@ -932,9 +934,6 @@ static int arasan_nand_send_rdcmd(struct 
arasan_nand_command_format *curr_cmd,
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
 
-   reg_val = readl(&arasan_nand_base->memadr_reg2);
-   reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
-   writel(reg_val, &arasan_nand_base->memadr_reg2);
buf_index = 0;
 
return 0;
@@ -1219,7 +1218,7 @@ static int arasan_nand_init(struct nand_chip *nand_chip, 
int devnum)
writel(0x0, &arasan_nand_base->pgm_reg);
 
/* first scan to find the device and get the page size */
-   if (nand_scan_ident(mtd, 1, NULL)) {
+   if (nand_scan_ident(mtd, CONFIG_SYS_NAND_MAX_CHIPS, NULL)) {
printf("%s: nand_scan_ident failed\n", __func__);
goto fail;
}
-- 
1.9.1

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


[U-Boot] [PATCH v2] tools: zynqmpimage: round up partition size

2018-12-03 Thread Michael Tretter
The FSBL copies "Total Partition Word Length" * 4 bytes from the boot.bin,
which implies that the partition size is 4 byte aligned. When writing the
partition, mkimage calculates "Total Partition Word Length" by dividing
the size by 4. This implicitly cuts unaligned bytes at the end of the
added binary.

Instead of rounding down, the size must be round up to 4 bytes and the
binary padded accordingly.

Signed-off-by: Michael Tretter 
---
v2:
- do not realloc() data but malloc() and memcpy() new data
---
 tools/zynqmpbif.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
index 6c8f66055d..a33c15e1f0 100644
--- a/tools/zynqmpbif.c
+++ b/tools/zynqmpbif.c
@@ -319,16 +319,25 @@ static int bif_add_pmufw(struct bif_entry *bf, const char 
*data, size_t len)
 static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
 {
size_t parthdr_offset = 0;
+   size_t len_padded = ROUND(len, 4);
+
struct partition_header parthdr = {
-   .len_enc = cpu_to_le32(len / 4),
-   .len_unenc = cpu_to_le32(len / 4),
-   .len = cpu_to_le32(len / 4),
+   .len_enc = cpu_to_le32(len_padded / 4),
+   .len_unenc = cpu_to_le32(len_padded / 4),
+   .len = cpu_to_le32(len_padded / 4),
.entry_point = cpu_to_le64(bf->entry),
.load_address = cpu_to_le64(bf->load),
};
int r;
uint32_t csum;
 
+   if (len < len_padded) {
+   char *newdata = malloc(len_padded);
+   memcpy(newdata, data, len);
+   memset(newdata + len, 0, len_padded - len);
+   data = newdata;
+   }
+
if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
return bif_add_pmufw(bf, data, len);
 
-- 
2.19.1

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


Re: [U-Boot] [PATCH v1 1/3] ddr: vybrid: Add DDRMC calibration related registers (DQS to DQ)

2018-12-03 Thread Stefan Agner
On 02.12.2018 21:42, Lukasz Majewski wrote:
> This commit provides extra defines needed for DDR memory controller
> calibration (read leveling performing).
> 
> Signed-off-by: Lukasz Majewski 
> ---
> 
>  arch/arm/include/asm/arch-vf610/imx-regs.h | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-vf610/imx-regs.h
> b/arch/arm/include/asm/arch-vf610/imx-regs.h
> index 08ba8e94f8..f477e414f9 100644
> --- a/arch/arm/include/asm/arch-vf610/imx-regs.h
> +++ b/arch/arm/include/asm/arch-vf610/imx-regs.h
> @@ -206,11 +206,17 @@
>  #define DDRMC_CR88_TODTL_CMD(v)  (((v) & 0x1f) 
> << 16)
>  #define DDRMC_CR89_AODT_RWSMCS(v)((v) & 0xf)
>  #define DDRMC_CR91_R2W_SMCSDL(v) (((v) & 0x7) << 16)
> +#define DDRMC_CR93_SW_LVL_MODE(v)(((v) & 0x3) << 8)
> +#define DDRMC_CR93_SWLVL_LOADBIT(16)
> +#define DDRMC_CR93_SWLVL_START   BIT(24)
> +#define DDRMC_CR93_SWLVL_EXITBIT(0)

SWLVL_EXIT is in CR94.

With that fixed, looks good.

Reviewed-by: Stefan Agner 

--
Stefan

> +#define DDRMC_CR94_SWLVL_OP_DONE BIT(8)
>  #define DDRMC_CR96_WLMRD(v)  (((v) & 0x3f) << 8)
>  #define DDRMC_CR96_WLDQSEN(v)((v) & 0x3f)
>  #define DDRMC_CR97_WRLVL_EN  (1 << 24)
>  #define DDRMC_CR98_WRLVL_DL_0(v) ((v) & 0x)
>  #define DDRMC_CR99_WRLVL_DL_1(v) ((v) & 0x)
> +#define DDRMC_CR101_PHY_RDLVL_EDGE   BIT(24)
>  #define DDRMC_CR102_RDLVL_GT_REGEN   (1 << 16)
>  #define DDRMC_CR102_RDLVL_REG_EN (1 << 8)
>  #define DDRMC_CR105_RDLVL_DL_0(v)(((v) & 0xff) << 8)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   3   >