Re: [U-Boot] [PATCH] travis: Use kernel.org pre-built toolchain for riscv

2018-09-03 Thread Rick Chen
 > From: Tom Rini [mailto:tr...@konsulko.com]
 > Sent: Tuesday, September 04, 2018 3:24 AM
 > To: Bin Meng
 > Cc: U-Boot Mailing List; Rick Jian-Zhi Chen(陳建志)
 > Subject: Re: [PATCH] travis: Use kernel.org pre-built toolchain for riscv
 >
 > On Mon, Sep 03, 2018 at 05:50:39PM +0800, Bin Meng wrote:
 > > Hi Tom,
 > >
 > > On Thu, Aug 30, 2018 at 9:12 PM Bin Meng  wrote:
 > > >
 > > > This updates travis configuration to use kernel.org pre-built
 > > > toolchain for riscv.
 > > >
 > > > Signed-off-by: Bin Meng 
 > > > ---
 > > >
 > > >  .travis.yml | 5 ++---
 > > >  1 file changed, 2 insertions(+), 3 deletions(-)
 > > >
 > >
 > > Since this is travis-ci changes, can we take this for v2018.09? I've
 > > verified that it works well for current riscv build on travis-ci.org.
 >
 > Seeing as things are still working before this change I would like
to see an ack
 > from the custodian, thanks!
 >
 > --
 > Tom

Hi Bin

I think lt is a positive way to use kernel.org pre-built toolchain for
code coverage.
And very agree with that.

But there is a problem, it maybe encounter in the future.
If I or someone try to add a private csr which the public toolchain
may not recognize it.
How shall it be overcomed ? Do you have any ideas ?

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


Re: [U-Boot] [PATCH 2/4] x86: tangier: pinmux: add API to configure protected pins

2018-09-03 Thread Bin Meng
On Mon, Sep 3, 2018 at 11:07 PM Georgii Staroselskii
 wrote:
>
> This API is going to be used to configure some pins that are protected
> for simple modification.
>
> It's not a comprehensive pinctrl driver but can be turned into one
> when we need this in the future. Now it is planned to be used only
> in one place. So that's why I decided not to polute the codebase with a
> full-blown pinctrl-merrifield nobody will use.
>
> This driver reads corresponding fields in DT and configures pins
> accordingly.
>
> The "protected" flag is used to distinguish configuration of SCU-owned
> pins from the ordinary ones.
>
> The code has been adapted from Linux work done by Andy Shevchenko
> in pinctrl-merrfifield.c
>
> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/cpu/tangier/Makefile |   2 +-
>  arch/x86/cpu/tangier/pinmux.c | 188 
> ++
>  2 files changed, 189 insertions(+), 1 deletion(-)
>  create mode 100644 arch/x86/cpu/tangier/pinmux.c
>

BTW: some more styling issues.

> diff --git a/arch/x86/cpu/tangier/Makefile b/arch/x86/cpu/tangier/Makefile
> index 8274482..68f4a32 100644
> --- a/arch/x86/cpu/tangier/Makefile
> +++ b/arch/x86/cpu/tangier/Makefile
> @@ -2,5 +2,5 @@
>  #
>  # Copyright (c) 2017 Intel Corporation
>
> -obj-y += car.o tangier.o sdram.o sysreset.o
> +obj-y += car.o tangier.o sdram.o sysreset.o pinmux.o
>  obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o
> diff --git a/arch/x86/cpu/tangier/pinmux.c b/arch/x86/cpu/tangier/pinmux.c
> new file mode 100644
> index 000..c59b63c
> --- /dev/null
> +++ b/arch/x86/cpu/tangier/pinmux.c
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2018 Emlid Limited
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define BUFCFG_OFFSET  0x100
> +
> +#define MRFLD_FAMILY_LEN   0x400
> +
> +/* These are taken from Linux kernel */
> +#define MRFLD_PINMODE_MASK 0x07
> +
> +#define pin_to_bufno(f, p)   ((p) - (f)->pin_base)
> +

It would be good if you can make the above 4 defines the same
indention so that they all look aligned.

> +struct mrfld_family {
> +   unsigned int family_number;
> +   unsigned int pin_base;
> +   size_t npins;
> +   void __iomem *regs;
> +};
> +
> +#define MRFLD_FAMILY(b, s, e)  \
> +   {   \

nits: and here the ending \ is not aligned with other lines

> +   .family_number = (b),   \
> +   .pin_base = (s),\
> +   .npins = (e) - (s) + 1, \
> +   }
> +

[snip]

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


Re: [U-Boot] [PATCH v4] gpio: dwapb_gpio: Add reset ctrl to driver

2018-09-03 Thread Marek Vasut
On 09/04/2018 03:34 AM, Ley Foon Tan wrote:
> On Thu, Aug 30, 2018 at 8:11 PM Marek Vasut  wrote:
>>
>> On 08/30/2018 02:45 AM, Ley Foon Tan wrote:
>>> On Wed, Aug 29, 2018 at 7:57 PM Marek Vasut  wrote:

 On 08/29/2018 10:44 AM, Ley Foon Tan wrote:
> Add code to reset all reset signals as in gpio DT node. A reset property
> is an optional feature, so only print out a warning and do not fail if a
> reset property is not present.
>
> If a reset property is discovered, then use it to deassert, thus
> bringing the IP out of reset.
>
> Signed-off-by: Ley Foon Tan 

 This is much better.

> +static int gpio_dwapb_reset(struct udevice *dev)
> +{
> + int ret;
> + struct gpio_dwapb_priv *priv = dev_get_priv(dev);
> +
> + ret = reset_get_bulk(dev, >resets);
> + if (ret) {
> + dev_warn(dev, "Can't get reset: %d\n", ret);

 Won't this barf on machines which either don't have DM_RESET enabled or
 don't have it described in DT ?
>>> By default, dev_warn() is not show up. Or we can move this dev_warn
>>> when "return ret" error below.
>>
>> I think that'd be better. If there is no reset support, no point in
>> warning. Or what do you think ?
>>
>> btw you could then also flatten the indent with some
>> ret = reset
>> if (ret == -ENOENT || )
>>  return 0;
>>
>> dev_warn();
>> return ret;
> 
> Okay, will change this.

OK, I'll queue it into -next then, thanks.

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


Re: [U-Boot] [PATCH 4/4] x86: tangier: acpi: add I2C6 node

2018-09-03 Thread Bin Meng
On Mon, Sep 3, 2018 at 11:07 PM Georgii Staroselskii
 wrote:
>
> Now that we have I2C#6 working, it's time to add a corresponsing
> ACPI binding.
>
> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/include/asm/arch-tangier/acpi/southcluster.asl | 10 ++
>  1 file changed, 10 insertions(+)
>

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


Re: [U-Boot] [PATCH 3/4] x86: dts: edison: configure I2C#6 pins

2018-09-03 Thread Bin Meng
On Tue, Sep 4, 2018 at 2:23 AM Andy Shevchenko
 wrote:
>
> On Mon, Sep 3, 2018 at 7:41 PM Georgii Staroselskii
>  wrote:
> >
> > Now that we have the pinctrl driver for Merrifield in place we can make
> > use of it and set I2C#6 pins appropriately.
> >
> > Initial configuration came from the firmware.  Which quite likely has
> > been used in the phones, where that is not part of Atom peripheral, is
> > in use. Thus we need to override the leftover.
> >
>
> Reviewed-by: Andy Shevchenko 
>
>
> > Signed-off-by: Georgii Staroselskii 
> > ---
> >  arch/x86/dts/edison.dts | 22 ++
> >  1 file changed, 22 insertions(+)
> >

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


Re: [U-Boot] [PATCH 2/4] x86: tangier: pinmux: add API to configure protected pins

2018-09-03 Thread Bin Meng
Hi Georgii,

On Mon, Sep 3, 2018 at 11:07 PM Georgii Staroselskii
 wrote:
>
> This API is going to be used to configure some pins that are protected
> for simple modification.
>
> It's not a comprehensive pinctrl driver but can be turned into one
> when we need this in the future. Now it is planned to be used only
> in one place. So that's why I decided not to polute the codebase with a
> full-blown pinctrl-merrifield nobody will use.
>
> This driver reads corresponding fields in DT and configures pins
> accordingly.
>
> The "protected" flag is used to distinguish configuration of SCU-owned
> pins from the ordinary ones.
>
> The code has been adapted from Linux work done by Andy Shevchenko
> in pinctrl-merrfifield.c
>
> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/cpu/tangier/Makefile |   2 +-
>  arch/x86/cpu/tangier/pinmux.c | 188 
> ++
>  2 files changed, 189 insertions(+), 1 deletion(-)
>  create mode 100644 arch/x86/cpu/tangier/pinmux.c
>

Basically this looks good to me, except several styling issues below:

> diff --git a/arch/x86/cpu/tangier/Makefile b/arch/x86/cpu/tangier/Makefile
> index 8274482..68f4a32 100644
> --- a/arch/x86/cpu/tangier/Makefile
> +++ b/arch/x86/cpu/tangier/Makefile
> @@ -2,5 +2,5 @@
>  #
>  # Copyright (c) 2017 Intel Corporation
>
> -obj-y += car.o tangier.o sdram.o sysreset.o
> +obj-y += car.o tangier.o sdram.o sysreset.o pinmux.o
>  obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o
> diff --git a/arch/x86/cpu/tangier/pinmux.c b/arch/x86/cpu/tangier/pinmux.c
> new file mode 100644
> index 000..c59b63c
> --- /dev/null
> +++ b/arch/x86/cpu/tangier/pinmux.c
> @@ -0,0 +1,188 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2018 Emlid Limited
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define BUFCFG_OFFSET  0x100
> +
> +#define MRFLD_FAMILY_LEN   0x400
> +
> +/* These are taken from Linux kernel */
> +#define MRFLD_PINMODE_MASK 0x07
> +
> +#define pin_to_bufno(f, p)   ((p) - (f)->pin_base)
> +
> +struct mrfld_family {
> +   unsigned int family_number;
> +   unsigned int pin_base;
> +   size_t npins;
> +   void __iomem *regs;
> +};
> +
> +#define MRFLD_FAMILY(b, s, e)  \
> +   {   \
> +   .family_number = (b),   \
> +   .pin_base = (s),\
> +   .npins = (e) - (s) + 1, \
> +   }
> +
> +static struct mrfld_family mrfld_families[] = {
> +   MRFLD_FAMILY(7, 101, 114),
> +};
> +
> +struct mrfld_pinctrl {
> +   const struct mrfld_family *families;
> +   size_t nfamilies;
> +};
> +
> +static const struct mrfld_family *
> +mrfld_get_family(struct mrfld_pinctrl *mp, unsigned int pin)
> +{
> +   const struct mrfld_family *family;
> +   unsigned int i;
> +
> +   for (i = 0; i < mp->nfamilies; i++) {
> +   family = >families[i];
> +   if (pin >= family->pin_base &&
> +   pin < family->pin_base + family->npins)

CHECK: Alignment should match open parenthesis

> +   return family;
> +   }
> +
> +   printf("failed to find family for pin %u\n", pin);
> +   return NULL;
> +}
> +
> +static void __iomem *
> +mrfld_get_bufcfg(struct mrfld_pinctrl *pinctrl, unsigned int pin)
> +{
> +   const struct mrfld_family *family;
> +   unsigned int bufno;
> +
> +   family =  mrfld_get_family(pinctrl, pin);
> +   if (!family)
> +   return NULL;
> +
> +   bufno = pin_to_bufno(family, pin);
> +
> +   return family->regs + BUFCFG_OFFSET + bufno * 4;
> +}
> +
> +static void
> +mrfld_setup_families(void *base_addr, struct mrfld_family *families, 
> unsigned int nfam)

WARNING: line over 80 characters

> +{
> +   for (int i = 0; i < nfam; i++) {
> +   struct mrfld_family *family = [i];
> +
> +   family->regs = base_addr + family->family_number * 
> MRFLD_FAMILY_LEN;

WARNING: line over 80 characters

> +   }
> +}
> +
> +static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits)
> +{
> +   struct mrfld_pinctrl *pinctrl;
> +   struct udevice *dev;
> +   void __iomem *bufcfg;
> +   u32 v, value;
> +   int ret;
> +
> +   ret = syscon_get_by_driver_data(X86_SYSCON_PINCONF, );
> +   if (ret)
> +   return ret;
> +
> +   pinctrl = dev_get_priv(dev);
> +
> +   bufcfg = mrfld_get_bufcfg(pinctrl, pin);
> +   if (!bufcfg)
> +   return -EINVAL;
> +
> +   value = readl(bufcfg);
> +
> +   v = (value & ~mask) | (bits & mask);
> +
> +   debug("scu: v: 0x%x p: 0x%x bits: %d, mask: %d bufcfg: 0x%p\n",
> +   v, (u32)bufcfg, bits, mask, bufcfg);

CHECK: Alignment should match open parenthesis

> +
> +   ret = 

Re: [U-Boot] [PATCH 1/4] x86: cpu: introduce scu_ipc_raw_command()

2018-09-03 Thread Bin Meng
On Tue, Sep 4, 2018 at 2:23 AM Andy Shevchenko
 wrote:
>
> On Mon, Sep 3, 2018 at 7:40 PM Georgii Staroselskii
>  wrote:
> >
> > This interface will be used to configure properly some pins on
> > Merrifield that are shared with SCU.
> >
> > scu_ipc_raw_command() writes SPTR and DPTR registers before sending
> > a command to SCU.
> >
> > This code has been ported from Linux work done by Andy Shevchenko.
> >
>
> Reviewed-by: Andy Shevchenko 

Somehow I did not receive the original patch email ...

Please see below

>
> > Signed-off-by: Georgii Staroselskii 
> > ---
> >  arch/x86/include/asm/scu.h |  4 
> >  arch/x86/lib/scu.c | 35 +++
> >  2 files changed, 39 insertions(+)
> >
> > diff --git a/arch/x86/include/asm/scu.h b/arch/x86/include/asm/scu.h
> > index 7ce5824..f5ec5a1 100644
> > --- a/arch/x86/include/asm/scu.h
> > +++ b/arch/x86/include/asm/scu.h
> > @@ -6,6 +6,8 @@
> >  #define _X86_ASM_SCU_IPC_H_
> >
> >  /* IPC defines the following message types */
> > +#define IPCMSG_INDIRECT_READ   0x02
> > +#define IPCMSG_INDIRECT_WRITE  0x05
> >  #define IPCMSG_WARM_RESET  0xf0
> >  #define IPCMSG_COLD_RESET  0xf1
> >  #define IPCMSG_SOFT_RESET  0xf2
> > @@ -23,5 +25,7 @@ struct ipc_ifwi_version {
> >  /* Issue commands to the SCU with or without data */
> >  int scu_ipc_simple_command(u32 cmd, u32 sub);
> >  int scu_ipc_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out, int 
> > outlen);
> > +int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
> > +   int outlen, u32 dptr, u32 sptr);
> >

Can we also add the complete function header with comments that
describe the parameters and return value? I see
scu_ipc_simple_command() has one in the .c file, but scu_ipc_command()
does not. For consistency, either we document the API in the .c, or
move the comment block to the .h?

> >  #endif /* _X86_ASM_SCU_IPC_H_ */
> > diff --git a/arch/x86/lib/scu.c b/arch/x86/lib/scu.c
> > index caa04c6..847bb77 100644
> > --- a/arch/x86/lib/scu.c
> > +++ b/arch/x86/lib/scu.c
> > @@ -101,6 +101,41 @@ static int scu_ipc_cmd(struct ipc_regs *regs, u32 cmd, 
> > u32 sub,
> > return err;
> >  }
> >
> > +int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
> > +   int outlen, u32 dptr, u32 sptr)
> > +{
> > +   int inbuflen = DIV_ROUND_UP(inlen, 4);
> > +   struct udevice *dev;
> > +   struct scu *scu;
> > +   int ret;
> > +
> > +   ret = syscon_get_by_driver_data(X86_SYSCON_SCU, );
> > +   if (ret)
> > +   return ret;
> > +
> > +   scu = dev_get_priv(dev);
> > +
> > +   /* Up to 16 bytes */
> > +   if (inbuflen > 4)
> > +   return -EINVAL;
> > +
> > +   writel(dptr, >regs->dptr);
> > +   writel(sptr, >regs->sptr);
> > +

It looks like that this new API shares some common codes with existing
API scu_ipc_command(). Is it possible to do some refactoring?

> > +   /*
> > +* SRAM controller doesn't support 8-bit writes, it only
> > +* supports 32-bit writes, so we have to copy input data into
> > +* the temporary buffer, and SCU FW will use the inlen to
> > +* determine the actual input data length in the temporary
> > +* buffer.
> > +*/
> > +
> > +   u32 inbuf[4] = {0};
> > +
> > +   memcpy(inbuf, in, inlen);
> > +
> > +   return scu_ipc_cmd(scu->regs, cmd, sub, inbuf, inlen, out, outlen);
> > +}
> >  /**
> >   * scu_ipc_simple_command() - send a simple command
> >   * @cmd: command

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


Re: [U-Boot] [PATCH v2 07/13] x86: Fix signed shift overflow in MSR_IA32_APICBASE_BASE

2018-09-03 Thread Bin Meng
Hi Eugeniu,

On Sat, Sep 1, 2018 at 6:59 PM Eugeniu Rosca  wrote:
>
> Hi there,
>
> On Tue, Aug 28, 2018 at 08:42:01AM +0200, Eugeniu Rosca wrote:
> > Hi Bin,
> >
> > cc: Masahiro, Andrey
> >
> > On Tue, Aug 28, 2018 at 10:05:51AM +0800, Bin Meng wrote:
> > > Hi Eugeniu,
> > >
> > > On Mon, Aug 27, 2018 at 7:19 AM Eugeniu Rosca  
> > > wrote:
> > > >
> > > > Fix the following UBSAN report:
> > > >  ==
> > > >  UBSAN: Undefined behaviour in arch/x86/cpu/lapic.c:73:14
> > > >  left shift of 1048575 by 12 places cannot be represented in type 'int'
> > > >  ==
> > > >
> > > > Steps to reproduce the above:
> > > > * echo CONFIG_UBSAN=y >> configs/qemu-x86_defconfig
> > > > * make ARCH=x86 qemu-x86_defconfig all
> > > > * qemu-system-i386 --version
> > > >   QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.31)
> > > > * qemu-system-i386 --nographic -bios u-boot.rom
> > > >
> > > > Fixes: 98568f0fa96b ("x86: Import MSR/MTRR code from Linux")
> > > > Signed-off-by: Eugeniu Rosca 
> > > > ---
> > > >
> > > > Changes in v2:
> > > >  - None. Newly pushed.
> > > > ---
> > > >  arch/x86/include/asm/msr-index.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/x86/include/asm/msr-index.h 
> > > > b/arch/x86/include/asm/msr-index.h
> > > > index 9c1dbe61d596..d8b7b8013c74 100644
> > > > --- a/arch/x86/include/asm/msr-index.h
> > > > +++ b/arch/x86/include/asm/msr-index.h
> > > > @@ -370,7 +370,7 @@
> > > >  #define MSR_IA32_APICBASE  0x001b
> > > >  #define MSR_IA32_APICBASE_BSP  (1<<8)
> > > >  #define MSR_IA32_APICBASE_ENABLE   (1<<11)
> > > > -#define MSR_IA32_APICBASE_BASE (0xf<<12)
> > > > +#define MSR_IA32_APICBASE_BASE (0xfUL << 12)
> > >
> > > I don't understand why such warnings is emitted: "left shift of
> > > 1048575 by 12 places cannot be represented in type 'int'"
> > >
> > > Compilers don't complain this code and Linux kernel has the same
> > > definition here.
> >
> > I wrote a basic kernel module printing the result of "(0xf << 12)"
> > and kernel UBSAN doesn't complain indeed.
> >
> > I started to compare the compiler flags between Linux and U-Boot and
> > nailed down empirically that Linux UBSAN warning is inhibited by the
> > -fno-strict-overflow gcc option, introduced in Linux commit [1]. The
> > latter actually replaces another gcc option -fwrapv, introduced in [2].
> >
> > Any of the two flags makes the UBSAN error vanish in the kernel.
> > Neither of the two flags is used in U-Boot.
> >
> > I am in the process of browsing some documentation related to -fwrapv
> > and -fno-strict-overflow (e.g. [3]). Please, feel free to share any
> > thoughts and/or cc anybody who might have dealt with these topics
> > in the past. I will come back with more feedback later.
> >
> > [1] v2.6.31 commit a137802ee839 ("Don't use '-fwrapv' compiler option: it's 
> > buggy in gcc-4.1.x")
> > [2] v2.6.29 commit 68df3755e383 ("Add '-fwrapv' to gcc CFLAGS")
> > [3] https://www.airs.com/blog/archives/120
> >
> > > Regards,
> > > Bin
>
> Just wanted to let you know that coreboot folks are going through
> similar discussions in [1]. Also, experimenting with various gcc
> versions and flags in my spare time, I collected some evidence [2]
> showing that the behavior of GCC UBSAN (-fsanitize=undefined &
> friends) may differ a lot depending on the gcc version and below
> flags (none used by U-Boot, but some used in Linux kernel):
>  -fwrapv
>  -fstrict-overflow
>  -fno-strict-overflow
>
> Checking how -fno-strict-overflow and -fwrapv compare to each other
> (since they seem to accomplish similar goals according to many sources),
> I've used the sample app from [3] to see how gcc handles signed integer
> wraparound depending on gcc version, flags, optimization level and
> on whether UBSAN is enabled or not. The variance/inconsistency of the
> results [4] is very high in my opinion.
>
> One clear conclusion of [4] is that questions like why gcc UBSAN
> complains in U-Boot but not in the Kernel require knowing at least the
> parameters  tracked in [4] (and maybe more).
>
> [1] https://mail.coreboot.org/pipermail/coreboot/2018-February/086146.html
> [2] UBSAN behavior (printing 1 << 31) is highly dependent on gcc version and 
> flags
>
>  +--+-+-+
>  |   gcc flags  | gcc version | UB? |
>  |--|-|-|
>  |  |  gcc-4.9.4  |  -  |
>  | -fsanitize=undefined |  gcc-5.5.0  |  y  |
>  |  |  gcc-7.3.0  |  y  |
>  |  |  gcc-8.1.0  |  y  |
>  +--+
>  |  |  gcc-4.9.4  |  -  |
>  | -fsanitize=undefined |  gcc-5.5.0  |  y  |
>  | -fstrict-overflow|  gcc-7.3.0  |  y  |
>  |  |  gcc-8.1.0 

Re: [U-Boot] [PATCH v4] gpio: dwapb_gpio: Add reset ctrl to driver

2018-09-03 Thread Ley Foon Tan
On Thu, Aug 30, 2018 at 8:11 PM Marek Vasut  wrote:
>
> On 08/30/2018 02:45 AM, Ley Foon Tan wrote:
> > On Wed, Aug 29, 2018 at 7:57 PM Marek Vasut  wrote:
> >>
> >> On 08/29/2018 10:44 AM, Ley Foon Tan wrote:
> >>> Add code to reset all reset signals as in gpio DT node. A reset property
> >>> is an optional feature, so only print out a warning and do not fail if a
> >>> reset property is not present.
> >>>
> >>> If a reset property is discovered, then use it to deassert, thus
> >>> bringing the IP out of reset.
> >>>
> >>> Signed-off-by: Ley Foon Tan 
> >>
> >> This is much better.
> >>
> >>> +static int gpio_dwapb_reset(struct udevice *dev)
> >>> +{
> >>> + int ret;
> >>> + struct gpio_dwapb_priv *priv = dev_get_priv(dev);
> >>> +
> >>> + ret = reset_get_bulk(dev, >resets);
> >>> + if (ret) {
> >>> + dev_warn(dev, "Can't get reset: %d\n", ret);
> >>
> >> Won't this barf on machines which either don't have DM_RESET enabled or
> >> don't have it described in DT ?
> > By default, dev_warn() is not show up. Or we can move this dev_warn
> > when "return ret" error below.
>
> I think that'd be better. If there is no reset support, no point in
> warning. Or what do you think ?
>
> btw you could then also flatten the indent with some
> ret = reset
> if (ret == -ENOENT || )
>  return 0;
>
> dev_warn();
> return ret;

Okay, will change this.

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


Re: [U-Boot] [PATCH] travis: Use kernel.org pre-built toolchain for riscv

2018-09-03 Thread Bin Meng
Hi Rick,

On Tue, Sep 4, 2018 at 3:23 AM Tom Rini  wrote:
>
> On Mon, Sep 03, 2018 at 05:50:39PM +0800, Bin Meng wrote:
> > Hi Tom,
> >
> > On Thu, Aug 30, 2018 at 9:12 PM Bin Meng  wrote:
> > >
> > > This updates travis configuration to use kernel.org pre-built
> > > toolchain for riscv.
> > >
> > > Signed-off-by: Bin Meng 
> > > ---
> > >
> > >  .travis.yml | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > >
> >
> > Since this is travis-ci changes, can we take this for v2018.09? I've
> > verified that it works well for current riscv build on travis-ci.org.
>
> Seeing as things are still working before this change I would like to
> see an ack from the custodian, thanks!

Are you OK with this?

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


[U-Boot] [PATCH] amlogic: board p212: Fix Ethernet PHY init

2018-09-03 Thread Jasper kcoding
Without this patch the Ethernet PHY on the p212 board does not get
fully configured.
When this happens Ethernet does not function.

The similar libretech-cc and khadas-vim boards have this code already.
That's why the Ethernet on these boards do work.

Signed-off-by: Jasper Kcoding 
Acked-by: Neil Armstrong 
---
 board/amlogic/p212/p212.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/amlogic/p212/p212.c b/board/amlogic/p212/p212.c
index 06c2eaee47..d5ce5397f3 100644
--- a/board/amlogic/p212/p212.c
+++ b/board/amlogic/p212/p212.c
@@ -29,7 +29,7 @@ int misc_init_r(void)
char serial[EFUSE_SN_SIZE];
ssize_t len;

-   meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, 0);
+   meson_gx_eth_init(PHY_INTERFACE_MODE_RMII,
MESON_GXL_USE_INTERNAL_RMII_PHY);

if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
--
2.11.0
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] watchdog: Add sunxi watchdog driver

2018-09-03 Thread Chris Blake
Based on the linux mainline driver, this adds support for the hardware
watchdog timer found on some sunxi boards.

Signed-off-by: Chris Blake 
---
 common/board_f.c |   3 +-
 drivers/watchdog/Kconfig |  18 
 drivers/watchdog/Makefile|   1 +
 drivers/watchdog/sunxi_wdt.c | 103 +++
 4 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 drivers/watchdog/sunxi_wdt.c

diff --git a/common/board_f.c b/common/board_f.c
index 88d7700..7b0d912 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -91,7 +91,8 @@ static int init_func_watchdog_init(void)
(defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
defined(CONFIG_DESIGNWARE_WATCHDOG) || \
-   defined(CONFIG_IMX_WATCHDOG))
+   defined(CONFIG_IMX_WATCHDOG) || \
+   defined(CONFIG_SUNXI_WDT))
hw_watchdog_init();
puts("   Watchdog enabled\n");
 # endif
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index d545b3e..bd09dad 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -20,6 +20,24 @@ config BCM2835_WDT
  This provides basic infrastructure to support BCM2835/2836 watchdog
  hardware, with a max timeout of ~15secs.
 
+config SUNXI_WDT
+   bool "SUNXI watchdog timer support"
+   select HW_WATCHDOG
+   help
+  Select this to enable the SUNXI watchdog timer.
+
+if SUNXI_WDT
+
+config SUNXI_WDT_TIMEOUT
+   int "SUNXI watchdog timeout setting"
+   default 10
+   range 1 16
+   depends on SUNXI_WDT
+   help
+ Adjust the timeout window for the SUNXI watchdog timer.
+
+endif
+
 config OMAP_WATCHDOG
bool "TI OMAP watchdog driver"
depends on ARCH_OMAP2PLUS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index f405f51..ce27bb5 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_BCM2835_WDT)   += bcm2835_wdt.o
 obj-$(CONFIG_WDT_ORION) += orion_wdt.o
 obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
 obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o
+obj-$(CONFIG_SUNXI_WDT) += sunxi_wdt.o
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
new file mode 100644
index 000..9d88b86
--- /dev/null
+++ b/drivers/watchdog/sunxi_wdt.c
@@ -0,0 +1,103 @@
+/*
+ * (C) Copyright 2018 Chris Blake 
+ * Roughly based on the mainline linux driver, sunxi_wdt.c
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without
+ * any warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#define WDT_CTRL_RESTART   (0x1 << 0)
+#define WDT_CTRL_KEY   (0x0a57 << 1)
+#define WDT_MODE_EN(0x1 << 0)
+#define WDT_TIMEOUT_MASK   (0xf)
+
+struct sunxi_wdt_reg {
+   u32 wdt_ctrl;
+   u32 wdt_cfg;
+   u32 wdt_mode;
+   u32 wdt_timeout_shift;
+   u32 wdt_reset_mask;
+   u32 wdt_reset_val;
+};
+
+static const struct sunxi_wdt_reg sun4i_wdt_reg = {
+   .wdt_ctrl = 0x00,
+   .wdt_cfg = 0x04,
+   .wdt_mode = 0x04,
+   .wdt_timeout_shift = 3,
+   .wdt_reset_mask = 0x02,
+   .wdt_reset_val = 0x02,
+};
+
+static const struct sunxi_wdt_reg sun6i_dog_regs = {
+   .wdt_ctrl = 0x10,
+   .wdt_cfg = 0x14,
+   .wdt_mode = 0x18,
+   .wdt_timeout_shift = 4,
+   .wdt_reset_mask = 0x03,
+   .wdt_reset_val = 0x01,
+};
+
+static const int wdt_timeout_map[] = {
+   [1] = 0x1,  /* 1s  */
+   [2] = 0x2,  /* 2s  */
+   [3] = 0x3,  /* 3s  */
+   [4] = 0x4,  /* 4s  */
+   [5] = 0x5,  /* 5s  */
+   [6] = 0x6,  /* 6s  */
+   [8] = 0x7,  /* 8s  */
+   [10] = 0x8, /* 10s */
+   [12] = 0x9, /* 12s */
+   [14] = 0xA, /* 14s */
+   [16] = 0xB, /* 16s */
+};
+
+#if defined(CONFIG_SUNXI_GEN_SUN6I)
+static const struct sunxi_wdt_reg *regs = _dog_regs;
+#else
+static const struct sunxi_wdt_reg *regs = _dog_regs;
+#endif
+
+static void *wdt_base = &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
+
+void hw_watchdog_reset(void)
+{
+   /* reload the watchdog */
+   writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, wdt_base + regs->wdt_ctrl);
+}
+
+void hw_watchdog_disable(void)
+{
+   /* Reset WDT Config */
+   writel(0, wdt_base + regs->wdt_mode);
+}
+
+void hw_watchdog_init(void)
+{
+   const u32 timeout = CONFIG_SUNXI_WDT_TIMEOUT;
+   u32 reg;
+
+   reg = readl(wdt_base + regs->wdt_mode);
+   reg &= ~(WDT_TIMEOUT_MASK << regs->wdt_timeout_shift);
+   reg |= wdt_timeout_map[timeout] << regs->wdt_timeout_shift;
+   writel(reg, wdt_base + regs->wdt_mode);
+
+   hw_watchdog_reset();
+
+   /* Set system reset function */
+   reg = readl(wdt_base + regs->wdt_cfg);
+   reg &= ~(regs->wdt_reset_mask);
+   reg |= regs->wdt_reset_val;
+  

[U-Boot] [PATCH 0/2] Watchdog: Add support for sunxi hardware watchdog

2018-09-03 Thread Chris Blake
The following patches are needed to add support for the hardware watchdog
found in most sunxi SoC's.

The patches below have only been tested on a sun50i device (H5 SoC) and work
as expected. The actual sunxi_wdt.c was roughly based off of the mainline
linux driver, and is enabled by adding CONFIG_SUNXI_WDT to your config. It is
not enabled by default.

Chris Blake (2):
  watchdog: Fix SPL builds when watchdog is enabled
  watchdog: Add sunxi watchdog driver

 common/board_f.c |   3 +-
 drivers/watchdog/Kconfig |  18 
 drivers/watchdog/Makefile|   1 +
 drivers/watchdog/sunxi_wdt.c | 103 +++
 include/watchdog.h   |   4 +-
 5 files changed, 126 insertions(+), 3 deletions(-)
 create mode 100644 drivers/watchdog/sunxi_wdt.c

-- 
2.7.4

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


[U-Boot] [PATCH 1/2] watchdog: Fix SPL builds when watchdog is enabled

2018-09-03 Thread Chris Blake
Without this fix, u-boot fails to comple as it tries to load watchdog.h
during an SPL build. This breaks support for things such as the sunxi
arch.

Signed-off-by: Chris Blake 
---
 include/watchdog.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/watchdog.h b/include/watchdog.h
index 14073cf..555f058 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -20,7 +20,7 @@
 int init_func_watchdog_reset(void);
 #endif
 
-#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
+#if (defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)) && 
!defined(CONFIG_SPL_BUILD)
 #define INIT_FUNC_WATCHDOG_INITinit_func_watchdog_init,
 #define INIT_FUNC_WATCHDOG_RESET   init_func_watchdog_reset,
 #else
@@ -47,7 +47,7 @@ int init_func_watchdog_reset(void);
/*
 * Maybe a software watchdog?
 */
-   #if defined(CONFIG_WATCHDOG)
+   #if defined(CONFIG_WATCHDOG) && !defined(CONFIG_SPL_BUILD)
#if defined(__ASSEMBLY__)
#define WATCHDOG_RESET bl watchdog_reset
#else
-- 
2.7.4

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


Re: [U-Boot] [PATCH 1/3] spi: davinci: Add platdata support

2018-09-03 Thread Adam Ford
On Mon, Sep 3, 2018 at 5:21 PM Adam Ford  wrote:
>
> On Mon, Sep 3, 2018 at 12:30 PM Jagan Teki  wrote:
> >
> > Davanci spi driver has DM support already, this patch
> > add support for platdata so-that SPL can use it for
> > low foot-print.
> >
>
> In order for this to work, I had to apply a patch [1] that I submitted before.
> That patch disabled the manual initialization of the UART in da850_lowlevel.c
> to not conflict with the DM version of initialization.
>
> Assuming that [1] gets applied first then this, you can add me as
> 'tested-by' on
> both patches 1 of 3 and 2 of 3.  I don't have the hardware to test 3 of 3.
>
> [1] - https://patchwork.ozlabs.org/patch/957336/
>
> adam
>

I should have stated, that without the [1] patch, this does does not work.

adam
> > Signed-off-by: Jagan Teki 
> > ---
> >  drivers/spi/davinci_spi.c  | 47 +++---
> >  include/dm/platform_data/spi_davinci.h | 15 
> >  2 files changed, 43 insertions(+), 19 deletions(-)
> >  create mode 100644 include/dm/platform_data/spi_davinci.h
> >
> > diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
> > index a822858323..07fa5e3b8a 100644
> > --- a/drivers/spi/davinci_spi.c
> > +++ b/drivers/spi/davinci_spi.c
> > @@ -14,6 +14,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  /* SPIGCR0 */
> >  #define SPIGCR0_SPIENA_MASK0x1
> > @@ -529,50 +530,58 @@ static int davinci_spi_xfer(struct udevice *dev, 
> > unsigned int bitlen,
> > return __davinci_spi_xfer(ds, bitlen, dout, din, flags);
> >  }
> >
> > +static const struct dm_spi_ops davinci_spi_ops = {
> > +   .claim_bus  = davinci_spi_claim_bus,
> > +   .release_bus= davinci_spi_release_bus,
> > +   .xfer   = davinci_spi_xfer,
> > +   .set_speed  = davinci_spi_set_speed,
> > +   .set_mode   = davinci_spi_set_mode,
> > +};
> > +
> >  static int davinci_spi_probe(struct udevice *bus)
> >  {
> > -   /* Nothing to do */
> > +   struct davinci_spi_slave *ds = dev_get_priv(bus);
> > +   struct davinci_spi_platdata *plat = bus->platdata;
> > +   ds->regs = plat->regs;
> > +   ds->num_cs = plat->num_cs;
> > +
> > return 0;
> >  }
> >
> > +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
> >  static int davinci_ofdata_to_platadata(struct udevice *bus)
> >  {
> > -   struct davinci_spi_slave *ds = dev_get_priv(bus);
> > -   const void *blob = gd->fdt_blob;
> > -   int node = dev_of_offset(bus);
> > +   struct davinci_spi_platdata *plat = bus->platdata;
> > +   fdt_addr_t addr;
> >
> > -   ds->regs = devfdt_map_physmem(bus, sizeof(struct davinci_spi_regs));
> > -   if (!ds->regs) {
> > -   printf("%s: could not map device address\n", __func__);
> > +   addr = devfdt_get_addr(bus);
> > +   if (addr == FDT_ADDR_T_NONE)
> > return -EINVAL;
> > -   }
> > -   ds->num_cs = fdtdec_get_int(blob, node, "num-cs", 4);
> > +
> > +   plat->regs = (struct davinci_spi_regs *)addr;
> > +   plat->num_cs = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), 
> > "num-cs", 4);
> >
> > return 0;
> >  }
> >
> > -static const struct dm_spi_ops davinci_spi_ops = {
> > -   .claim_bus  = davinci_spi_claim_bus,
> > -   .release_bus= davinci_spi_release_bus,
> > -   .xfer   = davinci_spi_xfer,
> > -   .set_speed  = davinci_spi_set_speed,
> > -   .set_mode   = davinci_spi_set_mode,
> > -};
> > -
> >  static const struct udevice_id davinci_spi_ids[] = {
> > { .compatible = "ti,keystone-spi" },
> > { .compatible = "ti,dm6441-spi" },
> > { .compatible = "ti,da830-spi" },
> > { }
> >  };
> > +#endif
> >
> >  U_BOOT_DRIVER(davinci_spi) = {
> > .name = "davinci_spi",
> > .id = UCLASS_SPI,
> > +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
> > .of_match = davinci_spi_ids,
> > -   .ops = _spi_ops,
> > .ofdata_to_platdata = davinci_ofdata_to_platadata,
> > -   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
> > +.platdata_auto_alloc_size = sizeof(struct davinci_spi_platdata),
> > +#endif
> > .probe = davinci_spi_probe,
> > +   .ops = _spi_ops,
> > +   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
> >  };
> >  #endif
> > diff --git a/include/dm/platform_data/spi_davinci.h 
> > b/include/dm/platform_data/spi_davinci.h
> > new file mode 100644
> > index 00..fbc62c262a
> > --- /dev/null
> > +++ b/include/dm/platform_data/spi_davinci.h
> > @@ -0,0 +1,15 @@
> > +/*
> > + * Copyright (C) 2018 Jagan Teki 
> > + *
> > + * SPDX-License-Identifier:GPL-2.0+
> > + */
> > +
> > +#ifndef __spi_davinci_h
> > +#define __spi_davinci_h
> > +
> > +struct davinci_spi_platdata {
> > +   struct davinci_spi_regs *regs;
> > +   u8 num_cs; /* total no. of CS available */
> > +};
> > +
> 

Re: [U-Boot] [PATCH 1/3] spi: davinci: Add platdata support

2018-09-03 Thread Adam Ford
On Mon, Sep 3, 2018 at 12:30 PM Jagan Teki  wrote:
>
> Davanci spi driver has DM support already, this patch
> add support for platdata so-that SPL can use it for
> low foot-print.
>

In order for this to work, I had to apply a patch [1] that I submitted before.
That patch disabled the manual initialization of the UART in da850_lowlevel.c
to not conflict with the DM version of initialization.

Assuming that [1] gets applied first then this, you can add me as
'tested-by' on
both patches 1 of 3 and 2 of 3.  I don't have the hardware to test 3 of 3.

[1] - https://patchwork.ozlabs.org/patch/957336/

adam

> Signed-off-by: Jagan Teki 
> ---
>  drivers/spi/davinci_spi.c  | 47 +++---
>  include/dm/platform_data/spi_davinci.h | 15 
>  2 files changed, 43 insertions(+), 19 deletions(-)
>  create mode 100644 include/dm/platform_data/spi_davinci.h
>
> diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
> index a822858323..07fa5e3b8a 100644
> --- a/drivers/spi/davinci_spi.c
> +++ b/drivers/spi/davinci_spi.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /* SPIGCR0 */
>  #define SPIGCR0_SPIENA_MASK0x1
> @@ -529,50 +530,58 @@ static int davinci_spi_xfer(struct udevice *dev, 
> unsigned int bitlen,
> return __davinci_spi_xfer(ds, bitlen, dout, din, flags);
>  }
>
> +static const struct dm_spi_ops davinci_spi_ops = {
> +   .claim_bus  = davinci_spi_claim_bus,
> +   .release_bus= davinci_spi_release_bus,
> +   .xfer   = davinci_spi_xfer,
> +   .set_speed  = davinci_spi_set_speed,
> +   .set_mode   = davinci_spi_set_mode,
> +};
> +
>  static int davinci_spi_probe(struct udevice *bus)
>  {
> -   /* Nothing to do */
> +   struct davinci_spi_slave *ds = dev_get_priv(bus);
> +   struct davinci_spi_platdata *plat = bus->platdata;
> +   ds->regs = plat->regs;
> +   ds->num_cs = plat->num_cs;
> +
> return 0;
>  }
>
> +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
>  static int davinci_ofdata_to_platadata(struct udevice *bus)
>  {
> -   struct davinci_spi_slave *ds = dev_get_priv(bus);
> -   const void *blob = gd->fdt_blob;
> -   int node = dev_of_offset(bus);
> +   struct davinci_spi_platdata *plat = bus->platdata;
> +   fdt_addr_t addr;
>
> -   ds->regs = devfdt_map_physmem(bus, sizeof(struct davinci_spi_regs));
> -   if (!ds->regs) {
> -   printf("%s: could not map device address\n", __func__);
> +   addr = devfdt_get_addr(bus);
> +   if (addr == FDT_ADDR_T_NONE)
> return -EINVAL;
> -   }
> -   ds->num_cs = fdtdec_get_int(blob, node, "num-cs", 4);
> +
> +   plat->regs = (struct davinci_spi_regs *)addr;
> +   plat->num_cs = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), 
> "num-cs", 4);
>
> return 0;
>  }
>
> -static const struct dm_spi_ops davinci_spi_ops = {
> -   .claim_bus  = davinci_spi_claim_bus,
> -   .release_bus= davinci_spi_release_bus,
> -   .xfer   = davinci_spi_xfer,
> -   .set_speed  = davinci_spi_set_speed,
> -   .set_mode   = davinci_spi_set_mode,
> -};
> -
>  static const struct udevice_id davinci_spi_ids[] = {
> { .compatible = "ti,keystone-spi" },
> { .compatible = "ti,dm6441-spi" },
> { .compatible = "ti,da830-spi" },
> { }
>  };
> +#endif
>
>  U_BOOT_DRIVER(davinci_spi) = {
> .name = "davinci_spi",
> .id = UCLASS_SPI,
> +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
> .of_match = davinci_spi_ids,
> -   .ops = _spi_ops,
> .ofdata_to_platdata = davinci_ofdata_to_platadata,
> -   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
> +.platdata_auto_alloc_size = sizeof(struct davinci_spi_platdata),
> +#endif
> .probe = davinci_spi_probe,
> +   .ops = _spi_ops,
> +   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
>  };
>  #endif
> diff --git a/include/dm/platform_data/spi_davinci.h 
> b/include/dm/platform_data/spi_davinci.h
> new file mode 100644
> index 00..fbc62c262a
> --- /dev/null
> +++ b/include/dm/platform_data/spi_davinci.h
> @@ -0,0 +1,15 @@
> +/*
> + * Copyright (C) 2018 Jagan Teki 
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#ifndef __spi_davinci_h
> +#define __spi_davinci_h
> +
> +struct davinci_spi_platdata {
> +   struct davinci_spi_regs *regs;
> +   u8 num_cs; /* total no. of CS available */
> +};
> +
> +#endif /* __spi_davinci_h */
> --
> 2.18.0.321.gffc6fa0e3
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 08/12] riscv: Add a helper routine to print CPU information

2018-09-03 Thread Auer, Lukas
On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> This adds a helper routine to print CPU information. Currently
> it prints all the instruction set extensions that the processor
> core supports.
> 
> Signed-off-by: Bin Meng 
> ---
> 
>  arch/riscv/Makefile  |   1 +
>  arch/riscv/cpu/Makefile  |   5 ++
>  arch/riscv/cpu/cpu.c |  49 +
>  arch/riscv/include/asm/csr.h | 124
> +++
>  4 files changed, 179 insertions(+)
>  create mode 100644 arch/riscv/cpu/Makefile
>  create mode 100644 arch/riscv/cpu/cpu.c
>  create mode 100644 arch/riscv/include/asm/csr.h
> 
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 084888a..af432e1 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -5,5 +5,6 @@
>  
>  head-y := arch/riscv/cpu/$(CPU)/start.o
>  
> +libs-y += arch/riscv/cpu/
>  libs-y += arch/riscv/cpu/$(CPU)/
>  libs-y += arch/riscv/lib/
> diff --git a/arch/riscv/cpu/Makefile b/arch/riscv/cpu/Makefile
> new file mode 100644
> index 000..63de163
> --- /dev/null
> +++ b/arch/riscv/cpu/Makefile
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2018, Bin Meng 
> +
> +obj-y += cpu.o
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> new file mode 100644
> index 000..ae57fb8
> --- /dev/null
> +++ b/arch/riscv/cpu/cpu.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018, Bin Meng 
> + */
> +
> +#include 
> +#include 
> +
> +enum {
> + ISA_INVALID = 0,
> + ISA_32BIT,
> + ISA_64BIT,
> + ISA_128BIT
> +};
> +
> +static const char * const isa_bits[] = {
> + [ISA_INVALID] = NULL,
> + [ISA_32BIT]   = "32",
> + [ISA_64BIT]   = "64",
> + [ISA_128BIT]  = "128"
> +};
> +
> +static inline bool supports_extension(char ext)
> +{
> + return csr_read(misa) & (1 << (ext - 'a'));
> +}
> +
> +int print_cpuinfo(void)
> +{
> + char name[32];
> + char *s = name;
> + int bit;
> +
> + s += sprintf(name, "rv");
> + bit = csr_read(misa) >> (sizeof(long) * 8 - 2);
> + s += sprintf(s, isa_bits[bit]);
> +
> + supports_extension('i') ? *s++ = 'i' : 'r';
> + supports_extension('m') ? *s++ = 'm' : 'i';
> + supports_extension('a') ? *s++ = 'a' : 's';
> + supports_extension('f') ? *s++ = 'f' : 'c';
> + supports_extension('d') ? *s++ = 'd' : '-';
> + supports_extension('c') ? *s++ = 'c' : 'v';
> + *s++ = '\0';
> +
> + printf("CPU:   %s\n", name);
> +
> + return 0;
> +}
> diff --git a/arch/riscv/include/asm/csr.h
> b/arch/riscv/include/asm/csr.h
> new file mode 100644
> index 000..50fccea
> --- /dev/null
> +++ b/arch/riscv/include/asm/csr.h
> @@ -0,0 +1,124 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2015 Regents of the University of California
> + *
> + * Taken from Linux arch/riscv/include/asm/csr.h
> + */
> +
> +#ifndef _ASM_RISCV_CSR_H
> +#define _ASM_RISCV_CSR_H
> +
> +/* Status register flags */
> +#define SR_SIE   _AC(0x0002, UL) /* Supervisor
> Interrupt Enable */
> +#define SR_SPIE  _AC(0x0020, UL) /* Previous
> Supervisor IE */
> +#define SR_SPP   _AC(0x0100, UL) /* Previously
> Supervisor */
> +#define SR_SUM   _AC(0x0004, UL) /* Supervisor
> access User Memory */
> +
> +#define SR_FS_AC(0x6000, UL) /* Floating-point
> Status */
> +#define SR_FS_OFF_AC(0x, UL)
> +#define SR_FS_INITIAL_AC(0x2000, UL)
> +#define SR_FS_CLEAN  _AC(0x4000, UL)
> +#define SR_FS_DIRTY  _AC(0x6000, UL)
> +
> +#define SR_XS_AC(0x00018000, UL) /* Extension Status
> */
> +#define SR_XS_OFF_AC(0x, UL)
> +#define SR_XS_INITIAL_AC(0x8000, UL)
> +#define SR_XS_CLEAN  _AC(0x0001, UL)
> +#define SR_XS_DIRTY  _AC(0x00018000, UL)
> +
> +#ifndef CONFIG_64BIT
> +#define SR_SD_AC(0x8000, UL) /* FS/XS dirty */
> +#else
> +#define SR_SD_AC(0x8000, UL) /* FS/XS
> dirty */
> +#endif
> +
> +/* SATP flags */
> +#if __riscv_xlen == 32
> +#define SATP_PPN _AC(0x003F, UL)
> +#define SATP_MODE_32 _AC(0x8000, UL)
> +#define SATP_MODESATP_MODE_32
> +#else
> +#define SATP_PPN _AC(0x0FFF, UL)
> +#define SATP_MODE_39 _AC(0x8000, UL)
> +#define SATP_MODESATP_MODE_39
> +#endif
> +
> +/* Interrupt Enable and Interrupt Pending flags */
> +#define SIE_SSIE _AC(0x0002, UL) /* Software Interrupt
> Enable */
> +#define SIE_STIE _AC(0x0020, UL) /* Timer Interrupt Enable
> */
> +
> +#define EXC_INST_MISALIGNED  0
> +#define EXC_INST_ACCESS  1
> +#define EXC_BREAKPOINT   3
> +#define EXC_LOAD_ACCESS  5
> +#define EXC_STORE_ACCESS 7
> +#define EXC_SYSCALL  8
> +#define EXC_INST_PAGE_FAULT  12
> +#define EXC_LOAD_PAGE_FAULT  13
> +#define EXC_STORE_PAGE_FAULT 15
> +
> +#ifndef 

Re: [U-Boot] [PATCH 03/12] riscv: bootm: Correct the 1st kernel argument to hart id

2018-09-03 Thread Auer, Lukas
On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> The first argument of Linux kernel is the risc-v core hart id,
> from which the kernel is booted from. It is not the mach_id,
> which seems to be copied from arm.
> 
> Signed-off-by: Bin Meng 
> ---
> 
>  arch/riscv/lib/bootm.c | 18 +-
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
> index 6662aff..754bbff 100644
> --- a/arch/riscv/lib/bootm.c
> +++ b/arch/riscv/lib/bootm.c
> @@ -25,10 +25,7 @@ int arch_fixup_fdt(void *blob)
>  
>  int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t
> *images)
>  {
> - bd_t*bd = gd->bd;
> - char*s;
> - int machid = bd->bi_arch_number;
> - void(*theKernel)(int arch, uint params);
> + void(*kernel)(int hart, uint dtb);

This probably does not cause any issues in u-boot, but the second
parameter should be 32 bit or 64 bit depending on the architecture.
Since you are already changing the kernel arguments it would make sense
to also change dtb from uint to ulong or void *.

>  
>   /*
>* allow the PREP bootm subcommand, it is required for bootm to
> work
> @@ -39,18 +36,12 @@ int do_bootm_linux(int flag, int argc, char
> *argv[], bootm_headers_t *images)
>   if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
>   return 1;
>  
> - theKernel = (void (*)(int, uint))images->ep;
> -
> - s = env_get("machid");
> - if (s) {
> - machid = simple_strtoul(s, NULL, 16);
> - printf("Using machid 0x%x from environment\n", machid);
> - }
> + kernel = (void (*)(int, uint))images->ep;
>  
>   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
>  
>   debug("## Transferring control to Linux (at address %08lx)
> ...\n",
> -(ulong)theKernel);
> +(ulong)kernel);
>  
>   if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
>  #ifdef CONFIG_OF_LIBFDT
> @@ -66,8 +57,9 @@ int do_bootm_linux(int flag, int argc, char
> *argv[], bootm_headers_t *images)
>   printf("\nStarting kernel ...\n\n");
>  
>   cleanup_before_linux();
> + /* TODO: hardcode the hart id to zero for now */
>   if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
> - theKernel(machid, (unsigned long)images->ft_addr);
> + kernel(0, (unsigned long)images->ft_addr);
>  

You can use the mhartid CSR to get the hart id. This will limit u-boot
to running in machine mode however. Alternatively you can also use the
hart id, which is passed in a0 by the bootloader.

Thanks,
Lukas

>   /* does not return */
>  



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


Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt board support

2018-09-03 Thread Auer, Lukas
On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> This adds QEMU RISC-V 'virt' board target support, with the hope of
> helping people easily test U-Boot on RISC-V.
> 
> The QEMU virt machine models a generic RISC-V virtual machine with
> support for the VirtIO standard networking and block storage devices.
> It has CLINT, PLIC, 16550A UART devices in addition to VirtIO and
> it also uses device-tree to pass configuration information to guest
> software. It implements RISC-V privileged architecture spec v1.10.
> 
> Both 32-bit and 64-bit builds are supported. Support is pretty much
> preliminary, only booting to U-Boot shell with the UART driver on
> a single core. Booting Linux is not supported yet.
> 

For your information and to avoid duplicate work, I am working on a
patch set that improves RISC-V support in u-boot. I am currently able
to boot Linux on a multi-core setup in QEMU, but they are not quite
ready to submit yet.

Thank you for your patches, it's great to see better support for RISC-V 
in u-boot! I will add a few comments based on what I have learned so
far from working with u-boot on RISC-V.

> Signed-off-by: Bin Meng 
> 
> ---
> 
>  arch/riscv/Kconfig  |  4 +++
>  arch/riscv/cpu/qemu/Makefile|  6 +
>  arch/riscv/cpu/qemu/cpu.c   | 29 +
>  arch/riscv/cpu/qemu/dram.c  | 17 
>  board/emulation/qemu-riscv/Kconfig  | 21 +++
>  board/emulation/qemu-riscv/MAINTAINERS  |  7 +
>  board/emulation/qemu-riscv/Makefile |  5 
>  board/emulation/qemu-riscv/qemu-riscv.c | 23 +
>  configs/qemu-riscv32_defconfig  | 10 +++
>  configs/qemu-riscv64_defconfig  | 11 
>  doc/README.qemu-riscv   | 46
> +
>  include/configs/qemu-riscv.h| 21 +++
>  12 files changed, 200 insertions(+)
>  create mode 100644 arch/riscv/cpu/qemu/Makefile
>  create mode 100644 arch/riscv/cpu/qemu/cpu.c
>  create mode 100644 arch/riscv/cpu/qemu/dram.c
>  create mode 100644 board/emulation/qemu-riscv/Kconfig
>  create mode 100644 board/emulation/qemu-riscv/MAINTAINERS
>  create mode 100644 board/emulation/qemu-riscv/Makefile
>  create mode 100644 board/emulation/qemu-riscv/qemu-riscv.c
>  create mode 100644 configs/qemu-riscv32_defconfig
>  create mode 100644 configs/qemu-riscv64_defconfig
>  create mode 100644 doc/README.qemu-riscv
>  create mode 100644 include/configs/qemu-riscv.h
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 49f87de..168ca3d 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -11,9 +11,13 @@ choice
>  config TARGET_AX25_AE350
>   bool "Support ax25-ae350"
>  
> +config TARGET_QEMU_VIRT
> + bool "Support QEMU Virt Board"
> +
>  endchoice
>  
>  source "board/AndesTech/ax25-ae350/Kconfig"
> +source "board/emulation/qemu-riscv/Kconfig"
>  
>  choice
>   prompt "CPU selection"
> diff --git a/arch/riscv/cpu/qemu/Makefile
> b/arch/riscv/cpu/qemu/Makefile
> new file mode 100644
> index 000..258e462
> --- /dev/null
> +++ b/arch/riscv/cpu/qemu/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2018, Bin Meng 
> +
> +obj-y += dram.o
> +obj-y += cpu.o
> diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> new file mode 100644
> index 000..a064639
> --- /dev/null
> +++ b/arch/riscv/cpu/qemu/cpu.c
> @@ -0,0 +1,29 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018, Bin Meng 
> + */
> +
> +#include 
> +#include 
> +
> +/*
> + * cleanup_before_linux() is called just before we call linux
> + * it prepares the processor for linux
> + *
> + * we disable interrupt and caches.
> + */
> +int cleanup_before_linux(void)
> +{
> + disable_interrupts();
> +
> + /* turn off I/D-cache */
> +
> + return 0;
> +}
> +
> +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> argv[])
> +{
> + printf("reset unsupported yet\n");
> +
> + return 0;
> +}

We don't have a reset method on any RISC-V board yet. Instead of adding
the same 'unsupported' message for each CPU variant it might make more
sense to add a generic do_reset function for all CPU variants to lib/,
similar to the one for ARM (arch/arm/lib/reset.c).

> diff --git a/arch/riscv/cpu/qemu/dram.c b/arch/riscv/cpu/qemu/dram.c
> new file mode 100644
> index 000..84d87d2
> --- /dev/null
> +++ b/arch/riscv/cpu/qemu/dram.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018, Bin Meng 
> + */
> +
> +#include 
> +#include 
> +
> +int dram_init(void)
> +{
> + return fdtdec_setup_mem_size_base();
> +}
> +
> +int dram_init_banksize(void)
> +{
> + return fdtdec_setup_memory_banksize();
> +}
> diff --git a/board/emulation/qemu-riscv/Kconfig
> b/board/emulation/qemu-riscv/Kconfig
> new file mode 100644
> index 000..029f5efb
> --- /dev/null
> +++ 

Re: [U-Boot] [PATCH v3 4/5] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Alexander Graf


On 03.09.18 23:24, Heinrich Schuchardt wrote:
> On 09/03/2018 11:09 PM, Alexander Graf wrote:
>>
>>
>> On 03.09.18 18:35, Heinrich Schuchardt wrote:
>>> The patch implements the EFI_UNICODE_COLLATION_PROTOCOL.
>>>
>>> Signed-off-by: Heinrich Schuchardt 
>>> ---
>>> v3:
>>> no change
>>> v2:
>>> add more comments
>>> ---
>>>  MAINTAINERS|   2 +
>>>  include/cp1250.h   |  40 +++
>>>  include/cp437.h|  40 +++
>>>  include/efi_api.h  |  21 ++
>>>  include/efi_loader.h   |   5 +
>>>  lib/efi_loader/Makefile|  18 +-
>>>  lib/efi_loader/efi_boottime.c  |   6 +
>>>  lib/efi_loader/efi_unicode_collation.c | 329 +
>>>  8 files changed, 457 insertions(+), 4 deletions(-)
>>>  create mode 100644 include/cp1250.h
>>>  create mode 100644 include/cp437.h
>>>  create mode 100644 lib/efi_loader/efi_unicode_collation.c
>>>

[...]

>>> @@ -127,6 +130,8 @@ extern const efi_guid_t efi_file_info_guid;
>>>  /* GUID for file system information */
>>>  extern const efi_guid_t efi_file_system_info_guid;
>>>  extern const efi_guid_t efi_guid_device_path_utilities_protocol;
>>> +/* GUID of the Unicode collation protocol */
>>> +extern const efi_guid_t efi_guid_unicode_collation_protocol;
>>>  
>>>  extern unsigned int __efi_runtime_start, __efi_runtime_stop;
>>>  extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;
>>> diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
>>> index 1ffbf52a89..0769df20f7 100644
>>> --- a/lib/efi_loader/Makefile
>>> +++ b/lib/efi_loader/Makefile
>>> @@ -17,10 +17,20 @@ always += helloworld.efi
>>>  endif
>>>  
>>>  obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
>>> -obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o
>>> -obj-y += efi_memory.o efi_device_path_to_text.o efi_device_path.o
>>> -obj-y += efi_device_path_utilities.o efi_file.o efi_variable.o 
>>> efi_bootmgr.o
>>> -obj-y += efi_watchdog.o
>>> +obj-y += \
>>> +efi_bootmgr.o \
>>> +efi_boottime.o \
>>> +efi_console.o \
>>> +efi_device_path.o \
>>> +efi_device_path_to_text.o \
>>> +efi_device_path_utilities.o \
>>> +efi_file.o \
>>> +efi_image_loader.o \
>>> +efi_memory.o \
>>> +efi_runtime.o \
>>> +efi_unicode_collation.o \
>>> +efi_variable.o \
>>> +efi_watchdog.o
>>
>> Instead of line breaking them, just make each line an obj-y += line.
>>

[...]

>>> +const struct efi_unicode_collation_protocol efi_unicode_collation_protocol 
>>> = {
>>> +   .stri_coll = efi_stri_coll,
>>> +   .metai_match = efi_metai_match,
>>> +   .str_lwr = efi_str_lwr,
>>> +   .str_upr = efi_str_upr,
>>> +   .fat_to_str = efi_fat_to_str,
>>> +   .str_to_fat = efi_str_to_fat,
>>> +   .supported_languages = "en-US",
>>
>> I have to admit I'm slightly puzzled on the supported language field.
>> The spec says quite clearly in appendix M what to do, but everyone seems
>> to interpret the specs differently:
>>
>>   edk2 provides "en"
>>   appendix M example is "en-us"
>>   your patch provides "en-US"
>>
>> I'm not sure which one of them is correct :).
>>
> 
> The spec refers to RFC 4646. RFC 4646 refers to ISO 3166 which uses
> capital letters for the two letter region codes.
> 
> In RFC 4646 you can find the following example:
> 
> en-US (English as used in the United States)
> 
> The value from edk2 complies with RFC 4646. It simply does not specify a
> region.
> 
> So should I change the value to match edk2?

I think that would remove a potential pitfall, yes. And please change
the Makefile according to my comment above :).


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


Re: [U-Boot] [PATCH v3 4/5] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Heinrich Schuchardt
On 09/03/2018 11:09 PM, Alexander Graf wrote:
> 
> 
> On 03.09.18 18:35, Heinrich Schuchardt wrote:
>> The patch implements the EFI_UNICODE_COLLATION_PROTOCOL.
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>> v3:
>>  no change
>> v2:
>>  add more comments
>> ---
>>  MAINTAINERS|   2 +
>>  include/cp1250.h   |  40 +++
>>  include/cp437.h|  40 +++
>>  include/efi_api.h  |  21 ++
>>  include/efi_loader.h   |   5 +
>>  lib/efi_loader/Makefile|  18 +-
>>  lib/efi_loader/efi_boottime.c  |   6 +
>>  lib/efi_loader/efi_unicode_collation.c | 329 +
>>  8 files changed, 457 insertions(+), 4 deletions(-)
>>  create mode 100644 include/cp1250.h
>>  create mode 100644 include/cp437.h
>>  create mode 100644 lib/efi_loader/efi_unicode_collation.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 8c9cd83347..67b015205c 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -382,6 +382,8 @@ F:   doc/README.uefi
>>  F:  doc/README.iscsi
>>  F:  Documentation/efi.rst
>>  F:  include/capitalization.h
>> +F:  include/cp1250.h
>> +F:  include/cp437.h
>>  F:  include/efi*
>>  F:  include/pe.h
>>  F:  include/asm-generic/pe.h
>> diff --git a/include/cp1250.h b/include/cp1250.h
>> new file mode 100644
>> index 00..adacf8a958
>> --- /dev/null
>> +++ b/include/cp1250.h
>> @@ -0,0 +1,40 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +
>> +/*
>> + * Constant CP1250 contains the Unicode code points for characters 0x80 - 
>> 0xff
>> + * of the code page 1250.
>> + */
>> +#define CP1250 { \
>> +0x20ac, 0x, 0x201a, 0x, \
>> +0x201e, 0x2026, 0x2020, 0x2021, \
>> +0x, 0x2030, 0x0160, 0x2039, \
>> +0x015a, 0x0164, 0x017d, 0x0179, \
>> +0x, 0x2018, 0x2019, 0x201c, \
>> +0x201d, 0x2022, 0x2013, 0x2014, \
>> +0x, 0x2122, 0x0161, 0x203a, \
>> +0x015b, 0x0165, 0x017e, 0x017a, \
>> +0x00a0, 0x02c7, 0x02d8, 0x0141, \
>> +0x00a4, 0x0104, 0x00a6, 0x00a7, \
>> +0x00a8, 0x00a9, 0x015e, 0x00ab, \
>> +0x00ac, 0x00ad, 0x00ae, 0x017b, \
>> +0x00b0, 0x00b1, 0x02db, 0x0142, \
>> +0x00b4, 0x00b5, 0x00b6, 0x00b7, \
>> +0x00b8, 0x0105, 0x015f, 0x00bb, \
>> +0x013d, 0x02dd, 0x013e, 0x017c, \
>> +0x0154, 0x00c1, 0x00c2, 0x0102, \
>> +0x00c4, 0x0139, 0x0106, 0x00c7, \
>> +0x010c, 0x00c9, 0x0118, 0x00cb, \
>> +0x011a, 0x00cd, 0x00ce, 0x010e, \
>> +0x0110, 0x0143, 0x0147, 0x00d3, \
>> +0x00d4, 0x0150, 0x00d6, 0x00d7, \
>> +0x0158, 0x016e, 0x00da, 0x0170, \
>> +0x00dc, 0x00dd, 0x0162, 0x00df, \
>> +0x0155, 0x00e1, 0x00e2, 0x0103, \
>> +0x00e4, 0x013a, 0x0107, 0x00e7, \
>> +0x010d, 0x00e9, 0x0119, 0x00eb, \
>> +0x011b, 0x00ed, 0x00ee, 0x010f, \
>> +0x0111, 0x0144, 0x0148, 0x00f3, \
>> +0x00f4, 0x0151, 0x00f6, 0x00f7, \
>> +0x0159, 0x016f, 0x00fa, 0x0171, \
>> +0x00fc, 0x00fd, 0x0163, 0x02d9, \
>> +}
>> diff --git a/include/cp437.h b/include/cp437.h
>> new file mode 100644
>> index 00..0b2b97132e
>> --- /dev/null
>> +++ b/include/cp437.h
>> @@ -0,0 +1,40 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +
>> +/*
>> + * Constant CP437 contains the Unicode code points for characters 0x80 - 
>> 0xff
>> + * of the code page 437.
>> + */
>> +#define CP437 { \
>> +0x00c7, 0x00fc, 0x00e9, 0x00e2, \
>> +0x00e4, 0x00e0, 0x00e5, 0x00e7, \
>> +0x00ea, 0x00eb, 0x00e8, 0x00ef, \
>> +0x00ee, 0x00ec, 0x00c4, 0x00c5, \
>> +0x00c9, 0x00e6, 0x00c6, 0x00f4, \
>> +0x00f6, 0x00f2, 0x00fb, 0x00f9, \
>> +0x00ff, 0x00d6, 0x00dc, 0x00a2, \
>> +0x00a3, 0x00a5, 0x20a7, 0x0192, \
>> +0x00e1, 0x00ed, 0x00f3, 0x00fa, \
>> +0x00f1, 0x00d1, 0x00aa, 0x00ba, \
>> +0x00bf, 0x2310, 0x00ac, 0x00bd, \
>> +0x00bc, 0x00a1, 0x00ab, 0x00bb, \
>> +0x2591, 0x2592, 0x2593, 0x2502, \
>> +0x2524, 0x2561, 0x2562, 0x2556, \
>> +0x2555, 0x2563, 0x2551, 0x2557, \
>> +0x255d, 0x255c, 0x255b, 0x2510, \
>> +0x2514, 0x2534, 0x252c, 0x251c, \
>> +0x2500, 0x253c, 0x255e, 0x255f, \
>> +0x255a, 0x2554, 0x2569, 0x2566, \
>> +0x2560, 0x2550, 0x256c, 0x2567, \
>> +0x2568, 0x2564, 0x2565, 0x2559, \
>> +0x2558, 0x2552, 0x2553, 0x256b, \
>> +0x256a, 0x2518, 0x250c, 0x2588, \
>> +0x2584, 0x258c, 0x2590, 0x2580, \
>> +0x03b1, 0x00df, 0x0393, 0x03c0, \
>> +0x03a3, 0x03c3, 0x00b5, 0x03c4, \
>> +0x03a6, 0x0398, 0x03a9, 0x03b4, \
>> +0x221e, 0x03c6, 0x03b5, 0x2229, \
>> +0x2261, 0x00b1, 0x2265, 0x2264, \
>> +0x2320, 0x2321, 0x00f7, 0x2248, \
>> +0x00b0, 0x2219, 0x00b7, 0x221a, \
>> +0x207f, 0x00b2, 0x25a0, 0x00a0, \
>> +}
>> diff --git a/include/efi_api.h b/include/efi_api.h
>> index ebf2a3bc18..1efc448184 100644
>> --- a/include/efi_api.h
>> +++ b/include/efi_api.h
>> @@ -31,6 +31,7 @@ enum efi_timer_delay {
>>  EFI_TIMER_RELATIVE = 2
>>  };
>>  
>> +#define efi_intn_t 

Re: [U-Boot] [PATCH v3 4/5] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Alexander Graf


On 03.09.18 18:35, Heinrich Schuchardt wrote:
> The patch implements the EFI_UNICODE_COLLATION_PROTOCOL.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
> v3:
>   no change
> v2:
>   add more comments
> ---
>  MAINTAINERS|   2 +
>  include/cp1250.h   |  40 +++
>  include/cp437.h|  40 +++
>  include/efi_api.h  |  21 ++
>  include/efi_loader.h   |   5 +
>  lib/efi_loader/Makefile|  18 +-
>  lib/efi_loader/efi_boottime.c  |   6 +
>  lib/efi_loader/efi_unicode_collation.c | 329 +
>  8 files changed, 457 insertions(+), 4 deletions(-)
>  create mode 100644 include/cp1250.h
>  create mode 100644 include/cp437.h
>  create mode 100644 lib/efi_loader/efi_unicode_collation.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8c9cd83347..67b015205c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -382,6 +382,8 @@ F:doc/README.uefi
>  F:   doc/README.iscsi
>  F:   Documentation/efi.rst
>  F:   include/capitalization.h
> +F:   include/cp1250.h
> +F:   include/cp437.h
>  F:   include/efi*
>  F:   include/pe.h
>  F:   include/asm-generic/pe.h
> diff --git a/include/cp1250.h b/include/cp1250.h
> new file mode 100644
> index 00..adacf8a958
> --- /dev/null
> +++ b/include/cp1250.h
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +/*
> + * Constant CP1250 contains the Unicode code points for characters 0x80 - 
> 0xff
> + * of the code page 1250.
> + */
> +#define CP1250 { \
> + 0x20ac, 0x, 0x201a, 0x, \
> + 0x201e, 0x2026, 0x2020, 0x2021, \
> + 0x, 0x2030, 0x0160, 0x2039, \
> + 0x015a, 0x0164, 0x017d, 0x0179, \
> + 0x, 0x2018, 0x2019, 0x201c, \
> + 0x201d, 0x2022, 0x2013, 0x2014, \
> + 0x, 0x2122, 0x0161, 0x203a, \
> + 0x015b, 0x0165, 0x017e, 0x017a, \
> + 0x00a0, 0x02c7, 0x02d8, 0x0141, \
> + 0x00a4, 0x0104, 0x00a6, 0x00a7, \
> + 0x00a8, 0x00a9, 0x015e, 0x00ab, \
> + 0x00ac, 0x00ad, 0x00ae, 0x017b, \
> + 0x00b0, 0x00b1, 0x02db, 0x0142, \
> + 0x00b4, 0x00b5, 0x00b6, 0x00b7, \
> + 0x00b8, 0x0105, 0x015f, 0x00bb, \
> + 0x013d, 0x02dd, 0x013e, 0x017c, \
> + 0x0154, 0x00c1, 0x00c2, 0x0102, \
> + 0x00c4, 0x0139, 0x0106, 0x00c7, \
> + 0x010c, 0x00c9, 0x0118, 0x00cb, \
> + 0x011a, 0x00cd, 0x00ce, 0x010e, \
> + 0x0110, 0x0143, 0x0147, 0x00d3, \
> + 0x00d4, 0x0150, 0x00d6, 0x00d7, \
> + 0x0158, 0x016e, 0x00da, 0x0170, \
> + 0x00dc, 0x00dd, 0x0162, 0x00df, \
> + 0x0155, 0x00e1, 0x00e2, 0x0103, \
> + 0x00e4, 0x013a, 0x0107, 0x00e7, \
> + 0x010d, 0x00e9, 0x0119, 0x00eb, \
> + 0x011b, 0x00ed, 0x00ee, 0x010f, \
> + 0x0111, 0x0144, 0x0148, 0x00f3, \
> + 0x00f4, 0x0151, 0x00f6, 0x00f7, \
> + 0x0159, 0x016f, 0x00fa, 0x0171, \
> + 0x00fc, 0x00fd, 0x0163, 0x02d9, \
> +}
> diff --git a/include/cp437.h b/include/cp437.h
> new file mode 100644
> index 00..0b2b97132e
> --- /dev/null
> +++ b/include/cp437.h
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +/*
> + * Constant CP437 contains the Unicode code points for characters 0x80 - 0xff
> + * of the code page 437.
> + */
> +#define CP437 { \
> + 0x00c7, 0x00fc, 0x00e9, 0x00e2, \
> + 0x00e4, 0x00e0, 0x00e5, 0x00e7, \
> + 0x00ea, 0x00eb, 0x00e8, 0x00ef, \
> + 0x00ee, 0x00ec, 0x00c4, 0x00c5, \
> + 0x00c9, 0x00e6, 0x00c6, 0x00f4, \
> + 0x00f6, 0x00f2, 0x00fb, 0x00f9, \
> + 0x00ff, 0x00d6, 0x00dc, 0x00a2, \
> + 0x00a3, 0x00a5, 0x20a7, 0x0192, \
> + 0x00e1, 0x00ed, 0x00f3, 0x00fa, \
> + 0x00f1, 0x00d1, 0x00aa, 0x00ba, \
> + 0x00bf, 0x2310, 0x00ac, 0x00bd, \
> + 0x00bc, 0x00a1, 0x00ab, 0x00bb, \
> + 0x2591, 0x2592, 0x2593, 0x2502, \
> + 0x2524, 0x2561, 0x2562, 0x2556, \
> + 0x2555, 0x2563, 0x2551, 0x2557, \
> + 0x255d, 0x255c, 0x255b, 0x2510, \
> + 0x2514, 0x2534, 0x252c, 0x251c, \
> + 0x2500, 0x253c, 0x255e, 0x255f, \
> + 0x255a, 0x2554, 0x2569, 0x2566, \
> + 0x2560, 0x2550, 0x256c, 0x2567, \
> + 0x2568, 0x2564, 0x2565, 0x2559, \
> + 0x2558, 0x2552, 0x2553, 0x256b, \
> + 0x256a, 0x2518, 0x250c, 0x2588, \
> + 0x2584, 0x258c, 0x2590, 0x2580, \
> + 0x03b1, 0x00df, 0x0393, 0x03c0, \
> + 0x03a3, 0x03c3, 0x00b5, 0x03c4, \
> + 0x03a6, 0x0398, 0x03a9, 0x03b4, \
> + 0x221e, 0x03c6, 0x03b5, 0x2229, \
> + 0x2261, 0x00b1, 0x2265, 0x2264, \
> + 0x2320, 0x2321, 0x00f7, 0x2248, \
> + 0x00b0, 0x2219, 0x00b7, 0x221a, \
> + 0x207f, 0x00b2, 0x25a0, 0x00a0, \
> +}
> diff --git a/include/efi_api.h b/include/efi_api.h
> index ebf2a3bc18..1efc448184 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -31,6 +31,7 @@ enum efi_timer_delay {
>   EFI_TIMER_RELATIVE = 2
>  };
>  
> +#define efi_intn_t ssize_t
>  #define efi_uintn_t size_t
>  typedef uint16_t *efi_string_t;
>  
> @@ -958,4 +959,24 @@ struct 

Re: [U-Boot] [PATCH v3 1/5] efi_loader: capitalization table

2018-09-03 Thread Alexander Graf


On 03.09.18 18:35, Heinrich Schuchardt wrote:
> This patch provides a define to initialize a table that maps lower to
> capital letters for Unicode code point 0x - 0x.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
> v3:
>   remove codes < 0x80 from tables for code pages 437 and 1250
>   sort tables for code pages 437 and 1250
> v2:
>   add shorter tables for code pages 437 and 1250
> ---
>  MAINTAINERS  |1 +
>  include/capitalization.h | 1978 ++
>  2 files changed, 1979 insertions(+)
>  create mode 100644 include/capitalization.h
> 


[...]

> +/*
> + * Correspondence table for small and capital letters of codepage 437.
> + * Letters A-Z are handled in code.
> + */
> +#define CP437_CAPITALIZATION_TABLE { \
> + { 0x00c4, 0x00e4, }, \

Please keep the comments that indicate which character these are. Makes
the list much more appealing :) and more obvious.


Alex

> + { 0x00c5, 0x00e5, }, \
> + { 0x00c6, 0x00e6, }, \
> + { 0x00c7, 0x00e7, }, \
> + { 0x00c9, 0x00e9, }, \
> + { 0x00d1, 0x00f1, }, \
> + { 0x00d6, 0x00f6, }, \
> + { 0x00dc, 0x00fc, }, \
> + { 0x03a3, 0x03c3, }, \
> + { 0x03a6, 0x03c6, }, \
> + { 0x, 0x, }, \
> +}
> +
> +/*
> + * Correspondence table for small and capital letters of codepage 1250.
> + * Letters A-Z are handled in code.
> + */
> +#define CP1250_CAPITALIZATION_TABLE { \
> + { 0x00c1, 0x00e1, }, \
> + { 0x00c2, 0x00e2, }, \
> + { 0x00c4, 0x00e4, }, \
> + { 0x00c7, 0x00e7, }, \
> + { 0x00c9, 0x00e9, }, \
> + { 0x00cb, 0x00eb, }, \
> + { 0x00cd, 0x00ed, }, \
> + { 0x00ce, 0x00ee, }, \
> + { 0x00d3, 0x00f3, }, \
> + { 0x00d4, 0x00f4, }, \
> + { 0x00d6, 0x00f6, }, \
> + { 0x00da, 0x00fa, }, \
> + { 0x00dc, 0x00fc, }, \
> + { 0x00dd, 0x00fd, }, \
> + { 0x0102, 0x0103, }, \
> + { 0x0104, 0x0105, }, \
> + { 0x0106, 0x0107, }, \
> + { 0x010c, 0x010d, }, \
> + { 0x010e, 0x010f, }, \
> + { 0x0110, 0x0111, }, \
> + { 0x0118, 0x0119, }, \
> + { 0x011a, 0x011b, }, \
> + { 0x0139, 0x013a, }, \
> + { 0x013d, 0x013e, }, \
> + { 0x0141, 0x0142, }, \
> + { 0x0143, 0x0144, }, \
> + { 0x0147, 0x0148, }, \
> + { 0x0150, 0x0151, }, \
> + { 0x0154, 0x0155, }, \
> + { 0x0158, 0x0159, }, \
> + { 0x015a, 0x015b, }, \
> + { 0x015e, 0x015f, }, \
> + { 0x0160, 0x0161, }, \
> + { 0x0162, 0x0163, }, \
> + { 0x0164, 0x0165, }, \
> + { 0x016e, 0x016f, }, \
> + { 0x0170, 0x0171, }, \
> + { 0x0179, 0x017a, }, \
> + { 0x017b, 0x017c, }, \
> + { 0x017d, 0x017e, }, \
> + { 0x, 0x, }, \
> +}
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [ANN] U-Boot v2018.09-rc3 released

2018-09-03 Thread Tom Rini
Hey all,

Some of you may have noticed I didn't do a release last week.  Slipped
my mind until about Wednesday/Thursday and I figured it would make more
sense to just wait until today as I had promised a release today.  My
fault, got out of the habit of setting a calendar reminder.  You may
also have noticed some back-end git hiccups, and that's still being
looked into, but right this moment the main git is out of sync.  The
good news is that the mirror on github is not nor are the FTP archives.

I've done my best to keep to the usual plan of only taking in fixes and
Kconfig change and similar, so things are on track for a release next
Monday.  Thanks all!

-- 
Tom


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


Re: [U-Boot] [PATCH] travis: Use kernel.org pre-built toolchain for riscv

2018-09-03 Thread Tom Rini
On Mon, Sep 03, 2018 at 05:50:39PM +0800, Bin Meng wrote:
> Hi Tom,
> 
> On Thu, Aug 30, 2018 at 9:12 PM Bin Meng  wrote:
> >
> > This updates travis configuration to use kernel.org pre-built
> > toolchain for riscv.
> >
> > Signed-off-by: Bin Meng 
> > ---
> >
> >  .travis.yml | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> 
> Since this is travis-ci changes, can we take this for v2018.09? I've
> verified that it works well for current riscv build on travis-ci.org.

Seeing as things are still working before this change I would like to
see an ack from the custodian, 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] ARM: omap3_logic: Enable DM_PMIC and DM_REGULATOR

2018-09-03 Thread Adam Ford
Enabling DM_PMIC, DM_REGULATOR_FIXED, and DM_REGULATOR_GPIO
gives us the ability to better monitor voltages and enable
hardware through the device tree. The TL4030 (TPS65950) is
not yet migrated to DM, so this patch only enables the fixed
and GPIO controlled regulators.

Signed-off-by: Adam Ford 

diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig
index cea4e5521d..9b50a300a0 100644
--- a/configs/omap3_logic_defconfig
+++ b/configs/omap3_logic_defconfig
@@ -50,6 +50,11 @@ CONFIG_SMC911X_BASE=0x0800
 CONFIG_SMC911X_32_BIT=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_PMIC_CHILDREN is not set
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
-- 
2.17.1

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


[U-Boot] [PATCH 1/1] efi_loader: description efi_update_capsule()

2018-09-03 Thread Heinrich Schuchardt
Correct the description of efi_update_capsule().

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

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 2b4f399e9a..c5fbd91fa3 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -608,7 +608,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
  *
  * @capsule_header_array:  pointer to array of virtual pointers
  * @capsule_count: number of pointers in capsule_header_array
- * @capsule_size:  maximum capsule size
+ * @maximum_capsule_size:  maximum capsule size
  * @reset_type:type of reset needed for capsule update
  * Returns:status code
  */
-- 
2.18.0

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


[U-Boot] [PATCH] ARM: omap3_logic: Enable Pinctrl

2018-09-03 Thread Adam Ford
The simple pinctrl driver currently available works with the omap3.
Enabling this will use the device tree to automatically set the
pin-muxing for various drivers.

Signed-off-by: Adam Ford 

diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig
index c6acfab602..cea4e5521d 100644
--- a/configs/omap3_logic_defconfig
+++ b/configs/omap3_logic_defconfig
@@ -48,6 +48,8 @@ CONFIG_SPL_NAND_SIMPLE=y
 CONFIG_SMC911X=y
 CONFIG_SMC911X_BASE=0x0800
 CONFIG_SMC911X_32_BIT=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_SINGLE=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
-- 
2.17.1

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


[U-Boot] [PATCH 1/1] docs: kernel-doc: fix parsing of function pointers

2018-09-03 Thread Heinrich Schuchardt
kernel-doc fails to parse function definitions like the one below

efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
  void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
  void *notify_context, efi_guid_t *group,
  struct efi_event **event)
{

due to the "EFIAPI" attribute preceding the function name.

Signed-off-by: Heinrich Schuchardt 
---
I am submitted the same patch to the Kernel upstream:
https://lkml.org/lkml/2018/9/3/1185
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 31a34ced55a3..597e3223b791 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1381,7 +1381,7 @@ sub create_parameterlist() {
} elsif ($arg =~ m/\(.+\)\s*\(/) {
# pointer-to-function
$arg =~ tr/#/,/;
-   $arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/;
+   $arg =~ m/[^\(]+\([\w\s]*\*?\s*([\w\.]*)\s*\)/;
$param = $1;
$type = $arg;
$type =~ s/([^\(]+\(\*?)\s*$param/$1/;
-- 
2.18.0

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


Re: [U-Boot] [PATCH 0/4] Add a pinctrl driver for Merrifield to pinmux I2C#6

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 9:26 PM Andy Shevchenko
 wrote:

> Thanks for doing this!
>
> I'll review patches individually.
> By some reason Gmail doesn't show me Simon's and Bin's emails in the
> message. Are they delivered?

I reviewed, looks pretty much good, except few small comments in patch 2.

So, your next steps would be:
- wait for Bin and / or Simon reacting on this to see if we have
everything good with mail transport (might be just some Gmail
craziness)
- address my comments
- wait a bit (one day or so) to give time for others to look at
- address (meanwhile) comments from me and others if any
- send a new (v2) version of the series (don't forget to incorporate
tags I gave into your commit message)


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


Re: [U-Boot] [PATCH 2/4] x86: tangier: pinmux: add API to configure protected pins

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 7:39 PM Georgii Staroselskii
 wrote:
>
> This API is going to be used to configure some pins that are protected
> for simple modification.
>
> It's not a comprehensive pinctrl driver but can be turned into one
> when we need this in the future. Now it is planned to be used only
> in one place. So that's why I decided not to polute the codebase with a

polute -> pollute

> full-blown pinctrl-merrifield nobody will use.
>
> This driver reads corresponding fields in DT and configures pins
> accordingly.
>
> The "protected" flag is used to distinguish configuration of SCU-owned
> pins from the ordinary ones.
>
> The code has been adapted from Linux work done by Andy Shevchenko
> in pinctrl-merrfifield.c


> +static struct mrfld_family mrfld_families[] = {
> +   MRFLD_FAMILY(7, 101, 114),
> +};

This perhaps needs a comment that for now we are only serve I2C Family of pins.

> +static const struct mrfld_family *
> +mrfld_get_family(struct mrfld_pinctrl *mp, unsigned int pin)
> +{
> +   const struct mrfld_family *family;
> +   unsigned int i;
> +
> +   for (i = 0; i < mp->nfamilies; i++) {
> +   family = >families[i];

> +   if (pin >= family->pin_base &&
> +   pin < family->pin_base + family->npins)

Can it be one line?

> +   return family;
> +   }


> +   printf("failed to find family for pin %u\n", pin);

I think it should be an error message (I don't remember which function
is good for that, pr_err() maybe?).

> +   return NULL;
> +}


> +   return ret;
> +}

Missed blank line here.

> +static int mrfld_pinctrl_cfg_pin(int pin_node)
> +{

> +   is_protected = fdtdec_get_bool(gd->fdt_blob, pin_node, "protected");
> +   if (!is_protected)
> +   return -ENOTSUPP;

Similar comment perhaps needed, that it's for now we support just
protected Family of pins, i.e. I2C one.

> +   if (mode != 1)
> +   return -ENOTSUPP;

I don't think we need to limit to mode 1. Rather to check for mask (if
mode is in a range 0..7).

> +   u32 mask = MRFLD_PINMODE_MASK;

I'm not sure mixing definitions with code is a good idea.

> +   ret = mrfld_pinconfig_protected(pad_offset, mask, mode);
> +
> +   return ret;
> +}
> +
> +static int tangier_pinctrl_probe(struct udevice *dev)
> +{
> +   void *base_addr = syscon_get_first_range(X86_SYSCON_PINCONF);
> +   struct mrfld_pinctrl *pinctrl = dev_get_priv(dev);
> +   int pin_node;
> +   int ret;
> +
> +   mrfld_setup_families(base_addr, mrfld_families,
> +ARRAY_SIZE(mrfld_families));
> +
> +   pinctrl->families = mrfld_families;
> +   pinctrl->nfamilies = ARRAY_SIZE(mrfld_families);
> +
> +   for (pin_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
> +pin_node > 0;
> +pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) {
> +   ret = mrfld_pinctrl_cfg_pin(pin_node);

> +   if (ret != 0) {

Simple if (ret) should work.

> +   pr_err("%s: invalid configuration for the pin %d\n",
> + __func__, pin_node);
> +   }
> +   }
> +
> +   return 0;
> +}
> +

> +static const struct udevice_id tangier_pinctrl_match[] = {
> +   { .compatible = "intel,pinctrl-tangier", .data = X86_SYSCON_PINCONF },
> +   { /* sentinel */ }
> +};

Side note: I don't know for sure naming standards for compatible
strings, I guess this one is correct.

> +U_BOOT_DRIVER(tangier_pinctrl) = {
> +   .name = "tangier_pinctrl",
> +   .id = UCLASS_SYSCON,
> +   .of_match = tangier_pinctrl_match,
> +   .probe = tangier_pinctrl_probe,
> +   .priv_auto_alloc_size = sizeof(struct mrfld_pinctrl),
> +};

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


Re: [U-Boot] [PATCH 0/4] Add a pinctrl driver for Merrifield to pinmux I2C#6

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 7:41 PM Georgii Staroselskii
 wrote:
>
> We have lacked the support for any pinmuxing in U-Boot for Merrifield.
> A need for pinmuxing some pins has arisen from the fact the I2C#6 is shared
> with I2C#8 on Merrifield. The latter is not easily accessible because it's
> a part of a separate MCU we don't have easy access to.
>
> I2C#6 can be and should be made use of in Linux but couldn't because it
> was blocked by the SCU.
>
> The proposed change is to implement a minimalistic pinctrl driver that
> reads the configuration off a device tree blob and configures the pins
> accordingly.
>
> The driver needs some changes to SCU API and thus the addition of
> scu_ipc_raw_command().
>
> Andy Shevchenko has been helping me by making a prior review and made
> a lot of suggestions about the general approach that should be taken.
>
> He should also be given credit for the initial kernel code that I have
> taken as a reference.
>
> The code has been tested on 5 different Edisons on Intel Edison Breakout
> board and a couple of custom Emlid PCBs by booting a kernel and issuing
> a i2cdetect -r -y 6 and then loading a driver that made use of the bus.
>
> I also created a Gist on Github with a lot of relevant information like
>
> - output of `acpidump -o tables.dat`
> - dmesg
> - output of `grep -H 15 /sys/bus/acpi/devices/*/status`
> - cat /sys/kernel/debug/gpio
> - cat /sys/kernel/debug/pinctrl/INTC1002\:00/pins
> - output of `i2cdetect -y -r 6` w/ and w/o external device on the bus
>
> Here it is:
> https://gist.github.com/staroselskii/097808e05fd609dbafd4fe5ebd618708
>

Thanks for doing this!

I'll review patches individually.
By some reason Gmail doesn't show me Simon's and Bin's emails in the
message. Are they delivered?

> Georgii Staroselskii (4):
>   x86: cpu: introduce scu_ipc_raw_command()
>   x86: tangier: pinmux: add API to configure protected pins
>   x86: dts: edison: configure I2C#6 pins
>   x86: tangier: acpi: add I2C6 node
>
>  arch/x86/cpu/tangier/Makefile  |   2 +-
>  arch/x86/cpu/tangier/pinmux.c  | 188 
> +
>  arch/x86/dts/edison.dts|  22 +++
>  .../include/asm/arch-tangier/acpi/southcluster.asl |  10 ++
>  arch/x86/include/asm/scu.h |   4 +
>  arch/x86/lib/scu.c |  35 
>  6 files changed, 260 insertions(+), 1 deletion(-)
>  create mode 100644 arch/x86/cpu/tangier/pinmux.c
>
> --
> 2.7.4
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot



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


Re: [U-Boot] [PATCH 4/4] x86: tangier: acpi: add I2C6 node

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 7:38 PM Georgii Staroselskii
 wrote:
>
> Now that we have I2C#6 working, it's time to add a corresponsing
> ACPI binding.
>

Reviewed-by: Andy Shevchenko 


> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/include/asm/arch-tangier/acpi/southcluster.asl | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl 
> b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
> index b200e9f..7cdc4b2 100644
> --- a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
> +++ b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
> @@ -231,6 +231,16 @@ Device (PCI0)
>  }
>  }
>
> +Device (I2C6)
> +{
> +Name (_ADR, 0x00090001)
> +
> +Method (_STA, 0, NotSerialized)
> +{
> +Return (STA_VISIBLE)
> +}
> +}
> +
>  Device (GPIO)
>  {
>  Name (_ADR, 0x000c)
> --
> 2.7.4
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot



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


Re: [U-Boot] [PATCH 3/4] x86: dts: edison: configure I2C#6 pins

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 7:41 PM Georgii Staroselskii
 wrote:
>
> Now that we have the pinctrl driver for Merrifield in place we can make
> use of it and set I2C#6 pins appropriately.
>
> Initial configuration came from the firmware.  Which quite likely has
> been used in the phones, where that is not part of Atom peripheral, is
> in use. Thus we need to override the leftover.
>

Reviewed-by: Andy Shevchenko 


> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/dts/edison.dts | 22 ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
> index 1da7f54..0dd7240 100644
> --- a/arch/x86/dts/edison.dts
> +++ b/arch/x86/dts/edison.dts
> @@ -85,4 +85,26 @@
> compatible = "intel,reset-tangier";
> u-boot,dm-pre-reloc;
> };
> +
> +   pinctrl {
> +   compatible = "intel,pinctrl-tangier";
> +   reg = <0xff0c 0x8000>;
> +
> +   /*
> +* Initial configuration came from the firmware.
> +* Which quite likely has been used in the phones, where I2C 
> #8,
> +* that is not part of Atom peripheral, is in use.
> +* Thus we need to override the leftover.
> +*/
> +   i2c6_scl@0 {
> +   pad-offset = <111>;
> +   mode-func = <1>;
> +   protected;
> +   };
> +   i2c6_sda@0 {
> +   pad-offset = <112>;
> +   mode-func = <1>;
> +   protected;
> +   };
> +   };
>  };
> --
> 2.7.4
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot



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


Re: [U-Boot] [PATCH 1/4] x86: cpu: introduce scu_ipc_raw_command()

2018-09-03 Thread Andy Shevchenko
On Mon, Sep 3, 2018 at 7:40 PM Georgii Staroselskii
 wrote:
>
> This interface will be used to configure properly some pins on
> Merrifield that are shared with SCU.
>
> scu_ipc_raw_command() writes SPTR and DPTR registers before sending
> a command to SCU.
>
> This code has been ported from Linux work done by Andy Shevchenko.
>

Reviewed-by: Andy Shevchenko 

> Signed-off-by: Georgii Staroselskii 
> ---
>  arch/x86/include/asm/scu.h |  4 
>  arch/x86/lib/scu.c | 35 +++
>  2 files changed, 39 insertions(+)
>
> diff --git a/arch/x86/include/asm/scu.h b/arch/x86/include/asm/scu.h
> index 7ce5824..f5ec5a1 100644
> --- a/arch/x86/include/asm/scu.h
> +++ b/arch/x86/include/asm/scu.h
> @@ -6,6 +6,8 @@
>  #define _X86_ASM_SCU_IPC_H_
>
>  /* IPC defines the following message types */
> +#define IPCMSG_INDIRECT_READ   0x02
> +#define IPCMSG_INDIRECT_WRITE  0x05
>  #define IPCMSG_WARM_RESET  0xf0
>  #define IPCMSG_COLD_RESET  0xf1
>  #define IPCMSG_SOFT_RESET  0xf2
> @@ -23,5 +25,7 @@ struct ipc_ifwi_version {
>  /* Issue commands to the SCU with or without data */
>  int scu_ipc_simple_command(u32 cmd, u32 sub);
>  int scu_ipc_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out, int 
> outlen);
> +int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
> +   int outlen, u32 dptr, u32 sptr);
>
>  #endif /* _X86_ASM_SCU_IPC_H_ */
> diff --git a/arch/x86/lib/scu.c b/arch/x86/lib/scu.c
> index caa04c6..847bb77 100644
> --- a/arch/x86/lib/scu.c
> +++ b/arch/x86/lib/scu.c
> @@ -101,6 +101,41 @@ static int scu_ipc_cmd(struct ipc_regs *regs, u32 cmd, 
> u32 sub,
> return err;
>  }
>
> +int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
> +   int outlen, u32 dptr, u32 sptr)
> +{
> +   int inbuflen = DIV_ROUND_UP(inlen, 4);
> +   struct udevice *dev;
> +   struct scu *scu;
> +   int ret;
> +
> +   ret = syscon_get_by_driver_data(X86_SYSCON_SCU, );
> +   if (ret)
> +   return ret;
> +
> +   scu = dev_get_priv(dev);
> +
> +   /* Up to 16 bytes */
> +   if (inbuflen > 4)
> +   return -EINVAL;
> +
> +   writel(dptr, >regs->dptr);
> +   writel(sptr, >regs->sptr);
> +
> +   /*
> +* SRAM controller doesn't support 8-bit writes, it only
> +* supports 32-bit writes, so we have to copy input data into
> +* the temporary buffer, and SCU FW will use the inlen to
> +* determine the actual input data length in the temporary
> +* buffer.
> +*/
> +
> +   u32 inbuf[4] = {0};
> +
> +   memcpy(inbuf, in, inlen);
> +
> +   return scu_ipc_cmd(scu->regs, cmd, sub, inbuf, inlen, out, outlen);
> +}
>  /**
>   * scu_ipc_simple_command() - send a simple command
>   * @cmd: command
> --
> 2.7.4
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot



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


[U-Boot] [PATCH 3/3] configs: omapl138_lcdk: Enable DM_SPI, DM_SPI_FLASH

2018-09-03 Thread Jagan Teki
Enable DM_SPI and DM_SPI_FLASH for omapl138_lcdk board.

Cc: Peter Howard 
Signed-off-by: Jagan Teki 
---
Note:
This would need spi DT node.

 configs/omapl138_lcdk_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index e8c6cf03bc..de92a1af87 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -43,6 +43,7 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
 CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0x28000
 CONFIG_SPL_NAND_SIMPLE=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
@@ -51,4 +52,5 @@ CONFIG_DRIVER_TI_EMAC=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
+CONFIG_DM_SPI=y
 CONFIG_DAVINCI_SPI=y
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 2/3] board: da8xxevm: Add SPL DM for serial, spi

2018-09-03 Thread Jagan Teki
This patch add SPL DM support for da8xxevm boards
with SPL serial, SPI drivers supported via platdata.

Cc: Adam Ford 
Signed-off-by: Jagan Teki 
---
 board/davinci/da8xxevm/da850evm.c | 27 +++
 configs/da850_am18xxevm_defconfig |  3 +++
 configs/da850evm_defconfig|  3 +++
 include/configs/da850evm.h|  3 ---
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/board/davinci/da8xxevm/da850evm.c 
b/board/davinci/da8xxevm/da850evm.c
index 5583b45792..4cecb53124 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -49,6 +49,33 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define CFG_MAC_ADDR_OFFSET(flash->size - SZ_64K)
 
+#ifdef CONFIG_SPL_BUILD
+#include 
+#include 
+
+static const struct ns16550_platdata da850evm_serial = {
+   .base = DAVINCI_UART2_BASE,
+   .reg_shift = 2,
+   .clock = 15000,
+   .fcr = UART_FCR_DEFVAL,
+};
+
+U_BOOT_DEVICE(da850evm_uart) = {
+   .name = "ns16550_serial",
+   .platdata = _serial,
+};
+
+static const struct davinci_spi_platdata davinci_spi_data = {
+.regs = (struct davinci_spi_regs *)0x01f0e000,
+.num_cs = 4,
+};
+
+U_BOOT_DEVICE(davinci_spi) = {
+.name = "davinci_spi",
+.platdata = _spi_data,
+};
+#endif
+
 #ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 static int get_mac_addr(u8 *addr)
 {
diff --git a/configs/da850_am18xxevm_defconfig 
b/configs/da850_am18xxevm_defconfig
index c61d78e2fe..07bfcc15f5 100644
--- a/configs/da850_am18xxevm_defconfig
+++ b/configs/da850_am18xxevm_defconfig
@@ -8,6 +8,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
+CONFIG_SPL_DM=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="da850-evm"
@@ -35,6 +36,8 @@ CONFIG_CRC32_VERIFY=y
 # CONFIG_CMD_FS_GENERIC is not set
 CONFIG_CMD_DIAG=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_OF_PLATDATA=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_DM=y
 CONFIG_DA8XX_GPIO=y
diff --git a/configs/da850evm_defconfig b/configs/da850evm_defconfig
index 0b8bf2ad36..053173f2b1 100644
--- a/configs/da850evm_defconfig
+++ b/configs/da850evm_defconfig
@@ -7,6 +7,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
+CONFIG_SPL_DM=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="da850-evm"
@@ -37,6 +38,8 @@ CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:512k(u-boot.ais),64k(u-boot-env),7552k(kernel-spare),64k(MAC-Address)"
 CONFIG_CMD_DIAG=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_OF_PLATDATA=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_DM=y
 CONFIG_DM_GPIO=y
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h
index 7e52fea2a1..ebdadb44a8 100644
--- a/include/configs/da850evm.h
+++ b/include/configs/da850evm.h
@@ -23,8 +23,6 @@
 * DM support in SPL
 */
 #ifdef CONFIG_SPL_BUILD
-#undef CONFIG_DM_SPI
-#undef CONFIG_DM_SPI_FLASH
 #undef CONFIG_DM_I2C
 #undef CONFIG_DM_I2C_COMPAT
 #endif
@@ -117,7 +115,6 @@
 
 #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_DIRECT_NOR_BOOT)
 #define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE-4  /* NS16550 register size */
 #define CONFIG_SYS_NS16550_COM1DAVINCI_UART2_BASE /* Base address of 
UART2 */
 #endif
 #define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID)
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 1/3] spi: davinci: Add platdata support

2018-09-03 Thread Jagan Teki
Davanci spi driver has DM support already, this patch
add support for platdata so-that SPL can use it for
low foot-print.

Signed-off-by: Jagan Teki 
---
 drivers/spi/davinci_spi.c  | 47 +++---
 include/dm/platform_data/spi_davinci.h | 15 
 2 files changed, 43 insertions(+), 19 deletions(-)
 create mode 100644 include/dm/platform_data/spi_davinci.h

diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index a822858323..07fa5e3b8a 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* SPIGCR0 */
 #define SPIGCR0_SPIENA_MASK0x1
@@ -529,50 +530,58 @@ static int davinci_spi_xfer(struct udevice *dev, unsigned 
int bitlen,
return __davinci_spi_xfer(ds, bitlen, dout, din, flags);
 }
 
+static const struct dm_spi_ops davinci_spi_ops = {
+   .claim_bus  = davinci_spi_claim_bus,
+   .release_bus= davinci_spi_release_bus,
+   .xfer   = davinci_spi_xfer,
+   .set_speed  = davinci_spi_set_speed,
+   .set_mode   = davinci_spi_set_mode,
+};
+
 static int davinci_spi_probe(struct udevice *bus)
 {
-   /* Nothing to do */
+   struct davinci_spi_slave *ds = dev_get_priv(bus);
+   struct davinci_spi_platdata *plat = bus->platdata;
+   ds->regs = plat->regs;
+   ds->num_cs = plat->num_cs;
+
return 0;
 }
 
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int davinci_ofdata_to_platadata(struct udevice *bus)
 {
-   struct davinci_spi_slave *ds = dev_get_priv(bus);
-   const void *blob = gd->fdt_blob;
-   int node = dev_of_offset(bus);
+   struct davinci_spi_platdata *plat = bus->platdata;
+   fdt_addr_t addr;
 
-   ds->regs = devfdt_map_physmem(bus, sizeof(struct davinci_spi_regs));
-   if (!ds->regs) {
-   printf("%s: could not map device address\n", __func__);
+   addr = devfdt_get_addr(bus);
+   if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
-   }
-   ds->num_cs = fdtdec_get_int(blob, node, "num-cs", 4);
+
+   plat->regs = (struct davinci_spi_regs *)addr;
+   plat->num_cs = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), 
"num-cs", 4);
 
return 0;
 }
 
-static const struct dm_spi_ops davinci_spi_ops = {
-   .claim_bus  = davinci_spi_claim_bus,
-   .release_bus= davinci_spi_release_bus,
-   .xfer   = davinci_spi_xfer,
-   .set_speed  = davinci_spi_set_speed,
-   .set_mode   = davinci_spi_set_mode,
-};
-
 static const struct udevice_id davinci_spi_ids[] = {
{ .compatible = "ti,keystone-spi" },
{ .compatible = "ti,dm6441-spi" },
{ .compatible = "ti,da830-spi" },
{ }
 };
+#endif
 
 U_BOOT_DRIVER(davinci_spi) = {
.name = "davinci_spi",
.id = UCLASS_SPI,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
.of_match = davinci_spi_ids,
-   .ops = _spi_ops,
.ofdata_to_platdata = davinci_ofdata_to_platadata,
-   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
+.platdata_auto_alloc_size = sizeof(struct davinci_spi_platdata),
+#endif
.probe = davinci_spi_probe,
+   .ops = _spi_ops,
+   .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
 };
 #endif
diff --git a/include/dm/platform_data/spi_davinci.h 
b/include/dm/platform_data/spi_davinci.h
new file mode 100644
index 00..fbc62c262a
--- /dev/null
+++ b/include/dm/platform_data/spi_davinci.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2018 Jagan Teki 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __spi_davinci_h
+#define __spi_davinci_h
+
+struct davinci_spi_platdata {
+   struct davinci_spi_regs *regs;
+   u8 num_cs; /* total no. of CS available */
+};
+
+#endif /* __spi_davinci_h */
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 1/1] efi_loader: fix typos in efi_runtime.c

2018-09-03 Thread Heinrich Schuchardt
Fix multiple typos

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_runtime.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 27136cbedd..2b4f399e9a 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -30,8 +30,9 @@ static efi_status_t __efi_runtime EFIAPI 
efi_device_error(void);
 static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
 
 /*
- * TODO(s...@chromium.org): These defines and structs should come from the elf
- * header for each arch (or a generic header) rather than being repeated here.
+ * TODO(s...@chromium.org): These defines and structures should come from the 
ELF
+ * header for each architecture (or a generic header) rather than being 
repeated
+ * here.
  */
 #if defined(__aarch64__)
 #define R_RELATIVE R_AARCH64_RELATIVE
@@ -79,7 +80,7 @@ struct elf_rela {
 };
 
 /*
- * EFI Runtime code lives in 2 stages. In the first stage, U-Boot and an EFI
+ * EFI runtime code lives in two stages. In the first stage, U-Boot and an EFI
  * payload are running concurrently at the same time. In this mode, we can
  * handle a good number of runtime callbacks
  */
@@ -97,7 +98,7 @@ void __efi_runtime efi_update_table_header_crc32(struct 
efi_table_hdr *table)
 }
 
 /**
- * efi_reset_system_boottime() - reset system at boottime
+ * efi_reset_system_boottime() - reset system at boot time
  *
  * This function implements the ResetSystem() runtime service before
  * SetVirtualAddressMap() is called.
@@ -144,7 +145,7 @@ static void EFIAPI efi_reset_system_boottime(
 }
 
 /**
- * efi_get_time_boottime() - get current time at boottime
+ * efi_get_time_boottime() - get current time at boot time
  *
  * This function implements the GetTime runtime service before
  * SetVirtualAddressMap() is called.
@@ -335,7 +336,7 @@ static void efi_runtime_detach(ulong offset)
*p = newaddr;
}
 
-   /* Update crc32 */
+   /* Update CRC32 */
efi_update_table_header_crc32(_runtime_services.hdr);
 }
 
@@ -489,7 +490,7 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
  * available at runtime.
  *
  * @mmio_ptr:  address of the memory-mapped IO region
- * @len:   size of thememory-mapped IO region
+ * @len:   size of the memory-mapped IO region
  * Returns:status code
  */
 efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
-- 
2.18.0

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


[U-Boot] [PATCH 1/1] efi_loader: fix typos in efi_boottime.c

2018-09-03 Thread Heinrich Schuchardt
Fix numerous typos.

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

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index f9f59b93f9..dfddcb5aa5 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -106,8 +106,8 @@ void efi_save_gd(void)
 
 /*
  * Special case handler for error/abort that just forces things back to u-boot
- * world so we can dump out an abort msg, without any care about returning back
- * to UEFI world.
+ * world so we can dump out an abort message, without any care about returning
+ * back to UEFI world.
  */
 void efi_restore_gd(void)
 {
@@ -184,7 +184,7 @@ static void efi_queue_event(struct efi_event *event, bool 
check_tpl)
  * is_valid_tpl() - check if the task priority level is valid
  *
  * @tpl:   TPL level to check
- * ReturnValue:status code
+ * Return: status code
  */
 efi_status_t is_valid_tpl(efi_uintn_t tpl)
 {
@@ -627,7 +627,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t 
notify_tpl,
evt->notify_function = notify_function;
evt->notify_context = notify_context;
evt->group = group;
-   /* Disable timers on bootup */
+   /* Disable timers on boot up */
evt->trigger_next = -1ULL;
evt->is_queued = false;
evt->is_signaled = false;
@@ -733,7 +733,7 @@ void efi_timer_check(void)
  * efi_set_timer() - set the trigger time for a timer event or stop the event
  * @event:event for which the timer is set
  * @type: type of the timer
- * @trigger_time: trigger period in multiples of 100ns
+ * @trigger_time: trigger period in multiples of 100 ns
  *
  * This is the function for internal usage in U-Boot. For the API function
  * implementing the SetTimer service see efi_set_timer_ext.
@@ -748,8 +748,8 @@ efi_status_t efi_set_timer(struct efi_event *event, enum 
efi_timer_delay type,
return EFI_INVALID_PARAMETER;
 
/*
-* The parameter defines a multiple of 100ns.
-* We use multiples of 1000ns. So divide by 10.
+* The parameter defines a multiple of 100 ns.
+* We use multiples of 1000 ns. So divide by 10.
 */
do_div(trigger_time, 10);
 
@@ -775,7 +775,7 @@ efi_status_t efi_set_timer(struct efi_event *event, enum 
efi_timer_delay type,
  *   event
  * @event:event for which the timer is set
  * @type: type of the timer
- * @trigger_time: trigger period in multiples of 100ns
+ * @trigger_time: trigger period in multiples of 100 ns
  *
  * This function implements the SetTimer service.
  *
@@ -1062,7 +1062,7 @@ out:
 /**
  * efi_get_drivers() - get all drivers associated to a controller
  * @efiobj:   handle of the controller
- * @protocol: protocol guid (optional)
+ * @protocol: protocol GUID (optional)
  * @number_of_drivers:number of child controllers
  * @driver_handle_buffer: handles of the the drivers
  *
@@ -1127,7 +1127,7 @@ static efi_status_t efi_get_drivers(struct efi_object 
*efiobj,
 /**
  * efi_disconnect_all_drivers() - disconnect all drivers from a controller
  * @efiobj:   handle of the controller
- * @protocol: protocol guid (optional)
+ * @protocol: protocol GUID (optional)
  * @child_handle: handle of the child to destroy
  *
  * This function implements the DisconnectController service.
@@ -1409,7 +1409,7 @@ efi_status_t efi_install_configuration_table(const 
efi_guid_t *guid,
if (!guid)
return EFI_INVALID_PARAMETER;
 
-   /* Check for guid override */
+   /* Check for GUID override */
for (i = 0; i < systab.nr_tables; i++) {
if (!guidcmp(guid, [i].guid)) {
if (table)
@@ -1433,7 +1433,7 @@ efi_status_t efi_install_configuration_table(const 
efi_guid_t *guid,
systab.nr_tables = i + 1;
 
 out:
-   /* systab.nr_tables may have changed. So we need to update the crc32 */
+   /* systab.nr_tables may have changed. So we need to update the CRC32 */
efi_update_table_header_crc32();
 
/* Notify that the configuration table was changed */
@@ -1655,7 +1655,7 @@ static efi_status_t EFIAPI efi_load_image(bool 
boot_policy,
if (ret != EFI_SUCCESS)
goto failure;
} else {
-   /* In this case, file_path is the "device" path, ie.
+   /* In this case, file_path is the "device" path, i.e.
 * something like a HARDWARE_DEVICE:MEMORY_MAPPED
 */
ret = efi_setup_loaded_image(info, obj, file_path, NULL);
@@ -1679,7 +1679,7 @@ error:
 }
 
 /**
- * efi_start_image() - dall the entry point of an image
+ * efi_start_image() - call the entry point of an image
  * @image_handle:   handle of the image
  * @exit_data_size: size 

[U-Boot] [PATCH 1/4] x86: cpu: introduce scu_ipc_raw_command()

2018-09-03 Thread Georgii Staroselskii
This interface will be used to configure properly some pins on
Merrifield that are shared with SCU.

scu_ipc_raw_command() writes SPTR and DPTR registers before sending
a command to SCU.

This code has been ported from Linux work done by Andy Shevchenko.

Signed-off-by: Georgii Staroselskii 
---
 arch/x86/include/asm/scu.h |  4 
 arch/x86/lib/scu.c | 35 +++
 2 files changed, 39 insertions(+)

diff --git a/arch/x86/include/asm/scu.h b/arch/x86/include/asm/scu.h
index 7ce5824..f5ec5a1 100644
--- a/arch/x86/include/asm/scu.h
+++ b/arch/x86/include/asm/scu.h
@@ -6,6 +6,8 @@
 #define _X86_ASM_SCU_IPC_H_
 
 /* IPC defines the following message types */
+#define IPCMSG_INDIRECT_READ   0x02
+#define IPCMSG_INDIRECT_WRITE  0x05
 #define IPCMSG_WARM_RESET  0xf0
 #define IPCMSG_COLD_RESET  0xf1
 #define IPCMSG_SOFT_RESET  0xf2
@@ -23,5 +25,7 @@ struct ipc_ifwi_version {
 /* Issue commands to the SCU with or without data */
 int scu_ipc_simple_command(u32 cmd, u32 sub);
 int scu_ipc_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out, int 
outlen);
+int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
+   int outlen, u32 dptr, u32 sptr);
 
 #endif /* _X86_ASM_SCU_IPC_H_ */
diff --git a/arch/x86/lib/scu.c b/arch/x86/lib/scu.c
index caa04c6..847bb77 100644
--- a/arch/x86/lib/scu.c
+++ b/arch/x86/lib/scu.c
@@ -101,6 +101,41 @@ static int scu_ipc_cmd(struct ipc_regs *regs, u32 cmd, u32 
sub,
return err;
 }
 
+int scu_ipc_raw_command(u32 cmd, u32 sub, u32 *in, int inlen, u32 *out,
+   int outlen, u32 dptr, u32 sptr)
+{
+   int inbuflen = DIV_ROUND_UP(inlen, 4);
+   struct udevice *dev;
+   struct scu *scu;
+   int ret;
+
+   ret = syscon_get_by_driver_data(X86_SYSCON_SCU, );
+   if (ret)
+   return ret;
+
+   scu = dev_get_priv(dev);
+
+   /* Up to 16 bytes */
+   if (inbuflen > 4)
+   return -EINVAL;
+
+   writel(dptr, >regs->dptr);
+   writel(sptr, >regs->sptr);
+
+   /*
+* SRAM controller doesn't support 8-bit writes, it only
+* supports 32-bit writes, so we have to copy input data into
+* the temporary buffer, and SCU FW will use the inlen to
+* determine the actual input data length in the temporary
+* buffer.
+*/
+
+   u32 inbuf[4] = {0};
+
+   memcpy(inbuf, in, inlen);
+
+   return scu_ipc_cmd(scu->regs, cmd, sub, inbuf, inlen, out, outlen);
+}
 /**
  * scu_ipc_simple_command() - send a simple command
  * @cmd: command
-- 
2.7.4

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


[U-Boot] [PATCH v3 1/5] efi_loader: capitalization table

2018-09-03 Thread Heinrich Schuchardt
This patch provides a define to initialize a table that maps lower to
capital letters for Unicode code point 0x - 0x.

Signed-off-by: Heinrich Schuchardt 
---
v3:
remove codes < 0x80 from tables for code pages 437 and 1250
sort tables for code pages 437 and 1250
v2:
add shorter tables for code pages 437 and 1250
---
 MAINTAINERS  |1 +
 include/capitalization.h | 1978 ++
 2 files changed, 1979 insertions(+)
 create mode 100644 include/capitalization.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 46f826a0fe..8c9cd83347 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -381,6 +381,7 @@ T:  git git://github.com/agraf/u-boot.git
 F: doc/README.uefi
 F: doc/README.iscsi
 F: Documentation/efi.rst
+F: include/capitalization.h
 F: include/efi*
 F: include/pe.h
 F: include/asm-generic/pe.h
diff --git a/include/capitalization.h b/include/capitalization.h
new file mode 100644
index 00..ade4e8c634
--- /dev/null
+++ b/include/capitalization.h
@@ -0,0 +1,1978 @@
+/* SPDX-License-Identifier: Unicode-DFS-2016 */
+/*
+ * Capitalization tables
+ */
+
+struct capitalization_table {
+   u16 upper;
+   u16 lower;
+};
+
+/*
+ * Correspondence table for small and capital Unicode letters in the range of
+ * 0x - 0x based on 
http://www.unicode.org/Public/UCA/11.0.0/allkeys.txt
+ */
+#define UNICODE_CAPITALIZATION_TABLE { \
+   { 0x0531, /* ARMENIAN CAPITAL LETTER AYB */ \
+ 0x0561, /* ARMENIAN SMALL LETTER AYB */ }, \
+   { 0x0532, /* ARMENIAN CAPITAL LETTER BEN */ \
+ 0x0562, /* ARMENIAN SMALL LETTER BEN */ }, \
+   { 0x053E, /* ARMENIAN CAPITAL LETTER CA */ \
+ 0x056E, /* ARMENIAN SMALL LETTER CA */ }, \
+   { 0x0549, /* ARMENIAN CAPITAL LETTER CHA */ \
+ 0x0579, /* ARMENIAN SMALL LETTER CHA */ }, \
+   { 0x0543, /* ARMENIAN CAPITAL LETTER CHEH */ \
+ 0x0573, /* ARMENIAN SMALL LETTER CHEH */ }, \
+   { 0x0551, /* ARMENIAN CAPITAL LETTER CO */ \
+ 0x0581, /* ARMENIAN SMALL LETTER CO */ }, \
+   { 0x0534, /* ARMENIAN CAPITAL LETTER DA */ \
+ 0x0564, /* ARMENIAN SMALL LETTER DA */ }, \
+   { 0x0535, /* ARMENIAN CAPITAL LETTER ECH */ \
+ 0x0565, /* ARMENIAN SMALL LETTER ECH */ }, \
+   { 0x0537, /* ARMENIAN CAPITAL LETTER EH */ \
+ 0x0567, /* ARMENIAN SMALL LETTER EH */ }, \
+   { 0x0538, /* ARMENIAN CAPITAL LETTER ET */ \
+ 0x0568, /* ARMENIAN SMALL LETTER ET */ }, \
+   { 0x0556, /* ARMENIAN CAPITAL LETTER FEH */ \
+ 0x0586, /* ARMENIAN SMALL LETTER FEH */ }, \
+   { 0x0542, /* ARMENIAN CAPITAL LETTER GHAD */ \
+ 0x0572, /* ARMENIAN SMALL LETTER GHAD */ }, \
+   { 0x0533, /* ARMENIAN CAPITAL LETTER GIM */ \
+ 0x0563, /* ARMENIAN SMALL LETTER GIM */ }, \
+   { 0x0540, /* ARMENIAN CAPITAL LETTER HO */ \
+ 0x0570, /* ARMENIAN SMALL LETTER HO */ }, \
+   { 0x053B, /* ARMENIAN CAPITAL LETTER INI */ \
+ 0x056B, /* ARMENIAN SMALL LETTER INI */ }, \
+   { 0x0541, /* ARMENIAN CAPITAL LETTER JA */ \
+ 0x0571, /* ARMENIAN SMALL LETTER JA */ }, \
+   { 0x054B, /* ARMENIAN CAPITAL LETTER JHEH */ \
+ 0x057B, /* ARMENIAN SMALL LETTER JHEH */ }, \
+   { 0x0554, /* ARMENIAN CAPITAL LETTER KEH */ \
+ 0x0584, /* ARMENIAN SMALL LETTER KEH */ }, \
+   { 0x053F, /* ARMENIAN CAPITAL LETTER KEN */ \
+ 0x056F, /* ARMENIAN SMALL LETTER KEN */ }, \
+   { 0x053C, /* ARMENIAN CAPITAL LETTER LIWN */ \
+ 0x056C, /* ARMENIAN SMALL LETTER LIWN */ }, \
+   { 0x0544, /* ARMENIAN CAPITAL LETTER MEN */ \
+ 0x0574, /* ARMENIAN SMALL LETTER MEN */ }, \
+   { 0x0546, /* ARMENIAN CAPITAL LETTER NOW */ \
+ 0x0576, /* ARMENIAN SMALL LETTER NOW */ }, \
+   { 0x0555, /* ARMENIAN CAPITAL LETTER OH */ \
+ 0x0585, /* ARMENIAN SMALL LETTER OH */ }, \
+   { 0x054A, /* ARMENIAN CAPITAL LETTER PEH */ \
+ 0x057A, /* ARMENIAN SMALL LETTER PEH */ }, \
+   { 0x0553, /* ARMENIAN CAPITAL LETTER PIWR */ \
+ 0x0583, /* ARMENIAN SMALL LETTER PIWR */ }, \
+   { 0x054C, /* ARMENIAN CAPITAL LETTER RA */ \
+ 0x057C, /* ARMENIAN SMALL LETTER RA */ }, \
+   { 0x0550, /* ARMENIAN CAPITAL LETTER REH */ \
+ 0x0580, /* ARMENIAN SMALL LETTER REH */ }, \
+   { 0x054D, /* ARMENIAN CAPITAL LETTER SEH */ \
+ 0x057D, /* ARMENIAN SMALL LETTER SEH */ }, \
+   { 0x0547, /* ARMENIAN CAPITAL LETTER SHA */ \
+ 0x0577, /* ARMENIAN SMALL LETTER SHA */ }, \
+   { 0x054F, /* ARMENIAN CAPITAL LETTER TIWN */ \
+ 0x057F, /* ARMENIAN SMALL LETTER TIWN */ }, \
+   { 0x0539, /* ARMENIAN CAPITAL LETTER TO */ \
+ 0x0569, /* ARMENIAN SMALL LETTER TO */ }, \
+   { 0x054E, /* ARMENIAN CAPITAL LETTER VEW */ \
+ 0x057E, /* ARMENIAN SMALL LETTER VEW */ }, \
+   { 0x0548, /* ARMENIAN CAPITAL LETTER VO */ \
+ 

[U-Boot] [PATCH 4/4] x86: tangier: acpi: add I2C6 node

2018-09-03 Thread Georgii Staroselskii
Now that we have I2C#6 working, it's time to add a corresponsing
ACPI binding.

Signed-off-by: Georgii Staroselskii 
---
 arch/x86/include/asm/arch-tangier/acpi/southcluster.asl | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl 
b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
index b200e9f..7cdc4b2 100644
--- a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
+++ b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
@@ -231,6 +231,16 @@ Device (PCI0)
 }
 }
 
+Device (I2C6)
+{
+Name (_ADR, 0x00090001)
+
+Method (_STA, 0, NotSerialized)
+{
+Return (STA_VISIBLE)
+}
+}
+
 Device (GPIO)
 {
 Name (_ADR, 0x000c)
-- 
2.7.4

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


[U-Boot] [PATCH 3/4] x86: dts: edison: configure I2C#6 pins

2018-09-03 Thread Georgii Staroselskii
Now that we have the pinctrl driver for Merrifield in place we can make
use of it and set I2C#6 pins appropriately.

Initial configuration came from the firmware.  Which quite likely has
been used in the phones, where that is not part of Atom peripheral, is
in use. Thus we need to override the leftover.

Signed-off-by: Georgii Staroselskii 
---
 arch/x86/dts/edison.dts | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 1da7f54..0dd7240 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -85,4 +85,26 @@
compatible = "intel,reset-tangier";
u-boot,dm-pre-reloc;
};
+
+   pinctrl {
+   compatible = "intel,pinctrl-tangier";
+   reg = <0xff0c 0x8000>;
+
+   /*
+* Initial configuration came from the firmware.
+* Which quite likely has been used in the phones, where I2C #8,
+* that is not part of Atom peripheral, is in use.
+* Thus we need to override the leftover.
+*/
+   i2c6_scl@0 {
+   pad-offset = <111>;
+   mode-func = <1>;
+   protected;
+   };
+   i2c6_sda@0 {
+   pad-offset = <112>;
+   mode-func = <1>;
+   protected;
+   };
+   };
 };
-- 
2.7.4

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


[U-Boot] [PATCH v3 4/5] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Heinrich Schuchardt
The patch implements the EFI_UNICODE_COLLATION_PROTOCOL.

Signed-off-by: Heinrich Schuchardt 
---
v3:
no change
v2:
add more comments
---
 MAINTAINERS|   2 +
 include/cp1250.h   |  40 +++
 include/cp437.h|  40 +++
 include/efi_api.h  |  21 ++
 include/efi_loader.h   |   5 +
 lib/efi_loader/Makefile|  18 +-
 lib/efi_loader/efi_boottime.c  |   6 +
 lib/efi_loader/efi_unicode_collation.c | 329 +
 8 files changed, 457 insertions(+), 4 deletions(-)
 create mode 100644 include/cp1250.h
 create mode 100644 include/cp437.h
 create mode 100644 lib/efi_loader/efi_unicode_collation.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 8c9cd83347..67b015205c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -382,6 +382,8 @@ F:  doc/README.uefi
 F: doc/README.iscsi
 F: Documentation/efi.rst
 F: include/capitalization.h
+F: include/cp1250.h
+F: include/cp437.h
 F: include/efi*
 F: include/pe.h
 F: include/asm-generic/pe.h
diff --git a/include/cp1250.h b/include/cp1250.h
new file mode 100644
index 00..adacf8a958
--- /dev/null
+++ b/include/cp1250.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/*
+ * Constant CP1250 contains the Unicode code points for characters 0x80 - 0xff
+ * of the code page 1250.
+ */
+#define CP1250 { \
+   0x20ac, 0x, 0x201a, 0x, \
+   0x201e, 0x2026, 0x2020, 0x2021, \
+   0x, 0x2030, 0x0160, 0x2039, \
+   0x015a, 0x0164, 0x017d, 0x0179, \
+   0x, 0x2018, 0x2019, 0x201c, \
+   0x201d, 0x2022, 0x2013, 0x2014, \
+   0x, 0x2122, 0x0161, 0x203a, \
+   0x015b, 0x0165, 0x017e, 0x017a, \
+   0x00a0, 0x02c7, 0x02d8, 0x0141, \
+   0x00a4, 0x0104, 0x00a6, 0x00a7, \
+   0x00a8, 0x00a9, 0x015e, 0x00ab, \
+   0x00ac, 0x00ad, 0x00ae, 0x017b, \
+   0x00b0, 0x00b1, 0x02db, 0x0142, \
+   0x00b4, 0x00b5, 0x00b6, 0x00b7, \
+   0x00b8, 0x0105, 0x015f, 0x00bb, \
+   0x013d, 0x02dd, 0x013e, 0x017c, \
+   0x0154, 0x00c1, 0x00c2, 0x0102, \
+   0x00c4, 0x0139, 0x0106, 0x00c7, \
+   0x010c, 0x00c9, 0x0118, 0x00cb, \
+   0x011a, 0x00cd, 0x00ce, 0x010e, \
+   0x0110, 0x0143, 0x0147, 0x00d3, \
+   0x00d4, 0x0150, 0x00d6, 0x00d7, \
+   0x0158, 0x016e, 0x00da, 0x0170, \
+   0x00dc, 0x00dd, 0x0162, 0x00df, \
+   0x0155, 0x00e1, 0x00e2, 0x0103, \
+   0x00e4, 0x013a, 0x0107, 0x00e7, \
+   0x010d, 0x00e9, 0x0119, 0x00eb, \
+   0x011b, 0x00ed, 0x00ee, 0x010f, \
+   0x0111, 0x0144, 0x0148, 0x00f3, \
+   0x00f4, 0x0151, 0x00f6, 0x00f7, \
+   0x0159, 0x016f, 0x00fa, 0x0171, \
+   0x00fc, 0x00fd, 0x0163, 0x02d9, \
+}
diff --git a/include/cp437.h b/include/cp437.h
new file mode 100644
index 00..0b2b97132e
--- /dev/null
+++ b/include/cp437.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/*
+ * Constant CP437 contains the Unicode code points for characters 0x80 - 0xff
+ * of the code page 437.
+ */
+#define CP437 { \
+   0x00c7, 0x00fc, 0x00e9, 0x00e2, \
+   0x00e4, 0x00e0, 0x00e5, 0x00e7, \
+   0x00ea, 0x00eb, 0x00e8, 0x00ef, \
+   0x00ee, 0x00ec, 0x00c4, 0x00c5, \
+   0x00c9, 0x00e6, 0x00c6, 0x00f4, \
+   0x00f6, 0x00f2, 0x00fb, 0x00f9, \
+   0x00ff, 0x00d6, 0x00dc, 0x00a2, \
+   0x00a3, 0x00a5, 0x20a7, 0x0192, \
+   0x00e1, 0x00ed, 0x00f3, 0x00fa, \
+   0x00f1, 0x00d1, 0x00aa, 0x00ba, \
+   0x00bf, 0x2310, 0x00ac, 0x00bd, \
+   0x00bc, 0x00a1, 0x00ab, 0x00bb, \
+   0x2591, 0x2592, 0x2593, 0x2502, \
+   0x2524, 0x2561, 0x2562, 0x2556, \
+   0x2555, 0x2563, 0x2551, 0x2557, \
+   0x255d, 0x255c, 0x255b, 0x2510, \
+   0x2514, 0x2534, 0x252c, 0x251c, \
+   0x2500, 0x253c, 0x255e, 0x255f, \
+   0x255a, 0x2554, 0x2569, 0x2566, \
+   0x2560, 0x2550, 0x256c, 0x2567, \
+   0x2568, 0x2564, 0x2565, 0x2559, \
+   0x2558, 0x2552, 0x2553, 0x256b, \
+   0x256a, 0x2518, 0x250c, 0x2588, \
+   0x2584, 0x258c, 0x2590, 0x2580, \
+   0x03b1, 0x00df, 0x0393, 0x03c0, \
+   0x03a3, 0x03c3, 0x00b5, 0x03c4, \
+   0x03a6, 0x0398, 0x03a9, 0x03b4, \
+   0x221e, 0x03c6, 0x03b5, 0x2229, \
+   0x2261, 0x00b1, 0x2265, 0x2264, \
+   0x2320, 0x2321, 0x00f7, 0x2248, \
+   0x00b0, 0x2219, 0x00b7, 0x221a, \
+   0x207f, 0x00b2, 0x25a0, 0x00a0, \
+}
diff --git a/include/efi_api.h b/include/efi_api.h
index ebf2a3bc18..1efc448184 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -31,6 +31,7 @@ enum efi_timer_delay {
EFI_TIMER_RELATIVE = 2
 };
 
+#define efi_intn_t ssize_t
 #define efi_uintn_t size_t
 typedef uint16_t *efi_string_t;
 
@@ -958,4 +959,24 @@ struct efi_driver_binding_protocol {
efi_handle_t driver_binding_handle;
 };
 
+#define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
+   EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \
+0x92, 

[U-Boot] [PATCH v3 5/5] efi_selftest: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Heinrich Schuchardt
Provide a unit test for the EFI_UNICODE_COLLATION_PROTOCOL.

Signed-off-by: Heinrich Schuchardt 
---
v3:
no change
v2:
avoid lines over 80 characters
---
 lib/efi_selftest/Makefile |   1 +
 .../efi_selftest_unicode_collation.c  | 260 ++
 2 files changed, 261 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_unicode_collation.c

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 86aa72b0e0..80bc5d8a64 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -31,6 +31,7 @@ efi_selftest_snp.o \
 efi_selftest_textinput.o \
 efi_selftest_textoutput.o \
 efi_selftest_tpl.o \
+efi_selftest_unicode_collation.o \
 efi_selftest_util.o \
 efi_selftest_variables.o \
 efi_selftest_watchdog.o
diff --git a/lib/efi_selftest/efi_selftest_unicode_collation.c 
b/lib/efi_selftest/efi_selftest_unicode_collation.c
new file mode 100644
index 00..9765bd3e44
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_unicode_collation.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_unicode_collation
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt 
+ *
+ * Test unicode collation protocol.
+ */
+
+#include 
+
+static const efi_guid_t unicode_collation_protocol_guid =
+   EFI_UNICODE_COLLATION_PROTOCOL2_GUID;
+
+static struct efi_boot_services *boottime;
+
+static struct efi_unicode_collation_protocol *unicode_collation_protocol;
+
+/**
+ * setup() - setup unit test.
+ *
+ * @handle:handle of the loaded image
+ * @systable:  system table
+ * ReturnValue:EFI_ST_SUCCESS for success
+ */
+static int setup(const efi_handle_t handle,
+const struct efi_system_table *systable)
+{
+   efi_status_t ret;
+
+   boottime = systable->boottime;
+
+   ret = boottime->locate_protocol(_collation_protocol_guid, NULL,
+   (void **)_collation_protocol);
+   if (ret != EFI_SUCCESS) {
+   unicode_collation_protocol = NULL;
+   efi_st_error("Unicode collation protocol is not available.\n");
+   return EFI_ST_FAILURE;
+   }
+
+   return EFI_ST_SUCCESS;
+}
+
+static int test_stri_coll(void)
+{
+   efi_intn_t ret;
+   u16 c1[] = L"first";
+   u16 c2[] = L"FIRST";
+   u16 c3[] = L"second";
+
+   ret = unicode_collation_protocol->stri_coll(unicode_collation_protocol,
+   c1, c2);
+   if (ret) {
+   efi_st_error(
+   "stri_coll(\"%ps\", \"%ps\") = %zu\n", c1, c2, ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->stri_coll(unicode_collation_protocol,
+   c1, c3);
+   if (ret >= 0) {
+   efi_st_error(
+   "stri_coll(\"%ps\", \"%ps\") = %zu\n", c1, c3, ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->stri_coll(unicode_collation_protocol,
+   c3, c1);
+   if (ret <= 0) {
+   efi_st_error(
+   "stri_coll(\"%ps\", \"%ps\") = %zu\n", c3, c1, ret);
+   return EFI_ST_FAILURE;
+   }
+
+   return EFI_ST_SUCCESS;
+}
+
+static int test_metai_match(void)
+{
+   bool ret;
+   const u16 c[] = L"Das U-Boot";
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"*");
+   if (!ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"Da[rstu] U-Boot");
+   if (!ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"Da[q-v] U-Boot");
+   if (!ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"Da? U-Boot");
+   if (!ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"D*Bo*t");
+   if (!ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = unicode_collation_protocol->metai_match(
+   unicode_collation_protocol, c, L"Da[xyz] U-Boot");
+   if (ret) {
+   efi_st_error("metai_match returned %u\n", ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = 

[U-Boot] [PATCH 2/4] x86: tangier: pinmux: add API to configure protected pins

2018-09-03 Thread Georgii Staroselskii
This API is going to be used to configure some pins that are protected
for simple modification.

It's not a comprehensive pinctrl driver but can be turned into one
when we need this in the future. Now it is planned to be used only
in one place. So that's why I decided not to polute the codebase with a
full-blown pinctrl-merrifield nobody will use.

This driver reads corresponding fields in DT and configures pins
accordingly.

The "protected" flag is used to distinguish configuration of SCU-owned
pins from the ordinary ones.

The code has been adapted from Linux work done by Andy Shevchenko
in pinctrl-merrfifield.c

Signed-off-by: Georgii Staroselskii 
---
 arch/x86/cpu/tangier/Makefile |   2 +-
 arch/x86/cpu/tangier/pinmux.c | 188 ++
 2 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/tangier/pinmux.c

diff --git a/arch/x86/cpu/tangier/Makefile b/arch/x86/cpu/tangier/Makefile
index 8274482..68f4a32 100644
--- a/arch/x86/cpu/tangier/Makefile
+++ b/arch/x86/cpu/tangier/Makefile
@@ -2,5 +2,5 @@
 #
 # Copyright (c) 2017 Intel Corporation
 
-obj-y += car.o tangier.o sdram.o sysreset.o
+obj-y += car.o tangier.o sdram.o sysreset.o pinmux.o
 obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o
diff --git a/arch/x86/cpu/tangier/pinmux.c b/arch/x86/cpu/tangier/pinmux.c
new file mode 100644
index 000..c59b63c
--- /dev/null
+++ b/arch/x86/cpu/tangier/pinmux.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Emlid Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define BUFCFG_OFFSET  0x100
+
+#define MRFLD_FAMILY_LEN   0x400
+
+/* These are taken from Linux kernel */
+#define MRFLD_PINMODE_MASK 0x07
+
+#define pin_to_bufno(f, p)   ((p) - (f)->pin_base)
+
+struct mrfld_family {
+   unsigned int family_number;
+   unsigned int pin_base;
+   size_t npins;
+   void __iomem *regs;
+};
+
+#define MRFLD_FAMILY(b, s, e)  \
+   {   \
+   .family_number = (b),   \
+   .pin_base = (s),\
+   .npins = (e) - (s) + 1, \
+   }
+
+static struct mrfld_family mrfld_families[] = {
+   MRFLD_FAMILY(7, 101, 114),
+};
+
+struct mrfld_pinctrl {
+   const struct mrfld_family *families;
+   size_t nfamilies;
+};
+
+static const struct mrfld_family *
+mrfld_get_family(struct mrfld_pinctrl *mp, unsigned int pin)
+{
+   const struct mrfld_family *family;
+   unsigned int i;
+
+   for (i = 0; i < mp->nfamilies; i++) {
+   family = >families[i];
+   if (pin >= family->pin_base &&
+   pin < family->pin_base + family->npins)
+   return family;
+   }
+
+   printf("failed to find family for pin %u\n", pin);
+   return NULL;
+}
+
+static void __iomem *
+mrfld_get_bufcfg(struct mrfld_pinctrl *pinctrl, unsigned int pin)
+{
+   const struct mrfld_family *family;
+   unsigned int bufno;
+
+   family =  mrfld_get_family(pinctrl, pin);
+   if (!family)
+   return NULL;
+
+   bufno = pin_to_bufno(family, pin);
+
+   return family->regs + BUFCFG_OFFSET + bufno * 4;
+}
+
+static void
+mrfld_setup_families(void *base_addr, struct mrfld_family *families, unsigned 
int nfam)
+{
+   for (int i = 0; i < nfam; i++) {
+   struct mrfld_family *family = [i];
+
+   family->regs = base_addr + family->family_number * 
MRFLD_FAMILY_LEN;
+   }
+}
+
+static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits)
+{
+   struct mrfld_pinctrl *pinctrl;
+   struct udevice *dev;
+   void __iomem *bufcfg;
+   u32 v, value;
+   int ret;
+
+   ret = syscon_get_by_driver_data(X86_SYSCON_PINCONF, );
+   if (ret)
+   return ret;
+
+   pinctrl = dev_get_priv(dev);
+
+   bufcfg = mrfld_get_bufcfg(pinctrl, pin);
+   if (!bufcfg)
+   return -EINVAL;
+
+   value = readl(bufcfg);
+
+   v = (value & ~mask) | (bits & mask);
+
+   debug("scu: v: 0x%x p: 0x%x bits: %d, mask: %d bufcfg: 0x%p\n",
+   v, (u32)bufcfg, bits, mask, bufcfg);
+
+   ret = scu_ipc_raw_command(IPCMSG_INDIRECT_WRITE, 0, , 4,
+ NULL, 0, (u32)bufcfg, 0);
+   if (ret)
+   pr_err("Failed to set mode via SCU for pin %u (%d)\n", pin, 
ret);
+
+   return ret;
+}
+static int mrfld_pinctrl_cfg_pin(int pin_node)
+{
+   bool is_protected;
+   int pad_offset;
+   int mode;
+   int ret;
+
+   is_protected = fdtdec_get_bool(gd->fdt_blob, pin_node, "protected");
+   if (!is_protected)
+   return -ENOTSUPP;
+
+   pad_offset = fdtdec_get_int(gd->fdt_blob, pin_node, "pad-offset", -1);
+   if (pad_offset == -1)
+   return 

[U-Boot] [PATCH 0/4] Add a pinctrl driver for Merrifield to pinmux I2C#6

2018-09-03 Thread Georgii Staroselskii
We have lacked the support for any pinmuxing in U-Boot for Merrifield.
A need for pinmuxing some pins has arisen from the fact the I2C#6 is shared
with I2C#8 on Merrifield. The latter is not easily accessible because it's
a part of a separate MCU we don't have easy access to.

I2C#6 can be and should be made use of in Linux but couldn't because it
was blocked by the SCU.

The proposed change is to implement a minimalistic pinctrl driver that
reads the configuration off a device tree blob and configures the pins 
accordingly.

The driver needs some changes to SCU API and thus the addition of
scu_ipc_raw_command().

Andy Shevchenko has been helping me by making a prior review and made
a lot of suggestions about the general approach that should be taken.

He should also be given credit for the initial kernel code that I have
taken as a reference.

The code has been tested on 5 different Edisons on Intel Edison Breakout
board and a couple of custom Emlid PCBs by booting a kernel and issuing
a i2cdetect -r -y 6 and then loading a driver that made use of the bus.

I also created a Gist on Github with a lot of relevant information like

- output of `acpidump -o tables.dat`
- dmesg
- output of `grep -H 15 /sys/bus/acpi/devices/*/status`
- cat /sys/kernel/debug/gpio
- cat /sys/kernel/debug/pinctrl/INTC1002\:00/pins
- output of `i2cdetect -y -r 6` w/ and w/o external device on the bus

Here it is:
https://gist.github.com/staroselskii/097808e05fd609dbafd4fe5ebd618708

Georgii Staroselskii (4):
  x86: cpu: introduce scu_ipc_raw_command()
  x86: tangier: pinmux: add API to configure protected pins
  x86: dts: edison: configure I2C#6 pins
  x86: tangier: acpi: add I2C6 node

 arch/x86/cpu/tangier/Makefile  |   2 +-
 arch/x86/cpu/tangier/pinmux.c  | 188 +
 arch/x86/dts/edison.dts|  22 +++
 .../include/asm/arch-tangier/acpi/southcluster.asl |  10 ++
 arch/x86/include/asm/scu.h |   4 +
 arch/x86/lib/scu.c |  35 
 6 files changed, 260 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/tangier/pinmux.c

-- 
2.7.4

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


[U-Boot] [PATCH v3 00/05]efi_loader: EFI_UNICODE_COLLATION_PROTOCOL

2018-09-03 Thread Heinrich Schuchardt
This patchset implements the EFI_UNICODE_COLLATION_PROTOCOL and provides
unit tests.

An error in Unicode handling in the FAT file system shall be fixed after
merging Takahiro's FAT patches. Until then some redundancy between old and
new Unicode functions remains.

v3:
drop accepted patches
remove codes < 0x80 in capitalization table
add a test for capitalization of latin O with diaresis
v2:
use CONFIG_IS_ENABLED(EFI_LOADER) instead of
defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
add configuration option EFI_UNICODE_CAPITALIZATION
use ut_assert*() for testing
test illegal Unicode sequences
add more comments

Heinrich Schuchardt (5):
  efi_loader: capitalization table
  lib: charset: upper/lower case conversion
  test: tests for utf_to_lower() utf_to_upper().
  efi_loader: EFI_UNICODE_COLLATION_PROTOCOL
  efi_selftest: EFI_UNICODE_COLLATION_PROTOCOL

 MAINTAINERS   |3 +
 include/capitalization.h  | 1978 +
 include/charset.h |   16 +
 include/cp1250.h  |   40 +
 include/cp437.h   |   40 +
 include/efi_api.h |   21 +
 include/efi_loader.h  |5 +
 lib/charset.c |   47 +
 lib/efi_loader/Kconfig|   10 +
 lib/efi_loader/Makefile   |   18 +-
 lib/efi_loader/efi_boottime.c |6 +
 lib/efi_loader/efi_unicode_collation.c|  329 +++
 lib/efi_selftest/Makefile |1 +
 .../efi_selftest_unicode_collation.c  |  260 +++
 test/unicode_ut.c |   34 +
 15 files changed, 2804 insertions(+), 4 deletions(-)
 create mode 100644 include/capitalization.h
 create mode 100644 include/cp1250.h
 create mode 100644 include/cp437.h
 create mode 100644 lib/efi_loader/efi_unicode_collation.c
 create mode 100644 lib/efi_selftest/efi_selftest_unicode_collation.c

-- 
2.18.0

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


[U-Boot] [PATCH v3 2/5] lib: charset: upper/lower case conversion

2018-09-03 Thread Heinrich Schuchardt
Provide functions for upper and lower case conversion.

Signed-off-by: Heinrich Schuchardt 
---
v3:
no change
v2:
add configuration switch EFI_UNICODE_CAPITALIZATION
---
 include/charset.h  | 16 ++
 lib/charset.c  | 47 ++
 lib/efi_loader/Kconfig | 10 +
 3 files changed, 73 insertions(+)

diff --git a/include/charset.h b/include/charset.h
index 90870513ef..686db5a1fe 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -142,6 +142,22 @@ int utf16_utf8_strncpy(char **dst, const u16 *src, size_t 
count);
  */
 #define utf16_utf8_strcpy(d, s) utf16_utf8_strncpy((d), (s), SIZE_MAX)
 
+/**
+ * utf_to_lower() - convert a Unicode letter to lower case
+ *
+ * @code:  letter to convert
+ * Return: lower case letter or unchanged letter
+ */
+s32 utf_to_lower(const s32 code);
+
+/**
+ * utf_to_upper() - convert a Unicode letter to upper case
+ *
+ * @code:  letter to convert
+ * Return: upper case letter or unchanged letter
+ */
+s32 utf_to_upper(const s32 code);
+
 /**
  * u16_strlen - count non-zero words
  *
diff --git a/lib/charset.c b/lib/charset.c
index 39c8329830..72c808ce64 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -6,8 +6,18 @@
  */
 
 #include 
+#include 
 #include 
 
+static struct capitalization_table capitalization_table[] =
+#ifdef CONFIG_EFI_UNICODE_CAPITALIZATION
+   UNICODE_CAPITALIZATION_TABLE;
+#elif CONFIG_FAT_DEFAULT_CODEPAGE == 1250
+   CP1250_CAPITALIZATION_TABLE;
+#else
+   CP437_CAPITALIZATION_TABLE;
+#endif
+
 s32 utf8_get(const char **src)
 {
s32 code = 0;
@@ -241,6 +251,43 @@ int utf16_utf8_strncpy(char **dst, const u16 *src, size_t 
count)
return 0;
 }
 
+s32 utf_to_lower(const s32 code)
+{
+   struct capitalization_table *pos = capitalization_table;
+   s32 ret = code;
+
+   if (code <= 0x7f) {
+   if (code >= 'A' && code <= 'Z')
+   ret += 0x20;
+   return ret;
+   }
+   for (; pos->upper; ++pos) {
+   if (pos->upper == code) {
+   ret = pos->lower;
+   break;
+   }
+   }
+   return ret;
+}
+
+s32 utf_to_upper(const s32 code)
+{
+   struct capitalization_table *pos = capitalization_table;
+   s32 ret = code;
+
+   if (code <= 0x7f) {
+   if (code >= 'a' && code <= 'z')
+   ret -= 0x20;
+   return ret;
+   }
+   for (; pos->lower; ++pos) {
+   if (pos->lower == code) {
+   ret = pos->upper;
+   break;
+   }
+   }
+   return ret;
+}
 
 size_t u16_strlen(const u16 *in)
 {
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index ce6a09f0b4..dbf7339fe0 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -15,6 +15,16 @@ config EFI_LOADER
  interfaces to a loaded EFI application, enabling it to reuse U-Boot's
  device drivers.
 
+config EFI_UNICODE_CAPITALIZATION
+   bool "Support Unicode capitalization"
+   depends on EFI_LOADER
+   default y
+   help
+ Select this option to enable correct handling of the capitalization of
+ Unicode codepoints in the range 0x-0x. If this option is not
+ set, only the the correct handling of the letters of the codepage
+ used by the FAT file system is ensured.
+
 config EFI_LOADER_BOUNCE_BUFFER
bool "EFI Applications use bounce buffers for DMA operations"
depends on EFI_LOADER && ARM64
-- 
2.18.0

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


[U-Boot] [PATCH v3 3/5] test: tests for utf_to_lower() utf_to_upper().

2018-09-03 Thread Heinrich Schuchardt
Provide unit tests for utf_to_lower() utf_to_upper().

Signed-off-by: Heinrich Schuchardt 
---
v3:
add test for latin letter O with diaresis
v2:
use ut_assert*() for testing
---
 test/unicode_ut.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index d0dbd7985a..b94b4a651f 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -500,6 +500,40 @@ int ut_utf16_utf8_strncpy(struct unit_test_state *uts)
 }
 UNICODE_TEST(ut_utf16_utf8_strncpy);
 
+int ut_utf_to_lower(struct unit_test_state *uts)
+{
+   ut_asserteq('@', utf_to_lower('@'));
+   ut_asserteq('a', utf_to_lower('A'));
+   ut_asserteq('z', utf_to_lower('Z'));
+   ut_asserteq('[', utf_to_lower('['));
+   ut_asserteq('m', utf_to_lower('m'));
+   /* Latin letter O with diaresis (umlaut) */
+   ut_asserteq(0x00f6, utf_to_lower(0x00d6));
+#ifdef CONFIG_EFI_UNICODE_CAPITALIZATION
+   /* Cyrillic letter I*/
+   ut_asserteq(0x0438, utf_to_lower(0x0418));
+#endif
+   return 0;
+}
+UNICODE_TEST(ut_utf_to_lower);
+
+int ut_utf_to_upper(struct unit_test_state *uts)
+{
+   ut_asserteq('`', utf_to_upper('`'));
+   ut_asserteq('A', utf_to_upper('a'));
+   ut_asserteq('Z', utf_to_upper('z'));
+   ut_asserteq('{', utf_to_upper('{'));
+   ut_asserteq('M', utf_to_upper('M'));
+   /* Latin letter O with diaresis (umlaut) */
+   ut_asserteq(0x00d6, utf_to_upper(0x00f6));
+#ifdef CONFIG_EFI_UNICODE_CAPITALIZATION
+   /* Cyrillic letter I */
+   ut_asserteq(0x0418, utf_to_upper(0x0438));
+#endif
+   return 0;
+}
+UNICODE_TEST(ut_utf_to_upper);
+
 int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
struct unit_test *tests = ll_entry_start(struct unit_test, 
unicode_test);
-- 
2.18.0

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


Re: [U-Boot] [PATCH] spi: mxc_spi: Fix chipselect with DM_SPI in SPL

2018-09-03 Thread Jagan Teki
On Mon, Sep 3, 2018 at 4:02 PM, Bernhard Messerklinger
 wrote:
> Since CONFIG_IS_ENABLED(DM_SPI) is not working in SPL because
> CONFIG_SPL_DM_SPI is not defined we should go with #ifdef CONFIG_DM_SPI.

Better enabled it for SPL, did you find any size constraint? if yet
try for platdata?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4] usb: ehci-generic: Add vbus-supply regulator support

2018-09-03 Thread Marek Vasut
On 09/03/2018 03:39 PM, Patrice Chotard wrote:
> Add vbus-supply regulator support.
> On some board vbus is not controlled by the phy but by
> an external regulator.
> 
> Signed-off-by: Patrice Chotard 
> ---
> 
> Changes in v4:
>   - Remove useless dev->name in dev_dgb()

Two remaining nits, can you pull the regulator handling into separate
functions and put ifdef arounds those, with empty default
implementation? That way, the ifdefs won't be spread throughout the code.

Also, rebase on u-boot-usb/master please.

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


Re: [U-Boot] [PATCH 3/4] console: unify fgetc function when console MUX is deactivated

2018-09-03 Thread Patrick DELAUNAY
Hi Simon,

> From: s...@google.com  On Behalf Of Simon Glass
> Sent: mercredi 8 août 2018 11:56
> To: Patrick DELAUNAY 
> On 3 August 2018 at 05:38, Patrick Delaunay  wrote:
> > Unify the fgetc function when MUX is activated or not:
> > - always call tstc() : it is the normal behavior expected
> >   by serial uclass (call tstc then getc) and that avoids
> >   issue when SERIAL_RX_BUFFER is activated
> > - reload WATCHDOG in the char waiting loop
> >
> > This patch allow to have the same behavior when CONSOLE_MUX is
> > activated or not and avoid regression when this feature is deactivated.
> >
> > Signed-off-by: Patrick Delaunay 
> > ---
> >
> >  common/console.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> Reviewed-by: Simon Glass 
> 
> I'm not sure how to test this with the various cases...

Yes it is a difficully and I don't know the process in this case,
but at least the behavior (testc() function call) will be shared.

If this change seens too risky, it can be dropped as only the PATCH 1/4 is 
mandatory to solve my issue.

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


[U-Boot] [PATCH v3 18/20] test_avb: Update pymark.buildconfigspec information for the AVB tests

2018-09-03 Thread Jens Wiklander
Update the pymark.buildconfigspec to depend on 'cmd_mmc' in addition to
'cmd_avb' for those tests that needs more a more complete MMC
implementation or the "mmc" command.

Signed-off-by: Jens Wiklander 
---
 test/py/tests/test_avb.py | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/py/tests/test_avb.py b/test/py/tests/test_avb.py
index 7996e4845db3..9683fd80d074 100644
--- a/test/py/tests/test_avb.py
+++ b/test/py/tests/test_avb.py
@@ -23,7 +23,7 @@ mmc_dev = 1
 temp_addr = 0x9000
 temp_addr2 = 0x90002000
 
-@pytest.mark.buildconfigspec('cmd_avb')
+@pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc')
 def test_avb_verify(u_boot_console):
 """Run AVB 2.0 boot verification chain with avb subset of commands
 """
@@ -36,7 +36,7 @@ def test_avb_verify(u_boot_console):
 assert response.find(success_str)
 
 
-@pytest.mark.buildconfigspec('cmd_avb')
+@pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc')
 def test_avb_mmc_uuid(u_boot_console):
 """Check if 'avb get_uuid' works, compare results with
 'part list mmc 1' output
@@ -78,6 +78,7 @@ def test_avb_read_rb(u_boot_console):
 assert response == ''
 
 response = u_boot_console.run_command('avb read_rb 1')
+assert response == 'Rollback index: 0'
 
 
 @pytest.mark.buildconfigspec('cmd_avb')
@@ -89,9 +90,10 @@ def test_avb_is_unlocked(u_boot_console):
 assert response == ''
 
 response = u_boot_console.run_command('avb is_unlocked')
+assert response == 'Unlocked = 1'
 
 
-@pytest.mark.buildconfigspec('cmd_avb')
+@pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc')
 def test_avb_mmc_read(u_boot_console):
 """Test mmc read operation
 """
-- 
2.17.1

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


[U-Boot] [PATCH v3 20/20] Kconfig: sandbox: enable cmd_avb and dependencies

2018-09-03 Thread Jens Wiklander
Enables cmd_avb and its dependencies need to run the AVB tests.

Signed-off-by: Jens Wiklander 
---
 arch/Kconfig | 4 
 drivers/fastboot/Kconfig | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8f10f3fc06e8..543362578f50 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -92,6 +92,10 @@ config SANDBOX
imply LZMA
imply SCSI
imply TEE
+   imply AVB_VERIFY
+   imply LIBAVB
+   imply CMD_AVB
+   imply UDP_FUNCTION_FASTBOOT
 
 config SH
bool "SuperH architecture"
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index bc25ea1d9c7a..d63ecdd27e4b 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -35,6 +35,7 @@ config FASTBOOT_BUF_ADDR
ROCKCHIP_RK3399
default 0x28 if ROCKCHIP_RK3368
default 0x10 if ARCH_ZYNQMP
+   default 0 if SANDBOX
help
  The fastboot protocol requires a large memory buffer for
  downloads. Define this to the starting RAM address to use for
@@ -45,6 +46,7 @@ config FASTBOOT_BUF_SIZE
default 0x800 if ARCH_ROCKCHIP
default 0x600 if ARCH_ZYNQMP
default 0x200 if ARCH_SUNXI
+   default 0x8192 if SANDBOX
default 0x700
help
  The fastboot protocol requires a large memory buffer for
-- 
2.17.1

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


[U-Boot] [PATCH v3 16/20] test: tee: test TEE uclass

2018-09-03 Thread Jens Wiklander
Tests the TEE uclass with a sandbox tee driver.

Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 test/dm/Makefile |  1 +
 test/dm/tee.c| 98 
 2 files changed, 99 insertions(+)
 create mode 100644 test/dm/tee.c

diff --git a/test/dm/Makefile b/test/dm/Makefile
index d2ed96c61533..272374b92fb0 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -44,4 +44,5 @@ obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 obj-$(CONFIG_SPMI) += spmi.o
 obj-$(CONFIG_WDT) += wdt.o
+obj-$(CONFIG_TEE) += tee.o
 endif
diff --git a/test/dm/tee.c b/test/dm/tee.c
new file mode 100644
index ..ab1c7da9d2d3
--- /dev/null
+++ b/test/dm/tee.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int open_session(struct udevice *dev, u32 *session)
+{
+   struct tee_open_session_arg arg;
+   const struct tee_optee_ta_uuid uuid = TA_AVB_UUID;
+   int rc;
+
+   memset(, 0, sizeof(arg));
+   tee_optee_ta_uuid_to_octets(arg.uuid, );
+   rc = tee_open_session(dev, , 0, NULL);
+   if (rc)
+   return rc;
+   if (arg.ret)
+   return -EIO;
+   *session = arg.session;
+
+   return 0;
+}
+
+static int invoke_func(struct udevice *dev, u32 session)
+{
+   struct tee_param param = { .attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT };
+   struct tee_invoke_arg arg;
+
+   memset(, 0, sizeof(arg));
+   arg.session = session;
+   arg.func = TA_AVB_CMD_READ_LOCK_STATE;
+
+   if (tee_invoke_func(dev, , 1, ) || arg.ret)
+   return -1;
+
+   return 0;
+}
+
+static int match(struct tee_version_data *vers, const void *data)
+{
+   return vers->gen_caps & TEE_GEN_CAP_GP;
+}
+
+static int dm_test_tee(struct unit_test_state *uts)
+{
+   struct tee_version_data vers;
+   struct udevice *dev;
+   struct sandbox_tee_state *state;
+   u32 session;
+   int rc;
+   u8 data[128];
+   struct tee_shm *reg_shm;
+   struct tee_shm *alloc_shm;
+
+   dev = tee_find_device(NULL, match, NULL, );
+   ut_assert(dev);
+   state = dev_get_priv(dev);
+   ut_assert(!state->session);
+
+   rc = open_session(dev, );
+   ut_assert(!rc);
+   ut_assert(session == state->session);
+
+   rc = invoke_func(dev, session);
+   ut_assert(!rc);
+
+   rc = tee_close_session(dev, session);
+   ut_assert(!rc);
+   ut_assert(!state->session);
+
+   ut_assert(!state->num_shms);
+   rc = tee_shm_register(dev, data, sizeof(data), 0, _shm);
+   ut_assert(!rc);
+   ut_assert(state->num_shms == 1);
+
+   rc = tee_shm_alloc(dev, 256, 0, _shm);
+   ut_assert(!rc);
+   ut_assert(state->num_shms == 2);
+
+   ut_assert(tee_shm_is_registered(reg_shm, dev));
+   ut_assert(tee_shm_is_registered(alloc_shm, dev));
+
+   tee_shm_free(reg_shm);
+   tee_shm_free(alloc_shm);
+   ut_assert(!state->num_shms);
+
+   return 0;
+}
+
+DM_TEST(dm_test_tee, DM_TESTF_SCAN_FDT);
-- 
2.17.1

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


[U-Boot] [PATCH v3 19/20] avb_verify: support sandbox configuration

2018-09-03 Thread Jens Wiklander
With CONFIG_SANDBOX malloc a buffer in get_sector_buf() and return that
instead of returning CONFIG_FASTBOOT_BUF_ADDR since there's no such
buffer reserved.

Signed-off-by: Jens Wiklander 
---
 include/avb_verify.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/avb_verify.h b/include/avb_verify.h
index a532a2331aea..7b95409d247e 100644
--- a/include/avb_verify.h
+++ b/include/avb_verify.h
@@ -76,7 +76,16 @@ static inline size_t get_sector_buf_size(void)
 
 static inline void *get_sector_buf(void)
 {
+#ifdef CONFIG_SANDBOX
+   static void *p;
+
+   if (!p)
+   p = avb_malloc_(get_sector_buf_size());
+
+   return p;
+#else
return (void *)CONFIG_FASTBOOT_BUF_ADDR;
+#endif
 }
 
 static inline bool is_buf_unaligned(void *buffer)
-- 
2.17.1

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


[U-Boot] [PATCH v3 14/20] sandbox: imply CONFIG_TEE (TEE uclass)

2018-09-03 Thread Jens Wiklander
Signed-off-by: Jens Wiklander 
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index bf1b4a9afac6..8f10f3fc06e8 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -91,6 +91,7 @@ config SANDBOX
imply HASH_VERIFY
imply LZMA
imply SCSI
+   imply TEE
 
 config SH
bool "SuperH architecture"
-- 
2.17.1

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


[U-Boot] [PATCH v3 13/20] sandbox: dt: add sandbox_tee node

2018-09-03 Thread Jens Wiklander
Adds a sandbox_tee node to enable the sandbox tee driver in all the
sandbox dts files.

Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 arch/sandbox/dts/sandbox.dts   | 4 
 arch/sandbox/dts/sandbox64.dts | 4 
 arch/sandbox/dts/test.dts  | 4 
 3 files changed, 12 insertions(+)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 9f444c96a9ec..f5c02e5396ff 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -311,6 +311,10 @@
};
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "cros-ec-keyboard.dtsi"
diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts
index 9e65d2fda3d3..0e32fdad9d81 100644
--- a/arch/sandbox/dts/sandbox64.dts
+++ b/arch/sandbox/dts/sandbox64.dts
@@ -311,6 +311,10 @@
};
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "cros-ec-keyboard.dtsi"
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 70356461959d..eee7518be823 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -604,6 +604,10 @@
};
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "sandbox_pmic.dtsi"
-- 
2.17.1

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


[U-Boot] [PATCH v3 12/20] tee: optee: support AVB trusted application

2018-09-03 Thread Jens Wiklander
Adds configuration option OPTEE_TA_AVB and a header file describing the
interface to the Android Verified Boot 2.0 (AVB) trusted application
provided by OP-TEE.

Tested-by: Igor Opaniuk 
Reviewed-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 MAINTAINERS|  1 +
 drivers/tee/optee/Kconfig  | 16 +
 drivers/tee/tee-uclass.c   | 24 +++
 include/tee.h  | 38 ++
 include/tee/optee_ta_avb.h | 48 ++
 5 files changed, 127 insertions(+)
 create mode 100644 include/tee/optee_ta_avb.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7458c606ee92..cb36c45d74ea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -576,6 +576,7 @@ M:  Jens Wiklander 
 S: Maintained
 F: drivers/tee/
 F: include/tee.h
+F: include/tee/
 
 UBI
 M: Kyungmin Park 
diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index 7484e6fea114..dbfa7846a30f 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -9,3 +9,19 @@ config OPTEE
  mechanism. This driver can request services from OP-TEE, but also
  handle Remote Procedure Calls (RPC) from OP-TEE needed to
  execute a service. For more information see: https://www.op-tee.org
+
+if OPTEE
+
+menu "OP-TEE options"
+
+config OPTEE_TA_AVB
+   bool "Support AVB TA"
+   default y
+   help
+ Enables support for the AVB Trusted Application (TA) in OP-TEE.
+ The TA can support the "avb" subcommands "read_rb", "write"rb"
+ and "is_unlocked".
+
+endmenu
+
+endif
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
index 1bee54ebf4af..abb88c0fee53 100644
--- a/drivers/tee/tee-uclass.c
+++ b/drivers/tee/tee-uclass.c
@@ -207,3 +207,27 @@ UCLASS_DRIVER(tee) = {
.pre_probe = tee_pre_probe,
.pre_remove = tee_pre_remove,
 };
+
+void tee_optee_ta_uuid_from_octets(struct tee_optee_ta_uuid *d,
+  const u8 s[TEE_UUID_LEN])
+{
+   d->time_low = ((u32)s[0] << 24) | ((u32)s[1] << 16) |
+ ((u32)s[2] << 8) | s[3],
+   d->time_mid = ((u32)s[4] << 8) | s[5];
+   d->time_hi_and_version = ((u32)s[6] << 8) | s[7];
+   memcpy(d->clock_seq_and_node, s + 8, sizeof(d->clock_seq_and_node));
+}
+
+void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN],
+const struct tee_optee_ta_uuid *s)
+{
+   d[0] = s->time_low >> 24;
+   d[1] = s->time_low >> 16;
+   d[2] = s->time_low >> 8;
+   d[3] = s->time_low;
+   d[4] = s->time_mid >> 8;
+   d[5] = s->time_mid;
+   d[6] = s->time_hi_and_version >> 8;
+   d[7] = s->time_hi_and_version;
+   memcpy(d + 8, s->clock_seq_and_node, sizeof(s->clock_seq_and_node));
+}
diff --git a/include/tee.h b/include/tee.h
index b86dbec257b4..98b1c9cc693a 100644
--- a/include/tee.h
+++ b/include/tee.h
@@ -49,6 +49,22 @@
 #define TEE_ORIGIN_TRUSTED_APP 0x0004
 
 struct udevice;
+
+/**
+ * struct tee_optee_ta_uuid - OP-TEE Trusted Application (TA) UUID format
+ *
+ * Used to identify an OP-TEE TA and define suitable to initialize structs
+ * of this format is distributed with the interface of the TA. The
+ * individual fields of this struct doesn't have any special meaning in
+ * OP-TEE. See RFC4122 for details on the format.
+ */
+struct tee_optee_ta_uuid {
+   u32 time_low;
+   u16 time_mid;
+   u16 time_hi_and_version;
+   u8 clock_seq_and_node[8];
+};
+
 /**
  * struct tee_shm - memory shared with the TEE
  * @dev:   The TEE device
@@ -333,4 +349,26 @@ int tee_close_session(struct udevice *dev, u32 session);
 int tee_invoke_func(struct udevice *dev, struct tee_invoke_arg *arg,
uint num_param, struct tee_param *param);
 
+/**
+ * tee_optee_ta_uuid_from_octets() - Converts to struct tee_optee_ta_uuid
+ * @d: Destination struct
+ * @s: Source UUID octets
+ *
+ * Conversion to a struct tee_optee_ta_uuid represantion from binary octet
+ * representation.
+ */
+void tee_optee_ta_uuid_from_octets(struct tee_optee_ta_uuid *d,
+  const u8 s[TEE_UUID_LEN]);
+
+/**
+ * tee_optee_ta_uuid_to_octets() - Converts from struct tee_optee_ta_uuid
+ * @d: Destination UUID octets
+ * @s: Source struct
+ *
+ * Conversion from a struct tee_optee_ta_uuid represantion to binary octet
+ * representation.
+ */
+void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN],
+const struct tee_optee_ta_uuid *s);
+
 #endif /* __TEE_H */
diff --git a/include/tee/optee_ta_avb.h b/include/tee/optee_ta_avb.h
new file mode 100644
index ..074386af19a1
--- /dev/null
+++ b/include/tee/optee_ta_avb.h
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/* Copyright (c) 2018, Linaro Limited */
+
+#ifndef __TA_AVB_H
+#define __TA_AVB_H
+
+#define TA_AVB_UUID { 0x023f8f1a, 0x292a, 0x432b, \
+ { 0x8f, 0xc4, 0xde, 0x84, 0x71, 

[U-Boot] [PATCH v3 17/20] avb_verify: support using OP-TEE TA AVB

2018-09-03 Thread Jens Wiklander
With CONFIG_OPTEE_TA_AVB use the trusted application AVB provided by
OP-TEE to manage rollback indexes and device lock status.

Signed-off-by: Jens Wiklander 
---
 common/avb_verify.c  | 118 ++-
 doc/README.avb2  |  13 +
 include/avb_verify.h |   4 ++
 3 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/common/avb_verify.c b/common/avb_verify.c
index 3a1282a09204..c2248c92514e 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 const unsigned char avb_root_pub[1032] = {
0x0, 0x0, 0x10, 0x0, 0x55, 0xd9, 0x4, 0xad, 0xd8, 0x4,
@@ -594,6 +596,65 @@ static AvbIOResult validate_vbmeta_public_key(AvbOps *ops,
return AVB_IO_RESULT_OK;
 }
 
+#ifdef CONFIG_OPTEE_TA_AVB
+static int get_open_session(struct AvbOpsData *ops_data)
+{
+   struct udevice *tee = NULL;
+
+   while (!ops_data->tee) {
+   const struct tee_optee_ta_uuid uuid = TA_AVB_UUID;
+   struct tee_open_session_arg arg;
+   int rc;
+
+   tee = tee_find_device(tee, NULL, NULL, NULL);
+   if (!tee)
+   return -ENODEV;
+
+   memset(, 0, sizeof(arg));
+   tee_optee_ta_uuid_to_octets(arg.uuid, );
+   rc = tee_open_session(tee, , 0, NULL);
+   if (!rc) {
+   ops_data->tee = tee;
+   ops_data->session = arg.session;
+   }
+   }
+
+   return 0;
+}
+
+static AvbIOResult invoke_func(struct AvbOpsData *ops_data, u32 func,
+  ulong num_param, struct tee_param *param)
+{
+   struct tee_invoke_arg arg;
+
+   if (get_open_session(ops_data))
+   return AVB_IO_RESULT_ERROR_IO;
+
+   memset(, 0, sizeof(arg));
+   arg.func = func;
+   arg.session = ops_data->session;
+
+   if (tee_invoke_func(ops_data->tee, , num_param, param))
+   return AVB_IO_RESULT_ERROR_IO;
+   switch (arg.ret) {
+   case TEE_SUCCESS:
+   return AVB_IO_RESULT_OK;
+   case TEE_ERROR_OUT_OF_MEMORY:
+   return AVB_IO_RESULT_ERROR_OOM;
+   case TEE_ERROR_TARGET_DEAD:
+   /*
+* The TA has paniced, close the session to reload the TA
+* for the next request.
+*/
+   tee_close_session(ops_data->tee, ops_data->session);
+   ops_data->tee = NULL;
+   return AVB_IO_RESULT_ERROR_IO;
+   default:
+   return AVB_IO_RESULT_ERROR_IO;
+   }
+}
+#endif
+
 /**
  * read_rollback_index() - gets the rollback index corresponding to the
  * location of given by @out_rollback_index.
@@ -609,6 +670,7 @@ static AvbIOResult read_rollback_index(AvbOps *ops,
   size_t rollback_index_slot,
   u64 *out_rollback_index)
 {
+#ifndef CONFIG_OPTEE_TA_AVB
/* For now we always return 0 as the stored rollback index. */
printf("%s not supported yet\n", __func__);
 
@@ -616,6 +678,27 @@ static AvbIOResult read_rollback_index(AvbOps *ops,
*out_rollback_index = 0;
 
return AVB_IO_RESULT_OK;
+#else
+   AvbIOResult rc;
+   struct tee_param param[2];
+
+   if (rollback_index_slot >= TA_AVB_MAX_ROLLBACK_LOCATIONS)
+   return AVB_IO_RESULT_ERROR_NO_SUCH_VALUE;
+
+   memset(param, 0, sizeof(param));
+   param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT;
+   param[0].u.value.a = rollback_index_slot;
+   param[1].attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT;
+
+   rc = invoke_func(ops->user_data, TA_AVB_CMD_READ_ROLLBACK_INDEX,
+ARRAY_SIZE(param), param);
+   if (rc)
+   return rc;
+
+   *out_rollback_index = (u64)param[1].u.value.a << 32 |
+ (u32)param[1].u.value.b;
+   return AVB_IO_RESULT_OK;
+#endif
 }
 
 /**
@@ -633,10 +716,27 @@ static AvbIOResult write_rollback_index(AvbOps *ops,
size_t rollback_index_slot,
u64 rollback_index)
 {
+#ifndef CONFIG_OPTEE_TA_AVB
/* For now this is a no-op. */
printf("%s not supported yet\n", __func__);
 
return AVB_IO_RESULT_OK;
+#else
+   struct tee_param param[2];
+
+   if (rollback_index_slot >= TA_AVB_MAX_ROLLBACK_LOCATIONS)
+   return AVB_IO_RESULT_ERROR_NO_SUCH_VALUE;
+
+   memset(param, 0, sizeof(param));
+   param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT;
+   param[0].u.value.a = rollback_index_slot;
+   param[1].attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT;
+   param[1].u.value.a = (u32)(rollback_index >> 32);
+   param[1].u.value.b = (u32)rollback_index;
+
+   return invoke_func(ops->user_data, TA_AVB_CMD_WRITE_ROLLBACK_INDEX,
+  

[U-Boot] [PATCH v3 15/20] tee: add sandbox driver

2018-09-03 Thread Jens Wiklander
Adds a sandboxtee driver which emulates a generic TEE with the OP-TEE
AVB TA.

Signed-off-by: Jens Wiklander 
---
 drivers/tee/Kconfig   |  12 +-
 drivers/tee/Makefile  |   1 +
 drivers/tee/optee/Kconfig |   2 +-
 drivers/tee/sandbox.c | 299 ++
 include/sandboxtee.h  |  15 ++
 5 files changed, 326 insertions(+), 3 deletions(-)
 create mode 100644 drivers/tee/sandbox.c
 create mode 100644 include/sandboxtee.h

diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
index 835c256e9239..4697b80913d6 100644
--- a/drivers/tee/Kconfig
+++ b/drivers/tee/Kconfig
@@ -1,8 +1,8 @@
 # Generic Trusted Execution Environment Configuration
 config TEE
bool "Trusted Execution Environment support"
-   depends on ARM && (ARM64 || CPU_V7A)
-   select ARM_SMCCC
+   depends on (ARM && (ARM64 || CPU_V7A)) || SANDBOX
+   select ARM_SMCCC if ARM
help
  This implements a generic interface towards a Trusted Execution
  Environment (TEE). A TEE is a trusted OS running in some secure
@@ -14,6 +14,14 @@ if TEE
 
 menu "TEE drivers"
 
+config SANDBOX_TEE
+   bool "Sandbox TEE emulator"
+   depends on SANDBOX
+   default y
+   help
+ This emulates a generic TEE needed for testing including the AVB
+ TA.
+
 source "drivers/tee/optee/Kconfig"
 
 endmenu
diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile
index 19633b60f235..f72c68c09f33 100644
--- a/drivers/tee/Makefile
+++ b/drivers/tee/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += tee-uclass.o
+obj-$(CONFIG_SANDBOX) += sandbox.o
 obj-$(CONFIG_OPTEE) += optee/
diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index dbfa7846a30f..d489834df926 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -10,7 +10,7 @@ config OPTEE
  handle Remote Procedure Calls (RPC) from OP-TEE needed to
  execute a service. For more information see: https://www.op-tee.org
 
-if OPTEE
+if OPTEE || SANDBOX
 
 menu "OP-TEE options"
 
diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
new file mode 100644
index ..cd073497615f
--- /dev/null
+++ b/drivers/tee/sandbox.c
@@ -0,0 +1,299 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Linaro Limited
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * The sandbox tee driver tries to emulate a generic TEE with the TA
+ * OPTEE_TA_AVB available.
+ */
+
+struct ta_entry {
+   struct tee_optee_ta_uuid uuid;
+   u32 (*open_session)(uint num_params, struct tee_param *params);
+   u32 (*invoke_func)(u32 func, uint num_params, struct tee_param *params);
+};
+
+#ifdef CONFIG_OPTEE_TA_AVB
+static u32 get_attr(uint n, uint num_params, struct tee_param *params)
+{
+   if (n >= num_params)
+   return TEE_PARAM_ATTR_TYPE_NONE;
+
+   return params[n].attr;
+}
+
+static u32 check_params(u8 p0, u8 p1, u8 p2, u8 p3, uint num_params,
+   struct tee_param *params)
+{
+   u8 p[] = { p0, p1, p2, p3};
+   uint n;
+
+   for (n = 0; n < ARRAY_SIZE(p); n++)
+   if (p[n] != get_attr(n, num_params, params))
+   goto bad_params;
+
+   for (; n < num_params; n++)
+   if (get_attr(n, num_params, params))
+   goto bad_params;
+
+   return TEE_SUCCESS;
+
+bad_params:
+   printf("Bad param attrs\n");
+
+   return TEE_ERROR_BAD_PARAMETERS;
+}
+
+static u64 ta_avb_rollback_indexes[TA_AVB_MAX_ROLLBACK_LOCATIONS];
+static u32 ta_avb_lock_state;
+
+static u32 ta_avb_open_session(uint num_params, struct tee_param *params)
+{
+   /*
+* We don't expect additional parameters when opening a session to
+* this TA.
+*/
+   return check_params(TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE,
+   TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE,
+   num_params, params);
+}
+
+static u32 ta_avb_invoke_func(u32 func, uint num_params,
+ struct tee_param *params)
+{
+   u32 res;
+   uint slot;
+   u64 val;
+
+   switch (func) {
+   case TA_AVB_CMD_READ_ROLLBACK_INDEX:
+   res = check_params(TEE_PARAM_ATTR_TYPE_VALUE_INPUT,
+  TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT,
+  TEE_PARAM_ATTR_TYPE_NONE,
+  TEE_PARAM_ATTR_TYPE_NONE,
+  num_params, params);
+   if (res)
+   return res;
+
+   slot = params[0].u.value.a;
+   if (slot >= ARRAY_SIZE(ta_avb_rollback_indexes)) {
+   printf("Rollback index slot out of bounds %lu\n", slot);
+   return TEE_ERROR_BAD_PARAMETERS;
+   }
+
+   val = ta_avb_rollback_indexes[slot];
+   

[U-Boot] [PATCH v3 10/20] arm: dt: hikey: Add optee node

2018-09-03 Thread Jens Wiklander
Sync with 14e21cb8f811 ("arm64: dt: hikey: Add optee node"
from Linux kernel.

Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 arch/arm/dts/hi6220-hikey.dts | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/hi6220-hikey.dts b/arch/arm/dts/hi6220-hikey.dts
index 818525197508..24f09257af00 100644
--- a/arch/arm/dts/hi6220-hikey.dts
+++ b/arch/arm/dts/hi6220-hikey.dts
@@ -31,6 +31,13 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x4000>;
};
+
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
 };
 
  {
-- 
2.17.1

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


[U-Boot] [PATCH v3 11/20] optee: support routing of rpmb data frames to mmc

2018-09-03 Thread Jens Wiklander
Adds support in optee supplicant to route signed (MACed) RPMB frames
from OP-TEE Secure OS to MMC and vice versa to manipulate the RPMB
partition.

Tested-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 drivers/tee/optee/Makefile|   1 +
 drivers/tee/optee/core.c  |   8 ++
 drivers/tee/optee/optee_private.h |  55 -
 drivers/tee/optee/rpmb.c  | 181 ++
 drivers/tee/optee/supplicant.c|   3 +
 5 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/tee/optee/rpmb.c

diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile
index 6148feb474a5..928d3f80027f 100644
--- a/drivers/tee/optee/Makefile
+++ b/drivers/tee/optee/Makefile
@@ -2,3 +2,4 @@
 
 obj-y += core.o
 obj-y += supplicant.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 726382da9bb8..7f870f2f735d 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -315,6 +315,13 @@ static u32 do_call_with_arg(struct udevice *dev, struct 
optee_msg_arg *arg)
param.a3 = res.a3;
handle_rpc(dev, , _list);
} else {
+   /*
+* In case we've accessed RPMB to serve an RPC
+* request we need to restore the previously
+* selected partition as the caller may expect it
+* to remain unchanged.
+*/
+   optee_suppl_rpmb_release(dev);
return call_err_to_res(res.a0);
}
}
@@ -651,4 +658,5 @@ U_BOOT_DRIVER(optee) = {
.probe = optee_probe,
.ops = _ops,
.platdata_auto_alloc_size = sizeof(struct optee_pdata),
+   .priv_auto_alloc_size = sizeof(struct optee_private),
 };
diff --git a/drivers/tee/optee/optee_private.h 
b/drivers/tee/optee/optee_private.h
index 35adb83afcc7..9442d1c176bc 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -6,7 +6,60 @@
 #ifndef __OPTEE_PRIVATE_H
 #define __OPTEE_PRIVATE_H
 
+#include 
+#include 
+
+/**
+ * struct optee_private - OP-TEE driver private data
+ * @rpmb_mmc:  mmc device for the RPMB partition
+ * @rpmb_dev_id:   mmc device id matching @rpmb_mmc
+ * @rpmb_original_part:the previosly active partition on the mmc 
device,
+ * used to restore active the partition when the RPMB
+ * accesses are finished
+ */
+struct optee_private {
+   struct mmc *rpmb_mmc;
+   int rpmb_dev_id;
+   int rpmb_original_part;
+};
+
+struct optee_msg_arg;
+
+void optee_suppl_cmd(struct udevice *dev, struct tee_shm *shm_arg,
+void **page_list);
+
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+/**
+ * optee_suppl_cmd_rpmb() - route RPMB frames to mmc
+ * @dev:   device with the selected RPMB partition
+ * @arg:   OP-TEE message holding the frames to transmit to the mmc
+ * and space for the response frames.
+ *
+ * Routes signed (MACed) RPMB frames from OP-TEE Secure OS to MMC and vice
+ * versa to manipulate the RPMB partition.
+ */
+void optee_suppl_cmd_rpmb(struct udevice *dev, struct optee_msg_arg *arg);
+
+/**
+ * optee_suppl_rpmb_release() - release mmc device
+ * @dev:   mmc device
+ *
+ * Releases the mmc device and restores the previously selected partition.
+ */
+void optee_suppl_rpmb_release(struct udevice *dev);
+#else
+static inline void optee_suppl_cmd_rpmb(struct udevice *dev,
+   struct optee_msg_arg *arg)
+{
+   debug("OPTEE_MSG_RPC_CMD_RPMB not implemented\n");
+   arg->ret = TEE_ERROR_NOT_IMPLEMENTED;
+}
+
+static inline void optee_suppl_rpmb_release(struct udevice *dev)
+{
+}
+#endif
+
 void *optee_alloc_and_init_page_list(void *buf, ulong len, u64 *phys_buf_ptr);
-void optee_suppl_cmd(struct udevice *dev, void *shm, void **page_list);
 
 #endif /* __OPTEE_PRIVATE_H */
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
new file mode 100644
index ..955155b3f8b1
--- /dev/null
+++ b/drivers/tee/optee/rpmb.c
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2018 Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "optee_msg.h"
+#include "optee_private.h"
+
+/*
+ * Request and response definitions must be in sync with the secure side of
+ * OP-TEE.
+ */
+
+/* Request */
+struct rpmb_req {
+   u16 cmd;
+#define RPMB_CMD_DATA_REQ  0x00
+#define RPMB_CMD_GET_DEV_INFO  0x01
+   u16 dev_id;
+   u16 block_count;
+   /* Optional data frames (rpmb_data_frame) follow */
+};
+
+#define RPMB_REQ_DATA(req) ((void *)((struct rpmb_req *)(req) + 1))
+
+/* Response to device info request */
+struct rpmb_dev_info {
+   u8 cid[16];
+   u8 rpmb_size_mult;  /* EXT CSD-slice 168: RPMB Size */
+   

[U-Boot] [PATCH v3 06/20] Add UCLASS_TEE for Trusted Execution Environment

2018-09-03 Thread Jens Wiklander
Adds a uclass to interface with a TEE (Trusted Execution Environment).

A TEE driver is a driver that interfaces with a trusted OS running in
some secure environment, for example, TrustZone on ARM cpus, or a
separate secure co-processor etc.

The TEE subsystem can serve a TEE driver for a Global Platform compliant
TEE, but it's not limited to only Global Platform TEEs.

The over all design is based on the TEE subsystem in the Linux kernel,
tailored for U-Boot.

Reviewed-by: Simon Glass 
Tested-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 MAINTAINERS  |   6 +
 drivers/Kconfig  |   2 +
 drivers/Makefile |   1 +
 drivers/tee/Kconfig  |  11 ++
 drivers/tee/Makefile |   3 +
 drivers/tee/tee-uclass.c | 209 
 include/dm/uclass-id.h   |   1 +
 include/tee.h| 336 +++
 8 files changed, 569 insertions(+)
 create mode 100644 drivers/tee/Kconfig
 create mode 100644 drivers/tee/Makefile
 create mode 100644 drivers/tee/tee-uclass.c
 create mode 100644 include/tee.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 58b61ac05882..7458c606ee92 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -571,6 +571,12 @@ TQ GROUP
 S: Orphaned (Since 2016-02)
 T: git git://git.denx.de/u-boot-tq-group.git
 
+TEE
+M: Jens Wiklander 
+S: Maintained
+F: drivers/tee/
+F: include/tee.h
+
 UBI
 M: Kyungmin Park 
 M: Heiko Schocher 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index c72abf893297..f3249ab1d143 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -94,6 +94,8 @@ source "drivers/spmi/Kconfig"
 
 source "drivers/sysreset/Kconfig"
 
+source "drivers/tee/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/timer/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index d53208540ea6..0fcae36f50f7 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -103,6 +103,7 @@ obj-y += smem/
 obj-y += soc/
 obj-$(CONFIG_REMOTEPROC) += remoteproc/
 obj-y += thermal/
+obj-$(CONFIG_TEE) += tee/
 
 obj-$(CONFIG_MACH_PIC32) += ddr/microchip/
 endif
diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
new file mode 100644
index ..f3fc3c2ca790
--- /dev/null
+++ b/drivers/tee/Kconfig
@@ -0,0 +1,11 @@
+# Generic Trusted Execution Environment Configuration
+config TEE
+   bool "Trusted Execution Environment support"
+   depends on ARM && (ARM64 || CPU_V7A)
+   select ARM_SMCCC
+   help
+ This implements a generic interface towards a Trusted Execution
+ Environment (TEE). A TEE is a trusted OS running in some secure
+ environment, for example, TrustZone on ARM cpus, or a separate
+ secure co-processor etc. See also:
+ https://en.wikipedia.org/wiki/Trusted_execution_environment
diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile
new file mode 100644
index ..b6d8e16e6211
--- /dev/null
+++ b/drivers/tee/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += tee-uclass.o
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
new file mode 100644
index ..1bee54ebf4af
--- /dev/null
+++ b/drivers/tee/tee-uclass.c
@@ -0,0 +1,209 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * struct tee_uclass_priv - information of a TEE, stored by the uclass
+ *
+ * @list_shm:  list of structe tee_shm representing memory blocks shared
+ * with the TEE.
+ */
+struct tee_uclass_priv {
+   struct list_head list_shm;
+};
+
+static const struct tee_driver_ops *tee_get_ops(struct udevice *dev)
+{
+   return device_get_ops(dev);
+}
+
+void tee_get_version(struct udevice *dev, struct tee_version_data *vers)
+{
+   tee_get_ops(dev)->get_version(dev, vers);
+}
+
+int tee_open_session(struct udevice *dev, struct tee_open_session_arg *arg,
+uint num_param, struct tee_param *param)
+{
+   return tee_get_ops(dev)->open_session(dev, arg, num_param, param);
+}
+
+int tee_close_session(struct udevice *dev, u32 session)
+{
+   return tee_get_ops(dev)->close_session(dev, session);
+}
+
+int tee_invoke_func(struct udevice *dev, struct tee_invoke_arg *arg,
+   uint num_param, struct tee_param *param)
+{
+   return tee_get_ops(dev)->invoke_func(dev, arg, num_param, param);
+}
+
+int __tee_shm_add(struct udevice *dev, ulong align, void *addr, ulong size,
+ u32 flags, struct tee_shm **shmp)
+{
+   struct tee_shm *shm;
+   void *p = addr;
+   int rc;
+
+   if (flags & TEE_SHM_ALLOC) {
+   if (align)
+   p = memalign(align, size);
+   else
+   p = malloc(size);
+   }
+   if (!p)
+   return -ENOMEM;
+
+   shm = calloc(1, sizeof(*shm));
+   if (!shm) {
+   rc = -ENOMEM;
+   goto err;
+   }
+
+   

[U-Boot] [PATCH v3 09/20] Documentation: tee uclass and op-tee driver

2018-09-03 Thread Jens Wiklander
Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 doc/README.tee | 112 +
 1 file changed, 112 insertions(+)
 create mode 100644 doc/README.tee

diff --git a/doc/README.tee b/doc/README.tee
new file mode 100644
index ..79e7996a6f5f
--- /dev/null
+++ b/doc/README.tee
@@ -0,0 +1,112 @@
+=
+TEE uclass
+=
+
+This document describes the TEE uclass in U-Boot
+
+A TEE (Trusted Execution Environment) is a trusted OS running in some
+secure environment, for example, TrustZone on ARM CPUs, or a separate
+secure co-processor etc. A TEE driver handles the details needed to
+communicate with the TEE.
+
+This uclass deals with:
+
+- Registration of TEE drivers
+
+- Managing shared memory between U-Boot and the TEE
+
+- Providing a generic API to the TEE
+
+The TEE interface
+=
+
+include/tee.h defines the generic interface to a TEE.
+
+A client finds the TEE device via tee_find_device(). Other important functions
+when interfacing with a TEE are:
+
+- tee_shm_alloc(), tee_shm_register() and tee_shm_free() to manage shared
+  memory objects often needed when communicating with the TEE.
+
+- tee_get_version() lets the client know which the capabilities of the TEE
+  device.
+
+- tee_open_session() opens a session to a Trusted Application
+
+- tee_invoke_func() invokes a function in a Trusted Application
+
+- tee_close_session() closes a session to a Trusted Application
+
+Much of the communication between clients and the TEE is opaque to the
+driver. The main job for the driver is to receive requests from the
+clients, forward them to the TEE and send back the results.
+
+OP-TEE driver
+=
+
+The OP-TEE driver handles OP-TEE [1] based TEEs. Currently it is only the ARM
+TrustZone based OP-TEE solution that is supported.
+
+Lowest level of communication with OP-TEE builds on ARM SMC Calling
+Convention (SMCCC) [2], which is the foundation for OP-TEE's SMC interface
+[3] used internally by the driver. Stacked on top of that is OP-TEE Message
+Protocol [4].
+
+OP-TEE SMC interface provides the basic functions required by SMCCC and some
+additional functions specific for OP-TEE. The most interesting functions are:
+
+- OPTEE_SMC_FUNCID_CALLS_UID (part of SMCCC) returns the version information
+  which is then returned by TEE_IOC_VERSION
+
+- OPTEE_SMC_CALL_GET_OS_UUID returns the particular OP-TEE implementation, used
+  to tell, for instance, a TrustZone OP-TEE apart from an OP-TEE running on a
+  separate secure co-processor.
+
+- OPTEE_SMC_CALL_WITH_ARG drives the OP-TEE message protocol
+
+- OPTEE_SMC_GET_SHM_CONFIG lets the driver and OP-TEE agree on which memory
+  range to used for shared memory between Linux and OP-TEE.
+
+The GlobalPlatform TEE Client API [5] is implemented on top of the generic
+TEE API.
+
+Picture of the relationship between the different components in the
+OP-TEE architecture:
+
+   U-Boot  Secure world
+   ~~  
+ ++   +-+
+ | Client |   | Trusted |
+ ||   | Application |
+ ++   +-+
+   /\   /\
+   ||   ||
+   \/   \/
+ ++   +-+
+ | TEE|   | TEE Internal|
+ | uclass |   | API |
+ ++   +-+
+ | OP-TEE |   | OP-TEE  |
+ | driver |   | Trusted OS  |
+ ++---+-+
+ | OP-TEE MSG   |
+ |  SMCCC (OPTEE_SMC_CALL_*)|
+ +--+
+
+RPC (Remote Procedure Call) are requests from secure world to the driver.
+An RPC is identified by a special range of SMCCC return values from
+OPTEE_SMC_CALL_WITH_ARG.
+
+References
+==
+
+[1] https://github.com/OP-TEE/optee_os
+
+[2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
+
+[3] drivers/tee/optee/optee_smc.h
+
+[4] drivers/tee/optee/optee_msg.h
+
+[5] http://www.globalplatform.org/specificationsdevice.asp look for
+"TEE Client API Specification v1.0" and click download.
-- 
2.17.1

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


[U-Boot] [PATCH v3 08/20] tee: add OP-TEE driver

2018-09-03 Thread Jens Wiklander
Adds a OP-TEE driver.

* Targets ARM and ARM64
* Supports using any U-Boot memory as shared memory
* Probes OP-TEE version using SMCs
* Uses OPTEE message protocol version 2 to communicate with secure world

Reviewed-by: Simon Glass 
Tested-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 drivers/tee/Kconfig  |  10 +
 drivers/tee/Makefile |   1 +
 drivers/tee/optee/Kconfig|  11 +
 drivers/tee/optee/Makefile   |   4 +
 drivers/tee/optee/core.c | 654 +++
 drivers/tee/optee/optee_msg.h| 425 +++
 drivers/tee/optee/optee_msg_supplicant.h | 240 +
 drivers/tee/optee/optee_private.h|  12 +
 drivers/tee/optee/optee_smc.h| 450 
 drivers/tee/optee/supplicant.c   |  93 
 10 files changed, 1900 insertions(+)
 create mode 100644 drivers/tee/optee/Kconfig
 create mode 100644 drivers/tee/optee/Makefile
 create mode 100644 drivers/tee/optee/core.c
 create mode 100644 drivers/tee/optee/optee_msg.h
 create mode 100644 drivers/tee/optee/optee_msg_supplicant.h
 create mode 100644 drivers/tee/optee/optee_private.h
 create mode 100644 drivers/tee/optee/optee_smc.h
 create mode 100644 drivers/tee/optee/supplicant.c

diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
index f3fc3c2ca790..835c256e9239 100644
--- a/drivers/tee/Kconfig
+++ b/drivers/tee/Kconfig
@@ -9,3 +9,13 @@ config TEE
  environment, for example, TrustZone on ARM cpus, or a separate
  secure co-processor etc. See also:
  https://en.wikipedia.org/wiki/Trusted_execution_environment
+
+if TEE
+
+menu "TEE drivers"
+
+source "drivers/tee/optee/Kconfig"
+
+endmenu
+
+endif
diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile
index b6d8e16e6211..19633b60f235 100644
--- a/drivers/tee/Makefile
+++ b/drivers/tee/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += tee-uclass.o
+obj-$(CONFIG_OPTEE) += optee/
diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
new file mode 100644
index ..7484e6fea114
--- /dev/null
+++ b/drivers/tee/optee/Kconfig
@@ -0,0 +1,11 @@
+# OP-TEE Trusted Execution Environment Configuration
+config OPTEE
+   bool "OP-TEE"
+   depends on ARM_SMCCC
+   help
+ This implements the OP-TEE Trusted Execution Environment (TEE)
+ driver. OP-TEE is a Trusted OS designed primarily to rely on the
+ ARM TrustZone(R) technology as the underlying hardware isolation
+ mechanism. This driver can request services from OP-TEE, but also
+ handle Remote Procedure Calls (RPC) from OP-TEE needed to
+ execute a service. For more information see: https://www.op-tee.org
diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile
new file mode 100644
index ..6148feb474a5
--- /dev/null
+++ b/drivers/tee/optee/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += core.o
+obj-y += supplicant.o
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
new file mode 100644
index ..726382da9bb8
--- /dev/null
+++ b/drivers/tee/optee/core.c
@@ -0,0 +1,654 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "optee_smc.h"
+#include "optee_msg.h"
+#include "optee_private.h"
+
+#define PAGELIST_ENTRIES_PER_PAGE \
+   ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
+
+typedef void (optee_invoke_fn)(unsigned long, unsigned long, unsigned long,
+  unsigned long, unsigned long, unsigned long,
+  unsigned long, unsigned long,
+  struct arm_smccc_res *);
+
+struct optee_pdata {
+   optee_invoke_fn *invoke_fn;
+};
+
+struct rpc_param {
+   u32 a0;
+   u32 a1;
+   u32 a2;
+   u32 a3;
+   u32 a4;
+   u32 a5;
+   u32 a6;
+   u32 a7;
+};
+
+/**
+ * reg_pair_to_ptr() - Make a pointer of 2 32-bit values
+ * @reg0:  High bits of the pointer
+ * @reg1:  Low bits of the pointer
+ *
+ * Returns the combined result, note that if a pointer is 32-bit wide @reg0
+ * will be discarded.
+ */
+static void *reg_pair_to_ptr(u32 reg0, u32 reg1)
+{
+   return (void *)(ulong)(((u64)reg0 << 32) | reg1);
+}
+
+/**
+ * reg_pair_from_64() - Split a 64-bit value into two 32-bit values
+ * @reg0:  High bits of @val
+ * @reg1:  Low bits of @val
+ * @val:   The value to split
+ */
+static void reg_pair_from_64(u32 *reg0, u32 *reg1, u64 val)
+{
+   *reg0 = val >> 32;
+   *reg1 = val;
+}
+
+/**
+ * optee_alloc_and_init_page_list() - Provide page list of memory buffer
+ * @buf:   Start of buffer
+ * @len:   Length of buffer
+ * @phys_buf_ptr   Physical pointer with coded offset to page list
+ *
+ * Secure world 

[U-Boot] [PATCH v3 07/20] dt/bindings: add bindings for optee

2018-09-03 Thread Jens Wiklander
Sync with c8bfafb15944 ("dt/bindings: add bindings for optee")
from Linux kernel.

Introduces linaro prefix and adds bindings for ARM TrustZone based OP-TEE
implementation.

Signed-off-by: Jens Wiklander 
---
 .../firmware/linaro,optee-tz.txt  | 31 +++
 1 file changed, 31 insertions(+)
 create mode 100644 doc/device-tree-bindings/firmware/linaro,optee-tz.txt

diff --git a/doc/device-tree-bindings/firmware/linaro,optee-tz.txt 
b/doc/device-tree-bindings/firmware/linaro,optee-tz.txt
new file mode 100644
index ..d38834c67dff
--- /dev/null
+++ b/doc/device-tree-bindings/firmware/linaro,optee-tz.txt
@@ -0,0 +1,31 @@
+OP-TEE Device Tree Bindings
+
+OP-TEE is a piece of software using hardware features to provide a Trusted
+Execution Environment. The security can be provided with ARM TrustZone, but
+also by virtualization or a separate chip.
+
+We're using "linaro" as the first part of the compatible property for
+the reference implementation maintained by Linaro.
+
+* OP-TEE based on ARM TrustZone required properties:
+
+- compatible : should contain "linaro,optee-tz"
+
+- method : The method of calling the OP-TEE Trusted OS. Permitted
+   values are:
+
+   "smc" : SMC #0, with the register assignments specified
+  in drivers/tee/optee/optee_smc.h
+
+   "hvc" : HVC #0, with the register assignments specified
+  in drivers/tee/optee/optee_smc.h
+
+
+
+Example:
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
-- 
2.17.1

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


[U-Boot] [PATCH v3 05/20] mmc: rpmb: add mmc_rpmb_route_frames()

2018-09-03 Thread Jens Wiklander
Adds mmc_rpmb_route_frames() to route RPMB data frames from/to an
external entity.

Tested-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 drivers/mmc/rpmb.c | 160 +
 include/mmc.h  |   2 +
 2 files changed, 162 insertions(+)

diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
index dfbdb0deb107..908f19208955 100644
--- a/drivers/mmc/rpmb.c
+++ b/drivers/mmc/rpmb.c
@@ -321,3 +321,163 @@ int mmc_rpmb_write(struct mmc *mmc, void *addr, unsigned 
short blk,
}
return i;
 }
+
+static int send_write_mult_block(struct mmc *mmc, const struct s_rpmb *frm,
+unsigned short cnt)
+{
+   struct mmc_cmd cmd = {
+   .cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK,
+   .resp_type = MMC_RSP_R1b,
+   };
+   struct mmc_data data = {
+   .src = (const void *)frm,
+   .blocks = cnt,
+   .blocksize = sizeof(*frm),
+   .flags = MMC_DATA_WRITE,
+   };
+
+   return mmc_send_cmd(mmc, , );
+}
+
+static int send_read_mult_block(struct mmc *mmc, struct s_rpmb *frm,
+   unsigned short cnt)
+{
+   struct mmc_cmd cmd = {
+   .cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK,
+   .resp_type = MMC_RSP_R1,
+   };
+   struct mmc_data data = {
+   .dest = (void *)frm,
+   .blocks = cnt,
+   .blocksize = sizeof(*frm),
+   .flags = MMC_DATA_READ,
+   };
+
+   return mmc_send_cmd(mmc, , );
+}
+
+static int rpmb_route_write_req(struct mmc *mmc, struct s_rpmb *req,
+   unsigned short req_cnt, struct s_rpmb *rsp,
+   unsigned short rsp_cnt)
+{
+   int ret;
+
+   /*
+* Send the write request.
+*/
+   ret = mmc_set_blockcount(mmc, req_cnt, true);
+   if (ret)
+   return ret;
+
+   ret = send_write_mult_block(mmc, req, req_cnt);
+   if (ret)
+   return ret;
+
+   /*
+* Read the result of the request.
+*/
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret)
+   return ret;
+
+   memset(rsp, 0, sizeof(*rsp));
+   rsp->request = cpu_to_be16(RPMB_REQ_STATUS);
+   ret = send_write_mult_block(mmc, rsp, 1);
+   if (ret)
+   return ret;
+
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret)
+   return ret;
+
+   return send_read_mult_block(mmc, rsp, 1);
+}
+
+static int rpmb_route_read_req(struct mmc *mmc, struct s_rpmb *req,
+  unsigned short req_cnt, struct s_rpmb *rsp,
+  unsigned short rsp_cnt)
+{
+   int ret;
+
+   /*
+* Send the read request.
+*/
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret)
+   return ret;
+
+   ret = send_write_mult_block(mmc, req, 1);
+   if (ret)
+   return ret;
+
+   /*
+* Read the result of the request.
+*/
+
+   ret = mmc_set_blockcount(mmc, rsp_cnt, false);
+   if (ret)
+   return ret;
+
+   return send_read_mult_block(mmc, rsp, rsp_cnt);
+}
+
+static int rpmb_route_frames(struct mmc *mmc, struct s_rpmb *req,
+unsigned short req_cnt, struct s_rpmb *rsp,
+unsigned short rsp_cnt)
+{
+   unsigned short n;
+
+   /*
+* If multiple request frames are provided, make sure that all are
+* of the same type.
+*/
+   for (n = 1; n < req_cnt; n++)
+   if (req[n].request != req->request)
+   return -EINVAL;
+
+   switch (be16_to_cpu(req->request)) {
+   case RPMB_REQ_KEY:
+   if (req_cnt != 1 || rsp_cnt != 1)
+   return -EINVAL;
+   return rpmb_route_write_req(mmc, req, req_cnt, rsp, rsp_cnt);
+
+   case RPMB_REQ_WRITE_DATA:
+   if (!req_cnt || rsp_cnt != 1)
+   return -EINVAL;
+   return rpmb_route_write_req(mmc, req, req_cnt, rsp, rsp_cnt);
+
+   case RPMB_REQ_WCOUNTER:
+   if (req_cnt != 1 || rsp_cnt != 1)
+   return -EINVAL;
+   return rpmb_route_read_req(mmc, req, req_cnt, rsp, rsp_cnt);
+
+   case RPMB_REQ_READ_DATA:
+   if (req_cnt != 1 || !req_cnt)
+   return -EINVAL;
+   return rpmb_route_read_req(mmc, req, req_cnt, rsp, rsp_cnt);
+
+   default:
+   debug("Unsupported message type: %d\n",
+ be16_to_cpu(req->request));
+   return -EINVAL;
+   }
+}
+
+int mmc_rpmb_route_frames(struct mmc *mmc, void *req, unsigned long reqlen,
+ void *rsp, unsigned long rsplen)
+{
+   /*
+* Whoever crafted the data supplied to this function knows how to
+* format 

[U-Boot] [PATCH v3 04/20] avb_verify: bugfix avb_ops_free() skipping free

2018-09-03 Thread Jens Wiklander
Before this patch avb_ops_free() was returning early if supplied "ops"
argument was not NULL. This patch fixes this by inverting the condition.

Signed-off-by: Jens Wiklander 
---
 common/avb_verify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/avb_verify.c b/common/avb_verify.c
index 20e35ade3029..3a1282a09204 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -732,7 +732,7 @@ void avb_ops_free(AvbOps *ops)
 {
struct AvbOpsData *ops_data;
 
-   if (ops)
+   if (!ops)
return;
 
ops_data = ops->user_data;
-- 
2.17.1

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


[U-Boot] [PATCH v3 03/20] cmd: avb: print error message if command fails

2018-09-03 Thread Jens Wiklander
Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 cmd/avb.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/cmd/avb.c b/cmd/avb.c
index ca4b26d5d7b3..ff00be4cee38 100644
--- a/cmd/avb.c
+++ b/cmd/avb.c
@@ -35,6 +35,8 @@ int do_avb_init(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
if (avb_ops)
return CMD_RET_SUCCESS;
 
+   printf("Failed to initialize avb2\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -65,6 +67,8 @@ int do_avb_read_part(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_SUCCESS;
}
 
+   printf("Failed to read from partition\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -108,6 +112,8 @@ int do_avb_read_part_hex(cmd_tbl_t *cmdtp, int flag, int 
argc,
return CMD_RET_SUCCESS;
}
 
+   printf("Failed to read from partition\n");
+
free(buffer);
return CMD_RET_FAILURE;
 }
@@ -138,6 +144,8 @@ int do_avb_write_part(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_SUCCESS;
}
 
+   printf("Failed to write in partition\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -161,6 +169,9 @@ int do_avb_read_rb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
printf("Rollback index: %llx\n", rb_idx);
return CMD_RET_SUCCESS;
}
+
+   printf("Failed to read rollback index\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -184,6 +195,8 @@ int do_avb_write_rb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
AVB_IO_RESULT_OK)
return CMD_RET_SUCCESS;
 
+   printf("Failed to write rollback index\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -210,6 +223,8 @@ int do_avb_get_uuid(cmd_tbl_t *cmdtp, int flag,
return CMD_RET_SUCCESS;
}
 
+   printf("Failed to read UUID\n");
+
return CMD_RET_FAILURE;
 }
 
@@ -320,6 +335,8 @@ int do_avb_is_unlocked(cmd_tbl_t *cmdtp, int flag,
return CMD_RET_SUCCESS;
}
 
+   printf("Can't determine device lock state.\n");
+
return CMD_RET_FAILURE;
 }
 
-- 
2.17.1

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


[U-Boot] [PATCH v3 02/20] cmd: avb read_rb: print rb_idx in hexadecimal

2018-09-03 Thread Jens Wiklander
Prior to this patch was do_avb_write_rb() reading supplied rb_idx as a
hexadecimal number while do_avb_read_rb() printed the read out rb_idx as
decimal number. For consistency change do_avb_read_rb() to print rb_idx
as a hexadecimal number too.

Reviewed-by: Simon Glass 
Reviewed-by: Igor Opaniuk 
Signed-off-by: Jens Wiklander 
---
 cmd/avb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/avb.c b/cmd/avb.c
index f045a0c64c4a..ca4b26d5d7b3 100644
--- a/cmd/avb.c
+++ b/cmd/avb.c
@@ -158,7 +158,7 @@ int do_avb_read_rb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
if (avb_ops->read_rollback_index(avb_ops, index, _idx) ==
AVB_IO_RESULT_OK) {
-   printf("Rollback index: %llu\n", rb_idx);
+   printf("Rollback index: %llx\n", rb_idx);
return CMD_RET_SUCCESS;
}
return CMD_RET_FAILURE;
-- 
2.17.1

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


[U-Boot] [PATCH v3 01/20] dm: fdt: scan for devices under /firmware too

2018-09-03 Thread Jens Wiklander
Just as /chosen may contain devices /firmware may contain devices, scan
for devices under /firmware too.

Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 drivers/core/root.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 72bcc7d7f2a3..0dca507e1187 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -265,9 +265,15 @@ static int dm_scan_fdt_node(struct udevice *parent, const 
void *blob,
for (offset = fdt_first_subnode(blob, offset);
 offset > 0;
 offset = fdt_next_subnode(blob, offset)) {
-   /* "chosen" node isn't a device itself but may contain some: */
-   if (!strcmp(fdt_get_name(blob, offset, NULL), "chosen")) {
-   pr_debug("parsing subnodes of \"chosen\"\n");
+   const char *node_name = fdt_get_name(blob, offset, NULL);
+
+   /*
+* The "chosen" and "firmware" nodes aren't devices
+* themselves but may contain some:
+*/
+   if (!strcmp(node_name, "chosen") ||
+   !strcmp(node_name, "firmware")) {
+   pr_debug("parsing subnodes of \"%s\"\n", node_name);
 
err = dm_scan_fdt_node(parent, blob, offset,
   pre_reloc_only);
@@ -286,8 +292,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const 
void *blob,
err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL);
if (err && !ret) {
ret = err;
-   debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),
- ret);
+   debug("%s: ret=%d\n", node_name, ret);
}
}
 
-- 
2.17.1

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


[U-Boot] [PATCH v3 00/20] AVB using OP-TEE

2018-09-03 Thread Jens Wiklander
Hi,

This adds support for storing AVB rollback indexes in the RPMB partition.
The RPMB partition (content and key) is managed by OP-TEE
(https://www.op-tee.org/) which is a secure OS leveraging ARM TrustZone.

The Linux kernel can already support OP-TEE with reading and updating
rollback indexes in the RPMB partition, the catch is that this is needed
before the kernel has booted.

The design here is the same as what is in the Linux kernel, with the
exception that the user space daemon tee-supplicant is integrated in the
OP-TEE driver here (drivers/tee/optee/supplicant.c) instead. A new uclass
(UCLASS_TEE) is introduced to provide an abstraction for interfacing with a
Trusted Execution Environment (TEE). There's also the OP-TEE driver using
UCLASS_TEE for registration.

A Trusted Application (TA) interface is added to be used by the AVB verify
functions which are updated accordingly. The TA is managed by OP-TEE and is
executed in a secure TrustZone protected environment.

The header files drivers/tee/optee/optee_{msg,msg_supplicant,smc}.h and
include/tee/optee_ta_avb.h are copied from
https://github.com/OP-TEE/optee_os/tree/master more or less unmodified.
They may need to be updated from time to time in order to support new
features.

In MMC there's a new function, mmc_rpmb_route_frames(), which as the name
suggests is used to route RPMB frames to/from the MMC. This saves OP-TEE
from implementing an MMC driver which would need to share resources with
its counterpart here in U-Boot.

This was tested on a Hikey (Kirin 620) board.

I've added myself as maintainer of the TEE stuff.

changes in v3:
* Addressed review comments from Simon Glass
* A few new patches
  - "avb_verify: bugfix avb_ops_free() skipping free"
  - "tee: add sandbox driver"
  - "test_avb: Update pymark.buildconfigspec information for the AVB tests"
  - "avb_verify: support sandbox configuration"
  - "Kconfig: sandbox: enable cmd_avb and dependencies"
* "sandbox: imply CONFIG_TEE (TEE uclass)", replacing
  "configs: sandbox: enable CONFIG_TEE (TEE uclass)"
* Moved sandbox driver to drivers/tee and added code to emulate the AVB TA
* Enabled a few AVB tests (test/py/tests/test_avb.py) for sandbox
* Bugfix tee_find_device()
* Commits "dm: fdt: scan for devices under /firmware too",
  "cmd: avb read_rb: print rb_idx in hexadecimal",
  "cmd: avb: print error message if command fails",
  "Add UCLASS_TEE for Trusted Execution Environment",
  "tee: add OP-TEE driver",
  "Documentation: tee uclass and op-tee driver",
  "test: tee: test TEE uclass",
  "arm: dt: hikey: Add optee node" and
  "sandbox: dt: add sandbox_tee node"
  Reviewed-by: Simon Glass 

changes in v2:
* Added sandbox driver and a test in test/dm for the new TEE uclass:
  Commit ("test: tee: test TEE uclass") and the enabling commits
  ("sandbox: dt: add sandbox_tee node") and
  ("configs: sandbox: enable CONFIG_TEE (TEE uclass)")
* Added descriptions of exported structs and functions
* Added documentation for the TEE uclass and the OP-TEE driver with
  the new commit ("Documentation: tee uclass and op-tee driver")
* Added documentation for the changes in avb_verify
* Addressed review comments from Simon Glass
* Added the commit ("cmd: avb: print error message if command fails")
* Made a few functions static in the OP-TEE driver
* Commit ("cmd: avb read_rb: print rb_idx in hexadecimal") and
  ("tee: optee: support AVB trusted application");
  Reviewed-by: Igor Opaniuk 

Thanks,
Jens

Jens Wiklander (20):
  dm: fdt: scan for devices under /firmware too
  cmd: avb read_rb: print rb_idx in hexadecimal
  cmd: avb: print error message if command fails
  avb_verify: bugfix avb_ops_free() skipping free
  mmc: rpmb: add mmc_rpmb_route_frames()
  Add UCLASS_TEE for Trusted Execution Environment
  dt/bindings: add bindings for optee
  tee: add OP-TEE driver
  Documentation: tee uclass and op-tee driver
  arm: dt: hikey: Add optee node
  optee: support routing of rpmb data frames to mmc
  tee: optee: support AVB trusted application
  sandbox: dt: add sandbox_tee node
  sandbox: imply CONFIG_TEE (TEE uclass)
  tee: add sandbox driver
  test: tee: test TEE uclass
  avb_verify: support using OP-TEE TA AVB
  test_avb: Update pymark.buildconfigspec information for the AVB tests
  avb_verify: support sandbox configuration
  Kconfig: sandbox: enable cmd_avb and dependencies

 MAINTAINERS   |   7 +
 arch/Kconfig  |   5 +
 arch/arm/dts/hi6220-hikey.dts |   7 +
 arch/sandbox/dts/sandbox.dts  |   4 +
 arch/sandbox/dts/sandbox64.dts|   4 +
 arch/sandbox/dts/test.dts |   4 +
 cmd/avb.c |  19 +-
 common/avb_verify.c   | 120 +++-
 doc/README.avb2   |  13 +
 doc/README.tee| 112 +++
 .../firmware/linaro,optee-tz.txt  |  31 +
 drivers/Kconfig 

Re: [U-Boot] [PATCH 1/9] dm: allow 4GB of DRAM on 32bit systems

2018-09-03 Thread Lokesh Vutla


On Sunday 02 September 2018 11:19 PM, Alexander Graf wrote:
> 
> 
>> Am 02.09.2018 um 18:04 schrieb Vagrant Cascadian :
>>
>>> On 2018-09-02, Alexander Graf  wrote:
 On 02.08.18 23:31, Dr. Philipp Tomsich wrote:

> On 2 Aug 2018, at 22:36, Simon Glass  wrote:
>
> On 26 July 2018 at 07:59, Philipp Tomsich
>  > wrote:
>> Even on 32bit systems a full 4GB of DRAM may be installed and reported
>> by the DRAM controller.  Whether these 4GB are larger available
>> depends on the size/configuration of address decoding windows and
>> architectural features (e.g. consider a hypothetical architecture that
>> uses dedicated instructions to access the 'memory-mapped' peripheral
>> IO ranges).  In U-Boot, the available DRAM, as reported by the
>> device-model is independent of the accessible DRAM (i.e. adjusted top
>> and effective size).
>>
>> This was first reported against the RK3288, which may have 4GB DRAM
>> attached, but will have a small (e.g. 128MB) window not accessible due
>> to address decoding limitations.
>>
>> The solution is to increase the types used for storing the ram_size to
>> have at least 33 bits even on 32bit systems... i.e. we need to use a
>> u64 for these always (this was previously only the case for
>> PHYS_64BIT, which will have unwanted side-effects for 32bit systems
>> and would require more intrusive changes).
>>
>> This commit changes the size-field in 'struct ram' and the ram_size in
>> 'gd' to be a u64.
>>
>> Reported-by: Marty E. Plummer 
>> Signed-off-by: Philipp Tomsich 
>> ---
>>
>> include/asm-generic/global_data.h | 2 +-
>> include/ram.h | 9 -
>> 2 files changed, 9 insertions(+), 2 deletions(-)
>>
>
> Reviewed-by: Simon Glass mailto:s...@chromium.org>>
>
>> diff --git a/include/asm-generic/global_data.h 
>> b/include/asm-generic/global_data.h
>> index 0fd4900..f3d687c 100644
>> --- a/include/asm-generic/global_data.h
>> +++ b/include/asm-generic/global_data.h
>> @@ -55,7 +55,7 @@ typedef struct global_data {
>>   unsigned long ram_base; /* Base address of RAM used by 
>> U-Boot */
>>   unsigned long ram_top;  /* Top address of RAM used by 
>> U-Boot */
>>   unsigned long relocaddr;/* Start address of U-Boot in RAM 
>> */
>> -   phys_size_t ram_size;   /* RAM size */
>> +   u64 ram_size;   /* RAM size */
>>   unsigned long mon_len;  /* monitor len */
>>   unsigned long irq_sp;   /* irq stack pointer */
>>   unsigned long start_addr_sp;/* start_addr_stackpointer */
>> diff --git a/include/ram.h b/include/ram.h
>> index 67e22d7..1fe024f 100644
>> --- a/include/ram.h
>> +++ b/include/ram.h
>> @@ -9,7 +9,14 @@
>>
>> struct ram_info {
>>   phys_addr_t base;
>> -   size_t size;
>> +   /*
>> +* We use a 64bit type for the size to correctly handle 32bit
>> +* systems with 4GB of DRAM (which would overflow a 32bit type
>> +* and read back as 0).  For 64bit systems, we assume (for now)
>
> forever :-)
>
>> +* that they will always have less than 2^65 byte of DRAM
>> +* installed. -- prt
>
> Is the prt your signature? I suggest dropping it.

 In fact it is. But I’ll need to rewrite the entire comment anyway for the 
 next
 version of this series as there’s even more functions and places that the
 memory size is stored in...

>
>> +*/
>> +   u64 size;
>>>
>>> With LPAE available in all modern ARM cores, shouldn't phys_addr_t just
>>> be u64? And then we'd probably want to use that throughout the code, right?
>>
>> Quite a few currently supported boards do not support LPAE, e.g. imx6.
> 
> What I'm trying to say is that we probably want to make phys_addr_t be u64 
> when CONFIG_LPAE is set.

That's right. Enabling PHYS_64BIT should be sufficient. Based on this
phys_addr_t should be set to u32 or u64. arm already does that[1].

[1]
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/include/asm/types.h;h=9af7353f0866f05dbe298a603d52d90e9c8e6d28;hb=HEAD


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


[U-Boot] [PATCH] ARM: dts: logicpd-torpedo-37xx-devkit-u-boot: Fix MMC Card Detect

2018-09-03 Thread Adam Ford
When re-syncing the DTS files from the kernel, something caused
the MMC driver to no longer detect the MMC card. Undoing the
CD-invert appears to fix the issue.

Fixes: e6ea2390cde3 ("ARM: DTS: Resync LogicPD-Torpedo-37xx-devkit
with Linux 4.18-RC4")

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi 
b/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi
index 4028fe7642..d584b4a9ab 100644
--- a/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi
+++ b/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi
@@ -20,10 +20,6 @@
clock-frequency = <40>;
 };
 
- {
-   cd-inverted;
-};
-
  {
   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 2/4] serial: protect access to serial rx buffer

2018-09-03 Thread Stefan

Hi Patrick,

On 03.09.2018 15:35, Patrick DELAUNAY wrote:

Hi Simon and Stefan,

Sorry for my late answer (I just come back from my summer holiday)


From: s...@google.com  On Behalf Of Simon Glass
Sent: mercredi 8 août 2018 11:56

On 3 August 2018 at 05:38, Patrick Delaunay  wrote:

Add test to avoid access to rx buffer when this buffer is empty.
In this case directly call getc() function to avoid issue when tstc()
is not called.

Signed-off-by: Patrick Delaunay 
---

  drivers/serial/serial-uclass.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/serial/serial-uclass.c
b/drivers/serial/serial-uclass.c index 321d23e..4121a37 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -228,6 +228,9 @@ static int _serial_getc(struct udevice *dev)
 struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
 char val;

+   if (upriv->rd_ptr == upriv->wr_ptr)
+   return __serial_getc(dev);
+
 val = upriv->buf[upriv->rd_ptr++];
 upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;

--
2.7.4



Reviewed-by: Simon Glass 

BTW I think the code in _serial_tstc() is wrong, or at least sub-optimal:

/* Read all available chars into the RX buffer */ while (__serial_tstc(dev)) {
upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE; }

It should call serial_getc() until it returns -EAGAIN. There should be no need 
to
call __serial_tstc() first,


This part had be added by Stefan Roese in
SHA1 3ca7a06afb7cbc867b7861a8b9aada74e5bbb559

But I check again the code, and I think the code is correct


I really hope so. I did test this implementation quite heavily at
that time.


but I agree it is not optimal.

we can directly ops->getc(dev) and no more __serial_getc() or
__serial_tstc() :
the behavior don't change but the access to serial driver is reduced.
When no char is available, ops->getc witll return -EAGAIN

static int _serial_tstc(struct udevice *dev)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
int err;

/* Read all available chars into the RX buffer */
while(1) {
err = ops->getc(dev);
if (err < 0)
break;
upriv->buf[upriv->wr_ptr++] = err;
upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
}

return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0;
}

If you are OK I will push a other patchset for these otpimisation.


I'm not 100% sure, if this new implementation is "better". Lets
compare the code:

Current version:
static int _serial_tstc(struct udevice *dev)
{
struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);

/* Read all available chars into the RX buffer */
while (__serial_tstc(dev)) {
upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
}

return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0;
}

New version:
static int _serial_tstc(struct udevice *dev)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
int err;

/* Read all available chars into the RX buffer */
while(1) {
err = ops->getc(dev);
if (err < 0)
break;
upriv->buf[upriv->wr_ptr++] = err;
upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
}

return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0;
}

The new version has more code and will most likely produce
a larger binary. You are removing the calls to the __foo()
functions - making the call chain a bit smaller. But this
will only affect the performance which is most likely negligible
in this case.

I any case, I don't object against any "optimizations" here.
But please make sure to test any changes very thorough - please
also on platforms with limited RX FIFO sizes.

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


[U-Boot] Breakage in ids8313 due to u-boot-imx

2018-09-03 Thread Stefano Babic
Hi Denis,

you introduced a way to switch the bus for the I2C counter. I merged
these changes into u-boot-imx (they were related to GE i.MX boards), Tom
found that this breaks ids8313 (PowerPC). In fact, ids8313 could not set
CONFIG_SYS_BOOTCOUNT_I2C_BUS (it is new), and the fallback in comment
does not apply.

I just noted that there is no CONFIG option in Kconfig and it must be
set in the header. However, that is forbidden and new CONFIG should be
supported via Kconfig.

Sure I have not noted this issue before, but this cannot flow in, also
because it breaks the ids8313. I tend to drop your patchset for the
incoming release.

Best regards,
Stefano

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4] usb: ehci-generic: Add vbus-supply regulator support

2018-09-03 Thread Patrice Chotard
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by
an external regulator.

Signed-off-by: Patrice Chotard 
---

Changes in v4:
  - Remove useless dev->name in dev_dgb()

Changes in v3:
  - Update test on device_get_supply_regulator() call
  - Replace pr_err() by dev_err()
  - Replace debug() by dev_dbg()

Changes in v2:
  - Add test on device_get_supply_regulator() call

 drivers/usb/host/ehci-generic.c | 39 ++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 5a56f66cfaa6..0db0ab28d16d 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include "ehci.h"
+#include 
 
 /*
  * Even though here we don't explicitly use "struct ehci_ctrl"
@@ -22,6 +23,9 @@ struct generic_ehci {
struct clk *clocks;
struct reset_ctl *resets;
struct phy phy;
+#ifdef CONFIG_DM_REGULATOR
+   struct udevice *vbus_supply;
+#endif
int clock_count;
int reset_count;
 };
@@ -145,9 +149,26 @@ static int ehci_usb_probe(struct udevice *dev)
}
}
 
+#ifdef CONFIG_DM_REGULATOR
+   err = device_get_supply_regulator(dev, "vbus-supply",
+ >vbus_supply);
+   if (err && err != -ENOENT)
+   goto reset_err;
+
+   if (priv->vbus_supply) {
+   err = regulator_set_enable(priv->vbus_supply, true);
+   if (err) {
+   dev_err(dev, "Error enabling VBUS supply\n");
+   goto reset_err;
+   }
+   } else {
+   dev_dbg(dev, "No vbus supply\n");
+   }
+#endif
+
err = ehci_setup_phy(dev, 0);
if (err)
-   goto reset_err;
+   goto regulator_err;
 
hccr = map_physmem(dev_read_addr(dev), 0x100, MAP_NOCACHE);
hcor = (struct ehci_hcor *)((uintptr_t)hccr +
@@ -164,6 +185,15 @@ phy_err:
if (ret)
dev_err(dev, "failed to shutdown usb phy\n");
 
+regulator_err:
+#ifdef CONFIG_DM_REGULATOR
+   if (priv->vbus_supply) {
+   ret = regulator_set_enable(priv->vbus_supply, false);
+   if (ret)
+   dev_err(dev, "Error disabling VBUS supply\n");
+   }
+#endif
+
 reset_err:
ret = reset_release_all(priv->resets, priv->reset_count);
if (ret)
@@ -189,6 +219,13 @@ static int ehci_usb_remove(struct udevice *dev)
if (ret)
return ret;
 
+#ifdef CONFIG_DM_REGULATOR
+   if (priv->vbus_supply) {
+   ret = regulator_set_enable(priv->vbus_supply, false);
+   if (ret)
+   return ret;
+   }
+#endif
ret =  reset_release_all(priv->resets, priv->reset_count);
if (ret)
return ret;
-- 
1.9.1

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


Re: [U-Boot] [PATCH 2/4] serial: protect access to serial rx buffer

2018-09-03 Thread Patrick DELAUNAY
Hi Simon and Stefan,

Sorry for my late answer (I just come back from my summer holiday)

> From: s...@google.com  On Behalf Of Simon Glass
> Sent: mercredi 8 août 2018 11:56
> 
> On 3 August 2018 at 05:38, Patrick Delaunay  wrote:
> > Add test to avoid access to rx buffer when this buffer is empty.
> > In this case directly call getc() function to avoid issue when tstc()
> > is not called.
> >
> > Signed-off-by: Patrick Delaunay 
> > ---
> >
> >  drivers/serial/serial-uclass.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/serial/serial-uclass.c
> > b/drivers/serial/serial-uclass.c index 321d23e..4121a37 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -228,6 +228,9 @@ static int _serial_getc(struct udevice *dev)
> > struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> > char val;
> >
> > +   if (upriv->rd_ptr == upriv->wr_ptr)
> > +   return __serial_getc(dev);
> > +
> > val = upriv->buf[upriv->rd_ptr++];
> > upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
> >
> > --
> > 2.7.4
> >
> 
> Reviewed-by: Simon Glass 
> 
> BTW I think the code in _serial_tstc() is wrong, or at least sub-optimal:
> 
> /* Read all available chars into the RX buffer */ while (__serial_tstc(dev)) {
>upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
>upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE; }
> 
> It should call serial_getc() until it returns -EAGAIN. There should be no 
> need to
> call __serial_tstc() first,

This part had be added by Stefan Roese in SHA1 
3ca7a06afb7cbc867b7861a8b9aada74e5bbb559

But I check again the code, and I think the code is correct but I agree it 
is not optimal.

we can directly ops->getc(dev) and no more __serial_getc() or __serial_tstc() :
the behavior don't change but the access to serial driver is reduced. 
When no char is available, ops->getc witll return -EAGAIN

static int _serial_tstc(struct udevice *dev)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
struct serial_dev_priv *upriv = dev_get_uclass_priv(dev); 
int err;

/* Read all available chars into the RX buffer */
while(1) {
err = ops->getc(dev);
if (err < 0)
break;
upriv->buf[upriv->wr_ptr++] = err;
upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
}

return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0;
}

If you are OK I will push a other patchset for these otpimisation.

> 
> Regards,
> Simon

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


Re: [U-Boot] [PATCH 02/13] pico-imx6ul: Convert to SPL

2018-09-03 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Mon, Sep 3, 2018 at 3:01 PM Fabio Estevam  wrote:
>
> Hi Jagan,
>
> On Sun, Sep 2, 2018 at 3:07 PM, Jagan Teki  wrote:
>
> >> --- /dev/null
> >> +++ b/board/technexion/pico-imx6ul/spl.c
> >> @@ -0,0 +1,115 @@
> >> +// SPDX-License-Identifier: GPL-2.0+
> >
> > space
> >
>
> >> +static void ccgr_init(void)
> >> +{
> >> +   struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
> >> +
> >> +   writel(0x, >CCGR0);
> >> +   writel(0x, >CCGR1);
> >> +   writel(0x, >CCGR2);
> >> +   writel(0x, >CCGR3);
> >> +   writel(0x, >CCGR4);
> >> +   writel(0x, >CCGR5);
> >> +   writel(0x, >CCGR6);
> >> +   writel(0x, >CCGR7);

are you sure that arrive to 7?

> >
> > These can be know values.
>
> I am sorry, but I did not understand your comments.
>

I think that it's not a good strategy to enable all the gate in general here.

Michael

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



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 02/13] pico-imx6ul: Convert to SPL

2018-09-03 Thread Fabio Estevam
Hi Jagan,

On Sun, Sep 2, 2018 at 3:07 PM, Jagan Teki  wrote:

>> --- /dev/null
>> +++ b/board/technexion/pico-imx6ul/spl.c
>> @@ -0,0 +1,115 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>
> space
>

>> +static void ccgr_init(void)
>> +{
>> +   struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
>> +
>> +   writel(0x, >CCGR0);
>> +   writel(0x, >CCGR1);
>> +   writel(0x, >CCGR2);
>> +   writel(0x, >CCGR3);
>> +   writel(0x, >CCGR4);
>> +   writel(0x, >CCGR5);
>> +   writel(0x, >CCGR6);
>> +   writel(0x, >CCGR7);
>
> These can be know values.

I am sorry, but I did not understand your comments.

Please clarify.

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


Re: [U-Boot] [PATCH] amlogic: board p212: Fix Ethernet PHY init

2018-09-03 Thread Neil Armstrong
Hi jasper,

On 28/08/2018 22:26, Jasper Kcoding wrote:
> Without this patch the Ethernet PHY on the p212 board does not get fully 
> configured.
> When this happens Ethernet does not function.
> 
> The similar libretech-cc and khadas-vim boards have this code already.
> That's why the Ethernet on these boards do work.

Please add a "Signed-off-by" tag.

> ---
>  board/amlogic/p212/p212.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/amlogic/p212/p212.c b/board/amlogic/p212/p212.c
> index 06c2eaee47..d5ce5397f3 100644
> --- a/board/amlogic/p212/p212.c
> +++ b/board/amlogic/p212/p212.c
> @@ -29,7 +29,7 @@ int misc_init_r(void)
>   char serial[EFUSE_SN_SIZE];
>   ssize_t len;
>  
> - meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, 0);
> + meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, 
> MESON_GXL_USE_INTERNAL_RMII_PHY);
>  
>   if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
>   len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
> 

Acked-by: Neil Armstrong 

Please resend with my Acked-by tag !

Thanks for fixing this...

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


[U-Boot] [PATCH] spi: mxc_spi: Fix chipselect with DM_SPI in SPL

2018-09-03 Thread Bernhard Messerklinger
Since CONFIG_IS_ENABLED(DM_SPI) is not working in SPL because
CONFIG_SPL_DM_SPI is not defined we should go with #ifdef CONFIG_DM_SPI.

Signed-off-by: Bernhard Messerklinger 
---

 drivers/spi/mxc_spi.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 0dccc38b82..bd31e79505 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -57,26 +57,30 @@ static inline struct mxc_spi_slave *to_mxc_spi_slave(struct 
spi_slave *slave)
return container_of(slave, struct mxc_spi_slave, slave);
 }
 
+#ifdef CONFIG_DM_SPI
 static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
 {
-   if (CONFIG_IS_ENABLED(DM_SPI)) {
-   dm_gpio_set_value(>ss, 1);
-   } else {
-   if (mxcs->gpio > 0)
-   gpio_set_value(mxcs->gpio, mxcs->ss_pol);
-   }
+   dm_gpio_set_value(>ss, 1);
 }
 
 static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
 {
-   if (CONFIG_IS_ENABLED(DM_SPI)) {
-   dm_gpio_set_value(>ss, 0);
-   } else {
-   if (mxcs->gpio > 0)
-   gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
-   }
+   dm_gpio_set_value(>ss, 0);
+}
+#else
+static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
+{
+   if (mxcs->gpio > 0)
+   gpio_set_value(mxcs->gpio, mxcs->ss_pol);
 }
 
+static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
+{
+   if (mxcs->gpio > 0)
+   gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
+}
+#endif
+
 u32 get_cspi_div(u32 div)
 {
int i;
-- 
2.18.0


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


Re: [U-Boot] [PATCH] travis: Use kernel.org pre-built toolchain for riscv

2018-09-03 Thread Bin Meng
Hi Tom,

On Thu, Aug 30, 2018 at 9:12 PM Bin Meng  wrote:
>
> This updates travis configuration to use kernel.org pre-built
> toolchain for riscv.
>
> Signed-off-by: Bin Meng 
> ---
>
>  .travis.yml | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>

Since this is travis-ci changes, can we take this for v2018.09? I've
verified that it works well for current riscv build on travis-ci.org.

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


[U-Boot] [PATCH v2] sandbox: Build with -fPIC

2018-09-03 Thread Andy Shevchenko
Sandbox is not a real bootloader and it does require
a position independent code to be supported.

Thus, build it with -fPIC explicitly.

Fixes: 16940f720f9b ("Makefile: Don't generate position independent code")
Signed-off-by: Andy Shevchenko 
Reported-by: Simon Glass 
Tested-by: Bin Meng 
---

- rebased on top of latest u-boot/master
- added Bin's Tb tag

 arch/sandbox/config.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 2babcde881..95f9e3ff63 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -3,6 +3,7 @@
 
 PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
+PLATFORM_CPPFLAGS += -fPIC
 PLATFORM_LIBS += -lrt
 
 # Define this to avoid linking with SDL, which requires SDL libraries
-- 
2.18.0

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


Re: [U-Boot] [PATCH v1] sandbox: Build with -fPIC

2018-09-03 Thread Bin Meng
Hi Andy,

On Mon, Sep 3, 2018 at 4:33 PM Andy Shevchenko
 wrote:
>
> Sandbox is not a real bootloader and it does require
> a position independent code to be supported.
>
> Thus, build it with -fPIC explicitly.
>
> Fixes: 16940f720f9b ("Makefile: Don't generate position independent code")
> Signed-off-by: Andy Shevchenko 
> Reported-by: Simon Glass 
> ---
>  arch/sandbox/config.mk | 1 +
>  1 file changed, 1 insertion(+)

This patch does not apply on top of u-boot/master. Can you please rebase?

Manually applied the changes, and tested Sandbox on my Ubuntu 16.04
machine, although it does not expose the issue that Simon was seeing
on 18.04.

FWIW

Tested-by: Bin Meng 

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


Re: [U-Boot] [PATCH] serial: mxc: Add match string for i.mx6 quad/dual lite serial

2018-09-03 Thread Hannes Schmelzer

On 09/03/2018 10:17 AM, Bernhard Messerklinger wrote:

Signed-off-by: Bernhard Messerklinger 
---

  drivers/serial/serial_mxc.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 4f1f822c58..e586c18cf0 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -339,6 +339,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice 
*dev)
  static const struct udevice_id mxc_serial_ids[] = {
{ .compatible = "fsl,imx6ul-uart" },
{ .compatible = "fsl,imx7d-uart" },
+   { .compatible = "fsl,imx6q-uart" },
{ }
  };
  #endif

Reviewed-by: Hannes Schmelzer 
Tested-by: Hannes Schmelzer 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v6 20/31] mtd: declare MTD_PARTITIONS symbol in Kconfig

2018-09-03 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Mon, 3 Sep 2018
13:17:13 +0530:

> On Thu, Aug 16, 2018 at 9:00 PM, Miquel Raynal
>  wrote:
> > UBI selects MTD_PARTITIONS which is the symbol to compile
> > drivers/mtd/mtdpart.c. Unfortunately, the symbol was not defined in
> > Kconfig and this worked only with board files defining it. Fix this by
> > adding a boolean in Kconfig so boards defined by defconfig files only
> > will work as expected.
> >
> > Signed-off-by: Miquel Raynal 
> > ---
> >  drivers/mtd/Kconfig | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> > index 9341d518f3..d98457e223 100644
> > --- a/drivers/mtd/Kconfig
> > +++ b/drivers/mtd/Kconfig
> > @@ -1,5 +1,8 @@
> >  menu "MTD Support"
> >
> > +config MTD_PARTITIONS
> > +   bool
> > +  
> 
> I think I can drop this patch, along with
> "mtd: declare MTD_PARTITIONS symbol in Kconfig"

Oh I see what you mean! It looks like the problem reported here has
already been fixed by:

commit 9c5b00973bceb7c0192bd6b03672d69b092700b4
Author: Adam Ford 
Date:   Sat Jul 7 22:18:22 2018 -0500

Convert CONFIG_MTD_PARTITIONS et al to Kconfig

This converts the following to Kconfig:
   CONFIG_MTD_PARTITIONS
   CONFIG_MTD_DEVICE

Signed-off-by: Adam Ford 

And indeed I saw the double entry when I rebased and removed the
duplicate. So yes, you can drop this one, and I will drop the unneeded
patch in the "Clean MTD partition..." series.

Good catch!
Miquèl
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2] MMC: davinici_mmc: Enable CD and WP with DM and OF_CONTROL

2018-09-03 Thread Adam Ford
When used with a device tree, this will extract the card detect
and write protect pins from the device tree and configure them
accordingly.  This assumes the GPIO_ACTIVE_LOW/HIGH is supported
by da8xx_gpio.

Signed-off-by: Adam Ford 
---
V2: Wrap the CD and WP GPIO references around DM_GPIO to prevent errors

diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
index db950ea5ec..0d63279db0 100644
--- a/drivers/mmc/davinci_mmc.c
+++ b/drivers/mmc/davinci_mmc.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DAVINCI_MAX_BLOCKS (32)
 #define WATCHDOG_COUNT (10)
@@ -35,6 +36,8 @@ struct davinci_mmc_priv {
struct davinci_mmc_regs *reg_base;  /* Register base address */
uint input_clk; /* Input clock to MMC controller */
uint version;   /* MMC Controller version */
+   struct gpio_desc cd_gpio;   /* Card Detect GPIO */
+   struct gpio_desc wp_gpio;   /* Write Protect GPIO */
 };
 
 struct davinci_mmc_plat
@@ -425,9 +428,41 @@ static const struct mmc_ops dmmc_ops = {
.init   = dmmc_init,
 };
 #else
+
+static int davinci_mmc_getcd(struct udevice *dev)
+{
+   int value = -1;
+#if CONFIG_IS_ENABLED(DM_GPIO)
+   struct davinci_mmc_priv *priv = dev_get_priv(dev);
+   value = dm_gpio_get_value(>cd_gpio);
+#endif
+   /* if no CD return as 1 */
+   if (value < 0)
+   return 1;
+
+   return value;
+}
+
+static int davinci_mmc_getwp(struct udevice *dev)
+{
+   int value = -1;
+#if CONFIG_IS_ENABLED(DM_GPIO)
+   struct davinci_mmc_priv *priv = dev_get_priv(dev);
+
+   value = dm_gpio_get_value(>wp_gpio);
+#endif
+   /* if no WP return as 0 */
+   if (value < 0)
+   return 0;
+
+   return value;
+}
+
 static const struct dm_mmc_ops davinci_mmc_ops = {
.send_cmd   = davinci_mmc_send_cmd,
.set_ios= davinci_mmc_set_ios,
+   .get_cd = davinci_mmc_getcd,
+   .get_wp = davinci_mmc_getwp,
 };
 #endif
 
@@ -475,6 +510,12 @@ static int davinci_mmc_probe(struct udevice *dev)
priv->reg_base = (struct davinci_mmc_regs *)dev_read_addr(dev);
priv->input_clk = clk_get(DAVINCI_MMCSD_CLKID);
 
+#if CONFIG_IS_ENABLED(DM_GPIO)
+   /* These GPIOs are optional */
+   gpio_request_by_name(dev, "cd-gpios", 0, >cd_gpio, GPIOD_IS_IN);
+   gpio_request_by_name(dev, "wp-gpios", 0, >wp_gpio, GPIOD_IS_IN);
+#endif
+
upriv->mmc = >mmc;
 
return davinci_dm_mmc_init(dev);
-- 
2.17.1

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


[U-Boot] [PATCH v1] sandbox: Build with -fPIC

2018-09-03 Thread Andy Shevchenko
Sandbox is not a real bootloader and it does require
a position independent code to be supported.

Thus, build it with -fPIC explicitly.

Fixes: 16940f720f9b ("Makefile: Don't generate position independent code")
Signed-off-by: Andy Shevchenko 
Reported-by: Simon Glass 
---
 arch/sandbox/config.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 5e7077bfe7..4599839791 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -3,6 +3,7 @@
 
 PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
+PLATFORM_CPPFLAGS += -fPIC
 PLATFORM_LIBS += -lrt
 
 LDFLAGS_FINAL += --gc-sections
-- 
2.18.0

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


Re: [U-Boot] [PATCH v6 20/31] mtd: declare MTD_PARTITIONS symbol in Kconfig

2018-09-03 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Mon, 3 Sep 2018
13:17:13 +0530:

> On Thu, Aug 16, 2018 at 9:00 PM, Miquel Raynal
>  wrote:
> > UBI selects MTD_PARTITIONS which is the symbol to compile
> > drivers/mtd/mtdpart.c. Unfortunately, the symbol was not defined in
> > Kconfig and this worked only with board files defining it. Fix this by
> > adding a boolean in Kconfig so boards defined by defconfig files only
> > will work as expected.
> >
> > Signed-off-by: Miquel Raynal 
> > ---
> >  drivers/mtd/Kconfig | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> > index 9341d518f3..d98457e223 100644
> > --- a/drivers/mtd/Kconfig
> > +++ b/drivers/mtd/Kconfig
> > @@ -1,5 +1,8 @@
> >  menu "MTD Support"
> >
> > +config MTD_PARTITIONS
> > +   bool
> > +  
> 
> I think I can drop this patch, along with
> "mtd: declare MTD_PARTITIONS symbol in Kconfig"

I am not sure to understand correctly what you intend to do?

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


Re: [U-Boot] [PATCH v7 10/13] cmd: mtd: add 'mtd' command

2018-09-03 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Mon, 3 Sep 2018
13:34:21 +0530:

> On Mon, Sep 3, 2018 at 12:24 PM, Miquel Raynal
>  wrote:
> > Hi Stefan,
> >
> > Stefan Roese  wrote on Sat, 1 Sep 2018 10:59:56 +0200:
> >  
> >> On 31.08.2018 16:57, Miquel Raynal wrote:  
> >> > There should not be a 'nand' command, a 'sf' command and certainly not
> >> > a new 'spi-nand' command. Write a 'mtd' command instead to manage all
> >> > MTD devices/partitions at once. This should be the preferred way to
> >> > access any MTD device.  
> >> > > Signed-off-by: Miquel Raynal   
> >> > Acked-by: Jagan Teki 
> >> > ---
> >> >   cmd/Kconfig  |  10 +-
> >> >   cmd/Makefile |   1 +
> >> >   cmd/mtd.c| 517 +++
> >> >   drivers/mtd/Makefile |   2 +-
> >> >   include/mtd.h|   1 +
> >> >   5 files changed, 528 insertions(+), 3 deletions(-)
> >> >   create mode 100644 cmd/mtd.c  
> >> > > diff --git a/cmd/Kconfig b/cmd/Kconfig  
> >> > index ef43ed8dda..0778d2ecff 100644
> >> > --- a/cmd/Kconfig
> >> > +++ b/cmd/Kconfig
> >> > @@ -847,6 +847,12 @@ config CMD_MMC_SWRITE
> >> >   Enable support for the "mmc swrite" command to write Android sparse
> >> >   images to eMMC.  
> >> >   > +config CMD_MTD  
> >> > +   bool "mtd"
> >> > +   select MTD_PARTITIONS
> >> > +   help
> >> > + MTD commands support.
> >> > +
> >> >   config CMD_NAND
> >> > bool "nand"
> >> > default y if NAND_SUNXI
> >> > @@ -1671,14 +1677,14 @@ config CMD_MTDPARTS  
> >> >   >   config MTDIDS_DEFAULT  
> >> > string "Default MTD IDs"
> >> > -   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
> >> > +   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
> >> > help
> >> >   Defines a default MTD IDs list for use with MTD partitions in the
> >> >   Linux MTD command line partitions format.  
> >> >   >   config MTDPARTS_DEFAULT  
> >> > string "Default MTD partition scheme"
> >> > -   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
> >> > +   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
> >> > help
> >> >   Defines a default MTD partitioning scheme in the Linux MTD command
> >> >   line partitions format
> >> > diff --git a/cmd/Makefile b/cmd/Makefile
> >> > index 323f1fd2c7..32fd102189 100644
> >> > --- a/cmd/Makefile
> >> > +++ b/cmd/Makefile
> >> > @@ -90,6 +90,7 @@ obj-$(CONFIG_CMD_MISC) += misc.o
> >> >   obj-$(CONFIG_CMD_MMC) += mmc.o
> >> >   obj-$(CONFIG_CMD_MMC_SPI) += mmc_spi.o
> >> >   obj-$(CONFIG_MP) += mp.o
> >> > +obj-$(CONFIG_CMD_MTD) += mtd.o
> >> >   obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
> >> >   obj-$(CONFIG_CMD_NAND) += nand.o
> >> >   obj-$(CONFIG_CMD_NET) += net.o
> >> > diff --git a/cmd/mtd.c b/cmd/mtd.c
> >> > new file mode 100644
> >> > index 00..32295fe86c
> >> > --- /dev/null
> >> > +++ b/cmd/mtd.c
> >> > @@ -0,0 +1,517 @@
> >> > +// SPDX-License-Identifier:  GPL-2.0+
> >> > +/*
> >> > + * mtd.c
> >> > + *
> >> > + * Generic command to handle basic operations on any memory device.
> >> > + *
> >> > + * Copyright: Bootlin, 2018
> >> > + * Author: Miquèl Raynal 
> >> > + */
> >> > +
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +#include 
> >> > +
> >> > +#define MTD_NAME_MAX_LEN 20
> >> > +
> >> > +static char *old_mtdparts;
> >> > +
> >> > +static void mtd_dump_buf(u8 *buf, uint len, uint offset)
> >> > +{
> >> > +   int i, j;
> >> > +
> >> > +   for (i = 0; i < len; ) {
> >> > +   printf("0x%08x:\t", offset + i);
> >> > +   for (j = 0; j < 8; j++)
> >> > +   printf("%02x ", buf[i + j]);
> >> > +   printf(" ");
> >> > +   i += 8;
> >> > +   for (j = 0; j < 8; j++)
> >> > +   printf("%02x ", buf[i + j]);
> >> > +   printf("\n");
> >> > +   i += 8;
> >> > +   }
> >> > +}
> >> > +
> >> > +static void mtd_show_parts(struct mtd_info *mtd, int level)
> >> > +{
> >> > +   struct mtd_info *part;
> >> > +   int i;
> >> > +
> >> > +   if (list_empty(>partitions))
> >> > +   return;
> >> > +
> >> > +   list_for_each_entry(part, >partitions, node) {
> >> > +   for (i = 0; i < level; i++)
> >> > +   printf("\t");
> >> > +   printf("* %s\n", part->name);
> >> > +   for (i = 0; i < level; i++)
> >> > +   printf("\t");
> >> > +   printf("  > Offset: 0x%llx bytes\n", part->offset);
> >> > +   for (i = 0; i < level; i++)
> >> > +   printf("\t");
> >> > +   printf("  > Size: 0x%llx bytes\n", part->size);
> >> > +
> >> > +   mtd_show_parts(part, level + 1);
> >> > +   }
> >> > +}
> >> > +
> >> > +static void mtd_show_device(struct mtd_info *mtd)
> >> > +{
> >> > +   /* Device */
> >> > +   printf("* %s", mtd->name);
> >> > +   if (mtd->dev)
> >> > +   printf(" [device: %s] 

[U-Boot] [PATCH] serial: mxc: Add match string for i.mx6 quad/dual lite serial

2018-09-03 Thread Bernhard Messerklinger
Signed-off-by: Bernhard Messerklinger 
---

 drivers/serial/serial_mxc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 4f1f822c58..e586c18cf0 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -339,6 +339,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice 
*dev)
 static const struct udevice_id mxc_serial_ids[] = {
{ .compatible = "fsl,imx6ul-uart" },
{ .compatible = "fsl,imx7d-uart" },
+   { .compatible = "fsl,imx6q-uart" },
{ }
 };
 #endif
-- 
2.18.0


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


Re: [U-Boot] [PATCH v7 10/13] cmd: mtd: add 'mtd' command

2018-09-03 Thread Jagan Teki
On Mon, Sep 3, 2018 at 12:24 PM, Miquel Raynal
 wrote:
> Hi Stefan,
>
> Stefan Roese  wrote on Sat, 1 Sep 2018 10:59:56 +0200:
>
>> On 31.08.2018 16:57, Miquel Raynal wrote:
>> > There should not be a 'nand' command, a 'sf' command and certainly not
>> > a new 'spi-nand' command. Write a 'mtd' command instead to manage all
>> > MTD devices/partitions at once. This should be the preferred way to
>> > access any MTD device.
>> > > Signed-off-by: Miquel Raynal 
>> > Acked-by: Jagan Teki 
>> > ---
>> >   cmd/Kconfig  |  10 +-
>> >   cmd/Makefile |   1 +
>> >   cmd/mtd.c| 517 +++
>> >   drivers/mtd/Makefile |   2 +-
>> >   include/mtd.h|   1 +
>> >   5 files changed, 528 insertions(+), 3 deletions(-)
>> >   create mode 100644 cmd/mtd.c
>> > > diff --git a/cmd/Kconfig b/cmd/Kconfig
>> > index ef43ed8dda..0778d2ecff 100644
>> > --- a/cmd/Kconfig
>> > +++ b/cmd/Kconfig
>> > @@ -847,6 +847,12 @@ config CMD_MMC_SWRITE
>> >   Enable support for the "mmc swrite" command to write Android sparse
>> >   images to eMMC.
>> >   > +config CMD_MTD
>> > +   bool "mtd"
>> > +   select MTD_PARTITIONS
>> > +   help
>> > + MTD commands support.
>> > +
>> >   config CMD_NAND
>> > bool "nand"
>> > default y if NAND_SUNXI
>> > @@ -1671,14 +1677,14 @@ config CMD_MTDPARTS
>> >   >   config MTDIDS_DEFAULT
>> > string "Default MTD IDs"
>> > -   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
>> > +   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
>> > help
>> >   Defines a default MTD IDs list for use with MTD partitions in the
>> >   Linux MTD command line partitions format.
>> >   >   config MTDPARTS_DEFAULT
>> > string "Default MTD partition scheme"
>> > -   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
>> > +   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
>> > help
>> >   Defines a default MTD partitioning scheme in the Linux MTD command
>> >   line partitions format
>> > diff --git a/cmd/Makefile b/cmd/Makefile
>> > index 323f1fd2c7..32fd102189 100644
>> > --- a/cmd/Makefile
>> > +++ b/cmd/Makefile
>> > @@ -90,6 +90,7 @@ obj-$(CONFIG_CMD_MISC) += misc.o
>> >   obj-$(CONFIG_CMD_MMC) += mmc.o
>> >   obj-$(CONFIG_CMD_MMC_SPI) += mmc_spi.o
>> >   obj-$(CONFIG_MP) += mp.o
>> > +obj-$(CONFIG_CMD_MTD) += mtd.o
>> >   obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
>> >   obj-$(CONFIG_CMD_NAND) += nand.o
>> >   obj-$(CONFIG_CMD_NET) += net.o
>> > diff --git a/cmd/mtd.c b/cmd/mtd.c
>> > new file mode 100644
>> > index 00..32295fe86c
>> > --- /dev/null
>> > +++ b/cmd/mtd.c
>> > @@ -0,0 +1,517 @@
>> > +// SPDX-License-Identifier:  GPL-2.0+
>> > +/*
>> > + * mtd.c
>> > + *
>> > + * Generic command to handle basic operations on any memory device.
>> > + *
>> > + * Copyright: Bootlin, 2018
>> > + * Author: Miquèl Raynal 
>> > + */
>> > +
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +
>> > +#define MTD_NAME_MAX_LEN 20
>> > +
>> > +static char *old_mtdparts;
>> > +
>> > +static void mtd_dump_buf(u8 *buf, uint len, uint offset)
>> > +{
>> > +   int i, j;
>> > +
>> > +   for (i = 0; i < len; ) {
>> > +   printf("0x%08x:\t", offset + i);
>> > +   for (j = 0; j < 8; j++)
>> > +   printf("%02x ", buf[i + j]);
>> > +   printf(" ");
>> > +   i += 8;
>> > +   for (j = 0; j < 8; j++)
>> > +   printf("%02x ", buf[i + j]);
>> > +   printf("\n");
>> > +   i += 8;
>> > +   }
>> > +}
>> > +
>> > +static void mtd_show_parts(struct mtd_info *mtd, int level)
>> > +{
>> > +   struct mtd_info *part;
>> > +   int i;
>> > +
>> > +   if (list_empty(>partitions))
>> > +   return;
>> > +
>> > +   list_for_each_entry(part, >partitions, node) {
>> > +   for (i = 0; i < level; i++)
>> > +   printf("\t");
>> > +   printf("* %s\n", part->name);
>> > +   for (i = 0; i < level; i++)
>> > +   printf("\t");
>> > +   printf("  > Offset: 0x%llx bytes\n", part->offset);
>> > +   for (i = 0; i < level; i++)
>> > +   printf("\t");
>> > +   printf("  > Size: 0x%llx bytes\n", part->size);
>> > +
>> > +   mtd_show_parts(part, level + 1);
>> > +   }
>> > +}
>> > +
>> > +static void mtd_show_device(struct mtd_info *mtd)
>> > +{
>> > +   /* Device */
>> > +   printf("* %s", mtd->name);
>> > +   if (mtd->dev)
>> > +   printf(" [device: %s] [parent: %s] [driver: %s]",
>> > +  mtd->dev->name, mtd->dev->parent->name,
>> > +  mtd->dev->driver->name);
>> > +   printf("\n");
>> > +
>> > +   /* MTD device information */
>> > +   printf("  > type: ");
>> > +   switch (mtd->type) {
>> > +   case MTD_RAM:
>> > +   printf("RAM\n");
>> > +   break;
>> > +   case MTD_ROM:
>> > 

Re: [U-Boot] [PATCH v1] Makefile: Don't generate position independent code

2018-09-03 Thread Andy Shevchenko
On Sun, Sep 02, 2018 at 05:50:24PM -0600, Simon Glass wrote:
> Hi,
> 
> On 10 August 2018 at 00:04, Bin Meng  wrote:
> > On Thu, Aug 9, 2018 at 9:07 PM, Andy Shevchenko
> >  wrote:
> >> On Thu, 2018-08-09 at 14:25 +0200, Heinrich Schuchardt wrote:
> >>
> >>>  I did not test loading of
> >>> Linux on x86.
> >>
> >> For the record I did test this.
> >>
> >
> > Tested-by: Bin Meng 
> > On QEMU x86 boards (except efi-x86_app_defconfig which is currently broken)
> >
> > applied to u-boot-x86, thanks!
> 
> This appears to break build sandbox on Ubuntu 18.04 at least (gcc-7.3).

Sandbox is not a real bootloader for sure :-)

Does the below cure?

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 5e7077bfe7..4599839791 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -3,6 +3,7 @@
 
 PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
+PLATFORM_CPPFLAGS += -fPIC
 PLATFORM_LIBS += -lrt
 
 LDFLAGS_FINAL += --gc-sections


> Can we revert it, or do something else stop it from happening with sandbox?
> 
> At present all testing is broken for me.

-- 
With Best Regards,
Andy Shevchenko


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


[U-Boot] [PATCH] imx: ge: remove comments from autogenerated files

2018-09-03 Thread Stefano Babic
defconfigs files should be generated and they should not
contain additional comments because they can be lost.
Force the rule dropping the commnts inside the GE
boards.

Signed-off-by: Stefano Babic 
CC: Denis Zalevskiy 
Reported-by: Tom Rini 
---
 configs/ge_bx50v3_defconfig | 31 ---
 configs/mx53ppd_defconfig   | 33 -
 2 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig
index 6a052e00a1..4e54efb5e0 100644
--- a/configs/ge_bx50v3_defconfig
+++ b/configs/ge_bx50v3_defconfig
@@ -1,6 +1,9 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x1780
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
+CONFIG_SYS_VPD_EEPROM_I2C_BUS=4
+CONFIG_SYS_VPD_EEPROM_SIZE=1024
 CONFIG_TARGET_GE_BX50V3=y
 CONFIG_NR_DRAM_BANKS=1
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
@@ -8,29 +11,6 @@ CONFIG_FIT=y
 CONFIG_BOOTDELAY=1
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
-
-# monitor's EEPROM is connected to the bus through the mux channel 1
-# (the number is the offset in CONFIG_SYS_I2C_BUSES)
-CONFIG_SYS_VPD_EEPROM_I2C_BUS=4
-# Address of Atmel 24C08 EEPROM
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN=1
-CONFIG_SYS_VPD_EEPROM_SIZE=1024
-
-CONFIG_BOOTCOUNT_I2C=y
-CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_SYS_BOOTCOUNT_I2C_BUS=4
-# bootcount is stored in VPD EEPROM
-# we are using generic driver instead of EEPROM one (while should use it)
-# at the end of VPD EEPROM: (SYS_VPD_EEPROM_SIZE - CONFIG_BOOTCOUNT_I2C_LEN)
-# so, the address is 0x3FE:
-# ("VPD EEPROM chip address" | "3rd 256-byte page"):
-CONFIG_SYS_BOOTCOUNT_I2C_ADDR=0x53
-# (+ "offset in the page"):
-CONFIG_SYS_BOOTCOUNT_ADDR=0xfe
-CONFIG_BOOTCOUNT_I2C_LEN=2
-CONFIG_BOOTCOUNT_ALEN=1
-
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_LAST_STAGE_INIT=y
@@ -50,7 +30,12 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_DOS_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_I2C=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=10
+CONFIG_SYS_BOOTCOUNT_ADDR=0xfe
+CONFIG_SYS_BOOTCOUNT_I2C_BUS=4
+CONFIG_SYS_BOOTCOUNT_I2C_ADDR=0x53
 CONFIG_FSL_ESDHC=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/mx53ppd_defconfig b/configs/mx53ppd_defconfig
index 3470faa156..b5d7e943c5 100644
--- a/configs/mx53ppd_defconfig
+++ b/configs/mx53ppd_defconfig
@@ -2,6 +2,9 @@ CONFIG_ARM=y
 CONFIG_ARCH_MX5=y
 CONFIG_SYS_TEXT_BASE=0x7780
 CONFIG_TARGET_MX53PPD=y
+CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
+CONFIG_SYS_VPD_EEPROM_I2C_BUS=2
+CONFIG_SYS_VPD_EEPROM_SIZE=1024
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/ge/mx53ppd/imximage.cfg"
@@ -9,31 +12,6 @@ CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
-
-# monitor's EEPROM is connected to the bus through the mux channel 1
-# (the number is the offset in CONFIG_SYS_I2C_BUSES)
-# (there is also Frame EEPROM connected to the channel 4 (bus 4))
-CONFIG_SYS_VPD_EEPROM_I2C_BUS=2
-# Address of Atmel 24C08 EEPROM
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN=1
-CONFIG_SYS_VPD_EEPROM_SIZE=1024
-
-CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_BOOTCOUNT_I2C=y
-# using bus where monitor's EEPROM is connected to
-CONFIG_SYS_BOOTCOUNT_I2C_BUS=2
-# bootcount is stored in Monitor's VPD EEPROM
-# we are using generic driver instead of EEPROM one (while should use it)
-# at the end of VPD EEPROM: (SYS_VPD_EEPROM_SIZE - CONFIG_BOOTCOUNT_I2C_LEN)
-# so, the address is 0x3FE:
-# ("VPD EEPROM chip address" | "3rd 256-byte page"):
-CONFIG_SYS_BOOTCOUNT_I2C_ADDR=0x53
-# (+ "offset in the page"):
-CONFIG_SYS_BOOTCOUNT_ADDR=0xfe
-CONFIG_BOOTCOUNT_I2C_LEN=2
-CONFIG_BOOTCOUNT_ALEN=1
-
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
@@ -50,7 +28,12 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_I2C=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=10
+CONFIG_SYS_BOOTCOUNT_ADDR=0xfe
+CONFIG_SYS_BOOTCOUNT_I2C_BUS=2
+CONFIG_SYS_BOOTCOUNT_I2C_ADDR=0x53
 CONFIG_FSL_ESDHC=y
 CONFIG_MII=y
 CONFIG_RTC_S35392A=y
-- 
2.17.1

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


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-03 Thread Stefano Babic
On 02/09/2018 16:15, Tom Rini wrote:
> On Sun, Sep 02, 2018 at 03:20:25PM +0200, Sébastien Szymanski wrote:
> 
>> Hi Tom,
>>
>>> On 1 Sep 2018, at 13:37, Tom Rini  wrote:
>>>
>>> - So I start reading the whole diff and I see:
>>> commit 8e00d802e402d2a6734a88ebeb77a70efcfc354c
>>> Author: Sébastien Szymanski 
>>> Date:   Wed Jul 25 14:47:53 2018 +0200
>>>
>>>ARM: opos6ul: make the board boot again
>>>
>>> Which is wrong.  The -u-boot.dtsi file is automatically included and
>>> should have all of the U-Boot specific DTS changes.
>>>
>>
>> :(
>>
>> I don’t understand your comment. What -u-boot.dtsi file is
>> automatically included ? I have put all the U-Boot specific DTS
>> changes in imx6ul-opos6ul-u-boot.dtsi and imx6u-opos6uldev-u-boot.dts
>> files.
> 
> Take a look at the u_boot_dtsi_options logic in scripts/Makefile.lib for
> all of the possible dtsi files that will be automatically included if
> found.  This is so that end the end for a given board you should be able
> to drop in the dts file(s) from Linux, create a -u-boot.dtsi and then
> have things work, no changes to the upstream files required nor
> specifying an otherwise unusual name.
> 

I revert the patch on u-boot.imx to get a clean build again that can be
accepted by Tom.

Regards,
Stefano

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v6 20/31] mtd: declare MTD_PARTITIONS symbol in Kconfig

2018-09-03 Thread Jagan Teki
On Thu, Aug 16, 2018 at 9:00 PM, Miquel Raynal
 wrote:
> UBI selects MTD_PARTITIONS which is the symbol to compile
> drivers/mtd/mtdpart.c. Unfortunately, the symbol was not defined in
> Kconfig and this worked only with board files defining it. Fix this by
> adding a boolean in Kconfig so boards defined by defconfig files only
> will work as expected.
>
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/mtd/Kconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> index 9341d518f3..d98457e223 100644
> --- a/drivers/mtd/Kconfig
> +++ b/drivers/mtd/Kconfig
> @@ -1,5 +1,8 @@
>  menu "MTD Support"
>
> +config MTD_PARTITIONS
> +   bool
> +

I think I can drop this patch, along with
"mtd: declare MTD_PARTITIONS symbol in Kconfig"
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >